-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
278 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
#define RESIN_PANEL_STRUCTURES \ | ||
list( \ | ||
/datum/resin_construction/resin_turf/wall, \ | ||
/datum/resin_construction/resin_turf/wall/thick, \ | ||
/datum/resin_construction/resin_turf/wall/reflective, \ | ||
/datum/resin_construction/resin_turf/membrane, \ | ||
/datum/resin_construction/resin_turf/membrane/thick, \ | ||
/datum/resin_construction/resin_obj/door, \ | ||
/datum/resin_construction/resin_obj/door/thick, \ | ||
/datum/resin_construction/resin_obj/resin_node, \ | ||
/datum/resin_construction/resin_obj/sticky_resin, \ | ||
/datum/resin_construction/resin_obj/fast_resin, \ | ||
/datum/resin_construction/resin_obj/resin_spike, \ | ||
/datum/resin_construction/resin_obj/acid_pillar, \ | ||
/turf/closed/wall/mineral/bone_resin \ | ||
) | ||
|
||
/client/proc/open_resin_panel() | ||
set name = "Resin Panel" | ||
set category = "Game Master" | ||
|
||
if(!check_rights(R_ADMIN)) | ||
return | ||
|
||
new /datum/resin_panel(usr) | ||
|
||
/datum/resin_panel | ||
var/static/list/structure_list | ||
var/static/list/removal_allowlist | ||
var/selected_structure | ||
var/selected_hive = XENO_HIVE_NORMAL | ||
var/client/holder | ||
var/build_click_intercept = FALSE | ||
|
||
/datum/resin_panel/New(user) | ||
if(isnull(structure_list)) //first run, init statics | ||
structure_list = get_structures() | ||
|
||
removal_allowlist = list() | ||
for(var/structure as anything in RESIN_PANEL_STRUCTURES) | ||
if(structure in GLOB.resin_constructions_list) | ||
var/datum/resin_construction/construct = structure | ||
removal_allowlist += construct.build_path | ||
else | ||
removal_allowlist += structure | ||
|
||
if(isclient(user)) | ||
holder = user | ||
else | ||
var/mob/mob = user | ||
holder = mob.client | ||
|
||
holder.click_intercept = src | ||
tgui_interact(holder.mob) | ||
|
||
/datum/resin_panel/proc/get_structures() | ||
var/list/structures = list() | ||
for(var/structure as anything in RESIN_PANEL_STRUCTURES) | ||
var/list/entry = list() | ||
|
||
if(structure in GLOB.resin_constructions_list) | ||
var/datum/resin_construction/construct = structure | ||
entry["name"] = construct.name | ||
entry["image"] = replacetext(construct.construction_name, " ", "-") | ||
entry["id"] = "[construct]" | ||
else if(structure in typesof(/turf)) | ||
var/turf/turf = structure | ||
entry["name"] = turf.name | ||
switch(turf) | ||
if(/turf/closed/wall/mineral/bone_resin) | ||
entry["image"] = "reflective-resin-wall" //looks just like it, saves on making new spritesheet for one image | ||
else | ||
entry["image"] = turf.icon_state | ||
entry["id"] = "[turf]" | ||
|
||
structures += list(entry) | ||
|
||
return structures | ||
|
||
/datum/resin_panel/ui_assets(mob/user) | ||
return list( | ||
get_asset_datum(/datum/asset/spritesheet/choose_resin), | ||
) | ||
|
||
/datum/resin_panel/ui_static_data(mob/user) | ||
var/list/data = list() | ||
|
||
data["structure_list"] = structure_list | ||
data["hives_list"] = ALL_XENO_HIVES | ||
|
||
return data | ||
|
||
/datum/resin_panel/ui_data(mob/user) | ||
var/list/data = list() | ||
|
||
data["selected_structure"] = selected_structure | ||
data["selected_hive"] = selected_hive | ||
data["build_click_intercept"] = build_click_intercept | ||
|
||
return data | ||
|
||
/datum/resin_panel/ui_close(mob/user) | ||
holder = null | ||
build_click_intercept = FALSE | ||
qdel(src) | ||
|
||
/datum/resin_panel/ui_state(mob/user) | ||
return GLOB.admin_state | ||
|
||
/datum/resin_panel/ui_status(mob/user, datum/ui_state/state) | ||
return UI_INTERACTIVE | ||
|
||
/datum/resin_panel/tgui_interact(mob/user, datum/tgui/ui) | ||
ui = SStgui.try_update_ui(user, src, ui) | ||
if(!ui) | ||
ui = new(user, src, "ResinPanel", "Resin Panel") | ||
ui.set_autoupdate(FALSE) | ||
ui.open() | ||
|
||
/datum/resin_panel/proc/InterceptClickOn(mob/user, params, atom/object) | ||
if(!build_click_intercept) | ||
return | ||
|
||
var/list/modifiers = params2list(params) | ||
|
||
if(LAZYACCESS(modifiers, MIDDLE_CLICK)) //remove | ||
if(!(object.type in removal_allowlist)) | ||
return | ||
|
||
if(isturf(object)) | ||
var/turf/turf = object | ||
turf.ScrapeAway() | ||
else | ||
qdel(object) | ||
else //add | ||
if(!selected_structure) | ||
return | ||
|
||
var/turf/current_turf = get_turf(object) | ||
|
||
var/atom/new_structure | ||
if(selected_structure in GLOB.resin_constructions_list) | ||
var/datum/resin_construction/construct = GLOB.resin_constructions_list[selected_structure] | ||
new_structure = construct.build(current_turf, selected_hive) | ||
else if(selected_structure in typesof(/turf)) | ||
var/turf/turf = selected_structure | ||
new_structure = current_turf.PlaceOnTop(turf) | ||
new_structure?.add_hiddenprint(user) //so admins know who placed it | ||
|
||
return TRUE | ||
|
||
/datum/resin_panel/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state) | ||
. = ..() | ||
if(.) | ||
return | ||
|
||
if(!check_rights(R_ADMIN)) | ||
return | ||
|
||
switch(action) | ||
if("set_selected_structure") | ||
var/selected_type = text2path(params["type"]) | ||
if(!(selected_type in RESIN_PANEL_STRUCTURES)) | ||
return | ||
selected_structure = selected_type | ||
return TRUE | ||
if("set_selected_hive") | ||
var/hive = params["selected_hive"] | ||
if(!(hive in ALL_XENO_HIVES)) | ||
return | ||
selected_hive = hive | ||
return TRUE | ||
if("toggle_build_click_intercept") | ||
build_click_intercept = !build_click_intercept | ||
return TRUE | ||
|
||
#undef RESIN_PANEL_STRUCTURES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { useBackend } from 'tgui/backend'; | ||
import { Box, Button, Dropdown, Section, Stack, Tabs } from 'tgui/components'; | ||
import { Window } from 'tgui/layouts'; | ||
import { BooleanLike, classes } from 'common/react'; | ||
|
||
interface ResinPanelData { | ||
structure_list: StructureEntry[]; | ||
hives_list: string[]; | ||
selected_structure: string; | ||
selected_hive: string; | ||
build_click_intercept: BooleanLike; | ||
} | ||
|
||
interface StructureEntry { | ||
name: string; | ||
image: string; | ||
id: string; | ||
} | ||
|
||
export const ResinPanel = (props, context) => { | ||
const { act, data } = useBackend<ResinPanelData>(context); | ||
const { | ||
structure_list, | ||
hives_list, | ||
selected_structure, | ||
selected_hive, | ||
build_click_intercept, | ||
} = data; | ||
|
||
let compact = false; | ||
|
||
return ( | ||
<Window | ||
width={350} | ||
height={15 + structure_list.length * 80} | ||
title="Resin Panel" | ||
theme="admin"> | ||
<Window.Content> | ||
<Section | ||
title="Resin" | ||
buttons={ | ||
<Stack> | ||
<Stack.Item> | ||
<Button | ||
selected={build_click_intercept} | ||
content="Click Build" | ||
tooltip="LMB to place, MMB to remove" | ||
onClick={() => act('toggle_build_click_intercept')} | ||
/> | ||
</Stack.Item> | ||
<Stack.Item> | ||
<Dropdown | ||
options={hives_list} | ||
selected={selected_hive} | ||
width="15rem" | ||
onSelected={(selected_hive) => { | ||
act('set_selected_hive', { selected_hive }); | ||
}} | ||
/> | ||
</Stack.Item> | ||
</Stack> | ||
} | ||
scrollable | ||
fill> | ||
<Tabs vertical fluid fill> | ||
{structure_list.map((item, index) => ( | ||
<Tabs.Tab | ||
key={index} | ||
selected={item.id === selected_structure} | ||
onClick={() => | ||
act('set_selected_structure', { type: item.id }) | ||
}> | ||
<Stack align="center"> | ||
<Stack.Item> | ||
<span | ||
className={classes([ | ||
`chooseresin${compact ? '32x32' : '64x64'}`, | ||
`${item.image}${compact ? '' : '_big'}`, | ||
'ChooseResin__BuildIcon', | ||
])} | ||
/> | ||
</Stack.Item> | ||
<Stack.Item grow> | ||
<Box>{item.name}</Box> | ||
</Stack.Item> | ||
</Stack> | ||
</Tabs.Tab> | ||
))} | ||
</Tabs> | ||
</Section> | ||
</Window.Content> | ||
</Window> | ||
); | ||
}; |