update_appearance (#55468)

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
This commit is contained in:
TemporalOroboros
2021-02-19 07:06:18 -08:00
committed by GitHub
parent dc4b7226d0
commit e4079c87b8
585 changed files with 4689 additions and 4133 deletions

View File

@@ -62,7 +62,7 @@
idle_threads = list()
if(looping_sound)
soundloop = new(list(src), enabled)
update_icon()
update_appearance()
/obj/item/modular_computer/Destroy()
kill_program(forced = TRUE)
@@ -168,21 +168,16 @@
. += get_modular_computer_parts_examine(user)
/obj/item/modular_computer/update_icon_state()
if(!enabled)
icon_state = icon_state_unpowered
else
icon_state = icon_state_powered
icon_state = enabled ? icon_state_powered : icon_state_unpowered
return ..()
/obj/item/modular_computer/update_overlays()
. = ..()
if(!display_overlays)
return
if(enabled)
if(active_program)
. += active_program.program_icon_state ? active_program.program_icon_state : icon_state_menu
else
. += icon_state_menu
if(enabled)
. += active_program?.program_icon_state || icon_state_menu
if(obj_integrity <= integrity_failure * max_integrity)
. += "bsod"
. += "broken"
@@ -217,7 +212,7 @@
if(looping_sound)
soundloop.start()
enabled = 1
update_icon()
update_appearance()
ui_interact(user)
return TRUE
else // Unpowered
@@ -353,7 +348,7 @@
var/mob/user = usr
if(user && istype(user))
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
update_icon()
update_appearance()
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
/obj/item/modular_computer/proc/get_ntnet_status(specific_action = 0)
@@ -380,7 +375,7 @@
if(loud)
physical.visible_message("<span class='notice'>\The [src] shuts down.</span>")
enabled = 0
update_icon()
update_appearance()
/**
* Toggles the computer's flashlight, if it has one.

View File

@@ -54,7 +54,7 @@
H.on_remove(src, user)
if(enabled && !use_power())
shutdown_computer()
update_icon()
update_appearance()
return TRUE

View File

@@ -111,7 +111,7 @@
active_program.program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
active_program = null
update_icon()
update_appearance()
if(user && istype(user))
ui_interact(user) // Re-open the UI on this computer. It should show the main screen now.
@@ -150,7 +150,7 @@
active_program = P
P.alert_pending = FALSE
idle_threads.Remove(P)
update_icon()
update_appearance()
return
var/obj/item/computer_hardware/processor_unit/PU = all_components[MC_CPU]
@@ -165,7 +165,7 @@
if(P.run_program(user))
active_program = P
P.alert_pending = FALSE
update_icon()
update_appearance()
return 1
if("PC_toggle_light")

View File

@@ -37,15 +37,14 @@
/obj/item/modular_computer/laptop/update_icon_state()
if(!screen_on)
icon_state = icon_state_closed
else
. = ..()
return
return ..()
/obj/item/modular_computer/laptop/update_overlays()
if(screen_on)
return ..()
else
if(!screen_on)
cut_overlays()
icon_state = icon_state_closed
return
return ..()
/obj/item/modular_computer/laptop/attack_self(mob/user)
if(!screen_on)
@@ -111,7 +110,7 @@
screen_on = !screen_on
display_overlays = screen_on
update_icon()
update_appearance()

View File

@@ -47,7 +47,7 @@
if(!machinery_computer)
return
..()
machinery_computer.update_icon()
machinery_computer.update_appearance()
return
/obj/item/modular_computer/processor/attack_ghost(mob/user)

View File

@@ -2,9 +2,10 @@
name = "tablet computer"
icon = 'icons/obj/modular_tablet.dmi'
icon_state = "tablet-red"
icon_state_unpowered = "tablet"
icon_state_powered = "tablet"
icon_state_unpowered = "tablet-red"
icon_state_powered = "tablet-red"
icon_state_menu = "menu"
base_icon_state = "tablet"
worn_icon_state = "tablet"
hardware_flag = PROGRAM_TABLET
max_hardware_size = 1
@@ -21,8 +22,9 @@
/obj/item/modular_computer/tablet/update_icon_state()
if(has_variants)
if(!finish_color)
finish_color = pick("red","blue","brown","green","black")
icon_state = icon_state_powered = icon_state_unpowered = "tablet-[finish_color]"
finish_color = pick("red", "blue", "brown", "green", "black")
icon_state = icon_state_powered = icon_state_unpowered = "[base_icon_state]-[finish_color]"
return ..()
/obj/item/modular_computer/tablet/syndicate_contract_uplink
name = "contractor tablet"
@@ -39,6 +41,8 @@
/// Given to Nuke Ops members.
/obj/item/modular_computer/tablet/nukeops
icon_state = "tablet-syndicate"
icon_state_powered = "tablet-syndicate"
icon_state_unpowered = "tablet-syndicate"
comp_light_luminosity = 6.3
has_variants = FALSE
device_theme = "syndicate"
@@ -55,6 +59,9 @@
/obj/item/modular_computer/tablet/integrated
name = "modular interface"
icon_state = "tablet-silicon"
icon_state_powered = "tablet-silicon"
icon_state_unpowered = "tablet-silicon"
base_icon_state = "tablet-silicon"
has_light = FALSE //tablet light button actually enables/disables the borg lamp
comp_light_luminosity = 0
has_variants = FALSE
@@ -139,6 +146,8 @@
/obj/item/modular_computer/tablet/integrated/syndicate
icon_state = "tablet-silicon-syndicate"
icon_state_powered = "tablet-silicon-syndicate"
icon_state_unpowered = "tablet-silicon-syndicate"
device_theme = "syndicate"

View File

@@ -53,26 +53,25 @@
return FALSE
return (cpu.emag_act(user))
/obj/machinery/modular_computer/update_icon()
cut_overlays()
icon_state = icon_state_powered
/obj/machinery/modular_computer/update_appearance(updates)
. = ..()
set_light(cpu?.enabled ? light_strength : 0)
if(!cpu || !cpu.enabled)
/obj/machinery/modular_computer/update_icon_state()
icon_state = (cpu?.enabled || (!(machine_stat & NOPOWER) && cpu?.use_power())) ? icon_state_powered : icon_state_unpowered
return ..()
/obj/machinery/modular_computer/update_overlays()
. = ..()
if(!cpu?.enabled)
if (!(machine_stat & NOPOWER) && (cpu?.use_power()))
add_overlay(screen_icon_screensaver)
else
icon_state = icon_state_unpowered
set_light(0)
. += screen_icon_screensaver
else
set_light(light_strength)
if(cpu.active_program)
add_overlay(cpu.active_program.program_icon_state ? cpu.active_program.program_icon_state : screen_icon_state_menu)
else
add_overlay(screen_icon_state_menu)
. += cpu.active_program?.program_icon_state || screen_icon_state_menu
if(cpu && cpu.obj_integrity <= cpu.integrity_failure * cpu.max_integrity)
add_overlay("bsod")
add_overlay("broken")
. += "bsod"
. += "broken"
/obj/machinery/modular_computer/AltClick(mob/user)
if(cpu)
@@ -101,13 +100,13 @@
if(cpu)
cpu.shutdown_computer(0)
set_machine_stat(machine_stat | NOPOWER)
update_icon()
update_appearance()
// Modular computers can have battery in them, we handle power in previous proc, so prevent this from messing it up for us.
/obj/machinery/modular_computer/power_change()
if(cpu?.use_power()) // If MC_CPU still has a power source, PC wouldn't go offline.
set_machine_stat(machine_stat & ~NOPOWER)
update_icon()
update_appearance()
return
. = ..()

View File

@@ -52,4 +52,4 @@
network_card.identification_string = "Unknown Console"
if(cpu)
cpu.screen_on = 1
update_icon()
update_appearance()

View File

@@ -66,7 +66,7 @@
// Relays icon update to the computer.
/datum/computer_file/program/proc/update_computer_icon()
if(computer)
computer.update_icon()
computer.update_appearance()
// Attempts to create a log in global ntnet datum. Returns 1 on success, 0 on fail.
/datum/computer_file/program/proc/generate_network_log(text)
@@ -221,7 +221,7 @@
program_state = PROGRAM_STATE_BACKGROUND // Should close any existing UIs
computer.active_program = null
computer.update_icon()
computer.update_appearance()
ui.close()
if(user && istype(user))

View File

@@ -84,7 +84,7 @@
if(A.health >= 0 && A.stat == DEAD)
A.revive(full_heal = FALSE, admin_revive = FALSE)
cardhold.update_icon()
cardhold.update_appearance()
// Finished restoring
if(A.health >= 100)

View File

@@ -27,7 +27,7 @@
computer.visible_message("<span class='notice'>\The [computer]'s screen brightly flashes and loud electrical buzzing is heard.</span>")
computer.enabled = FALSE
computer.update_icon()
computer.update_appearance()
var/obj/item/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD]
var/obj/item/computer_hardware/battery/battery_module = computer.all_components[MC_CELL]
var/obj/item/computer_hardware/recharger/recharger = computer.all_components[MC_CHARGE]

View File

@@ -32,7 +32,7 @@
game_active = FALSE
program_icon_state = "arcade_off"
if(istype(computer))
computer.update_icon()
computer.update_appearance()
ticket_count += 1
user?.mind?.adjust_experience(/datum/skill/gaming, 50)
sleep(10)
@@ -42,7 +42,7 @@
game_active = FALSE
program_icon_state = "arcade_off"
if(istype(computer))
computer.update_icon()
computer.update_appearance()
user?.mind?.adjust_experience(/datum/skill/gaming, 10)
sleep(10)
@@ -175,4 +175,4 @@
boss_id = rand(1,6)
pause_state = FALSE
if(istype(computer))
computer.update_icon()
computer.update_appearance()

View File

@@ -16,7 +16,7 @@
var/atom/selected
///Used to store when the next scan is available. Updated by the scan() proc.
var/next_scan = 0
///Used to keep track of the last value program_icon_state was set to, to prevent constant unnecessary update_icon() calls
///Used to keep track of the last value program_icon_state was set to, to prevent constant unnecessary update_appearance() calls
var/last_icon_state = ""
///Used by the tgui interface, themed NT or Syndicate.
var/arrowstyle = "ntosradarpointer.png"
@@ -175,7 +175,7 @@
if(!trackable(signal))
program_icon_state = "[initial(program_icon_state)]lost"
if(last_icon_state != program_icon_state)
computer.update_icon()
computer.update_appearance()
last_icon_state = program_icon_state
return
@@ -193,7 +193,7 @@
program_icon_state = "[initial(program_icon_state)]far"
if(last_icon_state != program_icon_state)
computer.update_icon()
computer.update_appearance()
last_icon_state = program_icon_state
computer.setDir(get_dir(here_turf, target_turf))

View File

@@ -28,7 +28,7 @@
ui_header = "smmon_[last_status].gif"
program_icon_state = "smmon_[last_status]"
if(istype(computer))
computer.update_icon()
computer.update_appearance()
/datum/computer_file/program/supermatter_monitor/run_program(mob/living/user)
. = ..(user)

View File

@@ -33,7 +33,7 @@
P.info = text_to_print
if(paper_title)
P.name = paper_title
P.update_icon()
P.update_appearance()
stored_paper--
P = null
return TRUE