mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-23 12:08:28 +01:00
Initial
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/client/proc/modify_robot(var/mob/living/silicon/robot/target in silicon_mob_list)
|
||||
set name = "Modify Robot"
|
||||
set desc = "Allows to add or remove modules to/from robots."
|
||||
set category = "Admin"
|
||||
if(!check_rights(R_ADMIN|R_FUN|R_VAREDIT|R_EVENT))
|
||||
return
|
||||
|
||||
var/datum/eventkit/modify_robot/modify_robot = new()
|
||||
modify_robot.target = target
|
||||
modify_robot.tgui_interact(src.mob)
|
||||
|
||||
/datum/eventkit/modify_robot
|
||||
var/mob/living/silicon/robot/target
|
||||
|
||||
/datum/eventkit/modify_robot/New()
|
||||
. = ..()
|
||||
|
||||
/datum/eventkit/modify_robot/tgui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "ModifyRobot", "Modify Robot")
|
||||
ui.open()
|
||||
|
||||
/datum/eventkit/modify_robot/Destroy()
|
||||
. = ..()
|
||||
|
||||
/datum/eventkit/modify_robot/tgui_data()
|
||||
. = list()
|
||||
if(target)
|
||||
.["target"] = list()
|
||||
.["target"]["name"] = target.name
|
||||
.["target"]["ckey"] = target.ckey
|
||||
.["target"]["module"] = target.module
|
||||
.["target"]["crisis_override"] = target.crisis_override
|
||||
.["target"]["active_restrictions"] = target.restrict_modules_to
|
||||
var/list/possible_restrictions = list()
|
||||
for(var/entry in robot_modules)
|
||||
if(!target.restrict_modules_to.Find(entry))
|
||||
possible_restrictions += entry
|
||||
.["target"]["possible_restrictions"] = possible_restrictions
|
||||
if(target.module)
|
||||
.["target"]["front"] = icon2base64(get_flat_icon(target,dir=SOUTH,no_anim=TRUE))
|
||||
.["target"]["side"] = icon2base64(get_flat_icon(target,dir=WEST,no_anim=TRUE))
|
||||
.["target"]["back"] = icon2base64(get_flat_icon(target,dir=NORTH,no_anim=TRUE))
|
||||
var/list/all_players = list()
|
||||
for(var/mob/living/silicon/robot/R in silicon_mob_list)
|
||||
var/list/info = list("displayText" = "[R]", "value" = "\ref[R]")
|
||||
all_players.Add(list(info))
|
||||
.["all_players"] = all_players
|
||||
|
||||
|
||||
/datum/eventkit/modify_robot/tgui_state(mob/user)
|
||||
return GLOB.tgui_admin_state
|
||||
|
||||
/datum/eventkit/modify_robot/tgui_act(action, params)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
switch(action)
|
||||
if("select_target")
|
||||
target = locate(params["new_target"])
|
||||
return TRUE
|
||||
if("toggle_crisis")
|
||||
target.crisis_override = !target.crisis_override
|
||||
return TRUE
|
||||
if("add_restriction")
|
||||
target.restrict_modules_to += robot_modules[params["new_restriction"]]
|
||||
if("remove_restriction")
|
||||
target.restrict_modules_to -= robot_modules[params["rem_restriction"]]
|
||||
@@ -0,0 +1,152 @@
|
||||
import { useState } from 'react';
|
||||
|
||||
import { useBackend } from '../../backend';
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Divider,
|
||||
Dropdown,
|
||||
Flex,
|
||||
NoticeBox,
|
||||
Section,
|
||||
Stack,
|
||||
Tabs,
|
||||
} from '../../components';
|
||||
import { Window } from '../../layouts';
|
||||
import { Data } from './types';
|
||||
|
||||
export const ModifyRobot = (props) => {
|
||||
const { act, data } = useBackend<Data>();
|
||||
|
||||
const { target, all_players } = data;
|
||||
|
||||
const [tab, setTab] = useState(0);
|
||||
|
||||
const tabs: React.JSX.Element[] = [];
|
||||
|
||||
tabs[0] = <Box />;
|
||||
tabs[1] = <Box />;
|
||||
tabs[2] = <Box />;
|
||||
tabs[3] = <Box />;
|
||||
tabs[4] = <Box />;
|
||||
tabs[5] = <Box />;
|
||||
|
||||
return (
|
||||
<Window width={400} height={600}>
|
||||
<Window.Content scrollable>
|
||||
{target ? (
|
||||
<NoticeBox info>
|
||||
{target.name} played by {target.ckey}.
|
||||
</NoticeBox>
|
||||
) : (
|
||||
<NoticeBox danger>No target selected. Please pick one.</NoticeBox>
|
||||
)}
|
||||
<Dropdown
|
||||
selected={target ? target.name : ''}
|
||||
options={all_players}
|
||||
onSelected={(value) =>
|
||||
act('select_target', {
|
||||
new_target: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
{target && !target.module ? (
|
||||
<>
|
||||
<NoticeBox warning>
|
||||
Target has no active module. Limited options available.
|
||||
</NoticeBox>
|
||||
<Button
|
||||
fluid
|
||||
color={target.crisis_override ? 'red' : 'green'}
|
||||
onClick={() => act('toggle_crisis')}
|
||||
>
|
||||
{(target.crisis_override ? 'Disable' : 'Enable') +
|
||||
' Crisis Override'}
|
||||
</Button>
|
||||
<Divider />
|
||||
<Flex>
|
||||
<Flex.Item grow />
|
||||
<Flex.Item shrink>
|
||||
<Section title="Active Restrictions">
|
||||
<Stack>
|
||||
<Stack.Item>
|
||||
{target.active_restrictions.map(
|
||||
(active_restriction, i) => {
|
||||
return (
|
||||
<Button
|
||||
fluid
|
||||
color="red"
|
||||
key={i}
|
||||
onClick={() =>
|
||||
act('add_restriction', {
|
||||
new_restriction: active_restriction,
|
||||
})
|
||||
}
|
||||
>
|
||||
{active_restriction}
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
<Flex.Item shrink>
|
||||
<Section title="Possible Restrictions">
|
||||
<Stack>
|
||||
<Stack.Item>
|
||||
{target.possible_restrictions.map(
|
||||
(possible_restriction, i) => {
|
||||
return (
|
||||
<Button
|
||||
fluid
|
||||
color="green"
|
||||
key={i}
|
||||
onClick={() =>
|
||||
act('remove_restriction', {
|
||||
rem_restriction: possible_restriction,
|
||||
})
|
||||
}
|
||||
>
|
||||
{possible_restriction}
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
)}
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Section>
|
||||
</Flex.Item>
|
||||
<Flex.Item grow />
|
||||
</Flex>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Tabs>
|
||||
<Tabs.Tab selected={tab === 0} onClick={() => setTab(0)}>
|
||||
Smites
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab selected={tab === 1} onClick={() => setTab(1)}>
|
||||
Medical
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab selected={tab === 2} onClick={() => setTab(2)}>
|
||||
Abilities
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab selected={tab === 3} onClick={() => setTab(3)}>
|
||||
Inventory
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab selected={tab === 4} onClick={() => setTab(4)}>
|
||||
Admin
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab selected={tab === 5} onClick={() => setTab(5)}>
|
||||
Fixes
|
||||
</Tabs.Tab>
|
||||
</Tabs>
|
||||
{tabs[tab]}
|
||||
</>
|
||||
)}
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
import { BooleanLike } from 'common/react';
|
||||
|
||||
export type Data = {
|
||||
target: {
|
||||
name: string;
|
||||
ckey: string;
|
||||
module: string;
|
||||
crisis_override: BooleanLike;
|
||||
active_restrictions: string[];
|
||||
possible_restrictions: string[];
|
||||
front: string | null;
|
||||
side: string | null;
|
||||
back: string | null;
|
||||
} | null;
|
||||
all_players: DropdownEntry[];
|
||||
};
|
||||
|
||||
export type DropdownEntry = {
|
||||
displayText: string;
|
||||
value: string;
|
||||
};
|
||||
+1
-1
@@ -1738,6 +1738,7 @@
|
||||
#include "code\modules\admin\holder2.dm"
|
||||
#include "code\modules\admin\IsBanned.dm"
|
||||
#include "code\modules\admin\map_capture.dm"
|
||||
#include "code\modules\admin\modify_robot.dm"
|
||||
#include "code\modules\admin\NewBan.dm"
|
||||
#include "code\modules\admin\news.dm"
|
||||
#include "code\modules\admin\persistence.dm"
|
||||
@@ -1814,7 +1815,6 @@
|
||||
#include "code\modules\admin\verbs\lightning_strike.dm"
|
||||
#include "code\modules\admin\verbs\map_template_loadverb.dm"
|
||||
#include "code\modules\admin\verbs\mapping.dm"
|
||||
#include "code\modules\admin\verbs\modify_robot.dm"
|
||||
#include "code\modules\admin\verbs\panicbunker.dm"
|
||||
#include "code\modules\admin\verbs\playsound.dm"
|
||||
#include "code\modules\admin\verbs\possess.dm"
|
||||
|
||||
Reference in New Issue
Block a user