From cb36e93a307834d69d1d676d218a08e159cc6f4d Mon Sep 17 00:00:00 2001 From: Aronai Sieyes Date: Fri, 15 May 2020 17:14:29 -0400 Subject: [PATCH] Add mini HUDs to mechs, rigs --- code/_onclick/hud/_defines.dm | 20 ++ code/_onclick/hud/hud.dm | 24 ++ code/_onclick/hud/rigmech.dm | 267 ++++++++++++++++++++ code/game/mecha/mecha.dm | 6 + code/modules/clothing/spacesuits/rig/rig.dm | 7 + icons/mob/screen_rigmech.dmi | Bin 0 -> 2955 bytes vorestation.dme | 1 + 7 files changed, 325 insertions(+) create mode 100644 code/_onclick/hud/rigmech.dm create mode 100644 icons/mob/screen_rigmech.dmi diff --git a/code/_onclick/hud/_defines.dm b/code/_onclick/hud/_defines.dm index 518cc78b91..978f2d782d 100644 --- a/code/_onclick/hud/_defines.dm +++ b/code/_onclick/hud/_defines.dm @@ -159,3 +159,23 @@ #define ui_ghost_teleport "SOUTH:6,CENTER+1:24" #define ui_ghost_pai "SOUTH: 6,CENTER+2:24" #define ui_ghost_updown "SOUTH: 6,CENTER+3:24" + +// Rig panel +#define ui_rig_deco1 "WEST:-7, SOUTH+5" +#define ui_rig_deco2 "WEST:-7, SOUTH+6" +#define ui_rig_pwr "WEST+1:-7, SOUTH+6" +#define ui_rig_health "WEST+1:-7, SOUTH+6" +#define ui_rig_air "WEST+1:-7, SOUTH+5" +#define ui_rig_airtoggle "WEST+1:-7, SOUTH+5" +#define ui_rig_deco1_f "WEST+2:-7, SOUTH+5" +#define ui_rig_deco2_f "WEST+2:-7, SOUTH+6" + +// Mech panel +#define ui_mech_deco1 "WEST:-7, SOUTH+8" +#define ui_mech_deco2 "WEST:-7, SOUTH+9" +#define ui_mech_pwr "WEST+1:-7, SOUTH+9" +#define ui_mech_health "WEST+1:-7, SOUTH+9" +#define ui_mech_air "WEST+1:-7, SOUTH+8" +#define ui_mech_airtoggle "WEST+1:-7, SOUTH+8" +#define ui_mech_deco1_f "WEST+2:-7, SOUTH+8" +#define ui_mech_deco2_f "WEST+2:-7, SOUTH+9" diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index c4dabaf3ca..c8e2f5f988 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -184,6 +184,7 @@ var/list/global_huds = list( var/list/adding var/list/other + var/list/miniobjs var/list/obj/screen/hotkeybuttons var/obj/screen/movable/action_button/hide_toggle/hide_actions_toggle @@ -193,6 +194,8 @@ var/list/global_huds = list( var/icon/ui_style var/ui_color var/ui_alpha + + var/list/minihuds = list() datum/hud/New(mob/owner) mymob = owner @@ -219,6 +222,7 @@ datum/hud/New(mob/owner) hotkeybuttons = null // item_action_list = null // ? mymob = null + qdel_null(minihuds) /datum/hud/proc/hidden_inventory_update() if(!mymob) return @@ -325,6 +329,26 @@ datum/hud/New(mob/owner) HUD.ui_color = client?.prefs?.UI_style_color HUD.ui_alpha = client?.prefs?.UI_style_alpha +/datum/hud/proc/apply_minihud(var/datum/mini_hud/MH) + if(MH in minihuds) + return + minihuds += MH + if(mymob.client) + mymob.client.screen -= miniobjs + miniobjs += MH.get_screen_objs() + if(mymob.client) + mymob.client.screen += miniobjs + +/datum/hud/proc/remove_minihud(var/datum/mini_hud/MH) + if(!(MH in minihuds)) + return + minihuds -= MH + if(mymob.client) + mymob.client.screen -= miniobjs + miniobjs -= MH.get_screen_objs() + if(mymob.client) + mymob.client.screen += miniobjs + //Triggered when F12 is pressed (Unless someone changed something in the DMF) /mob/verb/button_pressed_F12(var/full = 0 as null) set name = "F12" diff --git a/code/_onclick/hud/rigmech.dm b/code/_onclick/hud/rigmech.dm new file mode 100644 index 0000000000..91632e1604 --- /dev/null +++ b/code/_onclick/hud/rigmech.dm @@ -0,0 +1,267 @@ +/datum/mini_hud + var/datum/hud/main_hud + var/list/screenobjs = list() + var/list/types_to_instantiate + var/needs_processing = FALSE + +/datum/mini_hud/New(var/datum/hud/other) + apply_to_hud(other) + if(needs_processing) + START_PROCESSING(SSprocessing, src) + +/datum/mini_hud/Destroy() + main_hud?.remove_minihud(src) + main_hud = null + if(needs_processing) + STOP_PROCESSING(SSprocessing, src) + return ..() + +// Apply to a real /datum/hud +/datum/mini_hud/proc/apply_to_hud(var/datum/hud/other) + if(main_hud) + unapply_to_hud(main_hud) + main_hud = other + main_hud.apply_minihud(src) + +// Remove from a real /datum/hud +/datum/mini_hud/proc/unapply_to_hud(var/datum/hud/other) + main_hud.remove_minihud(src) + +// Update the hud +/datum/mini_hud/process() + return PROCESS_KILL // You shouldn't be here! + +// Return a list of screen objects we use +/datum/mini_hud/proc/get_screen_objs(var/mob/M) + return screenobjs + +// Specific types +/datum/mini_hud/rig + var/obj/item/weapon/rig/owner_rig + var/obj/screen/rig/power/power + var/obj/screen/rig/health/health + var/obj/screen/rig/air/air + var/obj/screen/rig/airtoggle/airtoggle + + needs_processing = TRUE + +/datum/mini_hud/rig/New(var/datum/hud/other, var/obj/item/weapon/rig/owner) + owner_rig = owner + power = new () + health = new () + air = new () + airtoggle = new () + + screenobjs = list(power, health, air, airtoggle) + screenobjs += new /obj/screen/rig/deco1 + screenobjs += new /obj/screen/rig/deco2 + screenobjs += new /obj/screen/rig/deco1_f + screenobjs += new /obj/screen/rig/deco2_f + + for(var/scr in screenobjs) + var/obj/screen/S = scr + S.master = owner_rig + ..() + +/datum/mini_hud/rig/Destroy() + if(owner_rig) + //owner_rig.minihud = null + owner_rig = null + return ..() + +/datum/mini_hud/rig/process() + if(!owner_rig) + qdel(src) + return + + var/obj/item/weapon/cell/rigcell = owner_rig.cell + var/obj/item/weapon/tank/rigtank = owner_rig.air_supply + + var/charge_percentage = rigcell ? rigcell.charge / rigcell.maxcharge : 0 + var/air_percentage = rigtank ? CLAMP(rigtank.air_contents.total_moles / 17.4693, 0, 1) : 0 + var/air_on = owner_rig.wearer?.internal ? 1 : 0 + + power.icon_state = "pwr[round(charge_percentage / 0.2, 1)]" + air.icon_state = "air[round(air_percentage / 0.2, 1)]" + health.icon_state = owner_rig.malfunctioning ? "health1" : "health5" + airtoggle.icon_state = "airon[air_on]" + +/datum/mini_hud/mech + var/obj/mecha/owner_mech + var/obj/screen/mech/power/power + var/obj/screen/mech/health/health + var/obj/screen/mech/air/air + var/obj/screen/mech/airtoggle/airtoggle + + needs_processing = TRUE + +/datum/mini_hud/mech/New(var/datum/hud/other, var/obj/mecha/owner) + owner_mech = owner + power = new () + health = new () + air = new () + airtoggle = new () + + screenobjs = list(power, health, air, airtoggle) + screenobjs += new /obj/screen/mech/deco1 + screenobjs += new /obj/screen/mech/deco2 + screenobjs += new /obj/screen/mech/deco1_f + screenobjs += new /obj/screen/mech/deco2_f + + for(var/scr in screenobjs) + var/obj/screen/S = scr + S.master = owner_mech + ..() + +/datum/mini_hud/mech/Destroy() + if(owner_mech) + owner_mech.minihud = null + owner_mech = null + return ..() + +/datum/mini_hud/mech/process() + if(!owner_mech) + qdel(src) + return + + var/obj/item/weapon/cell/mechcell = owner_mech.cell + var/obj/machinery/portable_atmospherics/canister/mechtank = owner_mech.internal_tank + + var/charge_percentage = mechcell ? mechcell.charge / mechcell.maxcharge : 0 + var/air_percentage = mechtank ? CLAMP(mechtank.air_contents.total_moles / 1863.47, 0, 1) : 0 + var/health_percentage = owner_mech.health / owner_mech.maxhealth + var/air_on = owner_mech.use_internal_tank + + power.icon_state = "pwr[round(charge_percentage / 0.2, 1)]" + air.icon_state = "air[round(air_percentage / 0.2, 1)]" + health.icon_state = "health[round(health_percentage / 0.2, 1)]" + airtoggle.icon_state = "airon[air_on]" + +// Screen objects +/obj/screen/rig + icon = 'icons/mob/screen_rigmech.dmi' + +/obj/screen/rig/deco1 + name = "RIG Status" + icon_state = "frame1_1" + screen_loc = ui_rig_deco1 + +/obj/screen/rig/deco2 + name = "RIG Status" + icon_state = "frame1_2" + screen_loc = ui_rig_deco2 + +/obj/screen/rig/deco1_f + name = "RIG Status" + icon_state = "frame1_1_far" + screen_loc = ui_rig_deco1_f + +/obj/screen/rig/deco2_f + name = "RIG Status" + icon_state = "frame1_2_far" + screen_loc = ui_rig_deco2_f + +/obj/screen/rig/power + name = "Charge Level" + icon_state = "pwr5" + screen_loc = ui_rig_pwr + +/obj/screen/rig/health + name = "Integrity Level" + icon_state = "health5" + screen_loc = ui_rig_health + +/obj/screen/rig/air + name = "Air Storage" + icon_state = "air5" + screen_loc = ui_rig_air + +/obj/screen/rig/airtoggle + name = "Toggle Air" + icon_state = "airoff" + screen_loc = ui_rig_airtoggle + +/obj/screen/rig/airtoggle/Click() + var/mob/living/carbon/human/user = usr + if(!istype(user) || user.stat || user.incapacitated()) + return + var/obj/item/weapon/rig/owner_rig = master + if(user != owner_rig.wearer) + return + user.toggle_internals() + +/obj/screen/mech + icon = 'icons/mob/screen_rigmech.dmi' + +/obj/screen/mech/deco1 + name = "Mech Status" + icon_state = "frame1_1" + screen_loc = ui_mech_deco1 + +/obj/screen/mech/deco2 + name = "Mech Status" + icon_state = "frame1_2" + screen_loc = ui_mech_deco2 + +/obj/screen/mech/deco1_f + name = "Mech Status" + icon_state = "frame1_1_far" + screen_loc = ui_mech_deco1_f + +/obj/screen/mech/deco2_f + name = "Mech Status" + icon_state = "frame1_2_far" + screen_loc = ui_mech_deco2_f + +/obj/screen/mech/power + name = "Charge Level" + icon_state = "pwr5" + screen_loc = ui_mech_pwr + +/obj/screen/mech/health + name = "Integrity Level" + icon_state = "health5" + screen_loc = ui_mech_health + +/obj/screen/mech/air + name = "Air Storage" + icon_state = "air5" + screen_loc = ui_mech_air + +/obj/screen/mech/airtoggle + name = "Toggle Air" + icon_state = "airoff" + screen_loc = ui_mech_airtoggle + +/obj/screen/mech/airtoggle/Click() + var/mob/living/carbon/human/user = usr + if(!istype(user) || user.stat || user.incapacitated()) + return + var/obj/mecha/owner_mech = master + if(user != owner_mech.occupant) + return + owner_mech.toggle_internal_tank() + +/* +/mob/observer/dead/create_mob_hud(datum/hud/HUD, apply_to_client = TRUE) + ..() + + var/list/adding = list() + HUD.adding = adding + + var/obj/screen/using + using = new /obj/screen/ghost/jumptomob() + using.screen_loc = ui_ghost_jumptomob + using.hud = src + adding += using + + using = new /obj/screen/ghost/orbit() + using.screen_loc = ui_ghost_orbit + using.hud = src + adding += using + + using = new /obj/screen/ghost/reenter_corpse() + using.screen_loc = ui_ghost_reenter_corpse + using.hud = src + adding += using +*/ \ No newline at end of file diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 990a99bc05..594c89a4ee 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -100,6 +100,8 @@ var/static/image/radial_image_lighttoggle = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_light") var/static/image/radial_image_statpanel = image(icon = 'icons/mob/radial.dmi', icon_state = "radial_examine2") + var/datum/mini_hud/mech/minihud + /obj/mecha/drain_power(var/drain_check) @@ -195,6 +197,7 @@ QDEL_NULL(pr_give_air) QDEL_NULL(pr_internal_damage) QDEL_NULL(spark_system) + QDEL_NULL(minihud) mechas_list -= src //global mech list . = ..() @@ -1321,6 +1324,8 @@ src.verbs += /obj/mecha/verb/eject src.log_append_to_last("[H] moved in as pilot.") src.icon_state = src.reset_icon() + if(occupant.hud_used) + minihud = new (occupant.hud_used, src) update_cell_alerts() update_damage_alerts() set_dir(dir_in) @@ -1386,6 +1391,7 @@ /obj/mecha/proc/go_out() if(!src.occupant) return var/atom/movable/mob_container + QDEL_NULL(minihud) if(ishuman(occupant)) mob_container = src.occupant else if(istype(occupant, /mob/living/carbon/brain)) diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index 392ec65ad8..1afd78dee0 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -93,6 +93,7 @@ // Wiring! How exciting. var/datum/wires/rig/wires var/datum/effect/effect/system/spark_spread/spark_system + var/datum/mini_hud/rig/minihud /obj/item/weapon/rig/examine() . = ..() @@ -188,6 +189,7 @@ START_PROCESSING(SSobj, src) else STOP_PROCESSING(SSobj, src) + QDEL_NULL(minihud) // Just in case we get removed some other way // If we've lost any parts, grab them back. var/mob/living/M @@ -363,6 +365,11 @@ // Success! canremove = seal_target + if(M.hud_used) + if(canremove) + QDEL_NULL(minihud) + else + minihud = new (M.hud_used, src) to_chat(M, "Your entire suit [canremove ? "loosens as the components relax" : "tightens around you as the components lock into place"].") M.client.screen -= booting_L qdel(booting_L) diff --git a/icons/mob/screen_rigmech.dmi b/icons/mob/screen_rigmech.dmi new file mode 100644 index 0000000000000000000000000000000000000000..65e2b3184dfae4f2c37583d357c994506b840cf6 GIT binary patch literal 2955 zcma)8c{o&U8-K8p^VTM*?nIYfleXsBP`@61l&V8=?exCdM?%(~~zw4yf+geJ9Dv1IBB=A-^ z2gtTVH(6K+db;eo;076bw4-wv?&6gTp}xUkzCnQiMCE3aPKYMyNn>fRcMCD@eyr{D zPjxsuC-2ohF7B+Y?-i-s{pIdo?VM?d|C|orCi4aY_u%r8U+W|6q zute`cP0!lk$01*PX@*lwYRTMd9WpxmJSA%6SKD<_$*e2nGYorQ%KN+T=c0l$!PRHpdA|E_ma16FARRuTC*;~9Kqe<+==LgQaa z48mQpzX!`U8++^Go)uMO!86oRkVs zNY#H#+ae~QeOb<7?#;u%o4a%Tq{g%|EDp@vAMU@(T#b!8w?BUyC*;mwthK4HgZzt+ zNB0Pm-Uu>YfbE8_*V&l+7`9A&-AWjXy(C}F8@b17nEz^A`K3R$#%}ZG;Yy<`Kb5$Z zJnr9&8NSj|kV|@nU92|m&%TsJMEB;W;B+3gxTl)rlE+plc1%c=<#Y&r|VCyz|RB%M_1|W+MM*jDa9Q#v`QpE`nMXcb@0YAmeeZ z3efuk&lW}zh#j_zWotc-KO>2LDO92B#GDfI>bALhkvN0Km7?x?E)}E8xaYxQ<+Zc222=_sNE@ziVOXsAMo4PUGm$fathjy z6PrXqc>asgeWGON%hCD0@5j`S(qmeSUE_H_p8c`W<};etGRU2e|Lz^`6X;$X*U(yQ z3|i;hGqACRyhjK?jyD$I3bG%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2RNcG$<`iT}E~8cy$oSlAs**wysL(WVrVpBa*A0sNq{%{k94vTGq1 ze7f$;=}*B3!FYsz~s<39FAA;G#<$Kvw#um_X{gH7tlY{|pX3+&O3T_ztc+bijQJoLDO^rY}3A z+J1ce3x0OTW7DPLWT|g2NTxw5(-UJ-tK5^av>N7|W;@>T#!epoIvjM;_SPLP{S~oN vdp~k&vmOo#V!s7?x19Y_o{u`V9=eL5-*;7|J0{|wziWUux5d?%o=f}>5!Qy6 literal 0 HcmV?d00001 diff --git a/vorestation.dme b/vorestation.dme index e0b3619c97..ec7a416f87 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -161,6 +161,7 @@ #include "code\_onclick\hud\picture_in_picture.dm" #include "code\_onclick\hud\radial.dm" #include "code\_onclick\hud\radial_persistent.dm" +#include "code\_onclick\hud\rigmech.dm" #include "code\_onclick\hud\robot.dm" #include "code\_onclick\hud\robot_vr.dm" #include "code\_onclick\hud\screen_objects.dm"