Fix tgui proc signatures and thus AI APC reboot

This allows state overloading

Make AI reboot code use ui_interact instead of attack_ai
Fixes #13762
This commit is contained in:
Bjorn Neergaard
2016-01-04 16:25:20 -06:00
parent f021d1920a
commit aec6bc103c
20 changed files with 75 additions and 81 deletions
+5 -11
View File
@@ -17,9 +17,7 @@
* optional master_ui datum/tgui The parent UI.
* optional state datum/ui_state The state used to determine status.
**/
/datum/proc/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, \
force_open = 0, datum/tgui/master_ui = null, \
datum/ui_state/state = default_state)
/datum/proc/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = default_state)
return -1 // Sorta implemented.
/**
@@ -76,21 +74,17 @@
*
* required uiref ref The UI that was closed.
**/
/client/verb/uiclose(uiref as text)
/client/verb/uiclose(ref as text)
// Name the verb, and hide it from the user panel.
set name = "uiclose"
set hidden = 1
// Get the UI based on the ref.
var/datum/tgui/ui = locate(uiref)
var/datum/tgui/ui = locate(ref)
// If we found the UI, close it.
if(istype(ui))
ui.close()
// If there is a custom ref, call that atom's Topic().
if(ui.ref)
var/href = "close=1"
src.Topic(href, params2list(href), ui.ref)
// Otherwise, if we use the legacy logic, unset the mob's machine.
else if(src && src.mob)
// Unset machine just to be sure.
if(src && src.mob)
src.mob.unset_machine()
+2 -6
View File
@@ -13,20 +13,16 @@
* required src_object datum The object/datum which owns the UI.
* required ui_key string The ui_key of the UI.
* optional ui datum/tgui The UI to be updated, if it exists.
* optional data list The data to update the UI with, if it exists.
* optional force_open bool If the UI should be re-opened instead of updated.
*
* return datum/tgui The found UI.
**/
/datum/subsystem/tgui/proc/try_update_ui(mob/user, datum/src_object, ui_key, datum/tgui/ui, \
list/data = null, force_open = 0)
if(!data)
data = src_object.get_ui_data(user)
/datum/subsystem/tgui/proc/try_update_ui(mob/user, datum/src_object, ui_key, datum/tgui/ui, force_open = 0)
if(isnull(ui)) // No UI was passed, so look for one.
ui = get_open_ui(user, src_object, ui_key)
if(!isnull(ui))
var/data = src_object.get_ui_data(user) // Get data from the src_object.
if(!force_open) // UI is already open; update it.
ui.push_data(data)
else // Re-open it anyways.
+3 -15
View File
@@ -24,7 +24,6 @@
"can_close" = 1,
"auto_format" = 0
)
var/atom/ref = null // An extra ref to call when the window is closed.
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.
@@ -46,16 +45,12 @@
* optional title string The title of the UI.
* optional width int The window width.
* optional height int The window height.
* optional ref atom An extra ref to use when the window is closed.
* optional master_ui datum/tgui The parent UI.
* optional state datum/ui_state The state used to determine status.
*
* return datum/tgui The requested UI.
**/
/datum/tgui/New(mob/user, datum/src_object, ui_key, interface, \
title, width = 0, height = 0, \
atom/ref = null, datum/tgui/master_ui = null, \
datum/ui_state/state = default_state)
/datum/tgui/New(mob/user, datum/src_object, ui_key, interface, title, width = 0, height = 0, datum/tgui/master_ui = null, datum/ui_state/state = default_state)
src.user = user
src.src_object = src_object
src.ui_key = ui_key
@@ -70,9 +65,6 @@
if(height)
src.height = height
if(ref)
src.ref = ref
src.master_ui = master_ui
if(master_ui)
master_ui.children += src
@@ -85,10 +77,8 @@
* public
*
* Open this UI (and initialize it with data).
*
* optional data list The data to intialize the UI with.
**/
/datum/tgui/proc/open(list/data = null)
/datum/tgui/proc/open()
set waitfor = 0 // Don't wait on sleep()s.
if(!user.client)
return // Bail if there is no client.
@@ -98,9 +88,7 @@
return // Bail if we're not supposed to open.
if(!initial_data)
if(!data) // If we don't have initial_data and data was not passed, get data from the src_object.
data = src_object.get_ui_data(user)
set_initial_data(data) // Otherwise use the passed data.
set_initial_data(src_object.get_ui_data(user)) // Get the UI data.
var/window_size = ""
if(width && height) // If we have a width and height, use them.