diff --git a/code/__HELPERS/type2type.dm b/code/__HELPERS/type2type.dm index 1f788cf44526..b474915e1050 100644 --- a/code/__HELPERS/type2type.dm +++ b/code/__HELPERS/type2type.dm @@ -218,21 +218,6 @@ . = "NONE" return . -/proc/ui_style2icon(ui_style) - switch(ui_style) - if("Retro") - return 'icons/mob/screen_retro.dmi' - if("Plasmafire") - return 'icons/mob/screen_plasmafire.dmi' - if("Slimecore") - return 'icons/mob/screen_slimecore.dmi' - if("Operative") - return 'icons/mob/screen_operative.dmi' - if("Clockwork") - return 'icons/mob/screen_clockwork.dmi' - else - return 'icons/mob/screen_midnight.dmi' - //colour formats /proc/rgb2hsl(red, green, blue) red /= 255;green /= 255;blue /= 255; diff --git a/code/_onclick/hud/action_button.dm b/code/_onclick/hud/action_button.dm index 47cb76a978ba..4ae61169b7b9 100644 --- a/code/_onclick/hud/action_button.dm +++ b/code/_onclick/hud/action_button.dm @@ -138,7 +138,7 @@ /datum/hud/proc/get_action_buttons_icons() . = list() - .["bg_icon"] = ui_style_icon + .["bg_icon"] = ui_style .["bg_state"] = "template" //TODO : Make these fit theme diff --git a/code/_onclick/hud/ai.dm b/code/_onclick/hud/ai.dm index 8d4aca5fbf18..92f141a532e6 100644 --- a/code/_onclick/hud/ai.dm +++ b/code/_onclick/hud/ai.dm @@ -166,9 +166,9 @@ /datum/hud/ai - ui_style_icon = 'icons/mob/screen_ai.dmi' + ui_style = 'icons/mob/screen_ai.dmi' -/datum/hud/ai/New(mob/owner, ui_style = 'icons/mob/screen_ai.dmi') +/datum/hud/ai/New(mob/owner) ..() var/obj/screen/using diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm index bb61f2218d6e..5e2747ec5ffb 100644 --- a/code/_onclick/hud/alert.dm +++ b/code/_onclick/hud/alert.dm @@ -588,7 +588,6 @@ so as to remain in compliance with the most up-to-date laws." // Re-render all alerts - also called in /datum/hud/show_hud() because it's needed there /datum/hud/proc/reorganize_alerts() var/list/alerts = mymob.alerts - var/icon_pref if(!hud_shown) for(var/i = 1, i <= alerts.len, i++) mymob.client.screen -= alerts[alerts[i]] @@ -596,9 +595,7 @@ so as to remain in compliance with the most up-to-date laws." for(var/i = 1, i <= alerts.len, i++) var/obj/screen/alert/alert = alerts[alerts[i]] if(alert.icon_state == "template") - if(!icon_pref) - icon_pref = ui_style2icon(mymob.client.prefs.UI_style) - alert.icon = icon_pref + alert.icon = ui_style switch(i) if(1) . = ui_alert1 diff --git a/code/_onclick/hud/alien.dm b/code/_onclick/hud/alien.dm index 72d06a58e912..81dcbf0fdf17 100644 --- a/code/_onclick/hud/alien.dm +++ b/code/_onclick/hud/alien.dm @@ -24,11 +24,10 @@ desc = "Allows you to sense the general direction of your Queen." screen_loc = ui_alien_queen_finder - /datum/hud/alien - ui_style_icon = 'icons/mob/screen_alien.dmi' + ui_style = 'icons/mob/screen_alien.dmi' -/datum/hud/alien/New(mob/living/carbon/alien/humanoid/owner, ui_style = 'icons/mob/screen_alien.dmi') +/datum/hud/alien/New(mob/living/carbon/alien/humanoid/owner) ..() var/obj/screen/using @@ -36,7 +35,7 @@ //equippable shit //hands - build_hand_slots(ui_style) + build_hand_slots() //begin buttons diff --git a/code/_onclick/hud/alien_larva.dm b/code/_onclick/hud/alien_larva.dm index def88b7ed72c..38dddb92c677 100644 --- a/code/_onclick/hud/alien_larva.dm +++ b/code/_onclick/hud/alien_larva.dm @@ -1,3 +1,6 @@ +/datum/hud/larva + ui_style = 'icons/mob/screen_alien.dmi' + /datum/hud/larva/New(mob/owner) ..() var/obj/screen/using diff --git a/code/_onclick/hud/constructs.dm b/code/_onclick/hud/constructs.dm index 729de9da4a79..d4f6b90ca645 100644 --- a/code/_onclick/hud/constructs.dm +++ b/code/_onclick/hud/constructs.dm @@ -1,11 +1,10 @@ - /datum/hud/constructs - ui_style_icon = 'icons/mob/screen_construct.dmi' + ui_style = 'icons/mob/screen_construct.dmi' /datum/hud/constructs/New(mob/owner) ..() pull_icon = new /obj/screen/pull() - pull_icon.icon = 'icons/mob/screen_construct.dmi' + pull_icon.icon = ui_style pull_icon.update_icon(mymob) pull_icon.screen_loc = ui_construct_pull static_inventory += pull_icon diff --git a/code/_onclick/hud/devil.dm b/code/_onclick/hud/devil.dm index 0cd0b6a6a9d1..b30eeefc1b0d 100644 --- a/code/_onclick/hud/devil.dm +++ b/code/_onclick/hud/devil.dm @@ -2,7 +2,7 @@ //Soul counter is stored with the humans, it does weird when you place it here apparently... -/datum/hud/devil/New(mob/owner, ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/devil/New(mob/owner) ..() var/obj/screen/using @@ -17,7 +17,7 @@ pull_icon.screen_loc = ui_drone_pull static_inventory += pull_icon - build_hand_slots(ui_style) + build_hand_slots() using = new /obj/screen/inventory() using.name = "hand" @@ -62,4 +62,4 @@ /mob/living/carbon/true_devil/create_mob_hud() if(client && !hud_used) - hud_used = new /datum/hud/devil(src, ui_style2icon(client.prefs.UI_style)) + hud_used = new /datum/hud/devil(src) diff --git a/code/_onclick/hud/drones.dm b/code/_onclick/hud/drones.dm index 8e39d96bf61c..bcdfa084d313 100644 --- a/code/_onclick/hud/drones.dm +++ b/code/_onclick/hud/drones.dm @@ -1,4 +1,4 @@ -/datum/hud/dextrous/drone/New(mob/owner, ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/dextrous/drone/New(mob/owner) ..() var/obj/screen/inventory/inv_box diff --git a/code/_onclick/hud/generic_dextrous.dm b/code/_onclick/hud/generic_dextrous.dm index 39a79b108bc8..c42714ba7c90 100644 --- a/code/_onclick/hud/generic_dextrous.dm +++ b/code/_onclick/hud/generic_dextrous.dm @@ -1,5 +1,5 @@ //Used for normal mobs that have hands. -/datum/hud/dextrous/New(mob/living/owner, ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/dextrous/New(mob/living/owner) ..() var/obj/screen/using @@ -14,7 +14,7 @@ pull_icon.screen_loc = ui_drone_pull static_inventory += pull_icon - build_hand_slots(ui_style) + build_hand_slots() using = new /obj/screen/swap_hand() using.icon = ui_style @@ -78,6 +78,6 @@ /mob/living/simple_animal/create_mob_hud() if(client && !hud_used) if(dextrous) - hud_used = new dextrous_hud_type(src, ui_style2icon(client.prefs.UI_style)) + hud_used = new dextrous_hud_type(src) else ..() diff --git a/code/_onclick/hud/ghost.dm b/code/_onclick/hud/ghost.dm index 8cff8fe09e5e..ea78da5952a9 100644 --- a/code/_onclick/hud/ghost.dm +++ b/code/_onclick/hud/ghost.dm @@ -44,7 +44,7 @@ var/mob/dead/observer/G = usr G.register_pai() -/datum/hud/ghost/New(mob/owner, ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/ghost/New(mob/owner) ..() var/obj/screen/using @@ -90,4 +90,4 @@ /mob/dead/observer/create_mob_hud() if(client && !hud_used) - hud_used = new /datum/hud/ghost(src, ui_style2icon(client.prefs.UI_style)) + hud_used = new /datum/hud/ghost(src) diff --git a/code/_onclick/hud/guardian.dm b/code/_onclick/hud/guardian.dm index 628efbffe59a..687d47c01744 100644 --- a/code/_onclick/hud/guardian.dm +++ b/code/_onclick/hud/guardian.dm @@ -32,9 +32,9 @@ if(dextrous) ..() else - hud_used = new /datum/hud/guardian(src, ui_style2icon(client.prefs.UI_style)) + hud_used = new /datum/hud/guardian(src) -/datum/hud/dextrous/guardian/New(mob/living/simple_animal/hostile/guardian/owner, ui_style = 'icons/mob/screen_midnight.dmi') //for a dextrous guardian +/datum/hud/dextrous/guardian/New(mob/living/simple_animal/hostile/guardian/owner) //for a dextrous guardian ..() var/obj/screen/using if(istype(owner, /mob/living/simple_animal/hostile/guardian/dextrous)) diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 5678b144846b..b5b42e06e1d4 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -4,6 +4,19 @@ including inventories and item quick actions. */ +// The default UI style is the first one in the list +GLOBAL_LIST_INIT(available_ui_styles, list( + "Midnight" = 'icons/mob/screen_midnight.dmi', + "Retro" = 'icons/mob/screen_retro.dmi', + "Plasmafire" = 'icons/mob/screen_plasmafire.dmi', + "Slimecore" = 'icons/mob/screen_slimecore.dmi', + "Operative" = 'icons/mob/screen_operative.dmi', + "Clockwork" = 'icons/mob/screen_clockwork.dmi' +)) + +/proc/ui_style2icon(ui_style) + return GLOB.available_ui_styles[ui_style] || GLOB.available_ui_styles[GLOB.available_ui_styles[1]] + /datum/hud var/mob/mymob @@ -45,12 +58,15 @@ var/obj/screen/internals var/obj/screen/mood - var/ui_style_icon = 'icons/mob/screen_midnight.dmi' + // subtypes can override this to force a specific UI style + var/ui_style -/datum/hud/New(mob/owner , ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/New(mob/owner) mymob = owner - ui_style_icon = ui_style + if (!ui_style) + // will fall back to the default if any of these are null + ui_style = ui_style2icon(owner.client && owner.client.prefs && owner.client.prefs.UI_style) hide_actions_toggle = new hide_actions_toggle.InitialiseIcon(src) @@ -68,38 +84,19 @@ if(mymob.hud_used == src) mymob.hud_used = null - qdel(hide_actions_toggle) - hide_actions_toggle = null - - qdel(module_store_icon) - module_store_icon = null - - if(static_inventory.len) - for(var/thing in static_inventory) - qdel(thing) - static_inventory.Cut() + QDEL_NULL(hide_actions_toggle) + QDEL_NULL(module_store_icon) + QDEL_LIST(static_inventory) inv_slots.Cut() action_intent = null zone_select = null pull_icon = null - if(toggleable_inventory.len) - for(var/thing in toggleable_inventory) - qdel(thing) - toggleable_inventory.Cut() - - if(hotkeybuttons.len) - for(var/thing in hotkeybuttons) - qdel(thing) - hotkeybuttons.Cut() - + QDEL_LIST(toggleable_inventory) + QDEL_LIST(hotkeybuttons) throw_icon = null - - if(infodisplay.len) - for(var/thing in infodisplay) - qdel(thing) - infodisplay.Cut() + QDEL_LIST(infodisplay) healths = null healthdoll = null @@ -112,15 +109,8 @@ alien_plasma_display = null alien_queen_finder = null - if(plane_masters.len) - for(var/thing in plane_masters) - qdel(plane_masters[thing]) - plane_masters.Cut() - - if(screenoverlays.len) - for(var/thing in screenoverlays) - qdel(thing) - screenoverlays.Cut() + QDEL_LIST_ASSOC_VAL(plane_masters) + QDEL_LIST(screenoverlays) mymob = null return ..() @@ -239,6 +229,19 @@ if(!mymob) return +/datum/hud/proc/update_ui_style(new_ui_style) + // do nothing if overridden by a subtype or already on that style + if (initial(ui_style) || ui_style == new_ui_style) + return + + for(var/atom/item in static_inventory + toggleable_inventory + hotkeybuttons + infodisplay + screenoverlays + inv_slots) + if (item.icon == ui_style) + item.icon = new_ui_style + + ui_style = new_ui_style + build_hand_slots() + hide_actions_toggle.InitialiseIcon(src) + //Triggered when F12 is pressed (Unless someone changed something in the DMF) /mob/verb/button_pressed_F12() set name = "F12" @@ -254,7 +257,7 @@ //(re)builds the hand ui slots, throwing away old ones //not really worth jugglying existing ones so we just scrap+rebuild //9/10 this is only called once per mob and only for 2 hands -/datum/hud/proc/build_hand_slots(ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/proc/build_hand_slots() for(var/h in hand_slots) var/obj/screen/inventory/hand/H = hand_slots[h] if(H) diff --git a/code/_onclick/hud/human.dm b/code/_onclick/hud/human.dm index bc369e5943b9..58d84c6678df 100644 --- a/code/_onclick/hud/human.dm +++ b/code/_onclick/hud/human.dm @@ -82,10 +82,10 @@ /mob/living/carbon/human/create_mob_hud() if(client && !hud_used) - hud_used = new /datum/hud/human(src, ui_style2icon(client.prefs.UI_style)) + hud_used = new /datum/hud/human(src) -/datum/hud/human/New(mob/living/carbon/human/owner, ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/human/New(mob/living/carbon/human/owner) ..() owner.overlay_fullscreen("see_through_darkness", /obj/screen/fullscreen/see_through_darkness) @@ -135,7 +135,7 @@ inv_box.screen_loc = ui_oclothing toggleable_inventory += inv_box - build_hand_slots(ui_style) + build_hand_slots() using = new /obj/screen/swap_hand() using.icon = ui_style diff --git a/code/_onclick/hud/monkey.dm b/code/_onclick/hud/monkey.dm index c469c1ef20c0..479fd59dae23 100644 --- a/code/_onclick/hud/monkey.dm +++ b/code/_onclick/hud/monkey.dm @@ -1,4 +1,4 @@ -/datum/hud/monkey/New(mob/living/carbon/monkey/owner, ui_style = 'icons/mob/screen_midnight.dmi') +/datum/hud/monkey/New(mob/living/carbon/monkey/owner) ..() var/obj/screen/using var/obj/screen/inventory/inv_box @@ -24,7 +24,7 @@ using.screen_loc = ui_drop_throw static_inventory += using - build_hand_slots(ui_style) + build_hand_slots() using = new /obj/screen/swap_hand() using.icon = ui_style @@ -152,4 +152,4 @@ /mob/living/carbon/monkey/create_mob_hud() if(client && !hud_used) - hud_used = new /datum/hud/monkey(src, ui_style2icon(client.prefs.UI_style)) + hud_used = new /datum/hud/monkey(src) diff --git a/code/_onclick/hud/robot.dm b/code/_onclick/hud/robot.dm index 769cdb224412..7cc51fade144 100644 --- a/code/_onclick/hud/robot.dm +++ b/code/_onclick/hud/robot.dm @@ -89,9 +89,9 @@ R.toggle_ionpulse() /datum/hud/robot - ui_style_icon = 'icons/mob/screen_cyborg.dmi' + ui_style = 'icons/mob/screen_cyborg.dmi' -/datum/hud/robot/New(mob/owner, ui_style = 'icons/mob/screen_cyborg.dmi') +/datum/hud/robot/New(mob/owner) ..() var/mob/living/silicon/robot/mymobR = mymob var/obj/screen/using diff --git a/code/modules/client/client_procs.dm b/code/modules/client/client_procs.dm index d5cdb30e53fd..35692e007ed9 100644 --- a/code/modules/client/client_procs.dm +++ b/code/modules/client/client_procs.dm @@ -197,7 +197,9 @@ GLOBAL_LIST_EMPTY(external_rsc_urls) new /datum/admins(localhost_rank, ckey, 1, 1) //preferences datum - also holds some persistent data for the client (because we may as well keep these datums to a minimum) prefs = GLOB.preferences_datums[ckey] - if(!prefs) + if(prefs) + prefs.parent = src + else prefs = new /datum/preferences(src) GLOB.preferences_datums[ckey] = prefs prefs.last_ip = address //these are gonna be used for banning diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 7c595a6618fc..feb7386be923 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -29,7 +29,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) //autocorrected this round, not that you'd need to check that. - var/UI_style = "Midnight" + var/UI_style = null var/buttons_locked = FALSE var/hotkeys = TRUE // yogs - Rebindable Keybindings var/tgui_fancy = TRUE @@ -129,6 +129,7 @@ GLOBAL_LIST_EMPTY(preferences_datums) custom_names["cyborg"] = pick(GLOB.ai_names) custom_names["clown"] = pick(GLOB.clown_names) custom_names["mime"] = pick(GLOB.mime_names) + UI_style = GLOB.available_ui_styles[1] if(istype(C)) if(!IsGuestKey(C.key)) load_path(C.ckey) @@ -1502,11 +1503,13 @@ GLOBAL_LIST_EMPTY(preferences_datums) clientfps = desiredfps parent.fps = desiredfps if("ui") - var/pickedui = input(user, "Choose your UI style.", "Character Preference") as null|anything in list("Midnight", "Plasmafire", "Retro", "Slimecore", "Operative", "Clockwork") + var/pickedui = input(user, "Choose your UI style.", "Character Preference", UI_style) as null|anything in GLOB.available_ui_styles if(pickedui) UI_style = pickedui + if (parent && parent.mob && parent.mob.hud_used) + parent.mob.hud_used.update_ui_style(ui_style2icon(UI_style)) if("pda_style") - var/pickedPDAStyle = input(user, "Choose your PDA style.", "Character Preference") as null|anything in list(MONO, SHARE, ORBITRON, VT) + var/pickedPDAStyle = input(user, "Choose your PDA style.", "Character Preference", pda_style) as null|anything in list(MONO, SHARE, ORBITRON, VT) if(pickedPDAStyle) pda_style = pickedPDAStyle if("pda_color") diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index f29320baa65a..83c80035273c 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -117,7 +117,7 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car //Sanitize ooccolor = sanitize_ooccolor(sanitize_hexcolor(ooccolor, 6, 1, initial(ooccolor))) lastchangelog = sanitize_text(lastchangelog, initial(lastchangelog)) - UI_style = sanitize_inlist(UI_style, list("Midnight", "Plasmafire", "Retro", "Slimecore", "Operative", "Clockwork"), initial(UI_style)) + UI_style = sanitize_inlist(UI_style, GLOB.available_ui_styles, GLOB.available_ui_styles[1]) hotkeys = sanitize_integer(hotkeys, 0, 1, initial(hotkeys)) tgui_fancy = sanitize_integer(tgui_fancy, 0, 1, initial(tgui_fancy)) tgui_lock = sanitize_integer(tgui_lock, 0, 1, initial(tgui_lock)) diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index d9598676dde7..7676ac91f086 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -441,10 +441,7 @@ held_items.len = amt if(hud_used) - var/style - if(client && client.prefs) - style = ui_style2icon(client.prefs.UI_style) - hud_used.build_hand_slots(style) + hud_used.build_hand_slots() /mob/living/carbon/human/change_number_of_hands(amt) diff --git a/code/modules/mob/login.dm b/code/modules/mob/login.dm index 7e7a86a9e41b..b99049a0143a 100644 --- a/code/modules/mob/login.dm +++ b/code/modules/mob/login.dm @@ -11,6 +11,7 @@ create_mob_hud() if(hud_used) hud_used.show_hud(hud_used.hud_version) + hud_used.update_ui_style(ui_style2icon(client.prefs.UI_style)) next_move = 1