From c3c37134688fa9d7485cf3bc05af56aff617130c Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Mon, 16 Oct 2023 14:52:13 +1100 Subject: [PATCH] Compiling/refining screen object work. --- code/__defines/mech.dm | 1 - code/_onclick/hud/deity.dm | 33 -------------- code/_onclick/hud/global_hud.dm | 4 +- code/_onclick/hud/hud.dm | 47 +++++--------------- code/_onclick/hud/pai.dm | 2 +- code/_onclick/hud/radial.dm | 8 ++-- code/_onclick/hud/radial_persistent.dm | 2 +- code/_onclick/hud/screen/_screen.dm | 15 ++++--- code/_onclick/hud/screen/screen_exosuit.dm | 2 +- code/_onclick/hud/screen/screen_gun.dm | 2 +- code/_onclick/hud/screen/screen_intent.dm | 33 ++++++++++++++ code/_onclick/hud/screen/screen_swaphands.dm | 9 ++++ code/_onclick/hud/screen/screen_toggle.dm | 1 + code/modules/mechs/interface/_interface.dm | 12 ++--- mods/species/ascent/mobs/nymph/nymph_ui.dm | 2 +- nebula.dme | 1 + 16 files changed, 83 insertions(+), 91 deletions(-) create mode 100644 code/_onclick/hud/screen/screen_swaphands.dm diff --git a/code/__defines/mech.dm b/code/__defines/mech.dm index bfa6071fdead..e01159f0fd0f 100644 --- a/code/__defines/mech.dm +++ b/code/__defines/mech.dm @@ -1,4 +1,3 @@ - #define HARDPOINT_BACK "back" #define HARDPOINT_LEFT_HAND "left hand" #define HARDPOINT_RIGHT_HAND "right hand" diff --git a/code/_onclick/hud/deity.dm b/code/_onclick/hud/deity.dm index 554dfca35e37..5a21848f9489 100644 --- a/code/_onclick/hud/deity.dm +++ b/code/_onclick/hud/deity.dm @@ -10,36 +10,3 @@ mymob.client.screen = list() mymob.client.screen += src.adding D.sync_to_mob(mymob) - -/obj/screen/intent/deity/proc/sync_to_mob(var/mob) - var/mob/living/deity/D = mob - for(var/i in 1 to D.control_types.len) - var/obj/screen/S = new() - S.SetName(null) //Don't want them to be able to actually right click it. - S.mouse_opacity = MOUSE_OPACITY_UNCLICKABLE - S.icon_state = "blank" - desc_screens[D.control_types[i]] = S - S.maptext_width = 128 - S.screen_loc = screen_loc - //This sets it up right. Trust me. - S.maptext_y = 33/2*i - i*i/2 - 10 - D.client.screen += S - S.maptext_x = -125 - - update_text() - -/obj/screen/intent/deity/proc/update_text() - if(!isdeity(usr)) - return - var/mob/living/deity/D = usr - for(var/i in D.control_types) - var/obj/screen/S = desc_screens[i] - var/datum/phenomena/P = D.intent_phenomenas[intent][i] - if(P) - S.maptext = "[P.name]" - else - S.maptext = null - -/obj/screen/intent/deity/handle_click(mob/user, params) - ..() - update_text() diff --git a/code/_onclick/hud/global_hud.dm b/code/_onclick/hud/global_hud.dm index 8bcfb40027f1..645bb5e6643f 100644 --- a/code/_onclick/hud/global_hud.dm +++ b/code/_onclick/hud/global_hud.dm @@ -18,7 +18,7 @@ var/global/datum/global_hud/hud // makes custom colored overlay, can also generate scanline /datum/global_hud/proc/setup_overlay(icon_state, color) - var/obj/screen/screen = new /obj/screen() + var/obj/screen/screen = new /obj/screen(null) screen.screen_loc = ui_entire_screen screen.icon = 'icons/effects/hud_full.dmi' screen.icon_state = icon_state @@ -39,7 +39,7 @@ var/global/datum/global_hud/hud //Holomap screen object is invisible and work //By setting it as n images location, without icon changes //Make it part of global hud since it's inmutable - holomap = new /obj/screen() + holomap = new /obj/screen(null) holomap.name = "holomap" holomap.icon = null holomap.layer = HUD_BASE_LAYER diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 858008741836..b5d7148e3e0f 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -25,7 +25,6 @@ var/show_intent_icons = FALSE var/hotkey_ui_hidden = FALSE //This is to hide the buttons that can be used via hotkeys. (hotkeybuttons list of buttons) - var/obj/screen/lingchemdisplay var/list/hand_hud_objects var/list/swaphand_hud_objects var/obj/screen/action_intent @@ -47,7 +46,6 @@ /datum/hud/Destroy() . = ..() stamina_bar = null - lingchemdisplay = null action_intent = null move_intent = null adding = null @@ -149,10 +147,15 @@ if(existing_box.slot_id == hand_tag) inv_box = existing_box break + if(!inv_box) - inv_box = new /obj/screen/inventory(null, mymob) + inv_box = new /obj/screen/inventory(null, mymob, ui_style, ui_color, ui_alpha) + else + inv_box.icon = ui_style + inv_box.color = ui_color + inv_box.alpha = ui_alpha + inv_box.SetName(hand_tag) - inv_box.icon = ui_style inv_box.icon_state = "hand_base" inv_box.cut_overlays() @@ -162,8 +165,6 @@ inv_box.update_icon() inv_box.slot_id = hand_tag - inv_box.color = ui_color - inv_box.alpha = ui_alpha inv_box.appearance_flags |= KEEP_TOGETHER LAZYDISTINCTADD(hand_hud_objects, inv_box) @@ -234,10 +235,7 @@ if(gear_slot in held_slots) continue - inv_box = new /obj/screen/inventory(null, mymob) - inv_box.icon = ui_style - inv_box.color = ui_color - inv_box.alpha = ui_alpha + inv_box = new /obj/screen/inventory(null, mymob, ui_style, ui_color, ui_alpha) var/datum/inventory_slot/inv_slot = inventory_slots[gear_slot] inv_box.SetName(inv_slot.slot_name) @@ -255,12 +253,7 @@ adding += inv_box if(has_hidden_gear) - var/obj/screen/using = new /obj/screen/toggle() - using.icon = ui_style - using.screen_loc = ui_inventory - using.color = ui_color - using.alpha = ui_alpha - adding += using + adding += new /obj/screen/toggle(null, mymob, ui_style, ui_color, ui_alpha) /datum/hud/proc/BuildHandsUI() @@ -268,34 +261,18 @@ var/ui_color = get_ui_color() var/ui_alpha = get_ui_alpha() - var/obj/screen/using - // Swap hand and quick equip screen elems. - using = new /obj/screen/equip() - using.icon = ui_style - using.color = ui_color - using.alpha = ui_alpha + var/obj/screen/using = new /obj/screen/equip(null, mymob, ui_style, ui_color, ui_alpha) src.adding += using LAZYADD(swaphand_hud_objects, using) var/list/held_slots = mymob.get_held_item_slots() if(length(held_slots) > 1) - using = new /obj/screen/inventory(null, mymob) - using.SetName("hand") - using.icon = ui_style - using.icon_state = "hand1" - using.color = ui_color - using.alpha = ui_alpha + using = new /obj/screen/inventory/swaphand(null, mymob, ui_style, ui_color, ui_alpha) src.adding += using LAZYADD(swaphand_hud_objects, using) - - using = new /obj/screen/inventory(null, mymob) - using.SetName("hand") - using.icon = ui_style - using.icon_state = "hand2" - using.color = ui_color - using.alpha = ui_alpha + using = new /obj/screen/inventory/swaphand/right(null, mymob, ui_style, ui_color, ui_alpha) src.adding += using LAZYADD(swaphand_hud_objects, using) diff --git a/code/_onclick/hud/pai.dm b/code/_onclick/hud/pai.dm index 14e7bbc0472f..28e869dc9d11 100644 --- a/code/_onclick/hud/pai.dm +++ b/code/_onclick/hud/pai.dm @@ -4,6 +4,6 @@ var/obj/screen/pai/hud_elem = hud_type if(TYPE_IS_ABSTRACT(hud_elem)) continue - new hud_elem(null, mymob) + adding += new hud_elem(null, mymob) mymob.client.screen = adding hide_inventory() diff --git a/code/_onclick/hud/radial.dm b/code/_onclick/hud/radial.dm index 49fe49e32daf..7427e3996b22 100644 --- a/code/_onclick/hud/radial.dm +++ b/code/_onclick/hud/radial.dm @@ -3,16 +3,18 @@ var/global/list/radial_menus = list() -/obj/screen/radial/Destroy() - parent = null - return ..() /obj/screen/radial icon = 'icons/screen/radial.dmi' layer = HUD_ABOVE_ITEM_LAYER plane = HUD_PLANE + requires_owner = FALSE var/datum/radial_menu/parent +/obj/screen/radial/Destroy() + parent = null + return ..() + /obj/screen/radial/slice icon_state = "radial_slice" var/choice diff --git a/code/_onclick/hud/radial_persistent.dm b/code/_onclick/hud/radial_persistent.dm index 592f98912e5b..840c5e304b66 100644 --- a/code/_onclick/hud/radial_persistent.dm +++ b/code/_onclick/hud/radial_persistent.dm @@ -23,7 +23,7 @@ var/datum/callback/select_proc_callback /datum/radial_menu/persistent/New() - close_button = new /obj/screen/radial/persistent/center + close_button = new /obj/screen/radial/persistent/center(null) close_button.parent = src /datum/radial_menu/persistent/element_chosen(choice_id,mob/user) diff --git a/code/_onclick/hud/screen/_screen.dm b/code/_onclick/hud/screen/_screen.dm index 19f8d3ae7f44..c6c2558f029b 100644 --- a/code/_onclick/hud/screen/_screen.dm +++ b/code/_onclick/hud/screen/_screen.dm @@ -4,11 +4,13 @@ For more information, see the byond documentation on the screen_loc and screen vars. */ /obj/screen - name = "" - icon = 'icons/mob/screen1.dmi' - plane = HUD_PLANE - layer = HUD_BASE_LAYER - appearance_flags = NO_CLIENT_COLOR + name = "" + icon = 'icons/mob/screen1.dmi' + plane = HUD_PLANE + layer = HUD_BASE_LAYER + appearance_flags = NO_CLIENT_COLOR + abstract_type = /obj/screen + is_spawnable_type = FALSE /// The mob that owns this screen object, if any. var/weakref/owner_ref @@ -20,7 +22,8 @@ var/user_incapacitation_flags = INCAPACITATION_DEFAULT /obj/screen/Initialize(mapload, mob/_owner, ui_style, ui_color, ui_alpha) - owner_ref = ismob(_owner) && weakref(_owner) + if(ismob(_owner)) + owner_ref = weakref(_owner) if(requires_owner && !owner_ref) PRINT_STACK_TRACE("ERROR: [type]'s Initialize() was not given an owner argument.") return INITIALIZE_HINT_QDEL diff --git a/code/_onclick/hud/screen/screen_exosuit.dm b/code/_onclick/hud/screen/screen_exosuit.dm index aadc464df3a5..0eca9ca30059 100644 --- a/code/_onclick/hud/screen/screen_exosuit.dm +++ b/code/_onclick/hud/screen/screen_exosuit.dm @@ -366,7 +366,7 @@ /obj/screen/exosuit/heat/Initialize(mapload, mob/_owner, ui_style, ui_color, ui_alpha) . = ..() - gauge_needle = new /obj/screen/exosuit/needle(_owner) + gauge_needle = new /obj/screen/exosuit/needle(null, _owner) add_vis_contents(src, gauge_needle) /obj/screen/exosuit/heat/Destroy() diff --git a/code/_onclick/hud/screen/screen_gun.dm b/code/_onclick/hud/screen/screen_gun.dm index b63c0c6edc24..4d0dd63e0dd8 100644 --- a/code/_onclick/hud/screen/screen_gun.dm +++ b/code/_onclick/hud/screen/screen_gun.dm @@ -5,7 +5,7 @@ var/toggle_flag /obj/screen/gun/handle_click(mob/user, params) - if(toggle_flag && isliving(user)) + if(isliving(user)) var/mob/living/shooter = user if(!shooter.aiming) shooter.aiming = new(user) diff --git a/code/_onclick/hud/screen/screen_intent.dm b/code/_onclick/hud/screen/screen_intent.dm index cb6078487555..5cad1249aa30 100644 --- a/code/_onclick/hud/screen/screen_intent.dm +++ b/code/_onclick/hud/screen/screen_intent.dm @@ -32,3 +32,36 @@ cut_overlays() add_overlay(image('icons/mob/screen_phenomena.dmi', icon_state = "hud", pixel_x = -138, pixel_y = -1)) compile_overlays() + +/obj/screen/intent/deity/proc/sync_to_mob(var/mob) + var/mob/living/deity/D = mob + for(var/i in 1 to D.control_types.len) + var/obj/screen/S = new() + S.SetName(null) //Don't want them to be able to actually right click it. + S.mouse_opacity = MOUSE_OPACITY_UNCLICKABLE + S.icon_state = "blank" + desc_screens[D.control_types[i]] = S + S.maptext_width = 128 + S.screen_loc = screen_loc + //This sets it up right. Trust me. + S.maptext_y = 33/2*i - i*i/2 - 10 + D.client.screen += S + S.maptext_x = -125 + + update_text() + +/obj/screen/intent/deity/proc/update_text() + if(!isdeity(usr)) + return + var/mob/living/deity/D = usr + for(var/i in D.control_types) + var/obj/screen/S = desc_screens[i] + var/datum/phenomena/P = D.intent_phenomenas[intent][i] + if(P) + S.maptext = "[P.name]" + else + S.maptext = null + +/obj/screen/intent/deity/handle_click(mob/user, params) + ..() + update_text() diff --git a/code/_onclick/hud/screen/screen_swaphands.dm b/code/_onclick/hud/screen/screen_swaphands.dm new file mode 100644 index 000000000000..037602bf9dda --- /dev/null +++ b/code/_onclick/hud/screen/screen_swaphands.dm @@ -0,0 +1,9 @@ +/obj/screen/inventory/swaphand + name = "hand" + icon_state = "hand1" + +/obj/screen/inventory/swaphand/handle_click(mob/user, params) + user.swap_hand() + +/obj/screen/inventory/swaphand/right + icon_state = "hand2" diff --git a/code/_onclick/hud/screen/screen_toggle.dm b/code/_onclick/hud/screen/screen_toggle.dm index b8e6b0f699dc..aa83c7733d43 100644 --- a/code/_onclick/hud/screen/screen_toggle.dm +++ b/code/_onclick/hud/screen/screen_toggle.dm @@ -1,6 +1,7 @@ /obj/screen/toggle name = "toggle" icon_state = "other" + screen_loc = ui_inventory /obj/screen/toggle/handle_click(mob/user, params) if(user.hud_used.inventory_shown) diff --git a/code/modules/mechs/interface/_interface.dm b/code/modules/mechs/interface/_interface.dm index 96a9cda10b18..42f184477cf7 100644 --- a/code/modules/mechs/interface/_interface.dm +++ b/code/modules/mechs/interface/_interface.dm @@ -21,11 +21,11 @@ client.screen |= hud_elements /mob/living/exosuit/InitializeHud() - zone_sel = new + zone_sel = new(null, src) if(!LAZYLEN(hud_elements)) var/i = 1 for(var/hardpoint in hardpoints) - var/obj/screen/exosuit/hardpoint/H = new(src, hardpoint) + var/obj/screen/exosuit/hardpoint/H = new(null, src, null, null, null, hardpoint) H.screen_loc = "LEFT:6,TOP-[i]:-16" hud_elements |= H hardpoint_hud_elements[hardpoint] = H @@ -36,21 +36,21 @@ i = 0 var/pos = 7 for(var/additional_hud in additional_hud_elements) - var/obj/screen/exosuit/M = new additional_hud(src) + var/obj/screen/exosuit/M = new additional_hud(null, src) M.screen_loc = "LEFT:6,BOTTOM+[pos]:[i]" hud_elements |= M i -= M.height - hud_health = new /obj/screen/exosuit/health(src) + hud_health = new /obj/screen/exosuit/health(null, src) hud_health.screen_loc = "RIGHT-1:28,CENTER-3:11" hud_elements |= hud_health hud_open = locate(/obj/screen/exosuit/toggle/hatch_open) in hud_elements - hud_power = new /obj/screen/exosuit/power(src) + hud_power = new /obj/screen/exosuit/power(null, src) hud_power.screen_loc = "RIGHT-1:28,CENTER-4:25" hud_elements |= hud_power hud_power_control = locate(/obj/screen/exosuit/toggle/power_control) in hud_elements hud_camera = locate(/obj/screen/exosuit/toggle/camera) in hud_elements - hud_heat = new /obj/screen/exosuit/heat(src) + hud_heat = new /obj/screen/exosuit/heat(null, src) hud_heat.screen_loc = "RIGHT-1:28,CENTER-4" hud_elements |= hud_heat diff --git a/mods/species/ascent/mobs/nymph/nymph_ui.dm b/mods/species/ascent/mobs/nymph/nymph_ui.dm index 6cb09324a2ee..340c18817cf2 100644 --- a/mods/species/ascent/mobs/nymph/nymph_ui.dm +++ b/mods/species/ascent/mobs/nymph/nymph_ui.dm @@ -61,4 +61,4 @@ /obj/screen/ascent_nymph_health name = "health" - name = screen_loc = ANYMPH_SCREEN_LOC_HEALTH + screen_loc = ANYMPH_SCREEN_LOC_HEALTH diff --git a/nebula.dme b/nebula.dme index cd313c4a6207..ba498a35eefa 100644 --- a/nebula.dme +++ b/nebula.dme @@ -210,6 +210,7 @@ #include "code\_onclick\hud\screen\screen_setup.dm" #include "code\_onclick\hud\screen\screen_stamina.dm" #include "code\_onclick\hud\screen\screen_storage.dm" +#include "code\_onclick\hud\screen\screen_swaphands.dm" #include "code\_onclick\hud\screen\screen_throw.dm" #include "code\_onclick\hud\screen\screen_toggle.dm" #include "code\_onclick\hud\screen\screen_up_hint.dm"