Merge pull request #5107 from Fox-McCloud/buttonssss

Fixes Performance Issue with Action buttons, removes redundant verbs
This commit is contained in:
TheDZD
2016-07-21 09:23:54 -04:00
committed by GitHub
20 changed files with 117 additions and 155 deletions

View File

@@ -281,6 +281,7 @@
..() ..()
/datum/action/item_action/toggle_research_scanner/ApplyIcon(obj/screen/movable/action_button/current_button) /datum/action/item_action/toggle_research_scanner/ApplyIcon(obj/screen/movable/action_button/current_button)
current_button.overlays.Cut()
if(button_icon && button_icon_state) if(button_icon && button_icon_state)
var/image/img = image(button_icon, current_button, "scan_mode") var/image/img = image(button_icon, current_button, "scan_mode")
current_button.overlays += img current_button.overlays += img

View File

@@ -374,6 +374,9 @@ Congratulations! You are now trained for xenobiology research!"}
to_chat(usr, "<span class='notice'>You switch the baton to [txt] mode.</span>") to_chat(usr, "<span class='notice'>You switch the baton to [txt] mode.</span>")
update_icon() update_icon()
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/weapon/abductor_baton/update_icon() /obj/item/weapon/abductor_baton/update_icon()
switch(mode) switch(mode)

View File

@@ -463,6 +463,9 @@ BLIND // can't see anything
flavour = "[copytext(adjust_flavour, 3, lentext(adjust_flavour) + 1)] up" //Trims off the 'un' at the beginning of the word. unzip -> zip, unbutton->button. flavour = "[copytext(adjust_flavour, 3, lentext(adjust_flavour) + 1)] up" //Trims off the 'un' at the beginning of the word. unzip -> zip, unbutton->button.
to_chat(user, "You [flavour] \the [src].") to_chat(user, "You [flavour] \the [src].")
suit_adjusted = 0 //Suit is no longer adjusted. suit_adjusted = 0 //Suit is no longer adjusted.
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
else else
var/flavour = "open" var/flavour = "open"
icon_state += "_open" icon_state += "_open"
@@ -471,6 +474,9 @@ BLIND // can't see anything
flavour = "[adjust_flavour]" flavour = "[adjust_flavour]"
to_chat(user, "You [flavour] \the [src].") to_chat(user, "You [flavour] \the [src].")
suit_adjusted = 1 //Suit's adjusted. suit_adjusted = 1 //Suit's adjusted.
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
else else
if(user.canUnEquip(src)) //Checks to see if the item can be unequipped. If so, lets shred. Otherwise, struggle and fail. if(user.canUnEquip(src)) //Checks to see if the item can be unequipped. If so, lets shred. Otherwise, struggle and fail.
if(contents) //If the suit's got any storage capability... if(contents) //If the suit's got any storage capability...
@@ -502,16 +508,6 @@ BLIND // can't see anything
if(!(initial(flags_inv) & HIDETAIL) && (flags_inv & HIDETAIL)) //Otherwise, remove the HIDETAIL flag if it wasn't already in the flags_inv to start with. if(!(initial(flags_inv) & HIDETAIL) && (flags_inv & HIDETAIL)) //Otherwise, remove the HIDETAIL flag if it wasn't already in the flags_inv to start with.
flags_inv &= ~HIDETAIL flags_inv &= ~HIDETAIL
/obj/item/clothing/suit/verb/openjacket(var/mob/user) //The verb you can use to adjust jackets.
set name = "Open/Close Jacket"
set category = "Object"
set src in usr
if(!isliving(usr))
return
if(usr.stat)
return
adjustsuit(user)
/obj/item/clothing/suit/ui_action_click(mob/user) //This is what happens when you click the HUD action button to adjust your suit. /obj/item/clothing/suit/ui_action_click(mob/user) //This is what happens when you click the HUD action button to adjust your suit.
if(!ignore_suitadjust) if(!ignore_suitadjust)
adjustsuit(user) adjustsuit(user)

View File

@@ -281,10 +281,7 @@
/obj/item/clothing/glasses/sunglasses/yeah/attack_self() /obj/item/clothing/glasses/sunglasses/yeah/attack_self()
pun() pun()
/obj/item/clothing/glasses/sunglasses/yeah/verb/pun() /obj/item/clothing/glasses/sunglasses/yeah/proc/pun()
set category = "Object"
set name = "YEAH!"
set src in usr
if(!punused)//one per round if(!punused)//one per round
punused = 1 punused = 1
playsound(src.loc, 'sound/misc/yeah.ogg', 100, 0) playsound(src.loc, 'sound/misc/yeah.ogg', 100, 0)
@@ -340,31 +337,28 @@
/obj/item/clothing/glasses/welding/attack_self() /obj/item/clothing/glasses/welding/attack_self()
toggle() toggle()
/obj/item/clothing/glasses/welding/proc/toggle()
if(up)
up = !up
flags |= GLASSESCOVERSEYES
flags_inv |= HIDEEYES
icon_state = initial(icon_state)
to_chat(usr, "You flip the [src] down to protect your eyes.")
flash_protect = 2
tint = initial(tint) //better than istype
else
up = !up
flags &= ~GLASSESCOVERSEYES
flags_inv &= ~HIDEEYES
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push the [src] up out of your face.")
flash_protect = 0
tint = 0
usr.update_inv_glasses()
/obj/item/clothing/glasses/welding/verb/toggle() for(var/X in actions)
set category = "Object" var/datum/action/A = X
set name = "Adjust welding goggles" A.UpdateButtonIcon()
set src in usr
if(usr.canmove && !usr.stat && !usr.restrained())
if(src.up)
src.up = !src.up
src.flags |= GLASSESCOVERSEYES
flags_inv |= HIDEEYES
icon_state = initial(icon_state)
to_chat(usr, "You flip the [src] down to protect your eyes.")
flash_protect = 2
tint = initial(tint) //better than istype
else
src.up = !src.up
src.flags &= ~HEADCOVERSEYES
flags_inv &= ~HIDEEYES
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push the [src] up out of your face.")
flash_protect = 0
tint = 0
usr.update_inv_glasses()
/obj/item/clothing/glasses/welding/superior /obj/item/clothing/glasses/welding/superior
name = "superior welding goggles" name = "superior welding goggles"

View File

@@ -355,14 +355,7 @@
/obj/item/clothing/head/griffin/attack_self() /obj/item/clothing/head/griffin/attack_self()
caw() caw()
/obj/item/clothing/head/griffin/verb/caw() /obj/item/clothing/head/griffin/proc/caw()
set category = "Object"
set name = "Caw"
set src in usr
if(!istype(usr, /mob/living)) return
if(usr.stat) return
if(cooldown < world.time - 20) // A cooldown, to stop people being jerks if(cooldown < world.time - 20) // A cooldown, to stop people being jerks
playsound(src.loc, "sound/misc/caw.ogg", 50, 1) playsound(src.loc, "sound/misc/caw.ogg", 50, 1)
cooldown = world.time cooldown = world.time

View File

@@ -50,26 +50,28 @@
toggle() toggle()
/obj/item/clothing/head/welding/proc/toggle() /obj/item/clothing/head/welding/proc/toggle()
set src in usr if(up)
up = !up
flags |= (HEADCOVERSEYES | HEADCOVERSMOUTH)
flags_inv |= (HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = initial(icon_state)
to_chat(usr, "You flip the [src] down to protect your eyes.")
flash_protect = 2
tint = 2
else
up = !up
flags &= ~(HEADCOVERSEYES | HEADCOVERSMOUTH)
flags_inv &= ~(HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push the [src] up out of your face.")
flash_protect = 0
tint = 0
usr.update_inv_head() //so our mob-overlays update
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
if(usr.canmove && !usr.stat && !usr.restrained())
if(src.up)
src.up = !src.up
src.flags |= (HEADCOVERSEYES | HEADCOVERSMOUTH)
flags_inv |= (HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = initial(icon_state)
to_chat(usr, "You flip the [src] down to protect your eyes.")
flash_protect = 2
tint = 2
else
src.up = !src.up
src.flags &= ~(HEADCOVERSEYES | HEADCOVERSMOUTH)
flags_inv &= ~(HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE)
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push the [src] up out of your face.")
flash_protect = 0
tint = 0
usr.update_inv_head() //so our mob-overlays update
/* /*

View File

@@ -34,30 +34,28 @@
/obj/item/clothing/mask/gas/welding/attack_self() /obj/item/clothing/mask/gas/welding/attack_self()
toggle() toggle()
/obj/item/clothing/mask/gas/welding/proc/toggle()
if(up)
up = !src.up
flags |= (MASKCOVERSEYES)
flags_inv |= (HIDEEYES)
icon_state = initial(icon_state)
to_chat(usr, "You flip the [src] down to protect your eyes.")
flash_protect = 2
tint = 2
else
up = !up
flags &= ~(MASKCOVERSEYES)
flags_inv &= ~(HIDEEYES)
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push the [src] up out of your face.")
flash_protect = 0
tint = 0
usr.update_inv_wear_mask() //so our mob-overlays update
/obj/item/clothing/mask/gas/welding/verb/toggle() for(var/X in actions)
set category = "Object" var/datum/action/A = X
set name = "Adjust welding mask" A.UpdateButtonIcon()
set src in usr
if(usr.canmove && !usr.stat && !usr.restrained())
if(src.up)
src.up = !src.up
src.flags |= (MASKCOVERSEYES)
flags_inv |= (HIDEEYES)
icon_state = initial(icon_state)
to_chat(usr, "You flip the [src] down to protect your eyes.")
flash_protect = 2
tint = 2
else
src.up = !src.up
src.flags &= ~(MASKCOVERSEYES)
flags_inv &= ~(HIDEEYES)
icon_state = "[initial(icon_state)]up"
to_chat(usr, "You push the [src] up out of your face.")
flash_protect = 0
tint = 0
usr.update_inv_wear_mask() //so our mob-overlays update
//Bane gas mask //Bane gas mask
/obj/item/clothing/mask/banemask /obj/item/clothing/mask/banemask
@@ -171,14 +169,7 @@
/obj/item/clothing/mask/gas/owl_mask/attack_self() /obj/item/clothing/mask/gas/owl_mask/attack_self()
hoot() hoot()
/obj/item/clothing/mask/gas/owl_mask/verb/hoot() /obj/item/clothing/mask/gas/owl_mask/proc/hoot()
set category = "Object"
set name = "Hoot"
set src in usr
if(!istype(usr, /mob/living)) return
if(usr.stat) return
if(cooldown < world.time - 35) // A cooldown, to stop people being jerks if(cooldown < world.time - 35) // A cooldown, to stop people being jerks
playsound(src.loc, "sound/misc/hoot.ogg", 50, 1) playsound(src.loc, "sound/misc/hoot.ogg", 50, 1)
cooldown = world.time cooldown = world.time
@@ -270,13 +261,7 @@
else else
return return
/obj/item/clothing/mask/gas/sechailer/verb/halt() /obj/item/clothing/mask/gas/sechailer/proc/halt()
set category = "Object"
set name = "HALT"
set src in usr
if(!istype(usr, /mob/living)) return
if(usr.stat) return
var/phrase = 0 //selects which phrase to use var/phrase = 0 //selects which phrase to use
var/phrase_text = null var/phrase_text = null
var/phrase_sound = null var/phrase_sound = null

View File

@@ -22,6 +22,9 @@
to_chat(user, "You [magpulse ? "enable" : "disable"] the mag-pulse traction system.") to_chat(user, "You [magpulse ? "enable" : "disable"] the mag-pulse traction system.")
user.update_inv_shoes() //so our mob-overlays update user.update_inv_shoes() //so our mob-overlays update
user.update_gravity(user.mob_has_gravity()) user.update_gravity(user.mob_has_gravity())
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/clothing/shoes/magboots/negates_gravity() /obj/item/clothing/shoes/magboots/negates_gravity()
return flags & NOSLIP return flags & NOSLIP

View File

@@ -250,7 +250,6 @@
unacidable = 1 unacidable = 1
hit_reaction_chance = 50 hit_reaction_chance = 50
/obj/item/clothing/suit/armor/reactive/attack_self(mob/user) /obj/item/clothing/suit/armor/reactive/attack_self(mob/user)
active = !(active) active = !(active)
if(active) if(active)
@@ -263,6 +262,9 @@
item_state = "reactiveoff" item_state = "reactiveoff"
add_fingerprint(user) add_fingerprint(user)
user.update_inv_wear_suit() user.update_inv_wear_suit()
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/clothing/suit/armor/reactive/emp_act(severity) /obj/item/clothing/suit/armor/reactive/emp_act(severity)
active = 0 active = 0

View File

@@ -7,7 +7,6 @@
/obj/item/clothing/suit/hooded/New() /obj/item/clothing/suit/hooded/New()
MakeHood() MakeHood()
verbs -= /obj/item/clothing/suit/verb/openjacket //you can't unbutton those, deal with it
..() ..()
/obj/item/clothing/suit/hooded/Destroy() /obj/item/clothing/suit/hooded/Destroy()
@@ -47,16 +46,6 @@
..() ..()
RemoveHood() RemoveHood()
/obj/item/clothing/suit/hooded/verb/Hooderize(var/mob/user)
set name = "Adjust the hood"
set category = "Object"
set src in usr
if(!isliving(usr))
return
if(usr.stat)
return
ToggleHood()
/obj/item/clothing/suit/hooded/proc/ToggleHood() /obj/item/clothing/suit/hooded/proc/ToggleHood()
if(!suit_adjusted) if(!suit_adjusted)
if(ishuman(loc)) if(ishuman(loc))

View File

@@ -800,6 +800,9 @@
icon_state = initial(icon_state) icon_state = initial(icon_state)
item_state = initial(item_state) item_state = initial(item_state)
usr.update_inv_wear_suit() usr.update_inv_wear_suit()
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/clothing/suit/lordadmiral /obj/item/clothing/suit/lordadmiral
name = "Lord Admiral's Coat" name = "Lord Admiral's Coat"

View File

@@ -495,22 +495,21 @@
/obj/item/clothing/head/fluff/chronx/ui_action_click() /obj/item/clothing/head/fluff/chronx/ui_action_click()
adjust() adjust()
/obj/item/clothing/head/fluff/chronx/verb/adjust() /obj/item/clothing/head/fluff/chronx/proc/adjust()
set name = "Transform Hood" if(adjusted)
set category = "Object" icon_state = initial(icon_state)
set src in usr item_state = initial(item_state)
if(isliving(usr) && !usr.incapacitated()) to_chat(usr, "You untransform \the [src].")
if(adjusted) adjusted = 0
icon_state = initial(icon_state) else
item_state = initial(item_state) icon_state += "_open"
to_chat(usr, "You untransform \the [src].") item_state += "_open"
adjusted = 0 to_chat(usr, "You transform \the [src].")
else adjusted = 1
icon_state += "_open" usr.update_inv_head()
item_state += "_open" for(var/X in actions)
to_chat(usr, "You transform \the [src].") var/datum/action/A = X
adjusted = 1 A.UpdateButtonIcon()
usr.update_inv_head()
/obj/item/clothing/suit/chaplain_hoodie/fluff/chronx //chronx100: Hughe O'Splash /obj/item/clothing/suit/chaplain_hoodie/fluff/chronx //chronx100: Hughe O'Splash
name = "Cthulhu's Robes" name = "Cthulhu's Robes"
@@ -523,18 +522,6 @@
adjust_flavour = "untransform" adjust_flavour = "untransform"
ignore_suitadjust = 0 ignore_suitadjust = 0
/obj/item/clothing/suit/chaplain_hoodie/fluff/chronx/New()
..()
verbs -= /obj/item/clothing/suit/verb/openjacket
/obj/item/clothing/suit/chaplain_hoodie/fluff/chronx/verb/adjust()
set name = "Transform Robes"
set category = "Object"
set src in usr
if(!istype(usr, /mob/living))
return
adjustsuit(usr)
/obj/item/clothing/shoes/black/fluff/chronx //chronx100: Hughe O'Splash /obj/item/clothing/shoes/black/fluff/chronx //chronx100: Hughe O'Splash
name = "Cthulhu's Boots" name = "Cthulhu's Boots"
desc = "Boots worn by the worshipers of Cthulhu. You see a name inscribed in blood on the inside: Hughe O'Splash" desc = "Boots worn by the worshipers of Cthulhu. You see a name inscribed in blood on the inside: Hughe O'Splash"

View File

@@ -50,7 +50,7 @@
return ..() return ..()
/mob/living/carbon/brain/update_canmove() /mob/living/carbon/brain/update_canmove(delay_action_updates = 0)
if(in_contents_of(/obj/mecha)) if(in_contents_of(/obj/mecha))
canmove = 1 canmove = 1
use_me = 1 //If it can move, let it emote use_me = 1 //If it can move, let it emote
@@ -59,7 +59,8 @@
else else
canmove = 0 canmove = 0
update_action_buttons_icon() if(!delay_action_updates)
update_action_buttons_icon()
return canmove return canmove
/mob/living/carbon/brain/ex_act() //you cant blow up brainmobs because it makes transfer_to() freak out when borgs blow up. /mob/living/carbon/brain/ex_act() //you cant blow up brainmobs because it makes transfer_to() freak out when borgs blow up.

View File

@@ -49,7 +49,7 @@
handle_disabilities() // eye, ear, brain damages handle_disabilities() // eye, ear, brain damages
handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc
update_canmove() update_canmove(1) // set to 1 to not update icon action buttons; rip this argument out if Life is ever refactored to be non-stupid. -Fox
if(client) if(client)
//regular_hud_updates() //THIS DOESN'T FUCKING UPDATE SHIT //regular_hud_updates() //THIS DOESN'T FUCKING UPDATE SHIT

View File

@@ -521,7 +521,7 @@
to_chat(src, "<span class='warning'>You are far too small to pull anything!</span>") to_chat(src, "<span class='warning'>You are far too small to pull anything!</span>")
return return
/mob/living/silicon/pai/update_canmove() /mob/living/silicon/pai/update_canmove(delay_action_updates = 0)
. = ..() . = ..()
density = 0 //this is reset every canmove update otherwise density = 0 //this is reset every canmove update otherwise

View File

@@ -337,7 +337,7 @@
/mob/living/silicon/robot/drone/remove_robot_verbs() /mob/living/silicon/robot/drone/remove_robot_verbs()
src.verbs -= silicon_subsystems src.verbs -= silicon_subsystems
/mob/living/silicon/robot/drone/update_canmove() /mob/living/silicon/robot/drone/update_canmove(delay_action_updates = 0)
. = ..() . = ..()
density = 0 //this is reset every canmove update otherwise density = 0 //this is reset every canmove update otherwise

View File

@@ -227,13 +227,14 @@
weapon_lock = 0 weapon_lock = 0
weaponlock_time = 120 weaponlock_time = 120
/mob/living/silicon/robot/update_canmove() /mob/living/silicon/robot/update_canmove(delay_action_updates = 0)
if(paralysis || stunned || weakened || buckled || lockcharge) if(paralysis || stunned || weakened || buckled || lockcharge)
canmove = 0 canmove = 0
else else
canmove = 1 canmove = 1
update_transform() update_transform()
update_action_buttons_icon() if(!delay_action_updates)
update_action_buttons_icon()
return canmove return canmove
//Robots on fire //Robots on fire

View File

@@ -161,7 +161,7 @@
diag_hud.add_hud_to(src) diag_hud.add_hud_to(src)
permanent_huds |= diag_hud permanent_huds |= diag_hud
/mob/living/simple_animal/bot/update_canmove() /mob/living/simple_animal/bot/update_canmove(delay_action_updates = 0)
. = ..() . = ..()
if(!on) if(!on)
. = 0 . = 0

View File

@@ -617,7 +617,7 @@
return verb return verb
/mob/living/simple_animal/update_canmove() /mob/living/simple_animal/update_canmove(delay_action_updates = 0)
if(paralysis || stunned || weakened || stat || resting) if(paralysis || stunned || weakened || stat || resting)
drop_r_hand() drop_r_hand()
drop_l_hand() drop_l_hand()
@@ -627,7 +627,8 @@
else else
canmove = 1 canmove = 1
update_transform() update_transform()
update_action_buttons_icon() if(!delay_action_updates)
update_action_buttons_icon()
return canmove return canmove
/mob/living/simple_animal/update_transform() /mob/living/simple_animal/update_transform()

View File

@@ -1016,7 +1016,7 @@ var/list/slot_equipment_priority = list( \
return 1 return 1
//Updates canmove, lying and icons. Could perhaps do with a rename but I can't think of anything to describe it. //Updates canmove, lying and icons. Could perhaps do with a rename but I can't think of anything to describe it.
/mob/proc/update_canmove() /mob/proc/update_canmove(delay_action_updates = 0)
var/ko = weakened || paralysis || stat || (status_flags & FAKEDEATH) var/ko = weakened || paralysis || stat || (status_flags & FAKEDEATH)
var/buckle_lying = !(buckled && !buckled.buckle_lying) var/buckle_lying = !(buckled && !buckled.buckle_lying)
if(ko || resting || stunned) if(ko || resting || stunned)
@@ -1041,7 +1041,8 @@ var/list/slot_equipment_priority = list( \
layer = initial(layer) layer = initial(layer)
update_transform() update_transform()
update_action_buttons_icon() if(!delay_action_updates)
update_action_buttons_icon()
return canmove return canmove
/mob/proc/fall(var/forced) /mob/proc/fall(var/forced)