mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-26 21:48:21 +01:00
Generic Action\Action Button System
This commit ports the GAABS from -tg-station13. The GAABS allows for generic, movable, hud elements for spells, powers, and items.
This commit is contained in:
@@ -37,7 +37,7 @@ var/list/image/ghost_darkness_images = list() //this is a list of images for thi
|
||||
verbs += /mob/dead/observer/proc/dead_tele
|
||||
|
||||
// Our new boo spell.
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/aoe_turf/boo(src)
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/aoe_turf/boo(src))
|
||||
|
||||
can_reenter_corpse = flags & GHOST_CAN_REENTER
|
||||
started_as_observer = flags & GHOST_IS_OBSERVER
|
||||
|
||||
@@ -58,6 +58,9 @@
|
||||
|
||||
//Status updates, death etc.
|
||||
handle_regular_status_updates()
|
||||
|
||||
handle_actions()
|
||||
|
||||
update_canmove()
|
||||
update_icons()
|
||||
|
||||
|
||||
@@ -197,8 +197,6 @@
|
||||
update_inv_l_hand()
|
||||
|
||||
|
||||
update_action_buttons()
|
||||
|
||||
|
||||
|
||||
//This is an UNSAFE proc. Use mob_can_equip() before calling this one! Or rather use equip_to_slot_if_possible() or advanced_equip_to_slot_if_possible()
|
||||
|
||||
@@ -138,6 +138,9 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
|
||||
|
||||
//Status updates, death etc.
|
||||
handle_regular_status_updates() //Optimized a bit
|
||||
|
||||
handle_actions()
|
||||
|
||||
update_canmove()
|
||||
|
||||
//Update our name based on whether our face is obscured/disfigured
|
||||
@@ -1044,20 +1047,19 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
|
||||
if(hud_updateflag)
|
||||
handle_hud_list()
|
||||
|
||||
|
||||
if(!client) return 0
|
||||
|
||||
if(hud_updateflag)
|
||||
handle_hud_list()
|
||||
|
||||
update_action_buttons()
|
||||
|
||||
for(var/image/hud in client.images)
|
||||
if(copytext(hud.icon_state,1,4) == "hud") //ugly, but icon comparison is worse, I believe
|
||||
client.images.Remove(hud)
|
||||
|
||||
client.screen.Remove(global_hud.blurry, global_hud.druggy, global_hud.vimpaired, global_hud.darkMask,/* global_hud.nvg*/)
|
||||
|
||||
update_action_buttons()
|
||||
|
||||
if(damageoverlay.overlays)
|
||||
damageoverlay.overlays = list()
|
||||
|
||||
@@ -1796,7 +1798,6 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
|
||||
holder.icon_state = "hudscientopia"
|
||||
|
||||
hud_list[NATIONS_HUD] = holder
|
||||
update_power_buttons()
|
||||
hud_updateflag = 0
|
||||
|
||||
/mob/living/carbon/human/proc/process_nations()
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
|
||||
handle_regular_status_updates() // Status updates, death etc.
|
||||
|
||||
handle_actions()
|
||||
|
||||
handle_wetness()
|
||||
|
||||
/mob/living/carbon/slime/proc/AIprocess() // the master AI process
|
||||
|
||||
@@ -67,6 +67,9 @@
|
||||
|
||||
//Status updates, death etc.
|
||||
handle_regular_status_updates()
|
||||
|
||||
handle_actions()
|
||||
|
||||
update_canmove()
|
||||
|
||||
if(client)
|
||||
|
||||
@@ -34,8 +34,7 @@
|
||||
for(var/spell in default_spells)
|
||||
var/obj/effect/proc_holder/spell/wizard/S = spell
|
||||
if(!S) return
|
||||
H.spell_list += new S
|
||||
H.update_power_buttons()
|
||||
H.AddSpell(new S)
|
||||
|
||||
/datum/superheroes/proc/assign_id(var/mob/living/carbon/human/H)
|
||||
var/obj/item/weapon/card/id/syndicate/W = new(H)
|
||||
@@ -147,7 +146,7 @@
|
||||
charge_max = 450
|
||||
clothes_req = 0
|
||||
range = 1 //Adjacent to user
|
||||
icon_power_button = "spell_greytide"
|
||||
action_icon_state = "spell_greytide"
|
||||
var/recruiting = 0
|
||||
|
||||
/obj/effect/proc_holder/spell/wizard/targeted/recruit/cast(list/targets)
|
||||
|
||||
@@ -242,6 +242,80 @@
|
||||
if(volume >= 20) fire_stacks -= 0.5
|
||||
if(volume >= 50) fire_stacks -= 1
|
||||
|
||||
/mob/living/regular_hud_updates()
|
||||
..()
|
||||
update_action_buttons()
|
||||
|
||||
/mob/living/proc/handle_actions()
|
||||
//Pretty bad, i'd use picked/dropped instead but the parent calls in these are nonexistent
|
||||
for(var/datum/action/A in actions)
|
||||
if(A.CheckRemoval(src))
|
||||
A.Remove(src)
|
||||
for(var/obj/item/I in src)
|
||||
if(I.action_button_name)
|
||||
if(!I.action)
|
||||
if(I.action_button_is_hands_free)
|
||||
I.action = new/datum/action/item_action/hands_free
|
||||
else
|
||||
I.action = new/datum/action/item_action
|
||||
I.action.name = I.action_button_name
|
||||
I.action.target = I
|
||||
I.action.Grant(src)
|
||||
return
|
||||
|
||||
/mob/living/update_action_buttons()
|
||||
if(!hud_used) return
|
||||
if(!client) return
|
||||
|
||||
if(hud_used.hud_shown != 1) //Hud toggled to minimal
|
||||
return
|
||||
|
||||
client.screen -= hud_used.hide_actions_toggle
|
||||
for(var/datum/action/A in actions)
|
||||
if(A.button)
|
||||
client.screen -= A.button
|
||||
|
||||
if(hud_used.action_buttons_hidden)
|
||||
if(!hud_used.hide_actions_toggle)
|
||||
hud_used.hide_actions_toggle = new(hud_used)
|
||||
hud_used.hide_actions_toggle.UpdateIcon()
|
||||
|
||||
if(!hud_used.hide_actions_toggle.moved)
|
||||
hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(1)
|
||||
//hud_used.SetButtonCoords(hud_used.hide_actions_toggle,1)
|
||||
|
||||
client.screen += hud_used.hide_actions_toggle
|
||||
return
|
||||
|
||||
var/button_number = 0
|
||||
for(var/datum/action/A in actions)
|
||||
button_number++
|
||||
if(A.button == null)
|
||||
var/obj/screen/movable/action_button/N = new(hud_used)
|
||||
N.owner = A
|
||||
A.button = N
|
||||
|
||||
var/obj/screen/movable/action_button/B = A.button
|
||||
|
||||
B.UpdateIcon()
|
||||
|
||||
B.name = A.UpdateName()
|
||||
|
||||
client.screen += B
|
||||
|
||||
if(!B.moved)
|
||||
B.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number)
|
||||
//hud_used.SetButtonCoords(B,button_number)
|
||||
|
||||
if(button_number > 0)
|
||||
if(!hud_used.hide_actions_toggle)
|
||||
hud_used.hide_actions_toggle = new(hud_used)
|
||||
hud_used.hide_actions_toggle.InitialiseIcon(src)
|
||||
if(!hud_used.hide_actions_toggle.moved)
|
||||
hud_used.hide_actions_toggle.screen_loc = hud_used.ButtonNumberToScreenCoords(button_number+1)
|
||||
//hud_used.SetButtonCoords(hud_used.hide_actions_toggle,button_number+1)
|
||||
client.screen += hud_used.hide_actions_toggle
|
||||
|
||||
//This is called when the mob is thrown into a dense turf
|
||||
/mob/living/proc/turf_collision(var/turf/T, var/speed)
|
||||
src.take_organ_damage(speed*5)
|
||||
|
||||
@@ -48,4 +48,6 @@
|
||||
var/nightvision = 0
|
||||
|
||||
var/list/icon/pipes_shown = list()
|
||||
var/last_played_vent
|
||||
var/last_played_vent
|
||||
|
||||
var/list/datum/action/actions = list()
|
||||
@@ -18,6 +18,7 @@
|
||||
silence_time = null
|
||||
src << "<font color=green>Communication circuit reinitialized. Speech and messaging functionality restored.</font>"
|
||||
handle_statuses()
|
||||
handle_actions()
|
||||
|
||||
/mob/living/silicon/pai/updatehealth()
|
||||
if(status_flags & GODMODE)
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
clamp_values()
|
||||
handle_regular_status_updates()
|
||||
|
||||
handle_actions()
|
||||
|
||||
if(client)
|
||||
handle_regular_hud_updates()
|
||||
update_items()
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
name = text("[initial(name)] ([rand(1, 1000)])")
|
||||
real_name = name
|
||||
for(var/spell in construct_spells)
|
||||
spell_list += new spell(src)
|
||||
AddSpell(new spell(src))
|
||||
|
||||
/mob/living/simple_animal/construct/Die()
|
||||
..()
|
||||
|
||||
@@ -56,9 +56,9 @@
|
||||
/mob/living/simple_animal/hostile/statue/New(loc, var/mob/living/creator)
|
||||
..()
|
||||
// Give spells
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/aoe_turf/flicker_lights(src)
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/aoe_turf/blindness(src)
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/targeted/night_vision(src)
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/aoe_turf/flicker_lights(src))
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/aoe_turf/blindness(src))
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/targeted/night_vision(src))
|
||||
|
||||
// Give nightvision
|
||||
see_invisible = SEE_INVISIBLE_OBSERVER_NOLIGHTING
|
||||
|
||||
@@ -108,6 +108,8 @@
|
||||
handle_weakened()
|
||||
handle_paralysed()
|
||||
|
||||
handle_actions()
|
||||
|
||||
//Movement
|
||||
if(!client && !stop_automated_movement && wander && (ckey == null))
|
||||
if(isturf(src.loc) && !resting && !buckled && canmove) //This is so it only moves if it's not inside a closet, gentics machine, etc.
|
||||
|
||||
+14
-1
@@ -1455,4 +1455,17 @@ mob/proc/yank_out_object()
|
||||
else
|
||||
src.visible_message("<span class='warning'>[src] pukes all over \himself!</span>","<span class='warning'>You puke all over yourself!</span>")
|
||||
location.add_vomit_floor(src, 1)
|
||||
playsound(location, 'sound/effects/splat.ogg', 50, 1)
|
||||
playsound(location, 'sound/effects/splat.ogg', 50, 1)
|
||||
|
||||
/mob/proc/AddSpell(var/obj/effect/proc_holder/spell/spell)
|
||||
spell_list += spell
|
||||
if(!spell.action)
|
||||
spell.action = new/datum/action/spell_action
|
||||
spell.action.target = spell
|
||||
spell.action.name = spell.name
|
||||
spell.action.button_icon = spell.action_icon
|
||||
spell.action.button_icon_state = spell.action_icon_state
|
||||
spell.action.background_icon_state = spell.action_background_icon_state
|
||||
if(isliving(src))
|
||||
spell.action.Grant(src)
|
||||
return
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
/mob/spirit/mask/New()
|
||||
..()
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/aoe_turf/conjure/create_talisman(src)
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/aoe_turf/blood_speech(src)
|
||||
spell_list += new /obj/effect/proc_holder/spell/wizard/aoe_turf/shatter_lights(src)
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/aoe_turf/conjure/create_talisman(src))
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/aoe_turf/blood_speech(src))
|
||||
AddSpell(new /obj/effect/proc_holder/spell/wizard/aoe_turf/shatter_lights(src))
|
||||
|
||||
|
||||
/mob/spirit/mask/verb/go_to_follower()
|
||||
|
||||
Reference in New Issue
Block a user