Adds a remote interaction state for NanoUI.

This state has two checks:
A preliminary check of the remote target, ensuring it's powered, etc. If the remote target is fully disabled, it closes the window and conducts no further checks.
It then makes a full check, ensuring that the mob is capable, within range of the source remoting to the remote target, etc.

Unlike most other static interaction states, whoever initializes the remote state is responsible for deleting it properly.

Conflicts:
	polaris.dme
This commit is contained in:
PsiOmegaDelta
2015-12-03 09:27:28 +01:00
committed by Neerti
parent f09dfe8347
commit 9db4ba1da0
6 changed files with 59 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
/datum/proc/nano_host()
return src
/datum/proc/nano_container()
return src
/datum/proc/CanUseTopic(var/mob/user, var/datum/topic_state/state)
var/src_object = nano_host()
return state.can_use_topic(src_object, user)

View File

@@ -0,0 +1,7 @@
/*
This state always returns STATUS_INTERACTIVE
*/
/var/global/datum/topic_state/interactive/interactive_state = new()
/datum/topic_state/interactive/can_use_topic(var/src_object, var/mob/user)
return STATUS_INTERACTIVE

View File

@@ -0,0 +1,39 @@
/*
This state checks that user is capable, within range of the remoter, etc. and that src_object meets the basic requirements for interaction (being powered, non-broken, etc.
Whoever initializes this state is also responsible for deleting it properly.
*/
/datum/topic_state/remote
var/datum/remoter
var/datum/remote_target
var/datum/topic_state/remoter_state
/datum/topic_state/remote/New(var/remoter, var/remote_target, var/datum/topic_state/remoter_state = default_state)
src.remoter = remoter
src.remote_target = remote_target
src.remoter_state = remoter_state
..()
/datum/topic_state/remote/Destroy()
src.remoter = null
src.remoter_state = null
// Force an UI update before we go, ensuring that any windows we may have opened for the remote target closes.
nanomanager.update_uis(remote_target.nano_container())
remote_target = null
return ..()
/datum/topic_state/remote/can_use_topic(var/datum/src_object, var/mob/user)
if(!(remoter && remoter_state)) // The remoter is gone, let us leave
return STATUS_CLOSE
if(src_object != remote_target)
error("remote - Unexpected src_object: Expected '[remote_target]'/[remote_target.type], was '[src_object]'/[src_object.type]")
// This checks if src_object is powered, etc.
// The interactive state is otherwise simplistic and only returns STATUS_INTERACTIVE and never checks distances, etc.
. = src_object.CanUseTopic(user, interactive_state)
if(. == STATUS_CLOSE)
return
// This is the (generally) heavy checking, making sure the user is capable, within range of the remoter source, etc.
return min(., remoter.CanUseTopic(user, remoter_state))

View File

@@ -428,6 +428,9 @@ nanoui is used to open and update nano browser uis
user << browse(null, "window=[window_id]")
for(var/datum/nanoui/child in children)
child.close()
children.Cut()
state = null
master_ui = null
/**
* Set the UI window to call the nanoclose verb when the window is closed