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

Replaces some progress bars with item bars, makes some bars be visible to the recipients #9361

Closed
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3f9d426
main-progbar-code
CydiaLamiales Jul 8, 2023
b13656a
some-progress
CydiaLamiales Jul 8, 2023
721d984
bit-more-progbar-work
CydiaLamiales Jul 8, 2023
4a217a8
work-on-crafting
CydiaLamiales Jul 9, 2023
5a9c25c
surgery-progbars
CydiaLamiales Jul 9, 2023
19e9c68
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Jul 9, 2023
94184fe
first-big-commit-only-20-percent-done
CydiaLamiales Jul 11, 2023
c50546d
Update code/datums/components/crafting/crafting.dm
CydiaLamiales Jul 12, 2023
8ad2ba0
bit-more-work
CydiaLamiales Jul 13, 2023
4a5d534
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Jul 13, 2023
9107370
quick-fix
CydiaLamiales Jul 13, 2023
51990a3
halfway-there
CydiaLamiales Jul 14, 2023
ad4906d
bit_more_work
CydiaLamiales Jul 15, 2023
9019bcb
fixes-again
CydiaLamiales Jul 15, 2023
9e99a48
holy_mother_of_all_commit_bombs
CydiaLamiales Jul 17, 2023
c0b69fb
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Jul 17, 2023
877d068
small-touchups
CydiaLamiales Jul 17, 2023
8d10435
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Jul 18, 2023
40b2666
SECONDS-define
CydiaLamiales Jul 18, 2023
7a38ca9
no-speed-boost-in-repair-for-cyborgs
CydiaLamiales Jul 18, 2023
cf8a8bd
oh-whoops-these-were-wrong
CydiaLamiales Jul 18, 2023
f48707a
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Jul 21, 2023
326fee6
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Jul 22, 2023
45a0d40
testus-restartus
CydiaLamiales Jul 22, 2023
a3b7734
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Jul 23, 2023
9ea406e
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Jul 25, 2023
71170cb
fix-these
CydiaLamiales Jul 25, 2023
6e8f1f4
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Jul 27, 2023
dd6e5bc
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Jul 27, 2023
5f4f839
Merge branch 'goonlike-progress-bars' of https://github.com/CydiaLami…
CydiaLamiales Jul 27, 2023
993f9c8
no-repeats-on-climbing
CydiaLamiales Jul 27, 2023
b0f854e
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Jul 30, 2023
20c241d
slightly-better-logic-for-the-cashed-list
CydiaLamiales Jul 30, 2023
0de9157
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Aug 14, 2023
aa127e9
fixes
CydiaLamiales Aug 14, 2023
d6f7f1e
better-icon-size-search-logic
CydiaLamiales Aug 14, 2023
7a3ce25
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Aug 18, 2023
30b3460
stripping-and-feeding-tweaks
CydiaLamiales Aug 18, 2023
3104e54
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Aug 19, 2023
20ad439
storage-issue-fix
CydiaLamiales Aug 19, 2023
3926e31
medibot-fixy
CydiaLamiales Aug 19, 2023
86f8f50
martial-art-scroll-fix
CydiaLamiales Aug 19, 2023
1c4b0ef
clientles-proccall-fix
CydiaLamiales Aug 19, 2023
a6332f7
color-and-click-fix
CydiaLamiales Aug 20, 2023
a362e0c
instant-doubleclick-completion-fix
CydiaLamiales Aug 20, 2023
15ca523
stuck-image-fix
CydiaLamiales Aug 21, 2023
f8bad4c
code-cleanup
CydiaLamiales Aug 22, 2023
7321381
Update code/modules/antagonists/clock_cult/items/replica_fabricator.dm
CydiaLamiales Aug 22, 2023
9bf4a7d
Update code/modules/power/apc/apc_attack.dm
CydiaLamiales Aug 22, 2023
86ebbce
Update code/modules/projectiles/guns/ballistic.dm
CydiaLamiales Aug 22, 2023
51bfd45
Update code/datums/elements/mechanical_repair.dm
CydiaLamiales Aug 22, 2023
f05f76d
Update code/game/objects/structures/loom.dm
CydiaLamiales Aug 22, 2023
a9e7293
while_looping_removal
CydiaLamiales Aug 22, 2023
9323fc2
paddles-icon-fix
CydiaLamiales Aug 22, 2023
ce22d04
afterattack-cleanup
CydiaLamiales Aug 22, 2023
93046e9
cooldowns-instead-of-vars
CydiaLamiales Aug 22, 2023
f5b5702
instant-doubleclick-tool-completion-fix
CydiaLamiales Aug 22, 2023
ffda9e8
testus-restartus
CydiaLamiales Aug 22, 2023
d7cc012
Update code/modules/multiz/movement/mob/living_zmove.dm
CydiaLamiales Aug 23, 2023
1284daf
typo-fix
CydiaLamiales Aug 23, 2023
7c66bb6
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Sep 4, 2023
5dd3125
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Sep 6, 2023
bd1db14
extrapolator-fix
CydiaLamiales Sep 6, 2023
9146423
Merge branch 'master' of https://github.com/CydiaLamiales/BeeStation-…
CydiaLamiales Sep 18, 2023
06c1c66
this_should_be_target_visible
CydiaLamiales Sep 18, 2023
595147d
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Sep 21, 2023
eccfdcf
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Oct 5, 2023
67138e5
Update lib_items.dm
CydiaLamiales Oct 5, 2023
9f0ce11
Update lib_items.dm
CydiaLamiales Oct 5, 2023
b18c6bf
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Oct 12, 2023
ca551c4
Merge branch 'master' into goonlike-progress-bars
CydiaLamiales Oct 16, 2023
b0d7752
fix-var-issue
CydiaLamiales Oct 16, 2023
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
1 change: 1 addition & 0 deletions beestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#include "code\__DEFINES\html_assistant.dm"
#include "code\__DEFINES\hud.dm"
#include "code\__DEFINES\icon_smoothing.dm"
#include "code\__DEFINES\icons.dm"
#include "code\__DEFINES\important_recursive_contents.dm"
#include "code\__DEFINES\instruments.dm"
#include "code\__DEFINES\interaction_flags.dm"
Expand Down
7 changes: 7 additions & 0 deletions code/__DEFINES/icons.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* Stores a list of items that had their leftmost and rightmost pixels found before, for the sake of optimization
*
* Format :
* * cached_image_borders[type] = list("left" = x, "right" = y, "bottom" = z, "top" = w)
*/
GLOBAL_LIST_EMPTY(cached_image_borders)
82 changes: 82 additions & 0 deletions code/__HELPERS/icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1459,3 +1459,85 @@ GLOBAL_LIST_EMPTY(friendly_animal_types)
animate(src, pixel_x = pixel_x + shiftx, pixel_y = pixel_y + shifty, time = 0.2, loop = duration)
pixel_x = initialpixelx
pixel_y = initialpixely

/**
* Returns a list that contains the leftmost, rightmost, bottom and top pixels in an atom's icon
*/
/atom/proc/get_bounding_box()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I just don't think this is going to work. Even with only around 300-500 calls getpixel becomes one of the most overtiming things on the server. Progress bar images need to be specifically chosen and have their parameters fed in directly, or they need to be an image with the normal progress bar below and ignore the fact that part of it might take a while to start showing.

var/list/return_list = list()
for(var/found_type in GLOB.cached_image_borders)
if(found_type == type)
return_list["left"] = GLOB.cached_image_borders[found_type]["left"]
return_list["right"] = GLOB.cached_image_borders[found_type]["right"]
return_list["top"] = GLOB.cached_image_borders[found_type]["top"]
return_list["bottom"] = GLOB.cached_image_borders[found_type]["bottom"]
return return_list

var/icon/tempicon = icon(icon, icon_state, dir, 1)
tempicon = getFlatIcon(src)
var/x_coord = 1
var/y_coord = 1
var/height = tempicon.Height()
var/width = tempicon.Width()
var/left_border = width
var/right_border = 1

tempicon.Scale(width, 1) //Flatten the icon into a 1 pixel high line
height = tempicon.Height()
while(y_coord <= height)
x_coord = 1
while(x_coord <= width)
var/pixel = tempicon.GetPixel(x_coord, y_coord)
if(!isnull(pixel))
if(left_border > x_coord)
left_border = x_coord
x_coord++
break
x_coord++
x_coord = width
while(x_coord > 0)
var/pixel = tempicon.GetPixel(x_coord, y_coord)
if(!isnull(pixel))
if(right_border < x_coord)
right_border = x_coord
x_coord--
break
x_coord--
y_coord++
return_list["left"] = left_border
return_list["right"] = right_border

tempicon = icon(icon, icon_state, dir, 1)
height = tempicon.Height()
width = tempicon.Width()
var/bottom_border = height
var/top_border = 1
x_coord = 1
y_coord = 1
tempicon.Scale(1, height) //Squash the icon into a 1 pixel wide pillar
width = tempicon.Width()

while(x_coord <= width)
y_coord = 1
while(y_coord <= height)
var/pixel = tempicon.GetPixel(x_coord, y_coord)
if(!isnull(pixel))
if(bottom_border > y_coord)
bottom_border = y_coord
y_coord++
break
y_coord++
y_coord = height
while(y_coord > 0)
var/pixel = tempicon.GetPixel(x_coord, y_coord)
if(!isnull(pixel))
if(top_border < y_coord)
top_border = y_coord
y_coord--
break
y_coord--
x_coord++
return_list["top"] = top_border
return_list["bottom"] = bottom_border
GLOB.cached_image_borders[type] = return_list
return return_list
72 changes: 61 additions & 11 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#define FACING_EACHOTHER 2
/// Two mobs one is facing a person, but the other is perpendicular
#define FACING_INIT_FACING_TARGET_TARGET_FACING_PERPENDICULAR 3 //! Do I win the most informative but also most stupid define award?
/// Used for the image that replaces the progressbar in do_after
#define BOUNDING_BOX_WIDTH 30
#define BOUNDING_BOX_HEIGHT 25

/// Gets the client of the mob, allowing for mocking of the client.
/// You only need to use this if you know you're going to be mocking clients somewhere else.
#define GET_CLIENT(mob) (##mob.client || ##mob.mock_client)

/proc/random_blood_type()
return pick(4;"O-", 36;"O+", 3;"A-", 28;"A+", 1;"B-", 20;"B+", 1;"AB-", 5;"AB+")
Expand Down Expand Up @@ -229,23 +236,29 @@ GLOBAL_LIST_EMPTY(species_list)
*
* Checks that `user` does not move, change hands, get stunned, etc. for the
* given `delay`. Returns `TRUE` on success or `FALSE` on failure.
*
*
* Arguments:
* * user - the primary "user" of the do_after.
* * delay - how long the do_after takes. Defaults to 3 SECONDS.
* * target - the (optional) target mob of the do_after. If they move/cease to exist, the do_after is cancelled.
* * timed_action_flags - optional flags to override certain do_after checks (see DEFINES/timed_action.dm).
* * progress - if TRUE, a progress bar is displayed.
* * show_to_target - if TRUE, shows the bar and item to the target
* * extra_checks - a callback that can be used to add extra checks to the do_after. Returning false in this callback will cancel the do_after.
* * add_item - shows said item being 'filled up' instead of the progress bar
* * x_offset - moves left/right increase/decrease for the item rendered above the bar
* * y_offset - moves up/down the item rendered above the bar
*/
/proc/do_after(mob/user, delay = 3 SECONDS, atom/target, timed_action_flags = NONE, progress = TRUE, datum/callback/extra_checks)
/proc/do_after(mob/user, delay = 3 SECONDS, atom/target, timed_action_flags = NONE, progress = TRUE, show_to_target = FALSE, \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this progrss bar cancel if add_item gets deleted? I'm pretty sure appearance will count as a reference but im not entirely sure. You'll have to check DM docs

datum/callback/extra_checks, atom/add_item, x_offset = 0, y_offset = 0)
if(!user)
return FALSE

if(target)
if(target in user.do_afters) // No stacking multiple do_afters on one target by a single person
return FALSE
LAZYADD(user.do_afters, target)
LAZYADD(target.targeted_by, user)

var/atom/user_loc = user.loc
var/atom/target_loc = target?.loc

Expand All @@ -257,13 +270,51 @@ GLOBAL_LIST_EMPTY(species_list)

delay *= user.cached_multiplicative_actions_slowdown

var/left_border = 1
var/right_border = 32
var/bottom_border = 1
var/top_border = 32
var/scale = 1
if(add_item)
var/list/temp_list = add_item.get_bounding_box()
left_border = temp_list["left"]
right_border = temp_list["right"]
bottom_border = temp_list["bottom"]
top_border = temp_list["top"]
var/leftright_diff = 0
var/topbottom_diff = 0
if((right_border - left_border + 1) > BOUNDING_BOX_WIDTH)
leftright_diff = right_border - left_border + 1
if((top_border - bottom_border + 1) > BOUNDING_BOX_HEIGHT)
topbottom_diff = top_border - bottom_border + 1
if(leftright_diff != 0 || topbottom_diff != 0)
if(topbottom_diff > leftright_diff)
scale = BOUNDING_BOX_HEIGHT / top_border
else
scale = BOUNDING_BOX_WIDTH / right_border
if(y_offset + bottom_border < 7)
y_offset = 7 - bottom_border
var/client/targeted_client
if(show_to_target)
if(target == user)
show_to_target = FALSE
else if(ismob(target))
var/mob/temp_mob = target
targeted_client = temp_mob.client
if(isnull(targeted_client))
show_to_target = FALSE
else
show_to_target = FALSE
var/datum/progressbar/progbar
if(progress)
if(target) // the progress bar needs a target, so if we don't have one just pass it the user.
progbar = new(user, delay, target)
if(add_item)
//var/mutable_appearance/itemappearance = add_item.appearance
//itemappearance.color = add_item.color
//itemappearance.overlays = add_item.overlays
//itemappearance.underlays = add_item.underlays
progbar = new(user, delay, target || user, show_to_target, add_item.appearance, left_border, right_border, x_offset, y_offset, scale, targeted_client)
else
progbar = new(user, delay, user)

progbar = new(user, delay, target || user, show_to_target, targeted_client = targeted_client)
var/endtime = world.time + delay
var/starttime = world.time
. = TRUE
Expand Down Expand Up @@ -307,6 +358,7 @@ GLOBAL_LIST_EMPTY(species_list)
break

if(progress)
//progbar.end_progress()
qdel(progbar)

if(!QDELETED(target))
Expand Down Expand Up @@ -487,10 +539,6 @@ GLOBAL_LIST_EMPTY(species_list)
if(player.stat != DEAD && player.mind && is_station_level(player.z))
. |= player.mind

/// Gets the client of the mob, allowing for mocking of the client.
/// You only need to use this if you know you're going to be mocking clients somewhere else.
#define GET_CLIENT(mob) (##mob.client || ##mob.mock_client)

///Return a string for the specified body zone. Should be used for parsing non-instantiated bodyparts, otherwise use [/obj/item/bodypart/var/plaintext_zone]
/proc/parse_zone(zone)
if(zone == BODY_ZONE_PRECISE_R_HAND)
Expand Down Expand Up @@ -743,3 +791,5 @@ GLOBAL_DATUM_INIT(dview_mob, /mob/dview, new)
#undef FACING_SAME_DIR
#undef FACING_EACHOTHER
#undef FACING_INIT_FACING_TARGET_TARGET_FACING_PERPENDICULAR
#undef BOUNDING_BOX_WIDTH
#undef BOUNDING_BOX_HEIGHT
12 changes: 11 additions & 1 deletion code/datums/components/crafting/crafting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,25 @@
if(check_contents(a, R, contents))
if(check_tools(a, R, contents))
//If we're a mob we'll try a do_after; non mobs will instead instantly construct the item
if(ismob(a) && !do_after(a, R.time, target = a))
var/atom/fake_atom = new(null)
var/atom/fake_result = R.result
fake_atom.icon = initial(fake_result.icon)
fake_atom.icon_state = initial(fake_result.icon_state_preview) || initial(fake_result.icon_state)
CydiaLamiales marked this conversation as resolved.
Show resolved Hide resolved
if(ismob(a) && !do_after(a, R.time, target = a, add_item = fake_atom, x_offset = R.bar_x_offset, y_offset = R.bar_y_offset))
qdel(fake_atom)
qdel(fake_result)
EvilDragonfiend marked this conversation as resolved.
Show resolved Hide resolved
return "."
qdel(fake_atom)
qdel(fake_result)
EvilDragonfiend marked this conversation as resolved.
Show resolved Hide resolved
contents = get_surroundings(a,R.blacklist)
if(!check_contents(a, R, contents))
return ", missing component."
if(!check_tools(a, R, contents))
return ", missing tool."
var/list/parts = del_reqs(R, a)
var/atom/movable/I = new R.result (get_turf(a.loc))
I.loc = get_turf(a.loc)

I.CheckParts(parts, R)
if(send_feedback)
SSblackbox.record_feedback("tally", "object_crafted", 1, I.type)
Expand Down
5 changes: 5 additions & 0 deletions code/datums/components/crafting/recipes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
var/always_available = TRUE //Set to FALSE if it needs to be learned first.
var/one_per_turf = FALSE ///Should only one object exist on the same turf?
var/dangerous_craft = FALSE /// Should admins be notified about this getting created by a non-antagonist?
var/bar_x_offset = 0
var/bar_y_offset = 0

/datum/crafting_recipe/New()
if(!(result in reqs))
Expand Down Expand Up @@ -221,6 +223,8 @@
/obj/item/bodypart/r_arm/robot = 1)
time = 40
category = CAT_ROBOT
bar_x_offset = -5
bar_y_offset = 5

/datum/crafting_recipe/honkbot
name = "Honkbot"
Expand Down Expand Up @@ -819,6 +823,7 @@
reqs = list(/obj/item/grown/log = 5)
result = /obj/structure/bonfire
category = CAT_PRIMAL
bar_x_offset = 5

/datum/crafting_recipe/skeleton_key
name = "Skeleton Key"
Expand Down
5 changes: 3 additions & 2 deletions code/datums/elements/mechanical_repair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
if((!affecting || (IS_ORGANIC_LIMB(affecting))) || user.a_intent == INTENT_HARM)
return

//can only do one progress bar at a time
if(target in user.do_afters)
return COMPONENT_NO_AFTERATTACK

Expand All @@ -31,7 +32,7 @@
if(user == target)
user.visible_message("<span class='notice'>[user] starts to fix some of the dents on [target == user ? "[p_their()]" : "[target]'s"] [parse_zone(affecting.body_zone)].</span>",
"<span class='notice'>You start fixing some of the dents on [target == user ? "your" : "[target]'s"] [parse_zone(affecting.body_zone)].</span>")
if(!do_after(user, 1.5 SECONDS, target))
if(!do_after(user, 1.5 SECONDS, target, show_to_target = TRUE, add_item = I))
return COMPONENT_NO_AFTERATTACK
item_heal_robotic(target, user, 15, 0, affecting)
user.changeNext_move(CLICK_CD_MELEE * 0.5) //antispam
Expand All @@ -43,7 +44,7 @@
if(user == target)
user.visible_message("<span class='notice'>[user] starts to fix some of the burn wires in [target == user ? "[p_their()]" : "[target]'s"] [parse_zone(affecting.body_zone)].</span>",
"<span class='notice'>You start fixing some of the burnt wires in [target == user ? "your" : "[target]'s"] [parse_zone(affecting.body_zone)].</span>")
if(!do_after(user, 1.5 SECONDS, target))
if(!do_after(user, 1.5 SECONDS, target, show_to_target = TRUE, add_item = coil))
return COMPONENT_NO_AFTERATTACK
if(coil.amount && item_heal_robotic(target, user, 0, 15, affecting))
coil.use(1)
Expand Down
8 changes: 5 additions & 3 deletions code/datums/elements/strippable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@

if(HAS_TRAIT(item, TRAIT_NO_STRIP))
return FALSE

if(source in user.do_afters)
to_chat(user, "<span class='warning'>You're already stripping [source]!</span>")
return FALSE
source.visible_message(
"<span class='warning'>[user] tries to remove [source]'s [item.name].</span>",
"<span class='userdanger'>[user] tries to remove your [item.name].</span>",
Expand Down Expand Up @@ -245,7 +247,7 @@
if(!ismob(source))
return FALSE

if(!do_after(user, get_equip_delay(equipping), source))
if(!do_after(user, get_equip_delay(equipping), source, show_to_target = TRUE, add_item = equipping))
return FALSE

if(!equipping.mob_can_equip(
Expand Down Expand Up @@ -310,7 +312,7 @@

/// A utility function for `/datum/strippable_item`s to start unequipping an item from a mob.
/proc/start_unequip_mob(obj/item/item, mob/source, mob/user, strip_delay)
if(!do_after(user, strip_delay || item.strip_delay, source))
if(!do_after(user, strip_delay || item.strip_delay, source, show_to_target = TRUE, add_item = item))
return FALSE

return TRUE
Expand Down
Loading