mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-15 17:13:46 +01:00
Switch to client-side hotkey toggling
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/datum/hotkey_mode
|
||||
var/name
|
||||
var/macro_hotkeys_inactive
|
||||
var/macro_hotkeys_active
|
||||
|
||||
/datum/hotkey_mode/qwerty
|
||||
name = "QWERTY"
|
||||
macro_hotkeys_inactive = "macro"
|
||||
macro_hotkeys_active = "hotkeymode"
|
||||
|
||||
/datum/hotkey_mode/azerty
|
||||
name = "AZERTY"
|
||||
macro_hotkeys_inactive = "azertymacro"
|
||||
macro_hotkeys_active = "azertyhotkeymode"
|
||||
|
||||
/datum/hotkey_mode/cyborg
|
||||
name = "Cyborg"
|
||||
macro_hotkeys_inactive = "borgmacro"
|
||||
macro_hotkeys_active = "borghotkeymode"
|
||||
@@ -65,25 +65,6 @@
|
||||
// Set on login.
|
||||
var/datum/media_manager/media = null
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//adv. hotkey mode vars, code using them in /interface/interface.dm//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
var/hotkeytype = "QWERTY" //what set of hotkeys is in use(defaulting to QWERTY because I can't be bothered to make this save on SQL)
|
||||
var/hotkeyon = 0 //is the hotkey on?
|
||||
|
||||
var/hotkeylist = list( //list defining hotkey types, look at lists in place for structure if adding any if the future
|
||||
"QWERTY" = list(
|
||||
"on" = "hotkeymode",
|
||||
"off" = "macro"),
|
||||
"AZERTY" = list(
|
||||
"on" = "AZERTYon",
|
||||
"off" = "AZERTYoff"),
|
||||
"Cyborg" = list(
|
||||
"on" = "borghotkeymode",
|
||||
"off" = "borgmacro")
|
||||
)
|
||||
|
||||
var/topic_debugging = 0 //if set to true, allows client to see nanoUI errors -- yes i realize this is messy but it'll make live testing infinitely easier
|
||||
|
||||
control_freak = CONTROL_FREAK_ALL | CONTROL_FREAK_SKIN | CONTROL_FREAK_MACROS
|
||||
|
||||
@@ -17,4 +17,3 @@
|
||||
|
||||
/mob/camera/Login()
|
||||
..()
|
||||
update_interface()
|
||||
|
||||
@@ -7,5 +7,3 @@
|
||||
if(GLOB.non_respawnable_keys[ckey])
|
||||
can_reenter_corpse = 0
|
||||
GLOB.respawnable_list -= src
|
||||
|
||||
update_interface()
|
||||
@@ -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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
+21
-34
@@ -52,7 +52,6 @@
|
||||
src << link(config.forumurl)
|
||||
else
|
||||
to_chat(src, "<span class='danger'>The forum URL is not set in the server configuration.</span>")
|
||||
return
|
||||
|
||||
/client/verb/rules()
|
||||
set name = "Rules"
|
||||
@@ -64,7 +63,6 @@
|
||||
src << link(config.rulesurl)
|
||||
else
|
||||
to_chat(src, "<span class='danger'>The rules URL is not set in the server configuration.</span>")
|
||||
return
|
||||
|
||||
/client/verb/github()
|
||||
set name = "GitHub"
|
||||
@@ -76,7 +74,6 @@
|
||||
src << link(config.githuburl)
|
||||
else
|
||||
to_chat(src, "<span class='danger'>The GitHub URL is not set in the server configuration.</span>")
|
||||
return
|
||||
|
||||
/client/verb/discord()
|
||||
set name = "Discord"
|
||||
@@ -88,7 +85,6 @@
|
||||
src << link(config.discordurl)
|
||||
else
|
||||
to_chat(src, "<span class='danger'>The Discord URL is not set in the server configuration.</span>")
|
||||
return
|
||||
|
||||
/client/verb/donate()
|
||||
set name = "Donate"
|
||||
@@ -100,8 +96,28 @@
|
||||
src << link(config.donationsurl)
|
||||
else
|
||||
to_chat(src, "<span class='danger'>The rules URL is not set in the server configuration.</span>")
|
||||
return
|
||||
|
||||
/client/verb/hotkey_mode()
|
||||
set name = "Set Hotkey Mode"
|
||||
set category = "Preferences"
|
||||
|
||||
var/list/hotkey_modes = list()
|
||||
for(var/hotkey_mode in subtypesof(/datum/hotkey_mode))
|
||||
var/datum/hotkey_mode/H = hotkey_mode
|
||||
hotkey_modes[initial(H.name)] = H
|
||||
|
||||
var/chosen_mode_name = input("Choose your preferred hotkey mode.", "Hotkey mode selection") as null|anything in hotkey_modes
|
||||
if(!chosen_mode_name)
|
||||
return
|
||||
|
||||
var/datum/hotkey_mode/chosen_mode = hotkey_modes[chosen_mode_name]
|
||||
var/datum/hotkey_mode/hotkey_mode = new chosen_mode()
|
||||
|
||||
winset(mob, null, "mainwindow.macro_hotkey_mode_inactive=[hotkey_mode.macro_hotkeys_inactive] mainwindow.macro_hotkey_mode_active=[hotkey_mode.macro_hotkeys_active] mainwindow.macro=[hotkey_mode.macro_hotkeys_inactive] hotkey_toggle.is-checked=false input.focus=true input.background-color=#d3b5b5")
|
||||
to_chat(usr, "<span class='info'>Your hotkey mode has been changed to [hotkey_mode.name].</span>")
|
||||
|
||||
qdel(hotkey_mode)
|
||||
|
||||
/client/verb/hotkeys_help()
|
||||
set name = "Hotkey Help"
|
||||
set category = "OOC"
|
||||
@@ -234,32 +250,3 @@ Any-Mode: (hotkey doesn't need to be on)
|
||||
|
||||
to_chat(src, hotkey_mode)
|
||||
to_chat(src, other)
|
||||
|
||||
//adv. hotkey mode verbs, vars located in /code/modules/client/client defines.dm
|
||||
/client/verb/hotkey_toggle()//toggles hotkey mode between on and off, respects selected type
|
||||
set name = ".Toggle Hotkey Mode"
|
||||
|
||||
hotkeyon = !hotkeyon//toggle the var
|
||||
to_chat(usr, (hotkeyon ? "Hotkey mode enabled." : "Hotkey mode disabled."))//feedback to the user
|
||||
|
||||
if(hotkeyon)//using an if statement because I don't want to clutter winset() with ? operators
|
||||
winset(usr, "mainwindow.hotkey_toggle", "is-checked=true")//checks the button
|
||||
else
|
||||
winset(usr, "mainwindow.hotkey_toggle", "is-checked=false")//unchecks the button
|
||||
if(mob)
|
||||
mob.update_interface()
|
||||
|
||||
/client/verb/hotkey_mode()//asks user for the hotkey type and changes the macro accordingly
|
||||
set name = "Set Hotkey Mode"
|
||||
set category = "Preferences"
|
||||
|
||||
var/hkt = input("Choose hotkey mode", "Hotkey mode") as null|anything in hotkeylist//ask the user for the hotkey type
|
||||
if(!hkt)
|
||||
return
|
||||
hotkeytype = hkt
|
||||
|
||||
var/hotkeys = hotkeylist[hotkeytype]//get the list containing the hotkey names
|
||||
var/hotkeyname = hotkeys[hotkeyon ? "on" : "off"]//get the name of the hotkey, to not clutter winset() to much
|
||||
|
||||
winset(usr, "mainwindow", "macro=[hotkeyname]")//change the hotkey
|
||||
to_chat(usr, "Hotkey mode changed to [hotkeytype].")
|
||||
|
||||
+713
-711
File diff suppressed because it is too large
Load Diff
@@ -329,6 +329,7 @@
|
||||
#include "code\datums\helper_datums\construction_datum.dm"
|
||||
#include "code\datums\helper_datums\events.dm"
|
||||
#include "code\datums\helper_datums\global_iterator.dm"
|
||||
#include "code\datums\helper_datums\hotkey_modes.dm"
|
||||
#include "code\datums\helper_datums\icon_snapshot.dm"
|
||||
#include "code\datums\helper_datums\map_template.dm"
|
||||
#include "code\datums\helper_datums\teleport.dm"
|
||||
|
||||
Reference in New Issue
Block a user