reworks game preferences (characters v2 staging) (#6310)

Co-authored-by: silicons <no@you.cat>
Co-authored-by: LordME <58342752+TheLordME@users.noreply.github.com>
This commit is contained in:
silicons
2024-04-08 12:44:30 +02:00
committed by GitHub
co-authored by silicons LordME
parent 9f1b911556
commit 39bc14bb4a
427 changed files with 3981 additions and 2842 deletions
@@ -1,96 +0,0 @@
/datum/category_item/player_setup_item/player_global/ui
name = "UI"
sort_order = 1
/datum/category_item/player_setup_item/player_global/ui/load_preferences(var/savefile/S)
S["UI_style"] >> pref.UI_style
S["UI_style_color"] >> pref.UI_style_color
S["UI_style_alpha"] >> pref.UI_style_alpha
S["ooccolor"] >> pref.ooccolor
S["tooltipstyle"] >> pref.tooltipstyle
S["client_fps"] >> pref.client_fps
/datum/category_item/player_setup_item/player_global/ui/save_preferences(var/savefile/S)
S["UI_style"] << pref.UI_style
S["UI_style_color"] << pref.UI_style_color
S["UI_style_alpha"] << pref.UI_style_alpha
S["ooccolor"] << pref.ooccolor
S["tooltipstyle"] << pref.tooltipstyle
S["client_fps"] << pref.client_fps
/datum/category_item/player_setup_item/player_global/ui/sanitize_preferences()
pref.UI_style = sanitize_inlist(pref.UI_style, all_ui_styles, initial(pref.UI_style))
pref.UI_style_color = sanitize_hexcolor(pref.UI_style_color, 6, 1, default = initial(pref.UI_style_color))
pref.UI_style_alpha = sanitize_integer(pref.UI_style_alpha, 0, 255, initial(pref.UI_style_alpha))
pref.ooccolor = sanitize_hexcolor(pref.ooccolor, 6, 1, initial(pref.ooccolor))
pref.tooltipstyle = sanitize_inlist(pref.tooltipstyle, all_tooltip_styles, initial(pref.tooltipstyle))
pref.client_fps = sanitize_integer(pref.client_fps, 0, MAX_CLIENT_FPS, initial(pref.client_fps))
/datum/category_item/player_setup_item/player_global/ui/content(datum/preferences/prefs, mob/user, data)
. = "<b>UI Style:</b> <a href='?src=\ref[src];select_style=1'><b>[pref.UI_style]</b></a><br>"
. += "<b>Custom UI</b> (recommended for White UI):<br>"
. += "-Color: <a href='?src=\ref[src];select_color=1'><b>[pref.UI_style_color]</b></a> [color_square(hex = pref.UI_style_color)] <a href='?src=\ref[src];reset=ui'>reset</a><br>"
. += "-Alpha(transparency): <a href='?src=\ref[src];select_alpha=1'><b>[pref.UI_style_alpha]</b></a><a href='?src=\ref[src];reset=alpha'>reset</a><br>"
. += "<b>Tooltip Style:</b> <a href='?src=\ref[src];select_tooltip_style=1'><b>[pref.tooltipstyle]</b></a><br>"
. += "<b>Client FPS:</b> <a href='?src=\ref[src];select_client_fps=1'><b>[pref.client_fps]</b></a><br>"
if(can_select_ooc_color(user))
. += "<b>OOC Color:</b>"
if(pref.ooccolor == initial(pref.ooccolor))
. += "<a href='?src=\ref[src];select_ooc_color=1'><b>Using Default</b></a><br>"
else
. += "<a href='?src=\ref[src];select_ooc_color=1'><b>[pref.ooccolor]</b></a> <table style='display:inline;' bgcolor='[pref.ooccolor]'><tr><td>__</td></tr></table><a href='?src=\ref[src];reset=ooc'>reset</a><br>"
/datum/category_item/player_setup_item/player_global/ui/OnTopic(var/href,var/list/href_list, var/mob/user)
if(href_list["select_style"])
var/UI_style_new = tgui_input_list(user, "Choose UI style.", "Character Preference", all_ui_styles, pref.UI_style)
if(!UI_style_new || !CanUseTopic(user)) return PREFERENCES_NOACTION
pref.UI_style = UI_style_new
return PREFERENCES_REFRESH
else if(href_list["select_color"])
var/UI_style_color_new = input(user, "Choose UI color, dark colors are not recommended!", "Global Preference", pref.UI_style_color) as color|null
if(isnull(UI_style_color_new) || !CanUseTopic(user)) return PREFERENCES_NOACTION
pref.UI_style_color = UI_style_color_new
return PREFERENCES_REFRESH
else if(href_list["select_alpha"])
var/UI_style_alpha_new = input(user, "Select UI alpha (transparency) level, between 50 and 255.", "Global Preference", pref.UI_style_alpha) as num|null
if(isnull(UI_style_alpha_new) || (UI_style_alpha_new < 50 || UI_style_alpha_new > 255) || !CanUseTopic(user)) return PREFERENCES_NOACTION
pref.UI_style_alpha = UI_style_alpha_new
return PREFERENCES_REFRESH
else if(href_list["select_ooc_color"])
var/new_ooccolor = input(user, "Choose OOC color:", "Global Preference") as color|null
if(new_ooccolor && can_select_ooc_color(user) && CanUseTopic(user))
pref.ooccolor = new_ooccolor
return PREFERENCES_REFRESH
else if(href_list["select_tooltip_style"])
var/tooltip_style_new = tgui_input_list(user, "Choose tooltip style.", "Global Preference", all_tooltip_styles, pref.tooltipstyle)
if(!tooltip_style_new || !CanUseTopic(user)) return PREFERENCES_NOACTION
pref.tooltipstyle = tooltip_style_new
return PREFERENCES_REFRESH
else if(href_list["select_client_fps"])
var/fps_new = input(user, "Input Client FPS (1-200, 0 uses server FPS)", "Global Preference", pref.client_fps) as null|num
if(isnull(fps_new) || !CanUseTopic(user)) return PREFERENCES_NOACTION
if(fps_new < 0 || fps_new > MAX_CLIENT_FPS) return PREFERENCES_NOACTION
pref.client_fps = fps_new
if(pref.client)
pref.client.fps = fps_new
return PREFERENCES_REFRESH
else if(href_list["reset"])
switch(href_list["reset"])
if("ui")
pref.UI_style_color = initial(pref.UI_style_color)
if("alpha")
pref.UI_style_alpha = initial(pref.UI_style_alpha)
if("ooc")
pref.ooccolor = initial(pref.ooccolor)
return PREFERENCES_REFRESH
return ..()
/datum/category_item/player_setup_item/player_global/ui/proc/can_select_ooc_color(var/mob/user)
return CONFIG_GET(flag/allow_admin_ooccolor) && check_rights(R_ADMIN, 0, user)
@@ -7,129 +7,10 @@
sort_order = 2
/datum/category_item/player_setup_item/player_global/settings/load_preferences(var/savefile/S)
S["lastchangelog"] >> pref.lastchangelog
S["lastnews"] >> pref.lastnews
S["default_slot"] >> pref.default_slot
S["preferences"] >> pref.preferences_enabled
S["preferences_disabled"] >> pref.preferences_disabled
/datum/category_item/player_setup_item/player_global/settings/save_preferences(var/savefile/S)
S["lastchangelog"] << pref.lastchangelog
S["lastnews"] << pref.lastnews
S["default_slot"] << pref.default_slot
S["preferences"] << pref.preferences_enabled
S["preferences_disabled"] << pref.preferences_disabled
/datum/category_item/player_setup_item/player_global/settings/sanitize_preferences()
// Ensure our preferences are lists.
if(!istype(pref.preferences_enabled, /list))
pref.preferences_enabled = list()
if(!istype(pref.preferences_disabled, /list))
pref.preferences_disabled = list()
// Arrange preferences that have never been enabled/disabled.
var/list/client_preference_keys = list()
for(var/cp in get_client_preferences())
var/datum/client_preference/client_pref = cp
client_preference_keys += client_pref.key
if((client_pref.key in pref.preferences_enabled) || (client_pref.key in pref.preferences_disabled))
continue
if(client_pref.enabled_by_default)
pref.preferences_enabled += client_pref.key
else
pref.preferences_disabled += client_pref.key
// Clean out preferences that no longer exist.
for(var/key in pref.preferences_enabled)
if(!(key in client_preference_keys))
pref.preferences_enabled -= key
for(var/key in pref.preferences_disabled)
if(!(key in client_preference_keys))
pref.preferences_disabled -= key
pref.lastchangelog = sanitize_istext(pref.lastchangelog, initial(pref.lastchangelog))
pref.lastnews = sanitize_istext(pref.lastnews, initial(pref.lastnews))
pref.default_slot = sanitize_integer(pref.default_slot, 1, config_legacy.character_slots, initial(pref.default_slot))
/datum/category_item/player_setup_item/player_global/settings/content(datum/preferences/prefs, mob/user, data)
. = list()
. += "<b>Preferences</b><br>"
. += "<table>"
var/mob/pref_mob = preference_mob()
for(var/cp in get_client_preferences())
var/datum/client_preference/client_pref = cp
if(!client_pref.may_toggle(pref_mob))
continue
. += "<tr><td>[client_pref.description]: </td>"
if(pref_mob.is_preference_enabled(client_pref.key))
. += "<td><span class='linkOn'><b>[client_pref.enabled_description]</b></span></td> <td><a href='?src=\ref[src];toggle_off=[client_pref.key]'>[client_pref.disabled_description]</a></td>"
else
. += "<td><a href='?src=\ref[src];toggle_on=[client_pref.key]'>[client_pref.enabled_description]</a></td> <td><span class='linkOn'><b>[client_pref.disabled_description]</b></span></td>"
. += "</tr>"
. += "</table>"
return jointext(., "")
/datum/category_item/player_setup_item/player_global/settings/OnTopic(var/href,var/list/href_list, var/mob/user)
var/mob/pref_mob = preference_mob()
if(href_list["toggle_on"])
. = pref_mob.set_preference(href_list["toggle_on"], TRUE)
else if(href_list["toggle_off"])
. = pref_mob.set_preference(href_list["toggle_off"], FALSE)
if(.)
return PREFERENCES_REFRESH
return ..()
/client/proc/is_preference_enabled(var/preference)
var/datum/client_preference/cp = get_client_preference(preference)
if(isnull(cp))
return FALSE
return prefs?.initialized? (cp.key in prefs.preferences_enabled) : cp.enabled_by_default
/client/proc/set_preference(var/preference, var/set_preference)
var/datum/client_preference/cp = get_client_preference(preference)
if(!cp)
return FALSE
preference = cp.key
if(set_preference && !(preference in prefs.preferences_enabled))
return toggle_preference(cp)
else if(!set_preference && (preference in prefs.preferences_enabled))
return toggle_preference(cp)
/client/proc/toggle_preference(var/preference, var/set_preference)
var/datum/client_preference/cp = get_client_preference(preference)
if(!cp)
return FALSE
preference = cp.key
var/enabled
if(preference in prefs.preferences_disabled)
prefs.preferences_enabled |= preference
prefs.preferences_disabled -= preference
enabled = TRUE
. = TRUE
else if(preference in prefs.preferences_enabled)
prefs.preferences_enabled -= preference
prefs.preferences_disabled |= preference
enabled = FALSE
. = TRUE
if(.)
cp.toggled(mob, enabled)
/mob/proc/is_preference_enabled(var/preference)
if(!client)
return FALSE
return client.is_preference_enabled(preference)
/mob/proc/set_preference(var/preference, var/set_preference)
if(!client)
return FALSE
if(!client.prefs)
log_debug(SPAN_DEBUGWARNING("Client prefs found to be null for mob [src] and client [ckey], this should be investigated."))
return FALSE
return client.set_preference(preference, set_preference)
@@ -9,7 +9,6 @@
/datum/category_item/player_setup_item/player_global/ooc/save_preferences(var/savefile/S)
S["ignored_players"] << pref.ignored_players
/*
/datum/category_item/player_setup_item/player_global/ooc/sanitize_preferences()
if(isnull(pref.ignored_players))
pref.ignored_players = list()
@@ -39,4 +38,3 @@
return PREFERENCES_REFRESH
return ..()
*/
@@ -1,66 +0,0 @@
/datum/category_item/player_setup_item/player_global/language_prefix
name = "Language Prefix"
is_global = TRUE
save_key = GLOBAL_DATA_LANGUAGE_PREFIX
/datum/category_item/player_setup_item/player_global/language_prefix/proc/valid_prefix(c)
return length(c) == 1 && !(c in list(";", ":", ".", "!", "*", "^")) && !contains_az09(c)
/datum/category_item/player_setup_item/player_global/language_prefix/filter_data(datum/preferences/prefs, data, list/errors)
var/list/prefixes = data
prefixes = sanitize_islist(prefixes)
for(var/c in prefixes)
if(!valid_prefix(c))
prefixes -= c
if(!length(prefixes))
return default_value()
return prefixes
/datum/category_item/player_setup_item/player_global/language_prefix/content(datum/preferences/prefs, mob/user, data)
var/list/prefixes = data
. = list()
. += "<b>Language Keys</b><br>"
. += " [jointext(prefixes, "")] [href_simple(prefs, "change", "Change")] [href_simple(prefs, "reset", "Reset")]"
/datum/category_item/player_setup_item/player_global/language_prefix/act(datum/preferences/prefs, mob/user, action, list/params)
switch(action)
if("change")
var/char
var/keys[0]
do
char = input("Enter a single special character.\nYou may re-select the same characters.\nThe following characters are already in use by radio: ; : .\nThe following characters are already in use by special say commands: ! * ^", "Enter Character - [3 - keys.len] remaining") as null|text
if(char)
if(length(char) > 1)
alert(user, "Only single characters allowed.", "Error", "Ok")
else if(char in list(";", ":", "."))
alert(user, "Radio character. Rejected.", "Error", "Ok")
else if(char in list("!","*", "^"))
alert(user, "Say character. Rejected.", "Error", "Ok")
else if(contains_az09(char))
alert(user, "Non-special character. Rejected.", "Error", "Ok")
else
keys.Add(char)
while(char && keys.len < 3)
if(keys.len == 3)
write(prefs, keys)
return PREFERENCES_REFRESH
return PREFERENCES_HANDLED
if("reset")
write(prefs, config_legacy.language_prefixes.Copy())
return PREFERENCES_REFRESH
return ..()
/datum/category_item/player_setup_item/player_global/language_prefix/default_value(randomizing)
return config_legacy.language_prefixes.Copy()
/datum/preferences/proc/get_language_prefixes()
var/list/L = get_global_data(GLOBAL_DATA_LANGUAGE_PREFIX)
return L.Copy()
/datum/preferences/proc/get_primary_language_prefix()
var/list/L = get_global_data(GLOBAL_DATA_LANGUAGE_PREFIX)
return L[1]
/datum/preferences/proc/is_language_prefix(c)
return c in get_global_data(GLOBAL_DATA_LANGUAGE_PREFIX)
@@ -1,365 +0,0 @@
var/list/_client_preferences
var/list/_client_preferences_by_key
var/list/_client_preferences_by_type
/proc/get_client_preferences()
if(!_client_preferences)
_client_preferences = list()
for(var/ct in subtypesof(/datum/client_preference))
var/datum/client_preference/client_type = ct
if(initial(client_type.description))
_client_preferences += new client_type()
return _client_preferences
/proc/get_client_preference(var/datum/client_preference/preference)
if(istype(preference))
return preference
if(ispath(preference))
return get_client_preference_by_type(preference)
return get_client_preference_by_key(preference)
/proc/get_client_preference_by_key(var/preference)
if(!_client_preferences_by_key)
_client_preferences_by_key = list()
for(var/ct in get_client_preferences())
var/datum/client_preference/client_pref = ct
_client_preferences_by_key[client_pref.key] = client_pref
return _client_preferences_by_key[preference]
/proc/get_client_preference_by_type(var/preference)
if(!_client_preferences_by_type)
_client_preferences_by_type = list()
for(var/ct in get_client_preferences())
var/datum/client_preference/client_pref = ct
_client_preferences_by_type[client_pref.type] = client_pref
return _client_preferences_by_type[preference]
/datum/client_preference
var/description
var/key
var/enabled_by_default = TRUE
var/enabled_description = "Yes"
var/disabled_description = "No"
/datum/client_preference/proc/may_toggle(var/mob/preference_mob)
return TRUE
/datum/client_preference/proc/toggled(var/mob/preference_mob, var/enabled)
return
/*********************
* Player Preferences *
*********************/
/datum/client_preference/play_admin_midis
description ="Play admin midis"
key = "SOUND_MIDI"
/datum/client_preference/play_lobby_music
description ="Play lobby music"
key = "SOUND_LOBBY"
/datum/client_preference/play_lobby_music/toggled(var/mob/preference_mob, var/enabled)
if(!preference_mob.client || !preference_mob.client.media)
return
if(enabled)
preference_mob.client.playtitlemusic()
else
preference_mob.client.media.stop_music()
/datum/client_preference/play_ambiance
description ="Play ambience"
key = "SOUND_AMBIENCE"
/datum/client_preference/play_ambiance/toggled(var/mob/preference_mob, var/enabled)
if(!enabled)
SEND_SOUND(preference_mob, sound(null, repeat = 0, wait = 0, volume = 0, channel = 1))
SEND_SOUND(preference_mob, sound(null, repeat = 0, wait = 0, volume = 0, channel = 2))
// Need to put it here because it should be ordered riiiight here.
/datum/client_preference/play_jukebox
description ="Play jukebox music"
key = "SOUND_JUKEBOX"
/datum/client_preference/play_jukebox/toggled(var/mob/preference_mob, var/enabled)
if(!enabled)
preference_mob.stop_all_music()
else
preference_mob.update_music()
/datum/client_preference/eating_noises
description = "Eating Noises"
key = "EATING_NOISES"
enabled_description = "Noisy"
disabled_description = "Silent"
/datum/client_preference/digestion_noises
description = "Digestion Noises"
key = "DIGEST_NOISES"
enabled_description = "Noisy"
disabled_description = "Silent"
/datum/client_preference/weather_sounds
description ="Weather sounds"
key = "SOUND_WEATHER"
enabled_description = "Audible"
disabled_description = "Silent"
/datum/client_preference/supermatter_hum
description ="Supermatter hum"
key = "SOUND_SUPERMATTER"
enabled_description = "Audible"
disabled_description = "Silent"
/datum/client_preference/ghost_ears
description ="Ghost ears"
key = "CHAT_GHOSTEARS"
enabled_description = "All Speech"
disabled_description = "Nearby"
/datum/client_preference/ghost_sight
description ="Ghost sight"
key = "CHAT_GHOSTSIGHT"
enabled_description = "All Emotes"
disabled_description = "Nearby"
/datum/client_preference/ghost_radio
description ="Ghost radio"
key = "CHAT_GHOSTRADIO"
enabled_description = "All Chatter"
disabled_description = "Nearby"
/datum/client_preference/chat_tags
description ="Chat tags"
key = "CHAT_SHOWICONS"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/air_pump_noise
description ="Air Pump Ambient Noise"
key = "SOUND_AIRPUMP"
enabled_description = "Audible"
disabled_description = "Silent"
/datum/client_preference/mob_tooltips
description ="Mob tooltips"
key = "MOB_TOOLTIPS"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/pickup_sounds
description = "Picked Up Item Sounds"
key = "SOUND_PICKED"
enabled_description = "Enabled"
disabled_description = "Disabled"
/datum/client_preference/drop_sounds
description = "Dropped Item Sounds"
key = "SOUND_DROPPED"
enabled_description = "Enabled"
disabled_description = "Disabled"
/datum/client_preference/hotkeys_default
description ="Hotkeys Default"
key = "HUD_HOTKEYS"
enabled_description = "Enabled"
disabled_description = "Disabled"
enabled_by_default = FALSE // Backwards compatibility
/datum/client_preference/subtle_see
description = "Subtle Emotes"
key = "SUBTLE_SEE"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/show_typing_indicator
description ="Typing indicator"
key = "SHOW_TYPING"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/show_typing_indicator/toggled(var/mob/preference_mob, var/enabled)
if(!enabled)
preference_mob.set_typing_indicator(FALSE)
/datum/client_preference/show_ooc
description ="OOC chat"
key = "CHAT_OOC"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/show_looc
description ="LOOC chat"
key = "CHAT_LOOC"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/show_dsay
description ="Dead chat"
key = "CHAT_DEAD"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/check_mention
description ="Emphasize Name Mention"
key = "CHAT_MENTION"
enabled_description = "Emphasize"
disabled_description = "Normal"
/datum/client_preference/show_progress_bar
description ="Progress Bar"
key = "SHOW_PROGRESS"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/browser_style
description = "Fake NanoUI Browser Style"
key = "BROWSER_STYLED"
enabled_description = "Fancy"
disabled_description = "Plain"
/datum/client_preference/ambient_occlusion
description = "Fake Ambient Occlusion"
key = "AMBIENT_OCCLUSION_PREF"
enabled_by_default = FALSE
enabled_description = "On"
disabled_description = "Off"
/datum/client_preference/ambient_occlusion/toggled(var/mob/preference_mob, var/enabled)
. = ..()
if(preference_mob.client)
preference_mob?.using_perspective?.planes?.sync_owner(preference_mob.client)
/datum/client_preference/instrument_toggle
description ="Hear In-game Instruments"
key = "SOUND_INSTRUMENT"
/datum/client_preference/anonymous_ghost_chat
description = "Anonymous Ghost Chat"
key = "ANON_GHOST_CHAT"
enabled_by_default = FALSE
enabled_description = "Hide ckey"
disabled_description = "Show ckey"
/datum/client_preference/show_in_advanced_who
description = "Show my status in advanced who"
key = "SHOW_IN_ADVANCED_WHO"
enabled_by_default = TRUE
enabled_description = "Visible"
disabled_description = "Hidden"
/datum/client_preference/announce_ghost_joinleave
description = "Announce joining/leaving as a ghost/observer"
key = "ANNOUNCE_GHOST_JOINLEAVE"
enabled_by_default = TRUE
enabled_description = "Announce"
disabled_description = "Silent"
/datum/client_preference/help_intent_firing
description = "Allow firing on help intent"
key = "HELP_INTENT_SAFETY"
enabled_by_default = FALSE
enabled_description = "Allow"
disabled_description = "Forbid"
/datum/client_preference/parallax
description = "Parallax (fancy space, disable for FPS issues"
key = "PARALLAX_ENABLED"
enabled_description = "Enabled"
disabled_description = "Disabled"
/datum/client_preference/parallax/toggled(mob/preference_mob, enabled)
. = ..()
preference_mob?.client?.parallax_holder?.reset()
/datum/client_preference/overhead_chat
description = "Overhead Chat"
key = "OVERHEAD_CHAT"
enabled_description = "Show"
disabled_description = "Hide"
enabled_by_default = TRUE
/********************
* Staff Preferences *
********************/
/datum/client_preference/admin/may_toggle(var/mob/preference_mob)
return check_rights(R_ADMIN, 0, preference_mob)
/datum/client_preference/mod/may_toggle(var/mob/preference_mob)
return check_rights(R_MOD|R_ADMIN, 0, preference_mob)
/datum/client_preference/debug/may_toggle(var/mob/preference_mob)
return check_rights(R_DEBUG|R_ADMIN, 0, preference_mob)
/datum/client_preference/mod/show_attack_logs
description = "Attack Log Messages"
key = "CHAT_ATTACKLOGS"
enabled_description = "Show"
disabled_description = "Hide"
enabled_by_default = FALSE
/datum/client_preference/debug/show_debug_logs
description = "Debug Log Messages"
key = "CHAT_DEBUGLOGS"
enabled_description = "Show"
disabled_description = "Hide"
enabled_by_default = FALSE
/datum/client_preference/admin/show_chat_prayers
description = "Chat Prayers"
key = "CHAT_PRAYER"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/holder/may_toggle(var/mob/preference_mob)
return preference_mob && preference_mob.client && preference_mob.client.holder
/datum/client_preference/holder/play_adminhelp_ping
description = "Adminhelps"
key = "SOUND_ADMINHELP"
enabled_description = "Hear"
disabled_description = "Silent"
/datum/client_preference/holder/hear_radio
description = "Radio chatter"
key = "CHAT_RADIO"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/holder/show_rlooc
description ="Remote LOOC chat"
key = "CHAT_RLOOC"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/holder/obfuscate_stealth_dsay
description = "Obfuscate Stealthmin Dsay"
key = "OBFUSCATE_STEALTH_DSAY"
enabled_by_default = FALSE
enabled_description = "On"
disabled_description = "Off"
/datum/client_preference/holder/stealth_ghost_mode
description = "Stealthmin Ghost Mode"
key = "STEALTH_GHOST_MODE"
enabled_by_default = FALSE
enabled_description = "Obfuscate Ghost"
disabled_description = "Normal Ghost"
/datum/client_preference/autocorrect
description = "Autocorrect"
key = "AUTOCORRECT"
enabled_description = "Enabled"
disabled_description = "Disabled"
/datum/client_preference/examine_look
description = "Examine Messages"
key = "EXAMINE_LOOK"
enabled_description = "Show"
disabled_description = "Hide"
/datum/client_preference/language_indicator
description = "Language Indicators"
key = "LANGUAGE_INDICATOR"
enabled_description = "Show"
disabled_description = "Hide"
@@ -1,214 +0,0 @@
// todo: convert and make looking up keys BY BIND possible
/datum/preferences
/// Custom Keybindings
var/list/key_bindings = list()
/// Hotkeys mode
var/hotkeys = TRUE
//Used in savefile update from 11, can be removed once that is no longer relevant.
/datum/preferences/proc/force_reset_keybindings()
var/choice = tgalert(client.mob, "Your basic keybindings need to be reset, emotes will remain as before. Would you prefer 'hotkey' or 'classic' mode?", "Reset keybindings", "Hotkey", "Classic")
hotkeys = (choice != "Classic")
var/list/oldkeys = key_bindings
key_bindings = (hotkeys) ? deep_copy_list(GLOB.hotkey_keybinding_list_by_key) : deep_copy_list(GLOB.classic_keybinding_list_by_key)
for(var/key in oldkeys)
if(!key_bindings[key])
key_bindings[key] = oldkeys[key]
client.update_movement_keys()
/datum/category_group/player_setup_category/keybindings
name = "Keybindings"
sort_order = 7
category_item_type = /datum/category_item/player_setup_item/keybinding
auto_split = FALSE
/datum/category_item/player_setup_item/keybinding/hotkey_mode
name = "Hotkey Mode"
sort_order = 1
/datum/category_item/player_setup_item/keybinding/hotkey_mode/load_preferences(savefile/S)
S["hotkeys"] >> pref.hotkeys
/datum/category_item/player_setup_item/keybinding/hotkey_mode/save_preferences(savefile/S)
WRITE_FILE(S["hotkeys"], pref.hotkeys)
/datum/category_item/player_setup_item/keybinding/hotkey_mode/sanitize_preferences()
pref.hotkeys = sanitize_integer(pref.hotkeys, 0, 1, initial(pref.hotkeys))
/datum/category_item/player_setup_item/keybinding/hotkey_mode/content(datum/preferences/prefs, mob/user, data)
. += "<b>Hotkey mode:</b> <a href='?src=[REF(src)];option=hotkeys'>[(pref.hotkeys) ? "Hotkeys" : "Default"]</a><br>"
. += "Keybindings mode controls how the game behaves with tab and map/input focus.<br>If it is on <b>Hotkeys</b>, the game will always attempt to force you to map focus, meaning keypresses are sent \
directly to the map instead of the input. You will still be able to use the command bar, but you need to tab to do it every time you click on the game map.<br>\
If it is on <b>Input</b>, the game will not force focus away from the input bar, and you can switch focus using TAB between these two modes: If the input bar is pink, that means that you are in non-hotkey mode, sending all keypresses of the normal \
alphanumeric characters, punctuation, spacebar, backspace, enter, etc, typing keys into the input bar. If the input bar is white, you are in hotkey mode, meaning all keypresses go into the game's keybind handling system unless you \
manually click on the input bar to shift focus there.<br>\
Input mode is the closest thing to the old input system.<br>\
<b>IMPORTANT:</b> While in input mode's non hotkey setting (tab toggled), Ctrl + KEY will send KEY to the keybind system as the key itself, not as Ctrl + KEY. This means Ctrl + T/W/A/S/D/all your familiar stuff still works, but you \
won't be able to access any regular Ctrl binds.<br>"
/datum/category_item/player_setup_item/keybinding/hotkey_mode/OnTopic(href, list/href_list, mob/user)
if(href_list["option"])
switch(href_list["option"])
if("hotkeys")
pref.hotkeys = !pref.hotkeys
user.client.set_macros()
return PREFERENCES_REFRESH
return ..()
/datum/category_item/player_setup_item/keybinding/bindings
name = "Bindings"
sort_order = 2
/datum/category_item/player_setup_item/keybinding/bindings/load_preferences(savefile/S)
S["key_bindings"] >> pref.key_bindings
/datum/category_item/player_setup_item/keybinding/bindings/save_preferences(savefile/S)
WRITE_FILE(S["key_bindings"], pref.key_bindings)
/datum/category_item/player_setup_item/keybinding/bindings/sanitize_preferences()
pref.key_bindings = sanitize_islist(pref.key_bindings, list())
for(var/key in pref.key_bindings)
var/list/L = pref.key_bindings[key]
for(var/kb in L)
if(!GLOB.keybindings_by_name[kb])
L -= kb
if(!length(L))
pref.key_bindings -= key
/datum/category_item/player_setup_item/keybinding/bindings/content(datum/preferences/prefs, mob/user, data)
. = list()
var/list/key_bindings = pref.key_bindings //cache for speed or atleast my finger's sake..
// Create an inverted list of keybindings -> key
var/list/user_binds = list()
for (var/key in key_bindings)
for(var/kb_name in key_bindings[key])
user_binds[kb_name] += list(key)
var/list/kb_categories = list()
// Group keybinds by category
for (var/name in GLOB.keybindings_by_name)
var/datum/keybinding/kb = GLOB.keybindings_by_name[name]
kb_categories[kb.category] += list(kb)
. += "<style>label { display: inline-block; width: 200px; }</style><body>"
for (var/category in kb_categories)
. += "<h3>[category]</h3>"
for (var/i in kb_categories[category])
var/datum/keybinding/kb = i
if(!length(user_binds[kb.name]))
. += "<label>[kb.full_name]</label> <a href ='?src=[REF(src)];option=keybindings_capture;keybinding=[kb.name];old_key=["Unbound"]'>Unbound</a>"
var/list/default_keys = pref.hotkeys ? kb.hotkey_keys : kb.classic_keys
if(LAZYLEN(default_keys))
. += "| Default: [default_keys.Join(", ")]"
. += "<br>"
else
var/bound_key = user_binds[kb.name][1]
. += "<label>[kb.full_name]</label> <a href ='?src=[REF(src)];option=keybindings_capture;keybinding=[kb.name];old_key=[bound_key]'>[bound_key]</a>"
for(var/bound_key_index in 2 to length(user_binds[kb.name]))
bound_key = user_binds[kb.name][bound_key_index]
. += " | <a href ='?src=[REF(src)];option=keybindings_capture;keybinding=[kb.name];old_key=[bound_key]'>[bound_key]</a>"
if(length(user_binds[kb.name]) < MAX_KEYS_PER_KEYBIND)
. += "| <a href ='?src=[REF(src)];option=keybindings_capture;keybinding=[kb.name]'>Add Secondary</a>"
var/list/default_keys = pref.hotkeys ? kb.classic_keys : kb.hotkey_keys
if(LAZYLEN(default_keys))
. += "| Default: [default_keys.Join(", ")]"
. += "<br>"
. += "<br><br>"
. += "<a href ='?src=[REF(src)];option=keybindings_reset'>\[Reset to default\]</a>"
. += "</body>"
. = jointext(., null)
/datum/category_item/player_setup_item/keybinding/bindings/OnTopic(href, list/href_list, mob/user)
if(href_list["option"])
switch(href_list["option"])
if("keybindings_capture")
var/datum/keybinding/kb = GLOB.keybindings_by_name[href_list["keybinding"]]
var/old_key = href_list["old_key"]
pref.CaptureKeybinding(user, kb, old_key, src)
return
if("keybindings_set")
var/kb_name = href_list["keybinding"]
if(!kb_name)
user << browse(null, "window=capturekeypress")
return PREFERENCES_REFRESH
var/clear_key = text2num(href_list["clear_key"])
var/old_key = href_list["old_key"]
if(clear_key)
if(pref.key_bindings[old_key])
pref.key_bindings[old_key] -= kb_name
if(!length(pref.key_bindings[old_key]))
pref.key_bindings -= old_key
user << browse(null, "window=capturekeypress")
SScharacters.queue_preferences_save(pref)
return PREFERENCES_REFRESH
var/new_key = uppertext(href_list["key"])
var/AltMod = text2num(href_list["alt"]) ? "Alt" : ""
var/CtrlMod = text2num(href_list["ctrl"]) ? "Ctrl" : ""
var/ShiftMod = text2num(href_list["shift"]) ? "Shift" : ""
var/numpad = text2num(href_list["numpad"]) ? "Numpad" : ""
// var/key_code = text2num(href_list["key_code"])
if(GLOB._kbMap[new_key])
new_key = GLOB._kbMap[new_key]
var/full_key
switch(new_key)
if("Alt")
full_key = "[new_key][CtrlMod][ShiftMod]"
if("Ctrl")
full_key = "[AltMod][new_key][ShiftMod]"
if("Shift")
full_key = "[AltMod][CtrlMod][new_key]"
else
full_key = "[AltMod][CtrlMod][ShiftMod][numpad][new_key]"
if(pref.key_bindings[old_key])
pref.key_bindings[old_key] -= kb_name
if(!length(pref.key_bindings[old_key]))
pref.key_bindings -= old_key
pref.key_bindings[full_key] += list(kb_name)
pref.key_bindings[full_key] = sortList(pref.key_bindings[full_key])
user << browse(null, "window=capturekeypress")
user.client.update_movement_keys()
SScharacters.queue_preferences_save(pref)
if("keybindings_reset")
var/choice = tgalert(user, "Would you prefer 'hotkey' or 'classic' defaults?", "Setup keybindings", "Hotkey", "Classic", "Cancel")
if(choice == "Cancel")
return PREFERENCES_REFRESH
pref.hotkeys = (choice == "Hotkey")
pref.key_bindings = (pref.hotkeys) ? deep_copy_list(GLOB.hotkey_keybinding_list_by_key) : deep_copy_list(GLOB.classic_keybinding_list_by_key)
user.client.update_movement_keys()
return PREFERENCES_REFRESH
return ..()
/datum/preferences/proc/CaptureKeybinding(mob/user, datum/keybinding/kb, old_key, datum/category_item/player_setup_item/keybinding/bindings/host)
var/HTML = {"
<div id='focus' style="outline: 0;" tabindex=0>Keybinding: [kb.full_name]<br>[kb.description]<br><br><b>Press any key to change<br>Press ESC to clear</b></div>
<script>
var deedDone = false;
document.onkeyup = function(e) {
if(deedDone){ return; }
var alt = e.altKey ? 1 : 0;
var ctrl = e.ctrlKey ? 1 : 0;
var shift = e.shiftKey ? 1 : 0;
var numpad = (95 < e.keyCode && e.keyCode < 112) ? 1 : 0;
var escPressed = e.keyCode == 27 ? 1 : 0;
var url = 'byond://?src=[REF(host)];option=keybindings_set;keybinding=[kb.name];old_key=[old_key];clear_key='+escPressed+';key='+e.key+';alt='+alt+';ctrl='+ctrl+';shift='+shift+';numpad='+numpad+';key_code='+e.keyCode;
window.location=url;
deedDone = true;
}
document.getElementById('focus').focus();
</script>
"}
winshow(user, "capturekeypress", TRUE)
var/datum/browser/popup = new(user, "capturekeypress", "<div align='center'>Keybindings</div>", 350, 300)
popup.set_content(HTML)
popup.open(FALSE)
onclose(user, "capturekeypress", src)