mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-09 16:05:07 +00:00
Allow dynamically updating UI style, do so on mob login (#38089)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user