Switch to client-side hotkey toggling

This commit is contained in:
Mark van Alphen
2019-04-05 19:53:01 +02:00
parent aa44ffa74e
commit aa58a88296
10 changed files with 757 additions and 797 deletions
-1
View File
@@ -17,4 +17,3 @@
/mob/camera/Login()
..()
update_interface()
-2
View File
@@ -7,5 +7,3 @@
if(GLOB.non_respawnable_keys[ckey])
can_reenter_corpse = 0
GLOB.respawnable_list -= src
update_interface()
-2
View File
@@ -17,6 +17,4 @@
//Should update regardless of if we can ventcrawl, since we can end up in pipes in other ways.
update_pipe_vision()
update_interface()
return .
@@ -1,6 +1,7 @@
/mob/living/silicon/robot/Login()
..()
if(client)
client.hotkeytype = "Cyborg"
regenerate_icons()
show_laws(0)
var/datum/hotkey_mode/cyborg/C = new()
winset(src, null, "mainwindow.macro_hotkey_mode_inactive=[C.macro_hotkeys_inactive] mainwindow.macro_hotkey_mode_active=[C.macro_hotkeys_active] mainwindow.macro=[C.macro_hotkeys_inactive] hotkey_toggle.is-checked=false input.focus=true input.background-color=#d3b5b5")
-26
View File
@@ -72,29 +72,3 @@
update_client_colour(0)
callHook("mob_login", list("client" = client, "mob" = src))
// Calling update_interface() in /mob/Login() causes the Cyborg to immediately be ghosted; because of winget().
// Calling it in the overriden Login, such as /mob/living/Login() doesn't cause this.
/mob/proc/update_interface()
spawn() // Spawn off so winget/winset don't delay callers.
if(client)
if(winget(src, "mainwindow.hotkey_toggle", "is-checked") == "true")
update_hotkey_mode()
else
update_normal_mode()
/mob/proc/update_hotkey_mode()
var/hotkeyname = "hotkeymode"
if(client)
var/hotkeys = client.hotkeylist[client.hotkeytype]
hotkeyname = hotkeys[client.hotkeyon ? "on" : "off"]
client.hotkeyon = 1
winset(src, null, "mainwindow.macro=[hotkeyname] hotkey_toggle.is-checked=true mapwindow.map.focus=true input.background-color=#F0F0F0")
/mob/proc/update_normal_mode()
var/hotkeyname = "macro"
if(client)
var/hotkeys = client.hotkeylist[client.hotkeytype]//get the list containing the hotkey names
hotkeyname = hotkeys[client.hotkeyon ? "on" : "off"]//get the name of the hotkey, to not clutter winset() to much
client.hotkeyon = 0
winset(src, null, "mainwindow.macro=[hotkeyname] hotkey_toggle.is-checked=false input.focus=true input.background-color=#D3B5B5")