-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathlegacy_toggles.dm
149 lines (125 loc) · 4.55 KB
/
legacy_toggles.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/// In the before times, toggles were all stored in one bitfield.
/// In order to preserve this existing data (and code) without massive
/// migrations, this middleware attempts to handle this in a way
/// transparent to the preferences UI itself.
/// In the future, the existing toggles data should just be migrated to
/// individual `/datum/preference/toggle`s.
/datum/preference_middleware/legacy_toggles
// DO NOT ADD ANY NEW TOGGLES HERE!
// Use `/datum/preference/toggle` instead.
var/static/list/legacy_toggles = list(
"announce_login" = ANNOUNCE_LOGIN,
"combohud_lighting" = COMBOHUD_LIGHTING,
"deadmin_always" = DEADMIN_ALWAYS,
"deadmin_antagonist" = DEADMIN_ANTAGONIST,
"deadmin_position_head" = DEADMIN_POSITION_HEAD,
"deadmin_position_security" = DEADMIN_POSITION_SECURITY,
"deadmin_position_silicon" = DEADMIN_POSITION_SILICON,
"disable_arrivalrattle" = DISABLE_ARRIVALRATTLE,
"disable_deathrattle" = DISABLE_DEATHRATTLE,
"member_public" = MEMBER_PUBLIC,
"sound_adminhelp" = SOUND_ADMINHELP,
"sound_ambience" = SOUND_AMBIENCE,
"sound_announcements" = SOUND_ANNOUNCEMENTS,
"sound_instruments" = SOUND_INSTRUMENTS,
"sound_lobby" = SOUND_LOBBY,
"sound_midi" = SOUND_MIDI,
"sound_prayer_fax" = SOUND_PRAYER_N_FAX,
"sound_ship_ambience" = SOUND_SHIP_AMBIENCE,
"sound_jukebox" = SOUND_JUKEBOX,
)
var/static/list/legacy_extra_toggles = list(
"split_admin_tabs" = SPLIT_ADMIN_TABS,
"fast_mc_refresh" = FAST_MC_REFRESH,
)
var/static/list/legacy_chat_toggles = list(
"chat_bankcard" = CHAT_BANKCARD,
"chat_dead" = CHAT_DEAD,
"chat_ghostears" = CHAT_GHOSTEARS,
"chat_ghostpda" = CHAT_GHOSTPDA,
"chat_ghostradio" = CHAT_GHOSTRADIO,
"chat_ghostsight" = CHAT_GHOSTSIGHT,
"chat_ghostwhisper" = CHAT_GHOSTWHISPER,
"chat_looc" = CHAT_LOOC,
"chat_ooc" = CHAT_OOC,
"chat_prayer" = CHAT_PRAYER_N_FAX,
"chat_pullr" = CHAT_PULLR,
"chat_typing_indicator" = CHAT_TYPING_INDICATOR,
"ghost_ckey" = GHOST_CKEY,
)
/datum/preference_middleware/legacy_toggles/get_character_preferences(mob/user)
if (preferences.current_window != PREFERENCE_TAB_GAME_PREFERENCES)
return list()
var/static/list/admin_only_legacy_toggles = list(
"admin_ignore_cult_ghost",
"announce_login",
"combohud_lighting",
"deadmin_always",
"deadmin_antagonist",
"deadmin_position_head",
"deadmin_position_security",
"deadmin_position_silicon",
"sound_adminhelp",
"sound_prayers",
)
var/static/list/admin_only_extra_toggles = list(
"split_admin_tabs",
"fast_mc_refresh",
)
var/static/list/admin_only_chat_toggles = list(
"chat_dead",
"chat_prayer",
)
var/static/list/donor_only_yog_toggles = list(
"quiet_mode",
)
var/static/list/deadmin_flags = list(
"deadmin_antagonist",
"deadmin_position_head",
"deadmin_position_security",
"deadmin_position_silicon",
)
var/list/new_game_preferences = list()
var/is_admin = is_admin(user.client)
for (var/toggle_name in legacy_toggles)
if (!is_admin && (toggle_name in admin_only_legacy_toggles))
continue
if (is_admin && (toggle_name in deadmin_flags) && (preferences.toggles & DEADMIN_ALWAYS))
continue
if (toggle_name == "member_public" && !preferences.unlock_content)
continue
new_game_preferences[toggle_name] = (preferences.toggles & legacy_toggles[toggle_name]) != 0
for (var/toggle_name in legacy_extra_toggles)
if (!is_admin && (toggle_name in admin_only_extra_toggles))
continue
new_game_preferences[toggle_name] = (preferences.extra_toggles & legacy_extra_toggles[toggle_name]) != 0
for (var/toggle_name in legacy_chat_toggles)
if (!is_admin && (toggle_name in admin_only_chat_toggles))
continue
new_game_preferences[toggle_name] = (preferences.chat_toggles & legacy_chat_toggles[toggle_name]) != 0
return list(
PREFERENCE_CATEGORY_GAME_PREFERENCES = new_game_preferences,
)
/datum/preference_middleware/legacy_toggles/pre_set_preference(mob/user, preference, value)
var/legacy_flag = legacy_toggles[preference]
if (!isnull(legacy_flag))
if (value)
preferences.toggles |= legacy_flag
else
preferences.toggles &= ~legacy_flag
// I know this looks silly, but this is the only one that cares
// and NO NEW LEGACY TOGGLES should ever be added.
if (legacy_flag == SOUND_LOBBY)
if (value && isnewplayer(user))
user.client?.playtitlemusic()
else
user.stop_sound_channel(CHANNEL_LOBBYMUSIC)
return TRUE
var/legacy_chat_flag = legacy_chat_toggles[preference]
if (!isnull(legacy_chat_flag))
if (value)
preferences.chat_toggles |= legacy_chat_flag
else
preferences.chat_toggles &= ~legacy_chat_flag
return TRUE
return FALSE