- Adds generic action and action buttons system

This commit is contained in:
AnturK
2015-04-08 16:23:25 +02:00
parent c925e8019e
commit e2c869bc77
31 changed files with 485 additions and 211 deletions
+2 -2
View File
@@ -441,9 +441,9 @@ var/list/admin_verbs_hideable = list(
message_admins("<span class='adminnotice'>[key_name_admin(usr)] gave [key_name(T)] the spell [S].</span>")
if(T.mind)
T.mind.spell_list += new S
T.mind.AddSpell(new S)
else
T.mob_spell_list += new S
T.AddSpell(new S)
message_admins("<span class='danger'>Spells given to mindless mobs will not be transferred in mindswap or cloning!</span>")
+2 -2
View File
@@ -143,9 +143,9 @@
santa_objective.completed = 1 //lets cut our santas some slack.
santa_objective.owner = santa.mind
santa.mind.objectives += santa_objective
santa.mind.spell_list += new /obj/effect/proc_holder/spell/aoe_turf/conjure/presents
santa.mind.AddSpell(new /obj/effect/proc_holder/spell/aoe_turf/conjure/presents)
var/obj/effect/proc_holder/spell/targeted/area_teleport/teleport/telespell = new(santa)
telespell.clothes_req = 0 //santa robes aren't actually magical.
santa.mind.spell_list += telespell //does the station have chimneys? WHO KNOWS!
santa.mind.AddSpell(telespell) //does the station have chimneys? WHO KNOWS!
santa << "<span class='boldannounce'>You are Santa! Your objective is to bring joy to the people on this station. You can conjure more presents using a spell, and there are several presents in your bag.</span>"
+3 -3
View File
@@ -33,9 +33,9 @@
I.key = C.key
//Operation: Fuck off and scare people
I.mind.spell_list += new /obj/effect/proc_holder/spell/targeted/area_teleport/teleport(null)
I.mind.spell_list += new /obj/effect/proc_holder/spell/targeted/turf_teleport/blink(null)
I.mind.spell_list += new /obj/effect/proc_holder/spell/targeted/ethereal_jaunt(null)
I.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/area_teleport/teleport(null))
I.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/turf_teleport/blink(null))
I.mind.AddSpell(new /obj/effect/proc_holder/spell/targeted/ethereal_jaunt(null))
ticker.mode.traitors += I.mind
I.mind.special_role = "imposter"
@@ -301,9 +301,6 @@
s_store = null
update_inv_s_store(0)
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()
//set redraw_mob to 0 if you don't wish the hud to be updated - if you're doing it manually in your own proc.
/mob/living/carbon/human/equip_to_slot(obj/item/I, slot, redraw_mob = 1)
-2
View File
@@ -375,8 +375,6 @@
/mob/living/carbon/handle_regular_hud_updates()
if(!client) return 0
update_action_buttons()
if(damageoverlay)
if(damageoverlay.overlays)
damageoverlay.overlays = list()
+72
View File
@@ -47,6 +47,8 @@
handle_disabilities() // eye, ear, brain damages
handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc
handle_actions()
update_canmove()
if(client)
@@ -131,6 +133,22 @@
if(ear_damage < 100)
adjustEarDamage(-0.05,-1)
/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
//this handles hud updates. Calls update_vision() and handle_hud_icons()
/mob/living/proc/handle_regular_hud_updates()
@@ -138,6 +156,7 @@
handle_vision()
handle_hud_icons()
update_action_buttons()
return 1
@@ -185,3 +204,56 @@
/mob/living/proc/handle_hud_icons_health()
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.UpdateIcon()
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
@@ -43,3 +43,4 @@
var/list/image/staticOverlays = list()
var/lying_pixel_offset = 0 //offset for pixel_y when the mob is lying down.
var/has_limbs = 0 //does the mob have distinct limbs?(arms,legs, chest,head)
var/list/datum/action/actions = list()
+13
View File
@@ -946,4 +946,17 @@ var/list/slot_equipment_priority = list( \
return
/mob/proc/setEarDamage()
return
/mob/proc/AddSpell(var/obj/effect/proc_holder/spell/spell)
mob_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