Add mini HUDs to mechs, rigs

This commit is contained in:
Aronai Sieyes
2020-05-15 17:14:29 -04:00
parent 51c38f8555
commit cb36e93a30
7 changed files with 325 additions and 0 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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
*/

View File

@@ -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))

View File

@@ -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, "<span class='notice'><b>Your entire suit [canremove ? "loosens as the components relax" : "tightens around you as the components lock into place"].</b></span>")
M.client.screen -= booting_L
qdel(booting_L)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

@@ -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"