Merge pull request #14650 from farie82/TGUI-labor-point-claim

[TGUI] labor claim console + misc fixes
This commit is contained in:
AffectedArc07
2020-10-18 17:23:14 +01:00
committed by GitHub
6 changed files with 166 additions and 130 deletions
@@ -181,6 +181,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "diamond"
origin_tech = "materials=6"
sheettype = "diamond"
merge_type = /obj/item/stack/sheet/mineral/diamond
materials = list(MAT_DIAMOND=MINERAL_MATERIAL_AMOUNT)
point_value = 25
@@ -197,6 +198,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "uranium sheet"
origin_tech = "materials=5"
sheettype = "uranium"
merge_type = /obj/item/stack/sheet/mineral/uranium
materials = list(MAT_URANIUM=MINERAL_MATERIAL_AMOUNT)
point_value = 20
@@ -210,6 +212,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "plasma sheet"
origin_tech = "plasmatech=2;materials=2"
sheettype = "plasma"
merge_type = /obj/item/stack/sheet/mineral/plasma
materials = list(MAT_PLASMA=MINERAL_MATERIAL_AMOUNT)
resistance_flags = FLAMMABLE
max_integrity = 100
@@ -252,6 +255,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "gold bar"
origin_tech = "materials=4"
sheettype = "gold"
merge_type = /obj/item/stack/sheet/mineral/gold
materials = list(MAT_GOLD=MINERAL_MATERIAL_AMOUNT)
point_value = 20
@@ -265,6 +269,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "silver bar"
origin_tech = "materials=4"
sheettype = "silver"
merge_type = /obj/item/stack/sheet/mineral/silver
materials = list(MAT_SILVER=MINERAL_MATERIAL_AMOUNT)
point_value = 20
@@ -278,6 +283,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "bananium sheet"
origin_tech = "materials=4"
sheettype = "bananium"
merge_type = /obj/item/stack/sheet/mineral/bananium
materials = list(MAT_BANANIUM=MINERAL_MATERIAL_AMOUNT)
point_value = 50
@@ -294,6 +300,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
singular_name = "beret"
origin_tech = "materials=4"
sheettype = "tranquillite"
merge_type = /obj/item/stack/sheet/mineral/tranquillite
materials = list(MAT_TRANQUILLITE=MINERAL_MATERIAL_AMOUNT)
wall_allowed = FALSE //no tranquilite walls in code
point_value = 50
@@ -319,6 +326,7 @@ GLOBAL_LIST_INIT(sandbag_recipes, list ( \
throw_speed = 1
throw_range = 3
sheettype = "titanium"
merge_type = /obj/item/stack/sheet/mineral/titanium
materials = list(MAT_TITANIUM=MINERAL_MATERIAL_AMOUNT)
point_value = 20
@@ -349,6 +357,7 @@ GLOBAL_LIST_INIT(titanium_recipes, list(
throw_speed = 1
throw_range = 3
sheettype = "plastitanium"
merge_type = /obj/item/stack/sheet/mineral/plastitanium
materials = list(MAT_TITANIUM=2000, MAT_PLASMA=2000)
point_value = 45
+53 -52
View File
@@ -1,5 +1,3 @@
GLOBAL_LIST(labor_sheet_values)
/**********************Prisoners' Console**************************/
/obj/machinery/mineral/labor_claim_console
@@ -14,6 +12,7 @@ GLOBAL_LIST(labor_sheet_values)
var/obj/machinery/door/airlock/release_door
var/door_tag = "prisonshuttle"
var/obj/item/radio/intercom/announcer
var/static/list/sheet_values
/obj/machinery/mineral/labor_claim_console/Initialize()
. = ..()
@@ -21,14 +20,13 @@ GLOBAL_LIST(labor_sheet_values)
announcer.config(list("Security" = 0))
locate_stacking_machine()
if(!GLOB.labor_sheet_values)
var/sheet_list = list()
if(!sheet_values)
for(var/sheet_type in subtypesof(/obj/item/stack/sheet))
var/obj/item/stack/sheet/sheet = sheet_type
if(!initial(sheet.point_value) || (initial(sheet.merge_type) && initial(sheet.merge_type) != sheet_type)) //ignore no-value sheets and x/fifty subtypes
continue
sheet_list += list(list("ore" = initial(sheet.name), "value" = initial(sheet.point_value)))
GLOB.labor_sheet_values = sheet_list
sheet_values += list(list("ore" = initial(sheet.name), "value" = initial(sheet.point_value)))
sheet_values = sortTim(sheet_values, /proc/cmp_sheet_list)
/obj/machinery/mineral/labor_claim_console/Destroy()
. = ..()
@@ -45,7 +43,7 @@ GLOBAL_LIST(labor_sheet_values)
I.forceMove(src)
inserted_id = I
to_chat(user, "<span class='notice'>You insert [I].</span>")
SSnanoui.update_uis(src)
SStgui.update_uis(src)
return
else
to_chat(user, "<span class='notice'>There's an ID inserted already.</span>")
@@ -53,75 +51,78 @@ GLOBAL_LIST(labor_sheet_values)
return ..()
/obj/machinery/mineral/labor_claim_console/attack_hand(mob/user)
ui_interact(user)
tgui_interact(user)
/obj/machinery/mineral/labor_claim_console/attack_ghost(mob/user)
attack_hand(user)
/obj/machinery/mineral/labor_claim_console/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1, var/master_ui = null, var/datum/topic_state/state = GLOB.default_state)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
/obj/machinery/mineral/labor_claim_console/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, datum/tgui/master_ui = null, datum/tgui_state/state = GLOB.tgui_default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "labor_claim_console.tmpl", name, 450, 625, state)
ui = new(user, src, ui_key, "LaborClaimConsole", name, 315, 470, master_ui, state)
ui.open()
/obj/machinery/mineral/labor_claim_console/ui_data(mob/user)
/obj/machinery/mineral/labor_claim_console/tgui_data(mob/user)
var/list/data = list()
var/can_go_home = FALSE
data["emagged"] = (emagged) ? TRUE : FALSE
data["emagged"] = emagged
data["id_inserted"] = inserted_id != null
if(inserted_id)
data["id"] = inserted_id
data["id_name"] = inserted_id.registered_name
data["points"] = inserted_id.points
data["goal"] = inserted_id.goal
data["id_points"] = inserted_id.points
data["id_goal"] = inserted_id.goal
if(check_auth())
can_go_home = TRUE
if(stacking_machine)
data["unclaimed_points"] = stacking_machine.points
data["ores"] = GLOB.labor_sheet_values
data["ores"] = sheet_values
data["can_go_home"] = can_go_home
return data
/obj/machinery/mineral/labor_claim_console/Topic(href, href_list)
/obj/machinery/mineral/labor_claim_console/tgui_act(action, params)
if(..())
return TRUE
return
if(href_list["handle_id"])
if(inserted_id)
if(!usr.put_in_hands(inserted_id))
inserted_id.forceMove(get_turf(src))
inserted_id = null
else
var/obj/item/I = usr.get_active_hand()
if(istype(I, /obj/item/card/id/prisoner))
if(!usr.unEquip(I))
return
I.forceMove(src)
inserted_id = I
if(href_list["claim_points"])
inserted_id.points += stacking_machine.points
stacking_machine.points = 0
to_chat(usr, "Points transferred.")
if(href_list["move_shuttle"])
if(!alone_in_area(get_area(src), usr))
to_chat(usr, "<span class='warning'>Prisoners are only allowed to be released while alone.</span>")
else
switch(SSshuttle.moveShuttle("laborcamp", "laborcamp_home", TRUE, usr))
if(1)
to_chat(usr, "<span class='notice'>Shuttle not found.</span>")
if(2)
to_chat(usr, "<span class='notice'>Shuttle already at station.</span>")
if(3)
to_chat(usr, "<span class='notice'>No permission to dock could be granted.</span>")
else
if(!(emagged))
var/message = "[inserted_id.registered_name] has returned to the station. Minerals and Prisoner ID card ready for retrieval."
announcer.autosay(message, "Labor Camp Controller", "Security")
to_chat(usr, "<span class='notice'>Shuttle received message and will be sent shortly.</span>")
usr.create_log(MISC_LOG, "used [src] to call the laborcamp shuttle")
switch(action)
if("handle_id")
if(inserted_id)
if(!usr.put_in_hands(inserted_id))
inserted_id.forceMove(get_turf(src))
inserted_id = null
else
var/obj/item/I = usr.get_active_hand()
if(istype(I, /obj/item/card/id/prisoner))
if(!usr.unEquip(I))
return
I.forceMove(src)
inserted_id = I
if("claim_points")
if(!inserted_id)
return
inserted_id.points += stacking_machine.points
stacking_machine.points = 0
to_chat(usr, "Points transferred.")
if("move_shuttle")
if(!alone_in_area(get_area(src), usr))
to_chat(usr, "<span class='warning'>Prisoners are only allowed to be released while alone.</span>")
else
switch(SSshuttle.moveShuttle("laborcamp", "laborcamp_home", TRUE, usr))
if(1)
to_chat(usr, "<span class='notice'>Shuttle not found.</span>")
if(2)
to_chat(usr, "<span class='notice'>Shuttle already at station.</span>")
if(3)
to_chat(usr, "<span class='notice'>No permission to dock could be granted.</span>")
else
if(!emagged)
var/message = "[inserted_id.registered_name] has returned to the station. Minerals and Prisoner ID card ready for retrieval."
announcer.autosay(message, "Labor Camp Controller", "Security")
to_chat(usr, "<span class='notice'>Shuttle received message and will be sent shortly.</span>")
usr.create_log(MISC_LOG, "used [src] to call the laborcamp shuttle")
return TRUE
+1
View File
@@ -62,6 +62,7 @@ GLOBAL_LIST_INIT(bluespace_crystal_recipes, list(new/datum/stack_recipe("Breakdo
icon_state = "polycrystal"
desc = "A stable polycrystal, made of fused-together bluespace crystals. You could probably break one off."
origin_tech = "bluespace=6;materials=3"
merge_type = /obj/item/stack/sheet/bluespace_crystal
materials = list(MAT_BLUESPACE = MINERAL_MATERIAL_AMOUNT)
attack_verb = list("bluespace polybashed", "bluespace polybattered", "bluespace polybludgeoned", "bluespace polythrashed", "bluespace polysmashed")
toolspeed = 1
-76
View File
@@ -1,76 +0,0 @@
<!--
Title: Point Claim Console
Used In File(s): \code\modules\mining\laborcamp\laborstacker.dm
-->
<style>
.statusLabel {
width: 200px;
}
.pointsValue {
float: left;
margin-right: 10px;
}
.centerButton {
float: none;
}
</style>
<h1>Ore values</h1>
<div class='statusDisplay'>
{{for data.ores}}
<div class="line">
<div class='statusLabel'>
{{:value.ore}}:
</div>
<div class='statusValue'>
{{:value.value}}
</div>
</div>
{{/for}}
</div>
<h1>Points</h1>
<div class='statusDisplay'>
<div class="line">
<div class='statusLabel'>
ID:
</div>
<div class='statusValue'>
{{:helper.link(data.id ? data.id_name : '-------------', null, { 'handle_id' : 1 })}}
</div>
</div>
{{if data.id}}
<div class="line">
<div class='statusLabel'>
Points collected:
</div>
<div class='statusValue'>
{{:data.points}}
</div>
</div>
<div class="line">
<div class='statusLabel'>
Goal:
</div>
<div class='statusValue'>
{{:data.goal}}
</div>
</div>
<div class="line">
<div class='statusLabel'>
Unclaimed points:
</div>
<div class='statusValue'>
<div class="pointsValue">{{:data.unclaimed_points}}</div>
{{:helper.link('Claim points', null, { 'claim_points' : 1 }, data.unclaimed_points ? null : 'disabled')}}
</div>
</div>
{{/if}}
</div>
<div class='statusDisplay'>
{{:helper.link('Move shuttle', null, { 'move_shuttle' : 1 }, data.can_go_home ? null : 'disabled', 'link centerButton')}}
</div>
@@ -0,0 +1,101 @@
import { toTitleCase } from 'common/string';
import { useBackend } from '../backend';
import { Box, Button, ProgressBar, LabeledList, Section, Table } from '../components';
import { Window } from '../layouts';
export const LaborClaimConsole = (props, context) => {
return (
<Window>
<Window.Content>
<ShuttleControlSection />
<MaterialValuesSection />
</Window.Content>
</Window>
);
};
const ShuttleControlSection = (props, context) => {
const { act, data } = useBackend(context);
const {
can_go_home,
emagged,
id_inserted,
id_name,
id_points,
id_goal,
unclaimed_points,
} = data;
const bad_progress = emagged ? 0 : 1;
const completionStatus = emagged ? "ERR0R" : (can_go_home ? "Completed!" : "Insufficient");
return (
<Section>
<LabeledList>
<LabeledList.Item label="Status">
{((!!id_inserted && (
<ProgressBar
value={id_points / id_goal}
ranges={{
good: [bad_progress, Infinity],
bad: [-Infinity, bad_progress],
}}>
{id_points + ' / ' + id_goal + ' ' + completionStatus}
</ProgressBar>
)) || (!!emagged && "ERR0R COMPLETED?!@") || "No ID inserted"
)}
</LabeledList.Item>
<LabeledList.Item label="Shuttle controls">
<Button fluid
content="Move shuttle"
disabled={!can_go_home}
onClick={() => act('move_shuttle')} />
</LabeledList.Item>
<LabeledList.Item
label="Unclaimed points">
<Button fluid
content={"Claim points (" + unclaimed_points + ")"}
disabled={!id_inserted || !unclaimed_points}
onClick={() => act('claim_points')} />
</LabeledList.Item>
<LabeledList.Item
label="Inserted ID">
<Button fluid
content={id_inserted ? id_name : '-------------'}
onClick={() => act('handle_id')} />
</LabeledList.Item>
</LabeledList>
</Section>
);
};
const MaterialValuesSection = (props, context) => {
const { data } = useBackend(context);
const {
ores,
} = data;
return (
<Section title="Material values">
<Table>
<Table.Row header>
<Table.Cell>
Material
</Table.Cell>
<Table.Cell collapsing textAlign="right">
Value
</Table.Cell>
</Table.Row>
{ores.map(ore => (
<Table.Row key={ore.ore}>
<Table.Cell>
{toTitleCase(ore.ore)}
</Table.Cell>
<Table.Cell collapsing textAlign="right">
<Box color="label" inline>
{ore.value}
</Box>
</Table.Cell>
</Table.Row>
))}
</Table>
</Section>
);
};
File diff suppressed because one or more lines are too long