Speeds up prefs menu by 10x. Not hyperbole. (#20034)

This commit is contained in:
AffectedArc07
2022-12-29 16:07:34 +01:00
committed by GitHub
parent e91b6c94f7
commit 590abafc0e
@@ -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>"
@@ -525,6 +525,7 @@ 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 = ""
@@ -532,11 +533,11 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
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))
@@ -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>"
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>"
@@ -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>"