Skip to content

Commit

Permalink
Cogbar Port (#2899)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
Do_afters have no visual feedback for nearby people, which is bad (and
leads to a lot of unintentional interruptions)

This adds a visual indicator in the form of a spinning cog that displays
to nearby players while you do a Do_after()
Ports [This Guy](tgstation/tgstation#82416) and
assorted. Thanks @jlsnow301
(plus some assorted stuff)

Implements it on do_mob()'s(which tg rightfully decided to kill.)
Some of our equip handling code makes me want to explode, but that's a
problem for another day
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
Action feedback 4 nearby players, less accidental tileswaps
<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog 

:cl: jlsnow301, sun-soaked
add: do_afters and do_mob actions now show nearby players a spinning cog
while in progress.
fix: the progressbar.dmm file is no longer misspelled "progess"bar
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->

---------

Co-authored-by: Sun-Soaked <[email protected]>
  • Loading branch information
Sun-Soaked and Sun-Soaked authored Apr 19, 2024
1 parent c4a58c8 commit 8407cfb
Show file tree
Hide file tree
Showing 17 changed files with 122 additions and 21 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
#define CAMERA_STATIC_LAYER 19
#define CAMERA_STATIC_RENDER_TARGET "CAMERA_STATIC_PLANE"

///Wants to be part of the game plane, but also wants to draw above literally everything else
#define HIGH_GAME_PLANE 30

//HUD layer defines

#define FULLSCREEN_PLANE 31
Expand Down
15 changes: 12 additions & 3 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ GLOBAL_LIST_EMPTY(species_list)
return "unknown"

///Timed action involving two mobs, the user and the target.
/proc/do_mob(mob/user , mob/target, time = 3 SECONDS, uninterruptible = FALSE, progress = TRUE, datum/callback/extra_checks = null, ignore_loc_change = FALSE)
/proc/do_mob(mob/user , mob/target, time = 3 SECONDS, uninterruptible = FALSE, progress = TRUE, datum/callback/extra_checks = null, ignore_loc_change = FALSE, hidden = FALSE)
if(!user || !target)
return FALSE

Expand All @@ -262,8 +262,11 @@ GLOBAL_LIST_EMPTY(species_list)
LAZYADD(target.targeted_by, user)
var/holding = user.get_active_held_item()
var/datum/progressbar/progbar
var/datum/cogbar/cog
if (progress)
progbar = new(user, time, target)
if(!hidden && time >= 1 SECONDS)
cog = new(user)

var/endtime = world.time+time
var/starttime = world.time
Expand Down Expand Up @@ -292,6 +295,8 @@ GLOBAL_LIST_EMPTY(species_list)
break
if(!QDELETED(progbar))
progbar.end_progress()

cog?.remove()
if(!QDELETED(target))
LAZYREMOVE(user.do_afters, target)
LAZYREMOVE(target.targeted_by, user)
Expand All @@ -311,7 +316,7 @@ GLOBAL_LIST_EMPTY(species_list)
return ..()

///Timed action involving one mob user. Target is optional.
/proc/do_after(mob/user, delay, needhand = TRUE, atom/target = null, progress = TRUE, datum/callback/extra_checks = null)
/proc/do_after(mob/user, delay, needhand = TRUE, atom/target = null, progress = TRUE, datum/callback/extra_checks = null, hidden = FALSE)
if(!user)
return FALSE

Expand Down Expand Up @@ -342,9 +347,11 @@ GLOBAL_LIST_EMPTY(species_list)
delay *= user.do_after_coefficent()

var/datum/progressbar/progbar
var/datum/cogbar/cog
if(progress)
progbar = new(user, delay, target || user)

if(!hidden && delay >= 1 SECONDS)
cog = new(user)
var/endtime = world.time + delay
var/starttime = world.time
. = TRUE
Expand Down Expand Up @@ -389,6 +396,8 @@ GLOBAL_LIST_EMPTY(species_list)
if(!QDELETED(progbar))
progbar.end_progress()

cog?.remove()

if(!QDELETED(target))
LAZYREMOVE(user.do_afters, target)
LAZYREMOVE(target.targeted_by, user)
Expand Down
88 changes: 88 additions & 0 deletions code/datums/cogbar.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#define COGBAR_ANIMATION_TIME (0.5 SECONDS)

/**
* ### Cogbar
* Represents that the user is busy doing something.
*/
/datum/cogbar
/// Who's doing the thing
var/mob/user
/// The user client
var/client/user_client
/// The visible element to other players
var/obj/effect/overlay/vis/cog
/// The blank image that overlaps the cog - hides it from the source user
var/image/blank
/// The offset of the icon
//var/offset_y


/datum/cogbar/New(mob/user)
src.user = user
src.user_client = user.client

//Porting oversized icon offsets later, they have too many other unported dependencies. sorry zephyr
//var/list/icon_offsets = user.get_oversized_icon_offsets()
//offset_y = icon_offsets["y"]

add_cog_to_user()

RegisterSignal(user, COMSIG_PARENT_QDELETING, PROC_REF(on_user_delete))


/datum/cogbar/Destroy()
if(user)
SSvis_overlays.remove_vis_overlay(user, user.managed_vis_overlays)
user_client?.images -= blank

user = null
user_client = null
cog = null
QDEL_NULL(blank)

return ..()


/// Adds the cog to the user, visible by other players
/datum/cogbar/proc/add_cog_to_user()
cog = SSvis_overlays.add_vis_overlay(user,
icon = 'icons/effects/progressbar.dmi',
iconstate = "cog",
plane = HIGH_GAME_PLANE,
add_appearance_flags = APPEARANCE_UI_IGNORE_ALPHA,
unique = TRUE,
alpha = 0,
)
cog.pixel_y = world.icon_size// + offset_y
animate(cog, alpha = 255, time = COGBAR_ANIMATION_TIME)

if(isnull(user_client))
return

blank = image('icons/blanks/32x32.dmi', cog, "nothing")
blank.plane = HIGH_GAME_PLANE
blank.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
blank.override = TRUE

user_client.images += blank


/// Removes the cog from the user
/datum/cogbar/proc/remove()
if(isnull(cog))
qdel(src)
return

animate(cog, alpha = 0, time = COGBAR_ANIMATION_TIME)

QDEL_IN(src, COGBAR_ANIMATION_TIME)


/// When the user is deleted, remove the cog
/datum/cogbar/proc/on_user_delete(datum/source)
SIGNAL_HANDLER

qdel(src)


#undef COGBAR_ANIMATION_TIME
2 changes: 1 addition & 1 deletion code/datums/progressbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
return
goal = goal_number
bar_loc = target
bar = image('icons/effects/progessbar.dmi', bar_loc, "prog_bar_0", HUD_LAYER)
bar = image('icons/effects/progressbar.dmi', bar_loc, "prog_bar_0", HUD_LAYER)
bar.plane = ABOVE_HUD_PLANE
bar.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
user = User
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/beds_chairs/alien_nest.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
M.visible_message("<span class='warning'>[M.name] struggles to break free from the gelatinous resin!</span>",\
"<span class='notice'>You struggle to break free from the gelatinous resin... (Stay still for two minutes.)</span>",\
"<span class='hear'>You hear squelching...</span>")
if(!do_after(M, 1200, target = src))
if(!do_after(M, 1200, target = src, hidden = TRUE))
if(M && M.buckled)
to_chat(M, "<span class='warning'>You fail to unbuckle yourself!</span>")
return
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/structures/kitchen_spike.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
"<span class='notice'>You struggle to break free from [src], exacerbating your wounds! (Stay still for two minutes.)</span>",\
"<span class='hear'>You hear a wet squishing noise..</span>")
M.adjustBruteLoss(30)
if(!do_after(M, 1200, target = src))
if(!do_after(M, 1200, target = src, hidden = TRUE))
if(M && M.buckled)
to_chat(M, "<span class='warning'>You fail to free yourself!</span>")
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/nukeop/equipment/borgchameleon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
to_chat(user, "<span class='notice'>You activate \the [src].</span>")
playsound(src, 'sound/effects/seedling_chargeup.ogg', 100, TRUE, -6)
apply_wibbly_filters(user)
if (do_after(user, 50, target=user) && user.cell.use(activationCost))
if (do_after(user, 50, target=user, hidden = TRUE) && user.cell.use(activationCost))
playsound(src, 'sound/effects/bamf.ogg', 100, TRUE, -6)
to_chat(user, "<span class='notice'>You are now disguised as the Nanotrasen engineering borg \"[friendlyName]\".</span>")
activate(user)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/nukeop/equipment/nuclearbomb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
if(istype(I, /obj/item/nuke_core_container))
var/obj/item/nuke_core_container/core_box = I
to_chat(user, "<span class='notice'>You start loading the plutonium core into [core_box]...</span>")
if(do_after(user,50,target=src))
if(do_after(user,50,target=src, hidden = TRUE))
if(core_box.load(core, user))
to_chat(user, "<span class='notice'>You load the plutonium core into [core_box].</span>")
deconstruction_state = NUKESTATE_CORE_REMOVED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
user.visible_message("<span class='notice'>You see [user] kicking against the glass of [src]!</span>", \
"<span class='notice'>You struggle inside [src], kicking the release with your foot... (this will take about [DisplayTimeText(breakout_time)].)</span>", \
"<span class='hear'>You hear a thump from [src].</span>")
if(do_after(user, breakout_time, target = src))
if(do_after(user, breakout_time, target = src, hidden = TRUE))
if(!user || user.stat != CONSCIOUS || user.loc != src)
return
user.visible_message("<span class='warning'>[user] successfully broke out of [src]!</span>", \
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/shoes/_shoes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
if(HAS_TRAIT(user, TRAIT_CLUMSY)) // based clowns trained their whole lives for this
mod_time *= 0.75

if(do_after(user, mod_time, needhand=TRUE, target=our_guy, extra_checks=CALLBACK(src, PROC_REF(still_shoed), our_guy)))
if(do_after(user, mod_time, needhand=TRUE, target=our_guy, extra_checks=CALLBACK(src, PROC_REF(still_shoed), our_guy), hidden = TRUE))
to_chat(user, "<span class='notice'>You [tied ? "untie" : "knot"] the laces on [loc]'s [src.name].</span>")
if(tied == SHOES_UNTIED)
adjust_laces(SHOES_KNOTTED, user)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@
buckle_cd = O.breakouttime
visible_message("<span class='warning'>[src] attempts to unbuckle [p_them()]self!</span>", \
"<span class='notice'>You attempt to unbuckle yourself... (This will take around [round(buckle_cd/600,1)] minute\s, and you need to stay still.)</span>")
if(do_after(src, buckle_cd, 0, target = src))
if(do_after(src, buckle_cd, 0, target = src, hidden = TRUE))
if(!buckled)
return
buckled.user_unbuckle_mob(src,src)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
else
return

if(do_mob(usr, src, POCKET_STRIP_DELAY/delay_denominator)) //placing an item into the pocket is 4 times faster
if(do_mob(usr, src, POCKET_STRIP_DELAY/delay_denominator, hidden = TRUE)) //placing an item into the pocket is 4 times faster
if(pocket_item)
if(pocket_item == (pocket_id == ITEM_SLOT_RPOCKET ? r_store : l_store)) //item still in the pocket we search
dropItemToGround(pocket_item)
Expand Down
16 changes: 8 additions & 8 deletions code/modules/ninja/suit/ninjaDrainAct.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ They *could* go in their appropriate files, but this is supposed to be modular
drain = S.cell.maxcharge - S.cell.charge
maxcapacity = 1//Reached maximum battery capacity.

if (do_after(H,10, target = src))
if (do_after(H,10, target = src, hidden = TRUE))
spark_system.start()
playsound(loc, "sparks", 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
cell.use(drain)
Expand Down Expand Up @@ -85,7 +85,7 @@ They *could* go in their appropriate files, but this is supposed to be modular
drain = S.cell.maxcharge - S.cell.charge
maxcapacity = 1

if (do_after(H,10, target = src))
if (do_after(H,10, target = src, hidden = TRUE))
spark_system.start()
playsound(loc, "sparks", 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
charge -= drain
Expand All @@ -104,7 +104,7 @@ They *could* go in their appropriate files, but this is supposed to be modular
. = 0

if(charge)
if(G.candrain && do_after(H,30, target = src))
if(G.candrain && do_after(H,30, target = src, hidden = TRUE))
. = charge
if(S.cell.charge + charge > S.cell.maxcharge)
S.cell.charge = S.cell.maxcharge
Expand All @@ -131,7 +131,7 @@ They *could* go in their appropriate files, but this is supposed to be modular

if(stored_research)
to_chat(H, "<span class='notice'>Copying files...</span>")
if(do_after(H, S.s_delay, target = src) && G.candrain && src)
if(do_after(H, S.s_delay, target = src, hidden = TRUE) && G.candrain && src)
stored_research.copy_research_to(S.stored_research)
to_chat(H, "<span class='notice'>Data analyzed. Process finished.</span>")

Expand All @@ -148,7 +148,7 @@ They *could* go in their appropriate files, but this is supposed to be modular

if(stored_research)
to_chat(H, "<span class='notice'>Copying files...</span>")
if(do_after(H, S.s_delay, target = src) && G.candrain && src)
if(do_after(H, S.s_delay, target = src, hidden = TRUE) && G.candrain && src)
stored_research.copy_research_to(S.stored_research)
to_chat(H, "<span class='notice'>Data analyzed. Process finished.</span>")

Expand All @@ -167,7 +167,7 @@ They *could* go in their appropriate files, but this is supposed to be modular
while(G.candrain && !maxcapacity && src)
drain = (round((rand(G.mindrain, G.maxdrain))/2))
var/drained = 0
if(PN && do_after(H,10, target = src))
if(PN && do_after(H,10, target = src, hidden = TRUE))
drained = min(drain, delayed_surplus())
add_delayedload(drained)
if(drained < drain)//if no power on net, drain apcs
Expand Down Expand Up @@ -207,7 +207,7 @@ They *could* go in their appropriate files, but this is supposed to be modular
if(S.cell.charge + drain > S.cell.maxcharge)
drain = S.cell.maxcharge - S.cell.charge
maxcapacity = 1
if (do_after(H,10, target = src))
if (do_after(H,10, target = src, hidden = TRUE))
spark_system.start()
playsound(loc, "sparks", 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
cell.use(drain)
Expand Down Expand Up @@ -235,7 +235,7 @@ They *could* go in their appropriate files, but this is supposed to be modular
if(S.cell.charge+drain > S.cell.maxcharge)
drain = S.cell.maxcharge - S.cell.charge
maxcapacity = 1
if (do_after(H,10))
if (do_after(H,10, hidden = TRUE))
spark_system.start()
playsound(loc, "sparks", 50, TRUE, SHORT_RANGE_SOUND_EXTRARANGE)
cell.use(drain)
Expand Down
Binary file removed icons/effects/progessbar.dmi
Binary file not shown.
Binary file added icons/effects/progressbar.dmi
Binary file not shown.
1 change: 1 addition & 0 deletions shiptest.dme
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@
#include "code\datums\changelog.dm"
#include "code\datums\chatmessage.dm"
#include "code\datums\cinematic.dm"
#include "code\datums\cogbar.dm"
#include "code\datums\dash_weapon.dm"
#include "code\datums\datacore.dm"
#include "code\datums\datum.dm"
Expand Down
2 changes: 1 addition & 1 deletion tgui/packages/tgui/interfaces/Cloner.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Cloner = (props, context) => {
beakerContents={data.beakerContents}
/>
</Section>
<Section title="Progess" minheight="50px">
<Section title="Progress" minheight="50px">
<ProgressBar
value={data.progress}
content={data.progress + '%'}
Expand Down

0 comments on commit 8407cfb

Please sign in to comment.