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

Optimize action buttons #8539

Merged
Merged
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
8 changes: 7 additions & 1 deletion code/game/objects/items/_inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
equipped.forceMove(src)
return FALSE


/obj/item/proc/equipped(mob/user, slot)
equip_slot = slot
if(user.pulling == src)
Expand All @@ -72,6 +73,9 @@
update_light()
if(flags & MOVE_NOTIFY)
user.update_on_move |= src
if(action_button_name)
user.action_button_add(src)


/obj/item/proc/dropped(mob/user)
GLOB.mob_unequipped_event.raise_event(user, src)
Expand All @@ -84,6 +88,9 @@
if(overslot && is_held())
remove_overslot_contents(user)
user.update_on_move -= src
if(action_button_name)
user.action_button_remove(src)


/obj/item/proc/remove_overslot_contents(mob/user)
if(overslot_contents)
Expand All @@ -92,7 +99,6 @@
overslot_contents = null



/obj/item/proc/mob_can_unequip(mob/M, slot, disable_warning = FALSE)
if(!slot) return FALSE
if(!M) return FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@
/obj/item/device/lighting/toggleable/flashlight/dropped(mob/user as mob)
if(light_direction)
set_dir(light_direction)
..()

/obj/item/device/lighting/toggleable/flashlight/afterattack(atom/A, mob/user)
var/turf/T = get_turf(A)
Expand Down
3 changes: 0 additions & 3 deletions code/modules/mob/living/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,11 @@
handle_disabilities() // eye, ear, brain damages
handle_status_effects() //all special effects, stunned, weakened, jitteryness, hallucination, sleeping, etc

handle_actions()

update_lying_buckled_and_verb_status()

handle_regular_hud_updates()



/mob/living/proc/Life_Check_Light()
if (HasMovementHandler(/datum/movement_handler/mob/transformation/))
return
Expand Down
81 changes: 35 additions & 46 deletions code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -431,52 +431,51 @@
/mob/living/proc/reagent_permeability()
return 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
if(I.action_button_proc)
I.action.action_type = AB_ITEM_PROC
I.action.procname = I.action_button_proc
if(I.action_button_arguments)
I.action.arguments = I.action_button_arguments
I.action.Grant(src)
/mob/proc/action_button_add(obj/item/item)
return

/mob/living/action_button_add(obj/item/item)
ASSERT(item)
if(!item.action_button_name)
return

if(!item.action)
if(item.action_button_is_hands_free)
item.action = new/datum/action/item_action/hands_free
else
item.action = new/datum/action/item_action
item.action.name = item.action_button_name
item.action.target = item
if(item.action_button_proc)
item.action.action_type = AB_ITEM_PROC
item.action.procname = item.action_button_proc
if(item.action_button_arguments)
item.action.arguments = item.action_button_arguments
item.action.Grant(src)


/mob/proc/action_button_remove(obj/item/item)
return

/mob/living/action_button_remove(obj/item/item)
ASSERT(item)
ASSERT(istype(item))
if(item.action)
item.action.Remove(src)
else
for(var/datum/action/action in actions)
if(action.target == item)
action.Remove(src)


/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++
Expand All @@ -495,13 +494,3 @@

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*/
1 change: 0 additions & 1 deletion code/modules/mob/living/silicon/robot/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//Status updates, death etc.
clamp_values()
handle_regular_status_updates()
handle_actions()

if(client)
handle_regular_hud_updates()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
client.create_UI(src.type)

add_click_catcher()
update_action_buttons()

client.CAN_MOVE_DIAGONALLY = FALSE

Expand Down
Loading