Skip to content

Commit

Permalink
update_appearance (tgstation#55468)
Browse files Browse the repository at this point in the history
Creates update_name and update_desc
Creates the wrapper proc update_appearance to batch update_name, update_desc, and update_icon together
Less non-icon handling code in update_icon and friends
Signal hooks for things that want to change names and descriptions
99%+ of the changes in this are just from switching everything over to update_appearance from update_icon
  • Loading branch information
TemporalOroboros authored Feb 19, 2021
1 parent dc4b722 commit e4079c8
Show file tree
Hide file tree
Showing 585 changed files with 4,688 additions and 4,132 deletions.
27 changes: 22 additions & 5 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,30 @@
#define EXAMINE_POSITION_BEFORE (1<<1)
//End positions
#define COMPONENT_EXNAME_CHANGED (1<<0)
///from base of atom/update_icon(): ()

///from base of [/atom/proc/update_appearance]: (updates)
#define COMSIG_ATOM_UPDATE_APPEARANCE "atom_update_appearance"
/// If returned from [COMSIG_ATOM_UPDATE_APPEARANCE] it prevents the atom from updating its name.
#define COMSIG_ATOM_NO_UPDATE_NAME UPDATE_NAME
/// If returned from [COMSIG_ATOM_UPDATE_APPEARANCE] it prevents the atom from updating its desc.
#define COMSIG_ATOM_NO_UPDATE_DESC UPDATE_DESC
/// If returned from [COMSIG_ATOM_UPDATE_APPEARANCE] it prevents the atom from updating its icon.
#define COMSIG_ATOM_NO_UPDATE_ICON UPDATE_ICON
///from base of [/atom/proc/update_name]: (updates)
#define COMSIG_ATOM_UPDATE_NAME "atom_update_name"
///from base of [/atom/proc/update_desc]: (updates)
#define COMSIG_ATOM_UPDATE_DESC "atom_update_desc"
///from base of [/atom/update_icon]: ()
#define COMSIG_ATOM_UPDATE_ICON "atom_update_icon"
#define COMSIG_ATOM_NO_UPDATE_ICON_STATE (1<<0)
#define COMSIG_ATOM_NO_UPDATE_OVERLAYS (1<<1)
///from base of atom/update_overlays(): (list/new_overlays)
/// If returned from [COMSIG_ATOM_UPDATE_ICON] it prevents the atom from updating its icon state.
#define COMSIG_ATOM_NO_UPDATE_ICON_STATE UPDATE_ICON_STATE
/// If returned from [COMSIG_ATOM_UPDATE_ICON] it prevents the atom from updating its overlays.
#define COMSIG_ATOM_NO_UPDATE_OVERLAYS UPDATE_OVERLAYS
///from base of [atom/update_icon_state]: ()
#define COMSIG_ATOM_UPDATE_ICON_STATE "atom_update_icon_state"
///from base of [/atom/update_overlays]: (list/new_overlays)
#define COMSIG_ATOM_UPDATE_OVERLAYS "atom_update_overlays"
///from base of atom/update_icon(): (signalOut, did_anything)
///from base of [/atom/update_icon]: (signalOut, did_anything)
#define COMSIG_ATOM_UPDATED_ICON "atom_updated_icon"
///from base of atom/Entered(): (atom/movable/entering, /atom)
#define COMSIG_ATOM_ENTERED "atom_entered"
Expand Down
12 changes: 12 additions & 0 deletions code/__DEFINES/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ GLOBAL_LIST_INIT(bitflags, list(1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 204
#define SUPERMATTER_IGNORES_1 (1 << 23)


// Update flags for [/atom/proc/update_appearance]
/// Update the atom's name
#define UPDATE_NAME (1<<0)
/// Update the atom's desc
#define UPDATE_DESC (1<<1)
/// Update the atom's icon state
#define UPDATE_ICON_STATE (1<<2)
/// Update the atom's overlays
#define UPDATE_OVERLAYS (1<<3)
/// Update the atom's icon
#define UPDATE_ICON (UPDATE_ICON_STATE|UPDATE_OVERLAYS)

/// If the thing can reflect light (lasers/energy)
#define RICOCHET_SHINY (1<<0)
/// If the thing can reflect matter (bullets/bomb shrapnel)
Expand Down
9 changes: 3 additions & 6 deletions code/_onclick/hud/action_button.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
name = "Show Buttons"
else
name = "Hide Buttons"
update_icon()
update_appearance()
usr.update_action_buttons()

/atom/movable/screen/movable/action_button/hide_toggle/AltClick(mob/user)
Expand All @@ -151,14 +151,11 @@
hide_icon = settings["toggle_icon"]
hide_state = settings["toggle_hide"]
show_state = settings["toggle_show"]
update_icon()
update_appearance()

/atom/movable/screen/movable/action_button/hide_toggle/update_overlays()
. = ..()
if(hidden)
. += show_appearance
else
. += hide_appearance
. += hidden ? show_appearance : hide_appearance

/atom/movable/screen/movable/action_button/MouseEntered(location,control,params)
if(!QDELETED(src))
Expand Down
6 changes: 3 additions & 3 deletions code/_onclick/hud/alien.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = ui_style
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_above_movement
pull_icon.hud = src
static_inventory += pull_icon
Expand All @@ -109,14 +109,14 @@

zone_select = new /atom/movable/screen/zone_sel/alien()
zone_select.hud = src
zone_select.update_icon()
zone_select.update_appearance()
static_inventory += zone_select

for(var/atom/movable/screen/inventory/inv in (static_inventory + toggleable_inventory))
if(inv.slot_id)
inv.hud = src
inv_slots[TOBITSHIFT(inv.slot_id) + 1] = inv
inv.update_icon()
inv.update_appearance()

/datum/hud/alien/persistent_inventory_update()
if(!mymob)
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/hud/alien_larva.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = 'icons/hud/screen_alien.dmi'
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_above_movement
pull_icon.hud = src
hotkeybuttons += pull_icon
Expand All @@ -33,5 +33,5 @@

zone_select = new /atom/movable/screen/zone_sel/alien()
zone_select.hud = src
zone_select.update_icon()
zone_select.update_appearance()
static_inventory += zone_select
2 changes: 1 addition & 1 deletion code/_onclick/hud/drones.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if(inv.slot_id)
inv.hud = src
inv_slots[TOBITSHIFT(inv.slot_id) + 1] = inv
inv.update_icon()
inv.update_appearance()


/datum/hud/dextrous/drone/persistent_inventory_update()
Expand Down
7 changes: 4 additions & 3 deletions code/_onclick/hud/families.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
desc = "Shows the current level of hostility the space police is planning to rain down on you. Better be careful."
icon = 'icons/obj/gang/wanted_160x32.dmi'
icon_state = "wanted_0"
base_icon_state = "wanted"
screen_loc = ui_wanted_lvl
/// Wanted level, affects the hud icon. Level 0 is default, and the level 0 icon is blank, so in case of no families gamemode (and thus no wanted level), this HUD element will never appear.
var/level = 0
Expand All @@ -14,7 +15,7 @@

/atom/movable/screen/wanted/Initialize()
. = ..()
update_icon()
update_appearance()

/atom/movable/screen/wanted/MouseEntered(location,control,params)
openToolTip(usr,src,params,title = name,content = desc, theme = "alerttooltipstyle")
Expand All @@ -23,5 +24,5 @@
closeToolTip(usr)

/atom/movable/screen/wanted/update_icon_state()
. = ..()
icon_state = "wanted_[level][cops_arrived ? "_active" : ""]"
icon_state = "[base_icon_state]_[level][cops_arrived ? "_active" : null]"
return ..()
6 changes: 3 additions & 3 deletions code/_onclick/hud/generic_dextrous.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = ui_style
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_drone_pull
pull_icon.hud = src
static_inventory += pull_icon
Expand Down Expand Up @@ -42,7 +42,7 @@
zone_select = new /atom/movable/screen/zone_sel()
zone_select.icon = ui_style
zone_select.hud = src
zone_select.update_icon()
zone_select.update_appearance()
static_inventory += zone_select

using = new /atom/movable/screen/area_creator
Expand All @@ -56,7 +56,7 @@
if(inv.slot_id)
inv.hud = src
inv_slots[TOBITSHIFT(inv.slot_id) + 1] = inv
inv.update_icon()
inv.update_appearance()

/datum/hud/dextrous/persistent_inventory_update()
if(!mymob)
Expand Down
4 changes: 2 additions & 2 deletions code/_onclick/hud/guardian.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = ui_style
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_living_pull
pull_icon.hud = src
static_inventory += pull_icon
Expand Down Expand Up @@ -70,7 +70,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = 'icons/hud/guardian.dmi'
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_living_pull
pull_icon.hud = src
static_inventory += pull_icon
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ GLOBAL_LIST_INIT(available_ui_styles, list(
hand_slots["[i]"] = hand_box
hand_box.hud = src
static_inventory += hand_box
hand_box.update_icon()
hand_box.update_appearance()

var/i = 1
for(var/atom/movable/screen/swap_hand/SH in static_inventory)
Expand Down
6 changes: 3 additions & 3 deletions code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = ui_style
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_above_intent
pull_icon.hud = src
static_inventory += pull_icon
Expand All @@ -309,7 +309,7 @@
zone_select = new /atom/movable/screen/zone_sel()
zone_select.icon = ui_style
zone_select.hud = src
zone_select.update_icon()
zone_select.update_appearance()
static_inventory += zone_select

combo_display = new /atom/movable/screen/combo()
Expand All @@ -319,7 +319,7 @@
if(inv.slot_id)
inv.hud = src
inv_slots[TOBITSHIFT(inv.slot_id) + 1] = inv
inv.update_icon()
inv.update_appearance()

update_locked_slots()

Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = ui_style
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_living_pull
pull_icon.hud = src
static_inventory += pull_icon
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/ooze.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
zone_select = new /atom/movable/screen/zone_sel()
zone_select.icon = ui_style
zone_select.hud = src
zone_select.update_icon()
zone_select.update_appearance()
static_inventory += zone_select

alien_plasma_display = new /atom/movable/screen/ooze_nutrition_display //Just going to use the alien plasma display because making new vars for each object is braindead.
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/revenanthud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

pull_icon = new /atom/movable/screen/pull()
pull_icon.icon = ui_style
pull_icon.update_icon()
pull_icon.update_appearance()
pull_icon.screen_loc = ui_living_pull
pull_icon.hud = src
static_inventory += pull_icon
Expand Down
15 changes: 7 additions & 8 deletions code/_onclick/hud/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,13 @@
pull_icon.icon = 'icons/hud/screen_cyborg.dmi'
pull_icon.screen_loc = ui_borg_pull
pull_icon.hud = src
pull_icon.update_icon()
pull_icon.update_appearance()
hotkeybuttons += pull_icon


zone_select = new /atom/movable/screen/zone_sel/robot()
zone_select.hud = src
zone_select.update_icon()
zone_select.update_appearance()
static_inventory += zone_select


Expand Down Expand Up @@ -273,20 +273,19 @@
/atom/movable/screen/robot/lamp
name = "headlamp"
icon_state = "lamp_off"
base_icon_state = "lamp"
var/mob/living/silicon/robot/robot

/atom/movable/screen/robot/lamp/Click()
. = ..()
if(.)
return
robot?.toggle_headlamp()
update_icon()
update_appearance()

/atom/movable/screen/robot/lamp/update_icon()
if(robot?.lamp_enabled)
icon_state = "lamp_on"
else
icon_state = "lamp_off"
/atom/movable/screen/robot/lamp/update_icon_state()
icon_state = "[base_icon_state]_[robot?.lamp_enabled ? "on" : "off"]"
return ..()

/atom/movable/screen/robot/modPC
name = "Modular Interface"
Expand Down
Loading

0 comments on commit e4079c8

Please sign in to comment.