Skip to content

Commit

Permalink
Prefs Deshittening Part 4 (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
RimiNosha authored Dec 26, 2023
1 parent 83bbd37 commit 80209b9
Show file tree
Hide file tree
Showing 16 changed files with 245 additions and 299 deletions.
3 changes: 2 additions & 1 deletion code/datums/matchmaking_panel.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ GLOBAL_DATUM_INIT(matchmaking_panel, /datum/matchmaking_panel, new)
to_chat(ui.user, span_warning("You have to wait 5 seconds between each refresh!"))
return

update_static_data(ui.user, ui)
TIMER_COOLDOWN_START(ui.user, COOLDOWN_MATCHMAKING_PANEL_REFRESH, 5 SECONDS)
update_static_data(ui.user, ui)

if("toggle_victim_status")
ui.user.client.prefs.write_preference(GLOB.preference_entries[/datum/preference/toggle/be_victim], !ui.user.client.prefs.read_preference(/datum/preference/toggle/be_victim))
return TRUE

/datum/matchmaking_panel/proc/get_other_players()
var/list/directory_mobs = list()
Expand Down
14 changes: 14 additions & 0 deletions code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if (!new_color)
return FALSE

// Handles turning #000000 to skin/mut color
if(new_color == COLOR_BLACK && !istype(requested_preference, /datum/preference/color/skin_color))
if(read_preference(/datum/preference/toggle/use_skin_tone))
new_color = skintone2hex(read_preference(/datum/preference/choiced/skin_tone))
else
new_color = read_preference(/datum/preference/color/skin_color)

if (!update_preference(requested_preference, new_color))
return FALSE

Expand Down Expand Up @@ -313,6 +320,13 @@ GLOBAL_LIST_EMPTY(preferences_datums)
if (!new_color)
return FALSE

// Handles turning #000000 to skin/mut color
if(new_color == COLOR_BLACK)
if(read_preference(/datum/preference/toggle/use_skin_tone))
new_color = skintone2hex(read_preference(/datum/preference/choiced/skin_tone))
else
new_color = read_preference(/datum/preference/color/skin_color)

old_value_list[index_key] = copytext(new_color, 2)

if (!update_preference(requested_preference, jointext(old_value_list, ";")))
Expand Down
2 changes: 2 additions & 0 deletions code/modules/client/preferences/assets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
name = "preferences"
early = TRUE
cross_round_cachable = TRUE
// Fuck you, you keep making the prefs page bug the fuck out on first open, and I'd rather eat the 10s init time.
load_immediately = TRUE

/datum/asset/spritesheet/preferences/create_spritesheets()
var/list/to_insert = list()
Expand Down
116 changes: 0 additions & 116 deletions code/modules/client/preferences/migrations/tgui_prefs_migration.dm

This file was deleted.

6 changes: 0 additions & 6 deletions code/modules/client/preferences/security_department.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@
savefile_identifier = PREFERENCE_CHARACTER
savefile_key = "prefered_security_department"

// This is what that #warn wants you to remove :)
/datum/preference/choiced/security_department/deserialize(input, datum/preferences/preferences)
if (!(input in GLOB.security_depts_prefs))
return SEC_DEPT_NONE
return ..(input, preferences)

/datum/preference/choiced/security_department/init_possible_values()
return GLOB.security_depts_prefs

Expand Down
82 changes: 15 additions & 67 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//This is the lowest supported version, anything below this is completely obsolete and the entire savefile will be wiped.
#define SAVEFILE_VERSION_MIN 32
#define SAVEFILE_VERSION_MIN 41

//This is the current version, anything below this will attempt to update (if it's not obsolete)
// You do not need to raise this if you are adding new values that have sane defaults.
// Only raise this value when changing the meaning/format/name/layout of an existing value
// where you would want the updater procs below to run
#define SAVEFILE_VERSION_MAX 43
#define SAVEFILE_VERSION_MAX 44

/*
SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Carn
Expand Down Expand Up @@ -40,71 +40,25 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
//if your savefile is 3 months out of date, then 'tough shit'.

/datum/preferences/proc/update_preferences(current_version, datum/json_savefile/S)
if(current_version < 33)
toggles |= SOUND_ENDOFROUND

if(current_version < 34)
write_preference(/datum/preference/toggle/auto_fit_viewport, TRUE)

if(current_version < 35) //makes old keybinds compatible with #52040, sets the new default
var/newkey = FALSE
for(var/list/key in key_bindings)
for(var/bind in key)
if(bind == "quick_equipbelt")
key -= "quick_equipbelt"
key |= "quick_equip_belt"

if(bind == "bag_equip")
key -= "bag_equip"
key |= "quick_equip_bag"

if(bind == "quick_equip_suit_storage")
newkey = TRUE
if(!newkey && !key_bindings["ShiftQ"])
key_bindings["ShiftQ"] = list("quick_equip_suit_storage")

if(current_version < 36)
if(key_bindings["ShiftQ"] == "quick_equip_suit_storage")
key_bindings["ShiftQ"] = list("quick_equip_suit_storage")

if(current_version < 37)
if(read_preference(/datum/preference/numeric/fps) == 0)
write_preference(GLOB.preference_entries[/datum/preference/numeric/fps], -1)

if (current_version < 38)
var/found_block_movement = FALSE

for (var/list/key in key_bindings)
for (var/bind in key)
if (bind == "block_movement")
found_block_movement = TRUE
break
if (found_block_movement)
break

if (!found_block_movement)
LAZYADD(key_bindings["Ctrl"], "block_movement")

if (current_version < 39)
LAZYADD(key_bindings["F"], "toggle_combat_mode")
LAZYADD(key_bindings["4"], "toggle_combat_mode")
if (current_version < 40)
LAZYADD(key_bindings["Space"], "hold_throw_mode")

if (current_version < 41)
migrate_preferences_to_tgui_prefs_menu()
return // We have no changed client prefs.

if (current_version < 42)
S.set_entry(S.get_entry("voice", pick(GLOB.emote_voices)))
S.remove_entry("voice") // Let's not savebloat

/datum/preferences/proc/update_character(current_version, list/save_data)
if (current_version < 41)
migrate_character_to_tgui_prefs_menu()

if (current_version < 42)
migrate_body_types(save_data)

// Synth colours are now handled by the color pref datum itself.
if (current_version < 44)
var/color_pref = save_data["synth_chassis_color"]
if(color_pref && copytext(color_pref, 1, 7) == "000000")
var/skin_pref = save_data["use_skin_tone"] ? skintone2hex(save_data["skin_tone"]) : save_data["skin_color"]
save_data["synth_chassis_color"] = "[skin_pref][copytext(color_pref, 7)]"

color_pref = save_data["synth_head_color"]
if(color_pref && copytext(color_pref, 1, 7) == "000000")
var/skin_pref = save_data["use_skin_tone"] ? skintone2hex(save_data["skin_tone"]) : save_data["skin_color"]
save_data["synth_head_color"] = "[skin_pref][copytext(color_pref, 7)]"

/// checks through keybindings for outdated unbound keys and updates them
/datum/preferences/proc/check_keybindings()
if(!parent)
Expand Down Expand Up @@ -346,12 +300,6 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car

save_data["version"] = SAVEFILE_VERSION_MAX //load_character will sanitize any bad data, so assume up-to-date.

// This is the version when the random security department was removed.
// When the minimum is higher than that version, it's impossible for someone to have the "Random" department.
#if SAVEFILE_VERSION_MIN > 40
#warn The prefered_security_department check in code/modules/client/preferences/security_department.dm is no longer necessary.
#endif

//Character
save_data["randomise"] = randomise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
continue

if(limb.body_zone == BODY_ZONE_HEAD)
if(head_of_choice.color_src && head_color && head_color != COLOR_BLACK) // If someone sets their colour to pure black, assume they want skin_tone as their colour.
if(head_of_choice.color_src && head_color)
limb.variable_color = head_color
else
limb.variable_color = null
Expand All @@ -122,7 +122,7 @@
limb.update_limb(is_creating = TRUE)
continue

if(chassis_of_choice.color_src && chassis_color && chassis_color != COLOR_BLACK) // Ditto
if(chassis_of_choice.color_src && chassis_color)
limb.variable_color = chassis_color
else
limb.variable_color = null
Expand Down
1 change: 0 additions & 1 deletion tgstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2800,7 +2800,6 @@
#include "code\modules\client\preferences\middleware\species.dm"
#include "code\modules\client\preferences\migrations\body_type_migration.dm"
#include "code\modules\client\preferences\migrations\convert_to_json_savefile.dm"
#include "code\modules\client\preferences\migrations\tgui_prefs_migration.dm"
#include "code\modules\client\preferences\species_features\_mutant.dm"
#include "code\modules\client\preferences\species_features\basic.dm"
#include "code\modules\client\preferences\species_features\human.dm"
Expand Down
30 changes: 12 additions & 18 deletions tgui/packages/tgui/interfaces/PreferencesMenu/AppearancePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,25 +53,19 @@ export const AppearancePage = (context, parentContext) => {

return (
catalog && (
<Stack.Item
<MainFeature
key={clothingKey}
mt={0.5}
pr={2}
pb={1}
ml={0}>
<MainFeature
catalog={catalog}
currentValue={clothing}
isOpen={currentClothingMenu === clothingKey}
handleClose={() => {
setCurrentClothingMenu(null);
}}
handleOpen={() => {
setCurrentClothingMenu(clothingKey);
}}
handleSelect={createSetPreference(act, clothingKey)}
/>
</Stack.Item>
catalog={catalog}
currentValue={clothing}
isOpen={currentClothingMenu === clothingKey}
handleClose={() => {
setCurrentClothingMenu(null);
}}
handleOpen={() => {
setCurrentClothingMenu(clothingKey);
}}
handleSelect={createSetPreference(act, clothingKey)}
/>
)
);
})}
Expand Down
Loading

0 comments on commit 80209b9

Please sign in to comment.