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

Speeds up the preferences menu by 10x. No that is not hyperbole. #20034

Merged
Merged
Changes from all commits
Commits
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
17 changes: 9 additions & 8 deletions code/modules/client/preference/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
user << browse_rsc(active_character.preview_icon_front, "previewicon.png")
user << browse_rsc(active_character.preview_icon_side, "previewicon2.png")

var/dat = ""
var/list/dat = list()
dat += "<center>"
dat += "<a href='?_src_=prefs;preference=tab;tab=[TAB_CHAR]' [current_tab == TAB_CHAR ? "class='linkOn'" : ""]>Character Settings</a>"
dat += "<a href='?_src_=prefs;preference=tab;tab=[TAB_GAME]' [current_tab == TAB_GAME ? "class='linkOn'" : ""]>Game Preferences</a>"
Expand Down Expand Up @@ -525,18 +525,19 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<tr><td colspan=3><h2>[cat]</h2></td></tr>"
for(var/kb in keybindings_by_cat["[GLOB.keybindings_groups[cat]]"])
var/datum/keybinding/KB = kb
var/kb_uid = KB.UID() // Cache this to reduce proc jumps
var/override_keys = (keybindings_overrides && keybindings_overrides[KB.name])
var/list/keys = override_keys || KB.keys
var/keys_buttons = ""
for(var/key in keys)
var/disp_key = key
if(override_keys)
disp_key = "<b>[disp_key]</b>"
keys_buttons += "<a href='?_src_=prefs;preference=keybindings;set=[KB.UID()];old=[url_encode(key)];'>[disp_key]</a>&nbsp;"
keys_buttons += "<a href='?_src_=prefs;preference=keybindings;set=[kb_uid];old=[url_encode(key)];'>[disp_key]</a>&nbsp;"
dat += "<tr>"
dat += "<td style='width: 25%'>[KB.name]</td>"
dat += "<td style='width: 45%'>[keys_buttons][(length(keys) < 5) ? "<a href='?_src_=prefs;preference=keybindings;set=[KB.UID()];'><span class='good'>+</span></a></td>" : "</td>"]"
dat += "<td style='width: 20%'><a href='?_src_=prefs;preference=keybindings;reset=[KB.UID()]'>Reset to Default</a> <a href='?_src_=prefs;preference=keybindings;clear=[KB.UID()]'>Clear</a></td>"
dat += "<td style='width: 45%'>[keys_buttons][(length(keys) < 5) ? "<a href='?_src_=prefs;preference=keybindings;set=[kb_uid];'><span class='good'>+</span></a></td>" : "</td>"]"
dat += "<td style='width: 20%'><a href='?_src_=prefs;preference=keybindings;reset=[kb_uid]'>Reset to Default</a> <a href='?_src_=prefs;preference=keybindings;clear=[kb_uid]'>Clear</a></td>"
if(KB.category == KB_CATEGORY_EMOTE_CUSTOM)
var/datum/keybinding/custom/custom_emote_keybind = kb
if(custom_emote_keybind.donor_exclusive && !(user.client.donator_level || user.client.holder || unlock_content))
Expand All @@ -552,8 +553,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<td style='width: 25%'>[custom_emote_keybind.default_emote_text]</td>"
else
dat += "<td style='width: 25%'><i>\"[active_character.real_name] [emote_text]\"</i></td>"
dat += "<td style='width: 45%'><a href='?_src_=prefs;preference=keybindings;custom_emote_set=[custom_emote_keybind.UID()];'>Change Text</a></td>"
farie82 marked this conversation as resolved.
Show resolved Hide resolved
dat += "<td style='width: 20%'><a href='?_src_=prefs;preference=keybindings;custom_emote_reset=[custom_emote_keybind.UID()];'>Reset to Default</a></td>"
dat += "<td style='width: 45%'><a href='?_src_=prefs;preference=keybindings;custom_emote_set=[kb_uid];'>Change Text</a></td>"
dat += "<td style='width: 20%'><a href='?_src_=prefs;preference=keybindings;custom_emote_reset=[kb_uid];'>Reset to Default</a></td>"
dat += "<tr><td colspan=4><br></td></tr>"
dat += "</tr>"
dat += "<tr><td colspan=4><br></td></tr>"
Expand All @@ -570,8 +571,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "</center>"

var/datum/browser/popup = new(user, "preferences", "<div align='center'>Character Setup</div>", 820, 720)
popup.set_content(dat)
popup.open(0)
popup.set_content(dat.Join(""))
popup.open(FALSE)

/datum/preferences/proc/open_load_dialog(mob/user)
var/dat = "<body>"
Expand Down