mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-28 06:27:26 +01:00
Update pool controller to use tgui
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
var/decalinpool = list() // List containing all of the cleanable decals in pool
|
||||
var/linked_area = null
|
||||
var/temperature = NORMAL //The temperature of the pool, starts off on normal, which has no effects.
|
||||
var/temperaturecolor = "" //used for nanoUI fancyness
|
||||
var/srange = 5 //The range of the search for pool turfs, change this for bigger or smaller pools.
|
||||
var/list/linkedmist = list() //Used to keep track of created mist
|
||||
var/deep_water = FALSE //set to 1 to drown even standing people
|
||||
@@ -68,7 +67,7 @@
|
||||
to_chat(user, "<span class='warning'>Nothing happens.</span>")//If not emagged, don't do anything, and don't tell the user that it can be emagged.
|
||||
|
||||
/obj/machinery/poolcontroller/attack_hand(mob/user as mob)
|
||||
ui_interact(user)
|
||||
tgui_interact(user)
|
||||
|
||||
/obj/machinery/poolcontroller/process()
|
||||
processMob() //Call the mob affecting proc
|
||||
@@ -151,64 +150,74 @@
|
||||
linkedmist.Cut()
|
||||
|
||||
|
||||
/obj/machinery/poolcontroller/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
/obj/machinery/poolcontroller/tgui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = TRUE, 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, "poolcontroller.tmpl", "Pool Controller Interface", 520, 410)
|
||||
ui = new(user, src, ui_key, "PoolController", "Pool Controller Interface", 520, 410)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/poolcontroller/ui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
|
||||
var/data[0]
|
||||
var/currenttemp
|
||||
switch(temperature) //So we can output nice things like "Cool" to nanoUI
|
||||
/obj/machinery/poolcontroller/proc/temp_to_str(temp)
|
||||
switch(temp) //So we can output nice things like "Cool" to tgUI
|
||||
if(FRIGID)
|
||||
currenttemp = "frigid"
|
||||
return "frigid"
|
||||
if(COOL)
|
||||
currenttemp = "cool"
|
||||
return "cool"
|
||||
if(NORMAL)
|
||||
currenttemp = "normal"
|
||||
return "normal"
|
||||
if(WARM)
|
||||
currenttemp = "warm"
|
||||
return "warm"
|
||||
if(SCALDING)
|
||||
currenttemp = "scalding"
|
||||
data["currentTemp"] = currenttemp
|
||||
return "scalding"
|
||||
|
||||
/obj/machinery/poolcontroller/proc/set_temp(val)
|
||||
if (val != WARM && val != NORMAL && val != COOL && !(emagged && (val == SCALDING || val == FRIGID)))
|
||||
return
|
||||
|
||||
if(val == SCALDING)
|
||||
miston()
|
||||
else
|
||||
mistoff()
|
||||
|
||||
temperature = val
|
||||
|
||||
|
||||
/obj/machinery/poolcontroller/proc/str_to_temp(str)
|
||||
switch(str)
|
||||
if("frigid")
|
||||
return FRIGID
|
||||
if("cool")
|
||||
return COOL
|
||||
if("normal")
|
||||
return NORMAL
|
||||
if("warm")
|
||||
return WARM
|
||||
if("scalding")
|
||||
return SCALDING
|
||||
|
||||
/obj/machinery/poolcontroller/proc/set_temp_str(target)
|
||||
var/temp = str_to_temp(target)
|
||||
if(temp)
|
||||
set_temp(temp)
|
||||
|
||||
|
||||
/obj/machinery/poolcontroller/tgui_data(mob/user, ui_key = "main", datum/topic_state/state = GLOB.default_state)
|
||||
var/list/data = list()
|
||||
data["currentTemp"] = temp_to_str(temperature)
|
||||
data["emagged"] = emagged
|
||||
data["TempColor"] = temperaturecolor
|
||||
|
||||
return data
|
||||
|
||||
|
||||
/obj/machinery/poolcontroller/Topic(href, href_list)
|
||||
/obj/machinery/poolcontroller/tgui_act(action, list/params)
|
||||
if(..())
|
||||
return 1
|
||||
return FALSE
|
||||
|
||||
switch(href_list["temp"])
|
||||
if("Scalding")
|
||||
if(!emagged)
|
||||
return 0
|
||||
temperature = SCALDING
|
||||
temperaturecolor = "#FF0000"
|
||||
miston()
|
||||
if("Frigid")
|
||||
if(!emagged)
|
||||
return 0
|
||||
temperature = FRIGID
|
||||
temperaturecolor = "#00CCCC"
|
||||
mistoff()
|
||||
if("Warm")
|
||||
temperature = WARM
|
||||
temperaturecolor = "#990000"
|
||||
mistoff()
|
||||
if("Cool")
|
||||
temperature = COOL
|
||||
temperaturecolor = "#009999"
|
||||
mistoff()
|
||||
if("Normal")
|
||||
temperature = NORMAL
|
||||
temperaturecolor = ""
|
||||
mistoff()
|
||||
switch(action)
|
||||
if("setTemp")
|
||||
set_temp_str(params["temp"])
|
||||
return TRUE
|
||||
|
||||
return 1
|
||||
return FALSE
|
||||
|
||||
#undef FRIGID
|
||||
#undef COOL
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
<!--
|
||||
Title: Pool Controller UI.
|
||||
Used In File(s): \code\game\machinery\poolcontroller.dm
|
||||
-->
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
<b>Current Temperature</b>:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
<font color={{:data.TempColor}}>{{:helper.capitalizeFirstLetter(data.currentTemp)}}</font>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemLabel">
|
||||
Safety Status:
|
||||
</div>
|
||||
<div class="itemContent">
|
||||
{{if data.emagged}}
|
||||
<b><font color='red'>WARNING: OVERRIDDEN</font></b>
|
||||
{{else}}
|
||||
<b><font color='green'>Nominal</font></b>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item">
|
||||
<div class="itemContent">
|
||||
<b>Temperature Selection:</b>
|
||||
</div>
|
||||
|
||||
{{if data.emagged}}
|
||||
<div class="itemContentWide" style="width: 100%;">
|
||||
{{:helper.link('Scalding', 'arrow-circle-up', { 'temp' : 'Scalding' }, data.currentTemp == "scalding" ? 'selected' : null)}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="itemContentWide" style="width: 100%;">
|
||||
{{:helper.link('Warm', 'arrow-circle-up', { 'temp' : 'Warm' }, data.currentTemp == "warm" ? 'selected' : null)}}
|
||||
</div>
|
||||
|
||||
<div class="itemContentWide" style="width: 100%;">
|
||||
{{:helper.link('Normal', 'arrow-circle-right', { 'temp' : 'Normal' }, data.currentTemp == "normal" ? 'selected' : null)}}
|
||||
</div>
|
||||
|
||||
<div class="itemContentWide" style="width: 100%;">
|
||||
{{:helper.link('Cool', 'arrow-circle-down', { 'temp' : 'Cool' }, data.currentTemp == "cool" ? 'selected' : null)}}
|
||||
</div>
|
||||
|
||||
{{if data.emagged}}
|
||||
<div class="itemContentWide" style="width: 100%;">
|
||||
{{:helper.link('Frigid', 'arrow-circle-down', { 'temp' : 'Frigid' }, data.currentTemp == "frigid" ? 'selected' : null)}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
@@ -0,0 +1,85 @@
|
||||
import { useBackend, useLocalState } from "../backend";
|
||||
import { Box, Button, Flex, Icon, Input, LabeledList, Section, Table, Tabs } from '../components';
|
||||
import { Window } from "../layouts";
|
||||
|
||||
const TEMPS = {
|
||||
scalding: { label: 'Scalding', color: '#FF0000', icon: 'fa fa-arrow-circle-up', requireEmag: true },
|
||||
warm: { label: 'Warm', color: '#990000', icon: 'fa fa-arrow-circle-up' },
|
||||
normal: { label: 'Normal', color: null, icon: 'fa fa-arrow-circle-right' },
|
||||
cool: { label: 'Cool', color: '#009999', icon: 'fa fa-arrow-circle-down' },
|
||||
frigid: { label: 'Frigid', color: '#00CCCC', icon: 'fa fa-arrow-circle-down', requireEmag: true },
|
||||
};
|
||||
|
||||
const TempButton = (properties, context) => {
|
||||
const { tempKey } = properties;
|
||||
const temp = TEMPS[tempKey];
|
||||
if (!temp) {
|
||||
return null;
|
||||
}
|
||||
const { data, act } = useBackend(context);
|
||||
const { currentTemp } = data;
|
||||
const { label, icon } = temp;
|
||||
const selected = tempKey === currentTemp;
|
||||
const setTemp = () => {
|
||||
act('setTemp', { temp: tempKey });
|
||||
};
|
||||
return (
|
||||
<div style={{ margin: '0 0 4px 0' }}>
|
||||
<Button selected={selected} onClick={setTemp} >
|
||||
<i className={icon} />
|
||||
{label}
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export const PoolController = (properties, context) => {
|
||||
const { data, act } = useBackend(context);
|
||||
const { emagged, currentTemp } = data;
|
||||
const { label: currentLabel, color: currentColor } = TEMPS[currentTemp] || TEMPS.normal;
|
||||
|
||||
return (
|
||||
<Window>
|
||||
<Window.Content>
|
||||
|
||||
<LabeledList>
|
||||
<LabeledList.Item labelColor="yellow" labelClassName="text-bold" label="Current Temperature">
|
||||
<span style={{ color: currentColor }}>
|
||||
{currentLabel}
|
||||
</span>
|
||||
</LabeledList.Item>
|
||||
|
||||
<LabeledList.Item labelColor="yellow" label="Saftey Status">
|
||||
{emagged ? (
|
||||
<span className="text-bold" style={{ color: 'red' }}>
|
||||
WARNING: OVERRIDDEN
|
||||
</span>
|
||||
) : (
|
||||
<span style={{ color: 'green' }}>
|
||||
Nominal
|
||||
</span>
|
||||
)}
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
|
||||
<div className="text-bold" style={{ margin: '8px 0 5px 0' }}>
|
||||
Temperature Selection:
|
||||
</div>
|
||||
|
||||
<div>
|
||||
{Object.keys(TEMPS).map(tempKey => {
|
||||
const temp = TEMPS[tempKey];
|
||||
const { requireEmag } = temp;
|
||||
if (requireEmag && !emagged) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<TempButton key={tempKey} tempKey={tempKey} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user