NanoUI Update: Seperate UI Data into ui_data() proc

This commit changes how NanoUI's live data updating system works.
Previously, data for the template was directly gathered in the
ui_interact proc. Now, it is seperated into the proc `ui_data`.

To players, this does absolutely nothing.
To coders, this opens up the potential for a much more complicated and
fancy graphical updating system in the future, because the data is
available on-demand without ever having to call
nanomanager.try_update_ui.
This commit is contained in:
Tigercat2000
2016-12-14 13:37:34 -08:00
parent 23717e9949
commit b9abce843d
78 changed files with 964 additions and 889 deletions
+14 -9
View File
@@ -113,6 +113,16 @@
repeat = 0
/datum/song/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1)
if(!instrumentObj)
return
ui = nanomanager.try_update_ui(user, instrumentObj, ui_key, ui, force_open)
if(!ui)
ui = new(user, instrumentObj, ui_key, "song.tmpl", instrumentObj.name, 700, 500)
ui.open()
ui.set_auto_update(1)
/datum/song/ui_data(mob/user, datum/topic_state/state = default_state)
var/data[0]
data["lines"] = lines
@@ -125,15 +135,7 @@
data["minTempo"] = world.tick_lag
data["maxTempo"] = 600
if(!instrumentObj)
return
ui = nanomanager.try_update_ui(user, instrumentObj, ui_key, ui, data, force_open)
if(!ui)
ui = new(user, instrumentObj, ui_key, "song.tmpl", instrumentObj.name, 700, 500)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)
return data
/datum/song/Topic(href, href_list)
if(!in_range(instrumentObj, usr) || (issilicon(usr) && instrumentObj.loc != usr) || !isliving(usr) || !usr.canmove || usr.restrained())
@@ -294,6 +296,9 @@
song.ui_interact(user, ui_key, ui, force_open)
/obj/structure/piano/ui_data(mob/user, datum/topic_state/state = default_state)
return song.ui_data(user, state)
/obj/structure/piano/Topic(href, href_list)
song.Topic(href, href_list)