Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NanoUI for Pool-Controller! (never again) #570

Merged
merged 2 commits into from Mar 15, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 44 additions & 52 deletions code/game/machinery/poolcontroller.dm
Expand Up @@ -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.
Expand All @@ -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 << "<span class='warning'>You flick the pool temperature to [temperature](WARNING).</span>" //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 << "<span class='warning'>You flick the pool temperature to [temperature](WARNING).</span>" //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 << "<span class='warning'>You flick the pool temperature to [temperature].</span>" //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 << "<span class='warning'>You flick the pool temperature to [temperature].</span>" //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
Expand Down Expand Up @@ -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
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add if(..()) return 1 here to ensure people can't use the machine at range.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will point out this is fixed on the next line, but github being github means this still appears


switch(href_list["temp"])
if("Scalding")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add if(emagged) checks in all the emag Topic href's to prevent exploits.

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
45 changes: 45 additions & 0 deletions nano/templates/poolcontroller.tmpl
@@ -0,0 +1,45 @@
<!--
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}}>{{:data.currentTemp}}</font>
</div>
</div>
<div class="item">
<div class="itemContent">
{{if data.emagged}}
<b><font color='red'>WARNING: SAFE MODE OVERRIDE</font></b>
{{else}}
<b><font color='green'>Safties Nominal</font></b>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo.

{{/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', 'circle-arrow-n', { 'temp' : 'Scalding' })}}
</div>
{{/if}}
<div class="itemContentWide" style="width: 100%;">
{{:helper.link('Warm', 'circle-arrow-n', { 'temp' : 'Warm' })}}
</div>
<div class="itemContentWide" style="width: 100%;">
{{:helper.link('Normal', 'circle-arrow-e', { 'temp' : 'Normal' })}}
</div>
<div class="itemContentWide" style="width: 100%;">
{{:helper.link('Cool', 'circle-arrow-s', { 'temp' : 'Cool' })}}
</div>
{{if data.emagged}}
<div class="itemContentWide" style="width: 100%;">
{{:helper.link('Frigid', 'circle-arrow-s', { 'temp' : 'Frigid' })}}
</div>
{{/if}}
</div>