Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIRROR] Ports mecha maptext and heat gauge from baystation #294

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions code/modules/mechs/interface/_interface.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@
var/pos = 7
for(var/additional_hud in additional_hud_elements)
var/obj/screen/exosuit/M = new additional_hud(src)
M.screen_loc = "LEFT+1:6,BOTTOM+[pos]:[i * -12]"
M.screen_loc = "LEFT+1:6,BOTTOM+[pos]:[i]"
hud_elements |= M
i++
if(i == 3)
pos--
i = 0
i -= M.height

hud_health = new /obj/screen/exosuit/health(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.screen_loc = "RIGHT-1:12,CENTER-4:25"
hud_power.screen_loc = "RIGHT-1:24,CENTER-4:25"
hud_elements |= hud_power
hud_heat = new /obj/screen/exosuit/heat(src)
hud_heat.screen_loc = "RIGHT-1:28,CENTER-4"
hud_elements |= hud_heat

refresh_hud()

Expand Down
132 changes: 118 additions & 14 deletions code/modules/mechs/interface/screen_objects.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Screen objects hereon out.
#define MECH_UI_STYLE(X) "<span style=\"font-family: 'Small Fonts'; -dm-text-outline: 1 black; font-size: 5px;\">" + X + "</span>"

/obj/screen/exosuit
name = "hardpoint"
icon = 'icons/mecha/mech_hud.dmi'
icon_state = "hardpoint"
icon_state = "base"
var/mob/living/exosuit/owner
var/height = 14

/obj/screen/exosuit/radio
name = "radio"
icon_state = "radio"
maptext = MECH_UI_STYLE("RADIO")
maptext_x = 5
maptext_y = 12

/obj/screen/exosuit/radio/Click()
if(..())
Expand All @@ -30,6 +35,7 @@
name = "hardpoint"
var/hardpoint_tag
var/obj/item/holding
icon_state = "hardpoint"

maptext_x = 34
maptext_y = 3
Expand Down Expand Up @@ -126,7 +132,7 @@
if(!(..()))
return

if(!owner.hatch_closed)
if(!owner?.hatch_closed)
to_chat(usr, SPAN_WARNING("Error: Hardpoint interface disabled while [owner.body.hatch_descriptor] is open."))
return

Expand All @@ -150,15 +156,19 @@

/obj/screen/exosuit/eject
name = "eject"
icon_state = "eject"
maptext = MECH_UI_STYLE("EJECT")
maptext_x = 5
maptext_y = 12

/obj/screen/exosuit/eject/Click()
if(..())
owner.eject(usr)

/obj/screen/exosuit/rename
name = "rename"
icon_state = "rename"
maptext = MECH_UI_STYLE("RENAME")
maptext_x = 1
maptext_y = 12

/obj/screen/exosuit/power
name = "power"
Expand All @@ -172,43 +182,64 @@

/obj/screen/exosuit/toggle
name = "toggle"
var/toggled
var/toggled = FALSE

/obj/screen/exosuit/toggle/Initialize()
. = ..()
queue_icon_update()

/obj/screen/exosuit/toggle/on_update_icon()
. = ..()
icon_state = "[initial(icon_state)][toggled ? "_enabled" : ""]"
maptext = FONT_COLORED(toggled ? COLOR_WHITE : COLOR_GRAY,initial(maptext))

/obj/screen/exosuit/toggle/Click()
if(..()) toggled()

/obj/screen/exosuit/toggle/proc/toggled()
toggled = !toggled
icon_state = "[initial(icon_state)][toggled ? "_enabled" : ""]"
queue_icon_update()
return toggled

/obj/screen/exosuit/toggle/air
name = "air"
icon_state = "air"
icon_state = "small_important"
maptext = MECH_UI_STYLE("AIR")
maptext_x = 9
maptext_y = 13
height = 12

/obj/screen/exosuit/toggle/air/toggled()
owner.use_air = ..()
to_chat(usr, SPAN_NOTICE("Auxiliary atmospheric system [owner.use_air ? "enabled" : "disabled"]."))

/obj/screen/exosuit/toggle/maint
name = "toggle maintenance protocol"
icon_state = "maint"
icon_state = "small"
maptext = MECH_UI_STYLE("MAINT")
maptext_x = 5
maptext_y = 13
height = 12

/obj/screen/exosuit/toggle/maint/toggled()
owner.maintenance_protocols = ..()
to_chat(usr, SPAN_NOTICE("Maintenance protocols [owner.maintenance_protocols ? "enabled" : "disabled"]."))

/obj/screen/exosuit/toggle/hardpoint
name = "toggle hardpoint lock"
icon_state = "hardpoint_lock"
maptext = MECH_UI_STYLE("GEAR")
maptext_x = 5
maptext_y = 12

/obj/screen/exosuit/toggle/hardpoint/toggled()
owner.hardpoints_locked = ..()
to_chat(usr, SPAN_NOTICE("Hardpoint system access is now [owner.hardpoints_locked ? "disabled" : "enabled"]."))

/obj/screen/exosuit/toggle/hatch
name = "toggle hatch lock"
icon_state = "hatch_lock"
maptext = MECH_UI_STYLE("LOCK")
maptext_x = 5
maptext_y = 12

/obj/screen/exosuit/toggle/hatch/toggled()
if(!owner.hatch_locked && !owner.hatch_closed)
Expand All @@ -219,16 +250,29 @@

/obj/screen/exosuit/toggle/hatch_open
name = "open or close hatch"
icon_state = "hatch_status"
maptext = MECH_UI_STYLE("CLOSE")
maptext_x = 4
maptext_y = 12

/obj/screen/exosuit/toggle/hatch_open/toggled()
if (!owner)
return
if(owner.hatch_locked && owner.hatch_closed)
to_chat(usr, SPAN_WARNING("You cannot open the hatch while it is locked."))
return
owner.hatch_closed = ..()
to_chat(usr, SPAN_NOTICE("The [owner.body.hatch_descriptor] is now [owner.hatch_closed ? "closed" : "open" ]."))
owner.update_icon()

/obj/screen/exosuit/toggle/hatch_open/on_update_icon()
. = ..()
if(owner.hatch_closed)
maptext = MECH_UI_STYLE("OPEN")
maptext_x = 5
else
maptext = MECH_UI_STYLE("CLOSE")
maptext_x = 4

// This is basically just a holder for the updates the exosuit does.
/obj/screen/exosuit/health
name = "exosuit integrity"
Expand All @@ -245,7 +289,11 @@
//Controls if cameras set the vision flags
/obj/screen/exosuit/toggle/camera
name = "toggle camera matrix"
icon_state = "camera"
icon_state = "small_important"
maptext = MECH_UI_STYLE("SENSOR")
maptext_x = 1
maptext_y = 13
height = 12

/obj/screen/exosuit/toggle/camera/toggled()
if(!owner.head)
Expand All @@ -257,5 +305,61 @@
owner.head.active_sensors = ..()
to_chat(usr, SPAN_NOTICE("[owner.head.name] advanced sensor mode is [owner.head.active_sensors ? "now" : "no longer" ] active."))

/obj/screen/exosuit/needle
#if DM_VERSION >= 513
vis_flags = VIS_INHERIT_ID
#endif
icon_state = "heatprobe_needle"

/obj/screen/exosuit/heat
name = "heat probe"
icon_state = "heatprobe"
var/celsius = TRUE
var/obj/screen/exosuit/needle/gauge_needle = null
desc = "TEST"

/obj/screen/exosuit/heat/Initialize()
. = ..()
gauge_needle = new /obj/screen/exosuit/needle(owner)
vis_contents += gauge_needle

/obj/screen/exosuit/heat/Destroy()
QDEL_NULL(gauge_needle)
. = ..()

#undef BAR_CAP
/obj/screen/exosuit/heat/Click(location, control, params)
if(..())
var/modifiers = params2list(params)
if(modifiers["shift"])
if(owner && owner.material)
usr.show_message(SPAN_NOTICE("Your suit's safe operating limit ceiling is [(celsius ? "[owner.material.melting_point - T0C] °C" : "[owner.material.melting_point] K" )]."), VISIBLE_MESSAGE)
return
if(modifiers["ctrl"])
celsius = !celsius
usr.show_message(SPAN_NOTICE("You switch the chassis probe display to use [celsius ? "celsius" : "kelvin"]."), VISIBLE_MESSAGE)
return
if(owner && owner.body && owner.body.diagnostics?.is_functional() && owner.loc)
usr.show_message(SPAN_NOTICE("The life support panel blinks several times as it updates:"), VISIBLE_MESSAGE)

usr.show_message(SPAN_NOTICE("Chassis heat probe reports temperature of [(celsius ? "[owner.bodytemperature - T0C] °C" : "[owner.bodytemperature] K" )]."), VISIBLE_MESSAGE)
if(owner.material.melting_point < owner.bodytemperature)
usr.show_message(SPAN_WARNING("Warning: Current chassis temperature exceeds operating parameters."), VISIBLE_MESSAGE)
var/air_contents = owner.loc.return_air()
if(!air_contents)
usr.show_message(SPAN_WARNING("The external air probe isn't reporting any data!"), VISIBLE_MESSAGE)
else
usr.show_message(SPAN_NOTICE("External probes report: [jointext(atmosanalyzer_scan(owner.loc, air_contents), "<br>")]"), VISIBLE_MESSAGE)
else
usr.show_message(SPAN_WARNING("The life support panel isn't responding."), VISIBLE_MESSAGE)

/obj/screen/exosuit/heat/proc/Update()
//Relative value of heat
if(owner && owner.body && owner.body.diagnostics?.is_functional() && gauge_needle)
var/value = clamp( owner.bodytemperature / (owner.material.melting_point * 1.55), 0, 1)
var/matrix/rot_matrix = matrix()
rot_matrix.Turn(Interpolate(-90, 90, value))
rot_matrix.Translate(0, -2)
animate(gauge_needle, transform = rot_matrix, 0.1, easing = SINE_EASING)

#undef BAR_CAP
#undef MECH_UI_STYLE
1 change: 1 addition & 0 deletions code/modules/mechs/mech.dm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
var/obj/screen/exosuit/health/hud_health
var/obj/screen/exosuit/toggle/hatch_open/hud_open
var/obj/screen/exosuit/power/hud_power
var/obj/screen/exosuit/heat/hud_heat

/mob/living/exosuit/is_flooded(lying_mob, absolute)
. = (body && body.pilot_coverage >= 100 && hatch_closed) ? FALSE : ..()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mechs/mech_life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
if(prob(5))
visible_message(SPAN_DANGER("\The [src]'s hull bends and buckles under the intense heat!"))

hud_heat.Update()

/mob/living/exosuit/death(var/gibbed)
// Eject the pilot.
Expand Down
Binary file modified icons/mecha/mech_hud.dmi
Binary file not shown.