Allow dynamically updating UI style, do so on mob login (#38089)

This commit is contained in:
Tad Hardesty
2018-05-30 03:52:50 -07:00
committed by yogstation13-bot
parent 33b18b66bc
commit c46bdbbcbd
21 changed files with 84 additions and 95 deletions

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -1,3 +1,6 @@
/datum/hud/larva
ui_style = 'icons/mob/screen_alien.dmi'
/datum/hud/larva/New(mob/owner)
..()
var/obj/screen/using

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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
..()

View File

@@ -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)

View File

@@ -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))

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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")

View File

@@ -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))

View File

@@ -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)

View File

@@ -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