Porting update_icon improvements. Part 1.

This commit is contained in:
Ghommie
2020-02-27 01:21:03 +01:00
parent 5bd62d129f
commit fc76cd9a9b
122 changed files with 733 additions and 723 deletions
+21 -10
View File
@@ -41,6 +41,11 @@ GLOBAL_LIST_EMPTY(PDAs)
var/mode = 0 //Controls what menu the PDA will display. 0 is hub; the rest are either built in or based on cartridge.
var/list/overlays_icons = list('icons/obj/pda_alt.dmi' = list("pda-r", "screen_default", "id_overlay", "insert_overlay", "light_overlay", "pai_overlay"))
var/current_overlays = PDA_STANDARD_OVERLAYS
//variables exclusively used on 'update_overlays' (which should never be called directly, and 'update_icon' doesn't use args anyway)
var/new_overlays = FALSE
var/new_alert = FALSE
var/font_index = 0 //This int tells DM which font is currently selected and lets DM know when the last font has been selected so that it can cycle back to the first font when "toggle font" is pressed again.
var/font_mode = "font-family:monospace;" //The currently selected font.
var/background_color = "#808000" //The currently selected background color.
@@ -123,7 +128,8 @@ GLOBAL_LIST_EMPTY(PDAs)
inserted_item = new inserted_item(src)
else
inserted_item = new /obj/item/pen(src)
update_icon(FALSE, TRUE)
new_overlays = TRUE
update_icon()
/obj/item/pda/CtrlShiftClick(mob/living/user)
. = ..()
@@ -144,7 +150,8 @@ GLOBAL_LIST_EMPTY(PDAs)
if(QDELETED(src) || isnull(new_icon) || new_icon == icon || !M.canUseTopic(src, BE_CLOSE, FALSE, NO_TK))
return
icon = new_icon
update_icon(FALSE, TRUE)
new_overlays = TRUE
update_icon()
to_chat(M, "[src] is now skinned as '[choice]'.")
/obj/item/pda/proc/set_new_overlays()
@@ -188,7 +195,8 @@ GLOBAL_LIST_EMPTY(PDAs)
var/pref_skin = GLOB.pda_reskins[C.prefs.pda_skin]
if(icon != pref_skin)
icon = pref_skin
update_icon(FALSE, TRUE)
new_overlays = TRUE
update_icon()
equipped = TRUE
/obj/item/pda/proc/update_label()
@@ -215,25 +223,27 @@ GLOBAL_LIST_EMPTY(PDAs)
return TRUE
return FALSE
/obj/item/pda/update_icon(alert = FALSE, new_overlays = FALSE)
/obj/item/pda/update_overlays()
. = ..()
if(new_overlays)
set_new_overlays()
cut_overlays()
add_overlay(alert ? current_overlays[PDA_OVERLAY_ALERT] : current_overlays[PDA_OVERLAY_SCREEN])
. += new_alert ? current_overlays[PDA_OVERLAY_ALERT] : current_overlays[PDA_OVERLAY_SCREEN]
var/mutable_appearance/overlay = new()
overlay.pixel_x = overlays_x_offset
if(id)
overlay.icon_state = current_overlays[PDA_OVERLAY_ID]
add_overlay(new /mutable_appearance(overlay))
. += new /mutable_appearance(overlay)
if(inserted_item)
overlay.icon_state = current_overlays[PDA_OVERLAY_ITEM]
add_overlay(new /mutable_appearance(overlay))
. += new /mutable_appearance(overlay)
if(fon)
overlay.icon_state = current_overlays[PDA_OVERLAY_LIGHT]
add_overlay(new /mutable_appearance(overlay))
. += new /mutable_appearance(overlay)
if(pai)
overlay.icon_state = "[current_overlays[PDA_OVERLAY_PAI]][pai.pai ? "" : "_off"]"
add_overlay(new /mutable_appearance(overlay))
. += new /mutable_appearance(overlay)
new_overlays = FALSE
new_alert = FALSE
/obj/item/pda/MouseDrop(mob/over, src_location, over_location)
var/mob/M = usr
@@ -849,6 +859,7 @@ GLOBAL_LIST_EMPTY(PDAs)
to_chat(L, "[icon2html(src)] <b>Message from [hrefstart][signal.data["name"]] ([signal.data["job"]])[hrefend], </b>[inbound_message] (<a href='byond://?src=[REF(src)];choice=Message;skiprefresh=1;target=[REF(signal.source)]'>Reply</a>) (<a href='byond://?src=[REF(src)];choice=toggle_block;target=[signal.data["name"]]'>BLOCK/UNBLOCK</a>)")
new_alert = TRUE
update_icon(TRUE)
/obj/item/pda/proc/send_to_all(mob/living/U)
@@ -454,7 +454,7 @@
on = FALSE
update_icon()
/obj/item/flashlight/glowstick/update_icon()
/obj/item/flashlight/glowstick/update_icon_state()
item_state = "glowstick"
cut_overlays()
if(!fuel)
@@ -87,27 +87,25 @@
. += "<span class='notice'>The last radiation amount detected was [last_tick_amount]</span>"
/obj/item/geiger_counter/update_icon()
/obj/item/geiger_counter/update_icon_state()
if(!scanning)
icon_state = "geiger_off"
return 1
if(obj_flags & EMAGGED)
else if(obj_flags & EMAGGED)
icon_state = "geiger_on_emag"
return 1
switch(radiation_count)
if(-INFINITY to RAD_LEVEL_NORMAL)
icon_state = "geiger_on_1"
if(RAD_LEVEL_NORMAL + 1 to RAD_LEVEL_MODERATE)
icon_state = "geiger_on_2"
if(RAD_LEVEL_MODERATE + 1 to RAD_LEVEL_HIGH)
icon_state = "geiger_on_3"
if(RAD_LEVEL_HIGH + 1 to RAD_LEVEL_VERY_HIGH)
icon_state = "geiger_on_4"
if(RAD_LEVEL_VERY_HIGH + 1 to RAD_LEVEL_CRITICAL)
icon_state = "geiger_on_4"
if(RAD_LEVEL_CRITICAL + 1 to INFINITY)
icon_state = "geiger_on_5"
..()
else
switch(radiation_count)
if(-INFINITY to RAD_LEVEL_NORMAL)
icon_state = "geiger_on_1"
if(RAD_LEVEL_NORMAL + 1 to RAD_LEVEL_MODERATE)
icon_state = "geiger_on_2"
if(RAD_LEVEL_MODERATE + 1 to RAD_LEVEL_HIGH)
icon_state = "geiger_on_3"
if(RAD_LEVEL_HIGH + 1 to RAD_LEVEL_VERY_HIGH)
icon_state = "geiger_on_4"
if(RAD_LEVEL_VERY_HIGH + 1 to RAD_LEVEL_CRITICAL)
icon_state = "geiger_on_4"
if(RAD_LEVEL_CRITICAL + 1 to INFINITY)
icon_state = "geiger_on_5"
/obj/item/geiger_counter/proc/update_sound()
var/datum/looping_sound/geiger/loop = soundloop
@@ -158,7 +158,7 @@
/obj/item/lightreplacer/attack_self(mob/user)
to_chat(user, status_string())
/obj/item/lightreplacer/update_icon()
/obj/item/lightreplacer/update_icon_state()
icon_state = "lightreplacer[(obj_flags & EMAGGED ? 1 : 0)]"
/obj/item/lightreplacer/proc/status_string()
+2 -2
View File
@@ -67,7 +67,7 @@
to_chat(user, "<span class='notice'>You clear the wired connection from the multitool.</span>")
update_icon()
/obj/item/multitool/update_icon()
/obj/item/multitool/update_icon_state()
if(selected_io)
icon_state = "multitool_red"
else
@@ -149,7 +149,7 @@
/obj/item/multitool/ai_detect/ui_action_click()
return
/obj/item/multitool/ai_detect/update_icon()
/obj/item/multitool/ai_detect/update_icon_state()
if(selected_io)
icon_state = "multitool_red"
else
+1 -1
View File
@@ -26,7 +26,7 @@
var/obj/structure/cable/attached // the attached cable
/obj/item/powersink/update_icon()
/obj/item/powersink/update_icon_state()
icon_state = "powersink[mode == OPERATING]"
/obj/item/powersink/proc/set_mode(value)
@@ -27,7 +27,7 @@
qpad = null
return TRUE
/obj/item/quantum_keycard/update_icon()
/obj/item/quantum_keycard/update_icon_state()
if(qpad)
icon_state = "quantum_keycard_on"
else
@@ -83,7 +83,7 @@
eject(usr)
/obj/item/taperecorder/update_icon()
/obj/item/taperecorder/update_icon_state()
if(!mytape)
icon_state = "taperecorder_empty"
else if(recording)