Re-structure tgui's ui_act

This commit is contained in:
Bjorn Neergaard
2016-01-22 19:25:36 -06:00
parent 4c192d705a
commit 1599742f7e
47 changed files with 713 additions and 621 deletions
+3 -2
View File
@@ -45,8 +45,9 @@
*
* return bool If the UI should be updated or not.
**/
/datum/proc/ui_act(action, list/params)
return 0 // Not implemented.
/datum/proc/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
if(!ui || ui.status != UI_INTERACTIVE)
return 1 // If UI is not interactive or usr calling Topic is not the UI user, bail.
/**
+16 -12
View File
@@ -16,17 +16,18 @@
var/width = 0 // The window width.
var/height = 0 // The window height
var/window_options = list( // Extra options to winset().
"focus" = 0,
"titlebar" = 1,
"can_resize" = 1,
"can_minimize" = 1,
"can_maximize" = 0,
"can_close" = 1,
"auto_format" = 0
"focus" = FALSE,
"titlebar" = TRUE,
"can_resize" = TRUE,
"can_minimize" = TRUE,
"can_maximize" = FALSE,
"can_close" = TRUE,
"auto_format" = FALSE
)
var/style = "nanotrasen" // The style to be used for this UI.
var/interface // The interface (template) to be used for this UI.
var/auto_update = 1 // Update the UI every MC tick.
var/auto_update = TRUE // Update the UI every MC tick.
var/initialized = FALSE // If the UI has been initialized yet.
var/list/initial_data // The data (and datastructure) used to initialize the UI.
var/status = UI_INTERACTIVE // The status/visibility of the UI.
var/datum/ui_state/state = null // Topic state used to determine status/interactability.
@@ -258,6 +259,9 @@
* If the src_object's ui_act() returns 1, update all UIs attacked to it.
**/
/datum/tgui/Topic(href, href_list)
if(user != usr)
return // Something is not right here.
var/action = href_list["action"]
var/params = href_list; params -= "action"
@@ -265,6 +269,7 @@
switch(action)
if("tgui:initialize")
user << output(url_encode(get_json(initial_data)), "[window_id].browser:initialize")
initialized = TRUE
return
if("tgui:link")
user << link(params["url"])
@@ -277,10 +282,7 @@
return
update_status(push = 0) // Update the window state.
if(status != UI_INTERACTIVE || user != usr)
return // If UI is not interactive or usr calling Topic is not the UI user.
var/update = src_object.ui_act(action, params, state) // Call ui_act() on the src_object.
var/update = src_object.ui_act(action, params, src, state) // Call ui_act() on the src_object.
if(src_object && update)
SStgui.update_uis(src_object) // If we have a src_object and its ui_act() told us to update.
@@ -313,6 +315,8 @@
**/
/datum/tgui/proc/push_data(data, force = 0)
update_status(push = 0) // Update the window state.
if(!initialized)
return // Cannot upadte UI if it is not set up yet.
if(status <= UI_DISABLED && !force)
return // Cannot update UI, we have no visibility.