From 0764cac389b700bbeac0df812eacfbffd8e33490 Mon Sep 17 00:00:00 2001 From: supersayu Date: Wed, 16 Oct 2013 01:33:41 -0400 Subject: [PATCH] Mecha HUD hiding Hides the user's inventory (as per F12) when they enter a mecha, since it is essentially unusable. Pressing F12 will reveal it, as will exiting the mecha. If your inventory is hidden before you enter the mech, it will remain hidden when you leave. --- code/_onclick/hud/hud.dm | 94 ++++++++++++++++++++++++---------------- code/game/mecha/mecha.dm | 8 ++++ 2 files changed, 64 insertions(+), 38 deletions(-) diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index c494298cb85..bc29d328761 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -186,52 +186,70 @@ datum/hud/New(mob/owner) else if(isovermind(mymob)) blob_hud() + if(istype(mymob.loc,/obj/mecha)) + hide_hud() + + +/datum/hud/proc/hide_hud() // hide hands is not currently used by anything but could be + if(!ismob(mymob)) + return 0 + if(!mymob.client) + return 0 + if(hud_shown) + hud_shown = 0 + if(adding) + mymob.client.screen -= adding + if(other) + mymob.client.screen -= other + if(hotkeybuttons) + mymob.client.screen -= hotkeybuttons + if(item_action_list) + mymob.client.screen -= item_action_list + + //These ones are not a part of 'adding', 'other' or 'hotkeybuttons' but we want them gone. + mymob.client.screen -= mymob.zone_sel //zone_sel is a mob variable for some reason. + + //These ones are a part of 'adding', 'other' or 'hotkeybuttons' but we want them to stay + mymob.client.screen += l_hand_hud_object //we want the hands to be visible + mymob.client.screen += r_hand_hud_object //we want the hands to be visible + mymob.client.screen += action_intent //we want the intent swticher visible + action_intent.screen_loc = ui_acti_alt //move this to the alternative position, where zone_select usually is. + + hidden_inventory_update() + persistant_inventory_update() + mymob.update_action_buttons() + +/datum/hud/proc/show_hud() + if(!ismob(mymob)) + return 0 + if(!mymob.client) + return 0 + if(!hud_shown) + hud_shown = 1 + if(adding) + mymob.client.screen += adding + if(other && inventory_shown) + mymob.client.screen += other + if(hotkeybuttons && !hotkey_ui_hidden) + mymob.client.screen += hotkeybuttons + + action_intent.screen_loc = ui_acti //Restore intent selection to the original position + mymob.client.screen += mymob.zone_sel //This one is a special snowflake + hidden_inventory_update() + persistant_inventory_update() + mymob.update_action_buttons() + //Triggered when F12 is pressed (Unless someone changed something in the DMF) /mob/verb/button_pressed_F12() set name = "F12" set hidden = 1 - if(hud_used) + if(hud_used && client) if(ishuman(src)) - if(!src.client) return - if(hud_used.hud_shown) - hud_used.hud_shown = 0 - if(src.hud_used.adding) - src.client.screen -= src.hud_used.adding - if(src.hud_used.other) - src.client.screen -= src.hud_used.other - if(src.hud_used.hotkeybuttons) - src.client.screen -= src.hud_used.hotkeybuttons - if(src.hud_used.item_action_list) - src.client.screen -= src.hud_used.item_action_list - - //Due to some poor coding some things need special treatment: - //These ones are a part of 'adding', 'other' or 'hotkeybuttons' but we want them to stay - src.client.screen += src.hud_used.l_hand_hud_object //we want the hands to be visible - src.client.screen += src.hud_used.r_hand_hud_object //we want the hands to be visible - src.client.screen += src.hud_used.action_intent //we want the intent swticher visible - src.hud_used.action_intent.screen_loc = ui_acti_alt //move this to the alternative position, where zone_select usually is. - - //These ones are not a part of 'adding', 'other' or 'hotkeybuttons' but we want them gone. - src.client.screen -= src.zone_sel //zone_sel is a mob variable for some reason. - + hud_used.hide_hud() else - hud_used.hud_shown = 1 - if(src.hud_used.adding) - src.client.screen += src.hud_used.adding - if(src.hud_used.other && src.hud_used.inventory_shown) - src.client.screen += src.hud_used.other - if(src.hud_used.hotkeybuttons && !src.hud_used.hotkey_ui_hidden) - src.client.screen += src.hud_used.hotkeybuttons - - - src.hud_used.action_intent.screen_loc = ui_acti //Restore intent selection to the original position - src.client.screen += src.zone_sel //This one is a special snowflake - - hud_used.hidden_inventory_update() - hud_used.persistant_inventory_update() - update_action_buttons() + hud_used.show_hud() else usr << "\red Inventory hiding is currently only supported for human mobs, sorry." else diff --git a/code/game/mecha/mecha.dm b/code/game/mecha/mecha.dm index 83b21f8694a..d52e9d4f13e 100644 --- a/code/game/mecha/mecha.dm +++ b/code/game/mecha/mecha.dm @@ -38,6 +38,7 @@ var/datum/effect/effect/system/spark_spread/spark_system = new var/lights = 0 var/lights_power = 6 + var/last_user_hud = 1 // used to show/hide the mecha hud while preserving previous preference //inner atmos var/use_internal_tank = 0 @@ -1000,6 +1001,10 @@ */ H.stop_pulling() H.forceMove(src) + if(H.hud_used) + last_user_hud = H.hud_used.hud_shown + H.hud_used.hide_hud() + src.occupant = H src.add_fingerprint(H) src.forceMove(src.loc) @@ -1145,6 +1150,9 @@ src.occupant.client.perspective = MOB_PERSPECTIVE */ src.occupant << browse(null, "window=exosuit") + if(src.occupant.hud_used && src.last_user_hud) + src.occupant.hud_used.show_hud() + if(istype(mob_container, /obj/item/device/mmi)) var/obj/item/device/mmi/mmi = mob_container if(mmi.brainmob)