Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WiP] New player preferences #13141

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
dc568f2
new preferences
volas Jun 3, 2024
4a6d05a
Serverside zoom settings
volas Jun 6, 2024
2d5175d
skin cleanup
volas Jun 14, 2024
a27396a
redone display settings
volas Jun 22, 2024
2569f57
Rename skin windwow so our settings don't conflict with other servers
volas Jun 22, 2024
e0e1276
Merge branch 'master' of github.com:TauCetiStation/TauCetiClassic int…
volas Jul 5, 2024
07135fa
meta / little things
volas Jul 11, 2024
d5aed9e
Backport of some tgui keyevent related things from tg
volas Jul 23, 2024
4275185
also this helper proc from tg
volas Jul 23, 2024
6b279ad
Keybinds, or part where everything gets worse
volas Jul 23, 2024
5ae06a8
new unit test
volas Jul 23, 2024
05a83fc
minimize
volas Jul 23, 2024
573bede
keybinds now converting from old saves too, cleanup
volas Jul 26, 2024
e9a23f7
little things
volas Jul 26, 2024
e216813
emote panel, looks terrible and i don't like it
volas Jul 28, 2024
1f0e845
Merge branch 'master' of github.com:TauCetiStation/TauCetiClassic int…
volas Aug 20, 2024
1fe4e75
better ui for admin/support prefs
volas Aug 20, 2024
0ec64b3
Audio settings final cleanup
volas Aug 21, 2024
606bc21
ghost skin pref
volas Aug 22, 2024
b504546
final cleanup
volas Aug 22, 2024
b5e9290
adjusted chat colors
volas Aug 23, 2024
4398f9e
fixes
volas Aug 25, 2024
6b3c8e0
prefs
volas Aug 25, 2024
a631147
Merge branch 'master' of github.com:TauCetiStation/TauCetiClassic int…
volas Aug 25, 2024
f425150
test warning
volas Aug 25, 2024
c73ada3
hud check
volas Aug 25, 2024
5e14777
proper fix for ui settings
volas Aug 25, 2024
f3a2c0c
Fixed give hotkey
volas Aug 28, 2024
a46329b
emote keybinds, sorted order, other things
volas Aug 30, 2024
e6c1451
Merge branch 'master' of github.com:TauCetiStation/TauCetiClassic int…
volas Aug 30, 2024
8f4b011
ci
volas Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/COMPONENTOWNERS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ components:
## Код ##

# /code/
code/modules/client/preferences_savefile.dm: volas
code/modules/client/: volas

## Конфиги ##
config/: volas
Expand Down
1 change: 0 additions & 1 deletion code/__DEFINES/chat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#define MESSAGE_TYPE_ATTACKLOG "attacklog"
#define MESSAGE_TYPE_DEBUG "debug"


// To chat defines
#define to_chat_private(usr, msg, type) to_chat(usr, msg, type, confidential = TRUE)

Expand Down
11 changes: 11 additions & 0 deletions code/__DEFINES/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,14 @@
0, 0, 0, 1, \
0, 0, 0, 0)

/**
* CHAT COLORS
*
* These are used in both dark and light chat themes and override default (css) colors,
* so should be accessible with both background colors
* (#ffffff for light, #131313 for dark, test it with any color contrast checker)
*/
#define OOC_COLOR_SUPPORTER "#cca000" // we use it just for nickname
#define OOC_COLOR_EVENTADMIN "#ae566d"
#define OOC_COLOR_CODEADMIN "#257227"
#define OOC_COLOR_ADMIN "#b82b00"
6 changes: 6 additions & 0 deletions code/__DEFINES/fonts.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define FONT_SYSTEM "System"
#define FONT_FIXEDSYS "Fixedsys"
#define FONT_SMALL_FONTS "Small Fonts"
#define FONT_TIMES_NEW_ROMAN "Times New Roman"
#define FONT_SERIF "Serif"
#define FONT_VERDANA "Verdana"
123 changes: 88 additions & 35 deletions code/__DEFINES/preferences.dm
Original file line number Diff line number Diff line change
@@ -1,43 +1,77 @@
//Preference toggles (it had more bits, but updating player saves without wiping method is a bit more complex).
#define SHOW_ANIMATIONS 16
#define SHOW_PROGBAR 32

#define TOGGLES_DEFAULT (SHOW_ANIMATIONS|SHOW_PROGBAR)

//Chat toggles
#define CHAT_OOC 1
#define CHAT_DEAD 2
#define CHAT_GHOSTEARS 4
#define CHAT_NOCLIENT_ATTACK 8
#define CHAT_PRAYER 16
#define CHAT_RADIO 32
#define CHAT_ATTACKLOGS 64
#define CHAT_DEBUGLOGS 128
#define CHAT_LOOC 256
#define CHAT_GHOSTRADIO 512
#define CHAT_GHOSTNPC 1024
#define CHAT_CKEY 2048

#define TOGGLES_DEFAULT_CHAT (CHAT_OOC|CHAT_DEAD|CHAT_NOCLIENT_ATTACK|CHAT_GHOSTEARS|CHAT_PRAYER|CHAT_RADIO|CHAT_GHOSTRADIO|CHAT_GHOSTNPC|CHAT_ATTACKLOGS|CHAT_LOOC|CHAT_CKEY)

#define GLOW_HIGH 0
#define GLOW_MED 1 //default.
#define GLOW_LOW 2
#define GLOW_DISABLE 3 //this option must be the highest number

#define PARALLAX_INSANE -1 //for show offs
#define PARALLAX_HIGH 0 //default.
#define PARALLAX_MED 1
#define PARALLAX_LOW 2
#define PARALLAX_DISABLE 3 //this option must be the highest number
// this can be little confusing, but call it as you would call
// /datum/preferences/proc/get_pref(type)
// ex. client.prefs.get_pref()
#define get_pref(type) prefs_player[type].value

// maximum binds per keybind
#define KEYBINDS_MAXIMUM 3

// pref types
#define PREF_TYPE_BOOLEAN "boolean"
#define PREF_TYPE_TEXT "text"
//#define PREF_TYPE_INTEGER "integer"
#define PREF_TYPE_RANGE "range"
#define PREF_TYPE_SELECT "select"
#define PREF_TYPE_HEX "hex"
#define PREF_TYPE_KEYBIND "keybind"
#define PREF_TYPE_CUSTOM "custom"

// pref domains (categories)
#define PREF_DOMAIN_PLAYER "player"
#define PREF_DOMAIN_KEYBINDS "keybinds"
#define PREF_DOMAIN_META "meta"
#define PREF_DOMAIN_CHARACTER "character" // todo

// player pref domain subcategories
#define PREF_PLAYER_DISPLAY "display"
#define PREF_PLAYER_EFFECTS "effects"
#define PREF_PLAYER_AUDIO "audio"
#define PREF_PLAYER_UI "ui"
#define PREF_PLAYER_CHAT "chat"
#define PREF_PLAYER_GAME "game"

// keybinds pref domain subcategories
#define PREF_KEYBINDS_CLIENT "CLIENT"
#define PREF_KEYBINDS_COMMUNICATION "COMMUNICATION"
#define PREF_KEYBINDS_MOVEMENT "MOVEMENT"
#define PREF_KEYBINDS_CARBON "CARBON"
#define PREF_KEYBINDS_HUMAN "HUMAN"
#define PREF_KEYBINDS_ROBOT "ROBOT"
#define PREF_KEYBINDS_EMOTE "EMOTE"
#define PREF_KEYBINDS_MISC "MISC"

///datum/pref/player/display/zoom_mode
#define SCALING_METHOD_NORMAL "normal"
#define SCALING_METHOD_DISTORT "distort"
//#define SCALING_METHOD_BLUR "blur" // gives worst result so currently not used and players can't choice it

///datum/pref/player/effects/glowlevel
#define GLOW_HIGH "high"
#define GLOW_MED "med"
#define GLOW_LOW "low"
#define GLOW_DISABLE "disable"

///datum/pref/player/effects/parallax
#define PARALLAX_INSANE "insane" //for show offs
#define PARALLAX_HIGH "high" //default.
#define PARALLAX_MED "med"
#define PARALLAX_LOW "low"
#define PARALLAX_DISABLE "disable"

#define PARALLAX_DELAY_DEFAULT world.tick_lag
#define PARALLAX_DELAY_MED 1
#define PARALLAX_DELAY_LOW 2

#define CHAT_GHOSTSIGHT_ALL 1
#define CHAT_GHOSTSIGHT_ALLMANUAL 2
#define CHAT_GHOSTSIGHT_NEARBYMOBS 3
///datum/pref/player/chat/attack_log
#define ATTACK_LOG_DISABLED "disabled"
#define ATTACK_LOG_BY_CLIENT "by_client"
//#define ATTACK_LOG_BOTH_CLIENT "both_client" // todo
#define ATTACK_LOG_ALL "all"

///datum/pref/player/game/ghost_skin
#define GHOST_SKIN_CHARACTER "character"
#define GHOST_SKIN_GHOST "ghost"
#define GHOST_SKIN_FLUFF "fluff"

//used for alternate_option
#define GET_RANDOM_JOB 0
Expand All @@ -55,3 +89,22 @@

//recommened client FPS
#define RECOMMENDED_FPS 100

// ui themes
#define UI_STYLE_WHITE "White"
#define UI_STYLE_MIDNIGHT "Midnight"
#define UI_STYLE_OLD "Old"
#define UI_STYLE_ORANGE "Orange"

// keybinds weight
#define WEIGHT_HIGHEST 0
#define WEIGHT_ADMIN 10
#define WEIGHT_CLIENT 20
#define WEIGHT_ROBOT 30
#define WEIGHT_MOB 40
#define WEIGHT_LIVING 50
#define WEIGHT_DEAD 60
#define WEIGHT_EMOTE 70
#define WEIGHT_LOWEST 999


31 changes: 17 additions & 14 deletions code/__DEFINES/sound.dm
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
//volume channels for client's volume sliders.
#define VOL_MUSIC (1<<0) // lobby.
#define VOL_AMBIENT (1<<1) // ambient music/environment sounds.

#define VOL_EFFECTS_MASTER (1<<2) // anything that doesn't go into sub categories (this acts as a master channel for all subs of this type).
//effects sub categories (VOL_EFFECTS_MASTER included, so that we don't need to type it everytime when we want to use just a sub category).
#define VOL_EFFECTS_VOICE_ANNOUNCEMENT (VOL_EFFECTS_MASTER | 1<<3) // voiced global announcements.
#define VOL_EFFECTS_MISC (VOL_EFFECTS_MASTER | 1<<4) // for any sound that may annoy players (like tesla engine).
#define VOL_EFFECTS_INSTRUMENT (VOL_EFFECTS_MASTER | 1<<5) // music instruments! actually this could be merged into spam category.
// OOC audio
#define VOL_LOBBY_MUSIC (1<<0) // music in lobby
#define VOL_NOTIFICATIONS (1<<1) // mainly for ghosts, such as cloning ready, admin pm, etc
#define VOL_ADMIN_SOUNDS (1<<2) // admin sounds or music (fun category)

#define VOL_NOTIFICATIONS (1<<6) // mainly for ghosts, such as cloning ready, admin pm, etc.
#define VOL_ADMIN (1<<7) // admin sounds or music (fun category).

// jukebox not a VOL_MUSIC sub category because jukebox plays thru javascript, which is not boynd's sound datum.
// IC audio
#define VOL_AMBIENT (1<<3) // ambient music/environment sounds
#define VOL_EFFECTS_MASTER (1<<4) // effects sounds // todo: rename to VOL_EFFECTS when you have time to push 500+ files change
#define VOL_VOICE_ANNOUNCEMENTS (1<<5) // voiced global announcements
#define VOL_MUSIC_INSTRUMENTS (1<<6) // music instruments!
#define VOL_SPAM_EFFECTS (1<<7) // separated channel for some spamming and annoying sounds so player can setup them separately (ex. tesla engine).
#define VOL_JUKEBOX (1<<8)

//Misc
#define VOL_LINEAR_TO_NON(vol_raw) ((20 ** clamp(vol_raw * 0.01, 0, 1.0)) - 0.99) / (20 - 0.99) // this converts byond's linear volume into non linear (don't change anything without heavy testing with debug, even 0.01 difference may break the sound or functions that connects with this).
#define SANITIZE_VOL(vol) vol * 0.5 // environment setting can overload sound that use 100% volume (0.5 actually is max, if you want pure sound with anything).
// converts raw preference volume (1-100) to non linear coefficient (0-1) we apply for SANITIZE_VOL(playsound volume)
// to get final client volume before any others environment effects
// (don't change anything without heavy testing with debug, even 0.01 difference may break the sound or functions that connects with this).
#define VOL_LINEAR_TO_NON(vol_raw) ((20 ** clamp(vol_raw * 0.01, 0, 1.0)) - 0.99) / (20 - 0.99)
// environment settings can overload sound that uses 100% volume, so we cap default volume at 50%
// (which means our build is quieter than others!!!)
#define SANITIZE_VOL(vol) vol * 0.5

//sound channels, max is 1024
#define CHANNEL_AMBIENT 1
Expand Down
1 change: 1 addition & 0 deletions code/__DEFINES/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
#define SS_WAIT_GNAW 20
#define SS_WAIT_DEFAULT 20
#define SS_WAIT_UNIT_TESTS 20
#define SS_WAIT_PREFERENCES 30
#define SS_WAIT_SUN 600
#define SS_WAIT_SMARTLIGHT 600

Expand Down
18 changes: 9 additions & 9 deletions code/__HELPERS/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,17 @@

/// Ensures that the lightness value of a color must be greater than the provided minimum.
/proc/color_lightness_max(color, min_lightness)
var/list/rgb = rgb2num(color)
var/list/hsl = rgb2hsl(rgb[1], rgb[2], rgb[3])
var/list/hsl = rgb2num(color, COLORSPACE_HSL)
hsl[3] = max(hsl[3], min_lightness)
var/list/transformed_rgb = hsl2rgb(hsl[1], hsl[2], hsl[3])
return rgb(transformed_rgb[1], transformed_rgb[2], transformed_rgb[3])
return rgb(hsl[1], hsl[2], hsl[3], space=COLORSPACE_HSL)

/// Ensures that the lightness value of a color must be less than the provided maximum.
/proc/color_lightness_min(color, max_lightness)
var/list/rgb = rgb2num(color)
var/list/hsl = rgb2hsl(rgb[1], rgb[2], rgb[3])
// Ensure high lightness (Minimum of 90%)
var/list/hsl = rgb2num(color, COLORSPACE_HSL)
hsl[3] = min(hsl[3], max_lightness)
var/list/transformed_rgb = hsl2rgb(hsl[1], hsl[2], hsl[3])
return rgb(transformed_rgb[1], transformed_rgb[2], transformed_rgb[3])
return rgb(hsl[1], hsl[2], hsl[3], space=COLORSPACE_HSL)

/proc/color_lightness_clamp(color, min_lightness, max_lightness)
var/list/hsl = rgb2num(color, COLORSPACE_HSL)
hsl[3] = clamp(hsl[3], min_lightness, max_lightness)
return rgb(hsl[1], hsl[2], hsl[3], space=COLORSPACE_HSL)
4 changes: 2 additions & 2 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
var/turf/ear = get_turf(M)
if(ear)
// Ghostship is magic: Ghosts can hear radio chatter from anywhere
if(speaker_coverage[ear] || (isobserver(M) && (M.client) && (M.client.prefs.chat_toggles & CHAT_GHOSTRADIO)))
if(speaker_coverage[ear] || (isobserver(M) && (M.client) && M.client.prefs.get_pref(/datum/pref/player/chat/ghostradio)))
. |= M // Since we're already looping through mobs, why bother using |= ? This only slows things down.
return .

Expand Down Expand Up @@ -506,7 +506,7 @@
C = M.client
if(!C)
return
winset(C, "mainwindow", "flash=5")
winset(C, "tcmainwindow", "flash=5")

//============VG PORTS============
/proc/recursive_type_check(atom/O, type = /atom)
Expand Down
18 changes: 14 additions & 4 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
sort_surgeries()

// Keybindings
for(var/KB in subtypesof(/datum/keybinding))
/* for(var/KB in subtypesof(/datum/keybinding))
var/datum/keybinding/keybinding = KB
if(!initial(keybinding.name))
continue
var/datum/keybinding/instance = new keybinding
global.keybindings_by_name[instance.name] = instance
if(length(instance.hotkey_keys))
for(var/bound_key in instance.hotkey_keys)
global.hotkey_keybinding_list_by_key[bound_key] += list(instance.name)
global.hotkey_keybinding_list_by_key[bound_key] += list(instance.name)*/

init_subtypes(/datum/crafting_recipe, crafting_recipes)
init_subtypes(/datum/dirt_cover, global.all_dirt_covers)
Expand Down Expand Up @@ -248,8 +248,12 @@
global.skillset_names_aliases[skillset.name] = s

global.all_emotes = list()
for(var/emote_type in subtypesof(/datum/emote))
global.all_emotes[emote_type] = new emote_type
global.all_emotes_keys = list()
for(var/emote_type as anything in subtypesof(/datum/emote))
var/datum/emote/E = new emote_type
global.all_emotes[emote_type] = E
if(E.key && E.key != "list")
global.all_emotes_keys |= E.key

global.emotes_for_emote_panel = list()
var/emote_icons = 'icons/misc/emotes.dmi'
Expand Down Expand Up @@ -297,6 +301,12 @@
for(var/datum/ringtone/Ring as anything in subtypesof(/datum/ringtone))
global.ringtones_by_names["[initial(Ring.name)]"] = new Ring

for(var/datum/pref/keybinds/KB as anything in subtypesof(/datum/pref/keybinds))
if(initial(KB.legacy_keyname))
legacy_keyname_to_pref[initial(KB.legacy_keyname)] = KB
// little fuckup happened and leap key was not converted on time and lost
legacy_keyname_to_pref["leap"] = /datum/pref/keybinds/human/race_ability

init_washing_items_list()

/proc/init_washing_items_list()
Expand Down
61 changes: 61 additions & 0 deletions code/__HELPERS/keys.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// list of valid byond keyboard keys based on https://www.byond.com/docs/ref/#/{skin}/macros
// + some missing from the table that were found experimentally
// not all of them are mapped with js keys and available to bind currently
var/global/list/byond_valid_keys = list (
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12",
"`", "-", "=", "\\",
"\[", "\]", ";", "'", ",", ".", "/",
"Numpad0", "Numpad1", "Numpad2", "Numpad3", "Numpad4", "Numpad5", "Numpad6", "Numpad7", "Numpad8", "Numpad9",
"North", "South", "East", "West", "Northwest", "Southwest", "Northeast", "Southeast",
"Center", "Return", "Escape", "Tab", "Space", "Back", "Insert", "Delete", "Pause", "Snapshot",
"LWin", "RWin", "Apps",
"Multiply", "Add", "Subtract", "Divide", "Separator",
"Shift", "Ctrl", "Alt",
"VolumeMute", "VolumeUp", "VolumeDown", "MediaPlayPause", "MediaStop", "MediaNext", "MediaPrev",
)

// Converts (some) browser keycodes to BYOND keycodes.
/proc/browser_keycode_to_byond(keycode)
keycode = text2num(keycode)
switch(keycode)
// letters and numbers
if(65 to 90, 48 to 57)
return ascii2text(keycode)
if(17)
return "Ctrl"
if(18)
return "Alt"
if(16)
return "Shift"
if(37)
return "West"
if(38)
return "North"
if(39)
return "East"
if(40)
return "South"
if(45)
return "Insert"
if(46)
return "Delete"
if(36)
return "Northwest"
if(35)
return "Southwest"
if(33)
return "Northeast"
if(34)
return "Southeast"
if(112 to 123)
return "F[keycode-111]"
if(96 to 105)
return "Numpad[keycode-96]"
if(188)
return ","
if(190)
return "."
if(189)
return "-"
4 changes: 2 additions & 2 deletions code/__HELPERS/logging.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
global.game_log << "\[[time_stamp()]]DEBUG: [text][log_end]"

for(var/client/C as anything in admins)
if(C.prefs.chat_toggles & CHAT_DEBUGLOGS)
if(C.prefs.get_pref(/datum/pref/player/chat/debug_log))
to_chat_debug(C, "DEBUG: [text]")

/proc/log_asset(text)
Expand Down Expand Up @@ -170,7 +170,7 @@
/proc/log_gc(text)
global.gc_log << "\[[time_stamp()]] [text][log_end]"
for(var/client/C in global.admins)
if(C.prefs.chat_toggles & CHAT_DEBUGLOGS)
if(C.prefs.get_pref(/datum/pref/player/chat/debug_log))
to_chat(C, "GC DEBUG: [text]")
#endif

Expand Down
Loading
Loading