From 811bf57d226903f761f6734483c9ddf187938642 Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Thu, 12 Mar 2015 19:51:27 +0100 Subject: [PATCH 1/2] NanoUI for Pool-Controller! (never again) --- code/game/machinery/poolcontroller.dm | 96 ++++++++++++--------------- nano/templates/poolcontroller.tmpl | 45 +++++++++++++ 2 files changed, 89 insertions(+), 52 deletions(-) create mode 100644 nano/templates/poolcontroller.tmpl diff --git a/code/game/machinery/poolcontroller.dm b/code/game/machinery/poolcontroller.dm index b4131a8437d..3e563295901 100644 --- a/code/game/machinery/poolcontroller.dm +++ b/code/game/machinery/poolcontroller.dm @@ -5,6 +5,7 @@ icon_state = "airlock_control_standby" var/list/linkedturfs = list() //List contains all of the linked pool turfs to this controller, assignment happens on New() 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/linkedmist = list() //Used to keep track of created mist var/misted = 0 //Used to check for mist. @@ -30,59 +31,11 @@ user << "\red Nothing happens." //If not emagged, don't do anything, and don't tell the user that it can be emagged. return //Return, nothing else needs to be done. - else //If it's not a multitool, defer to /obj/machinery/proc/attackby + else //If it's not a multitool, defer to /obj/machinery/attackby ..() -/obj/machinery/poolcontroller/attack_hand() - if(!Adjacent(usr)) - usr << "You moved away." - return - - if(emagged) //Emagging unlocks more (deadly) options. - var/temp = input("What temperature would you like to set the pool to?", "Pool Temperature") in list("Scalding","Frigid", "Warm", "Cool", "Normal","Cancel") //Allow user to choose which temperature they want. - - switch(temp) //Used for setting the actual temperature var based on user input. - if("Scalding") - miston() //Turn on warning mist for the pool - temperature = "scalding" //Burn em! - usr << "You flick the pool temperature to [temperature](WARNING)." //Differ from standard message to make sure the user understands the temperature is harmful. - return //Return to avoid calling the un-unique message. - if("Frigid") - temperature = "frigid" - usr << "You flick the pool temperature to [temperature](WARNING)." //Differ from standard message to make sure the user understands the temperature is harmful. - mistoff() //this won't get called otherwise - return //Return to avoid calling the un-unique message. - - //Regular non-traitorous temperature choices still avalible. - if("Warm") - temperature = "warm" - if("Cool") - temperature = "cool" - if("Normal") - temperature = "normal" - if("Cancel") - return - - mistoff() //Remove all mist, setting it to scalding returns before now, only regular temperatures will call it - usr << "You flick the pool temperature to [temperature]." //Inform the mob of the temperature they just picked. - return - - else - var/temp = input("What temperature would you like to set the pool to?", "Pool Temperature") in list("Warm","Cool","Normal","Cancel") //Allow user to choose which temperature they want. - - switch(temp) //Used for setting the actual temperature var based on user input. - if("Warm") - temperature = "warm" - if("Cool") - temperature = "cool" - if("Normal") - temperature = "normal" - if("Cancel") //Cancel does nothing and leaves the temperature at it's previous state. - return - - mistoff() //Remove all mist, because it shouldn't be here if the pool is not set to scalding - usr << "You flick the pool temperature to [temperature]." //Display what the user picked. - return +/obj/machinery/poolcontroller/attack_hand(mob/user as mob) + ui_interact(user) /obj/machinery/poolcontroller/process() updateMobs() //Call the mob affecting proc @@ -136,4 +89,43 @@ /obj/machinery/poolcontroller/proc/mistoff() //Delete all /obj/effect/mist from all linked pool tiles. for(var/obj/effect/mist/M in linkedmist) del(M) - misted = 0 //no mist left, turn off the tracking var \ No newline at end of file + misted = 0 //no mist left, turn off the tracking var + +/obj/machinery/poolcontroller/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + var/data[0] + + data["currentTemp"] = capitalize(src.temperature) + data["emagged"] = emagged + data["TempColor"] = temperaturecolor + + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + if(!ui) + ui = new(user, src, ui_key, "poolcontroller.tmpl", "Pool Controller Interface", 520, 410) + ui.set_initial_data(data) + ui.open() + +/obj/machinery/poolcontroller/Topic(href, href_list) + + switch(href_list["temp"]) + if("Scalding") + src.temperature = "scalding" + src.temperaturecolor = "#FF0000" + miston() + if("Frigid") + src.temperature = "frigid" + src.temperaturecolor = "#00CCCC" + mistoff() + if("Warm") + src.temperature = "warm" + src.temperaturecolor = "#990000" + mistoff() + if("Cool") + src.temperature = "cool" + src.temperaturecolor = "#009999" + mistoff() + if("Normal") + src.temperature = "normal" + src.temperaturecolor = "" + mistoff() + + return 1 \ No newline at end of file diff --git a/nano/templates/poolcontroller.tmpl b/nano/templates/poolcontroller.tmpl new file mode 100644 index 00000000000..cd01e3e8a0e --- /dev/null +++ b/nano/templates/poolcontroller.tmpl @@ -0,0 +1,45 @@ + +
+
+ Current Temperature: +
+
+ {{:data.currentTemp}} +
+
+
+
+ {{if data.emagged}} + WARNING: SAFE MODE OVERRIDE + {{else}} + Safties Nominal + {{/if}} +
+
+
+
+ Temperature Selection: +
+ {{if data.emagged}} +
+ {{:helper.link('Scalding', 'circle-arrow-n', { 'temp' : 'Scalding' })}} +
+ {{/if}} +
+ {{:helper.link('Warm', 'circle-arrow-n', { 'temp' : 'Warm' })}} +
+
+ {{:helper.link('Normal', 'circle-arrow-e', { 'temp' : 'Normal' })}} +
+
+ {{:helper.link('Cool', 'circle-arrow-s', { 'temp' : 'Cool' })}} +
+ {{if data.emagged}} +
+ {{:helper.link('Frigid', 'circle-arrow-s', { 'temp' : 'Frigid' })}} +
+ {{/if}} +
\ No newline at end of file From e0f2c1ac78e846bb6a0e4da5042aa06e77148c9f Mon Sep 17 00:00:00 2001 From: Tigercat2000 Date: Thu, 12 Mar 2015 21:55:20 +0100 Subject: [PATCH 2/2] Fix according to MarkvA's comments --- code/game/machinery/poolcontroller.dm | 5 +++++ nano/templates/poolcontroller.tmpl | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/code/game/machinery/poolcontroller.dm b/code/game/machinery/poolcontroller.dm index 3e563295901..aff22a0a681 100644 --- a/code/game/machinery/poolcontroller.dm +++ b/code/game/machinery/poolcontroller.dm @@ -105,13 +105,18 @@ ui.open() /obj/machinery/poolcontroller/Topic(href, href_list) + if(..()) return 1 switch(href_list["temp"]) if("Scalding") + if(!src.emagged) + return 0 src.temperature = "scalding" src.temperaturecolor = "#FF0000" miston() if("Frigid") + if(!src.emagged) + return 0 src.temperature = "frigid" src.temperaturecolor = "#00CCCC" mistoff() diff --git a/nano/templates/poolcontroller.tmpl b/nano/templates/poolcontroller.tmpl index cd01e3e8a0e..246542107a2 100644 --- a/nano/templates/poolcontroller.tmpl +++ b/nano/templates/poolcontroller.tmpl @@ -15,7 +15,7 @@ Used In File(s): \code\game\machinery\poolcontroller.dm {{if data.emagged}} WARNING: SAFE MODE OVERRIDE {{else}} - Safties Nominal + Safeties Nominal {{/if}}