From 08da2260a0ff4e343f905ce0a534c35bf9d98818 Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Mon, 28 Mar 2016 04:24:26 -0400 Subject: [PATCH] Ports tg's smooth progress bars --- code/__DEFINES/misc.dm | 4 +- code/__HELPERS/mobs.dm | 94 ++++++++++++++++++ code/__HELPERS/unsorted.dm | 89 ----------------- code/datums/progressbar.dm | 42 ++++++++ .../gamemodes/miniantags/revenant/revenant.dm | 8 +- code/game/objects/structures/watercloset.dm | 2 +- code/modules/mob/living/say.dm | 8 +- .../simple_animal/hostile/spaceworms.dm | 2 +- code/modules/paperwork/paper.dm | 2 +- icons/effects/doafter_icon.dmi | Bin 913 -> 0 bytes icons/effects/progessbar.dmi | Bin 0 -> 571 bytes paradise.dme | 1 + 12 files changed, 153 insertions(+), 99 deletions(-) create mode 100644 code/datums/progressbar.dm delete mode 100644 icons/effects/doafter_icon.dmi create mode 100644 icons/effects/progessbar.dmi diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index bfe7c5fcd9d..5516dadfa6d 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -180,4 +180,6 @@ #define TURF_DRY 0 #define TURF_WET_WATER 1 #define TURF_WET_LUBE 2 -#define TURF_WET_ICE 3 \ No newline at end of file +#define TURF_WET_ICE 3 + +#define APPEARANCE_UI_IGNORE_ALPHA RESET_COLOR|RESET_TRANSFORM|NO_CLIENT_COLOR|RESET_ALPHA \ No newline at end of file diff --git a/code/__HELPERS/mobs.dm b/code/__HELPERS/mobs.dm index 001f2b148ce..f8980d61ddd 100644 --- a/code/__HELPERS/mobs.dm +++ b/code/__HELPERS/mobs.dm @@ -162,3 +162,97 @@ proc/add_logs(mob/target, mob/user, what_done, var/object=null, var/addition=nul if(!admin) return msg_admin_attack("[key_name_admin(user)] [what_done] [key_name_admin(target)][object ? " with [object]" : " "][addition]") +/proc/do_mob(var/mob/user, var/mob/target, var/time = 30, var/uninterruptible = 0, progress = 1) + if(!user || !target) + return 0 + var/user_loc = user.loc + + var/drifting = 0 + if(!user.Process_Spacemove(0) && user.inertia_dir) + drifting = 1 + + var/target_loc = target.loc + + var/holding = user.get_active_hand() + var/datum/progressbar/progbar + if (progress) + progbar = new(user, time, target) + + var/endtime = world.time+time + var/starttime = world.time + . = 1 + while (world.time < endtime) + sleep(1) + if (progress) + progbar.update(world.time - starttime) + if(!user || !target) + . = 0 + break + if(uninterruptible) + continue + + if(drifting && !user.inertia_dir) + drifting = 0 + user_loc = user.loc + + if((!drifting && user.loc != user_loc) || target.loc != target_loc || user.get_active_hand() != holding || user.incapacitated() || user.lying ) + . = 0 + break + if (progress) + qdel(progbar) + +/proc/do_after(mob/user, delay, needhand = 1, atom/target = null, progress = 1) + if(!user) + return 0 + var/atom/Tloc = null + if(target) + Tloc = target.loc + + var/atom/Uloc = user.loc + + var/drifting = 0 + if(!user.Process_Spacemove(0) && user.inertia_dir) + drifting = 1 + + var/holding = user.get_active_hand() + + var/holdingnull = 1 //User's hand started out empty, check for an empty hand + if(holding) + holdingnull = 0 //Users hand started holding something, check to see if it's still holding that + + var/datum/progressbar/progbar + if (progress) + progbar = new(user, delay, target) + + var/endtime = world.time + delay + var/starttime = world.time + . = 1 + while (world.time < endtime) + sleep(1) + if (progress) + progbar.update(world.time - starttime) + + if(drifting && !user.inertia_dir) + drifting = 0 + Uloc = user.loc + + if(!user || user.stat || user.weakened || user.stunned || (!drifting && user.loc != Uloc)) + . = 0 + break + + if(Tloc && (!target || Tloc != target.loc)) + . = 0 + break + + if(needhand) + //This might seem like an odd check, but you can still need a hand even when it's empty + //i.e the hand is used to pull some item/tool out of the construction + if(!holdingnull) + if(!holding) + . = 0 + break + if(user.get_active_hand() != holding) + . = 0 + break + if (progress) + qdel(progbar) \ No newline at end of file diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index 6d3ad3f365e..0c99ec12416 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -601,95 +601,6 @@ proc/anim(turf/location as turf,target as mob|obj,a_icon,a_icon_state as text,fl else return get_step(ref, base_dir) -/proc/do_mob(var/mob/user , var/mob/target, var/time = 30, numticks = 5, var/uninterruptible = 0) //This is quite an ugly solution but i refuse to use the old request system. - if(!user || !target) - return 0 - if(numticks == 0) - return 0 - var/user_loc = user.loc - var/target_loc = target.loc - var/holding = user.get_active_hand() - var/timefraction = round(time/numticks) - var/image/progbar - for(var/i = 1 to numticks) - if(user.client) - progbar = make_progress_bar(i, numticks, target) - user.client.images |= progbar - sleep(timefraction) - if(!user || !target) - if(user && user.client) - user.client.images -= progbar - return 0 - if (!uninterruptible && (user.loc != user_loc || target.loc != target_loc || user.get_active_hand() != holding || user.stat || user.stunned || user.weakened || user.paralysis || user.lying)) - if(user && user.client) - user.client.images -= progbar - return 0 - if(user && user.client) - user.client.images -= progbar - if(user && user.client) - user.client.images -= progbar - return 1 - -/proc/make_progress_bar(var/current_number, var/goal_number, var/atom/target) - if(current_number && goal_number && target) - var/image/progbar - progbar = image("icon" = 'icons/effects/doafter_icon.dmi', "loc" = target, "icon_state" = "prog_bar_0") - progbar.icon_state = "prog_bar_[round(((current_number / goal_number) * 100), 10)]" - progbar.pixel_y = 32 - return progbar - -/proc/do_after(mob/user, delay, numticks = 5, needhand = 1, atom/target = null) - if(!user) - return 0 - - if(numticks == 0) - return 0 - - var/atom/Tloc = null - if(target) - Tloc = target.loc - - var/delayfraction = round(delay/numticks) - var/atom/Uloc = user.loc - var/holding = user.get_active_hand() - var/holdingnull = 1 //User is not holding anything - if(holding) - holdingnull = 0 //User is holding a tool of some kind - var/image/progbar - for (var/i = 1 to numticks) - if(user.client) - progbar = make_progress_bar(i, numticks, target) - user.client.images |= progbar - sleep(delayfraction) - if(!user || user.stat || user.weakened || user.stunned || !(user.loc == Uloc)) - if(user && user.client) - user.client.images -= progbar - return 0 - - if(Tloc && (!target || Tloc != target.loc)) //Tloc not set when we don't want to track target - if(user && user.client) - user.client.images -= progbar - return 0 // Target no longer exists or has moved - - if(needhand) - //This might seem like an odd check, but you can still need a hand even when it's empty - //i.e the hand is used to insert some item/tool into the construction - if(!holdingnull) - if(!holding) - if(user && user.client) - user.client.images -= progbar - return 0 - if(user.get_active_hand() != holding) - if(user && user.client) - user.client.images -= progbar - return 0 - if(user && user.client) - user.client.images -= progbar - if(user && user.client) - user.client.images -= progbar - if(user && user.client) - user.client.images -= progbar - return 1 //Takes: Anything that could possibly have variables and a varname to check. //Returns: 1 if found, 0 if not. /proc/hasvar(var/datum/A, var/varname) diff --git a/code/datums/progressbar.dm b/code/datums/progressbar.dm new file mode 100644 index 00000000000..ebf7aa3938d --- /dev/null +++ b/code/datums/progressbar.dm @@ -0,0 +1,42 @@ +/datum/progressbar + var/goal = 1 + var/image/bar + var/shown = 0 + var/mob/user + var/client/client + +/datum/progressbar/New(mob/User, goal_number, atom/target) + . = ..() + if (!istype(target)) + EXCEPTION("Invalid target given") + if (goal_number) + goal = goal_number + bar = image('icons/effects/progessbar.dmi', target, "prog_bar_0") + bar.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA + bar.pixel_y = 32 + user = User + if(user) + client = user.client + +/datum/progressbar/proc/update(progress) + //world << "Update [progress] - [goal] - [(progress / goal)] - [((progress / goal) * 100)] - [round(((progress / goal) * 100), 5)]" + if (!user || !user.client) + shown = 0 + return + if (user.client != client) + if (client) + client.images -= bar + if (user.client) + user.client.images += bar + + progress = Clamp(progress, 0, goal) + bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]" + if (!shown) + user.client.images += bar + shown = 1 + +/datum/progressbar/Destroy() + if (client) + client.images -= bar + qdel(bar) + . = ..() \ No newline at end of file diff --git a/code/game/gamemodes/miniantags/revenant/revenant.dm b/code/game/gamemodes/miniantags/revenant/revenant.dm index ba01a996b8c..784f96b9df2 100644 --- a/code/game/gamemodes/miniantags/revenant/revenant.dm +++ b/code/game/gamemodes/miniantags/revenant/revenant.dm @@ -129,7 +129,7 @@ draining = 1 essence_drained = rand(15, 20) src << "You search for the soul of [target]." - if(do_after(src, 10, 3, 0, target = target)) //did they get deleted in that second? + if(do_after(src, 10, 0, target = target)) //did they get deleted in that second? if(target.ckey) src << "Their soul burns with intelligence." essence_drained += rand(20, 30) @@ -138,7 +138,7 @@ essence_drained += rand(40, 50) else src << "Their soul is weak and faltering." - if(do_after(src, 20, 6, 0, target = target)) //did they get deleted NOW? + if(do_after(src, 20, 0, target = target)) //did they get deleted NOW? switch(essence_drained) if(1 to 30) src << "[target] will not yield much essence. Still, every bit counts." @@ -148,7 +148,7 @@ src << "Such a feast! [target] will yield much essence to you." if(90 to INFINITY) src << "Ah, the perfect soul. [target] will yield massive amounts of essence to you." - if(do_after(src, 20, 6, 0, target = target)) //how about now + if(do_after(src, 20, 0, target = target)) //how about now if(!target.stat) src << "They are now powerful enough to fight off your draining." target << "You feel something tugging across your body before subsiding." @@ -162,7 +162,7 @@ stun(27) target.visible_message("[target] suddenly rises slightly into the air, their skin turning an ashy gray.") target.Beam(src,icon_state="drain_life",icon='icons/effects/effects.dmi',time=26) - if(do_after(src, 30, 9, 0, target)) //As one cannot prove the existance of ghosts, ghosts cannot prove the existance of the target they were draining. + if(do_after(src, 30, 0, target)) //As one cannot prove the existance of ghosts, ghosts cannot prove the existance of the target they were draining. change_essence_amount(essence_drained, 0, target) if(essence_drained > 90) essence_regen_cap += 25 diff --git a/code/game/objects/structures/watercloset.dm b/code/game/objects/structures/watercloset.dm index cc73a42f0d0..b322a84de5b 100644 --- a/code/game/objects/structures/watercloset.dm +++ b/code/game/objects/structures/watercloset.dm @@ -82,7 +82,7 @@ if(open) GM.visible_message("[user] starts to give [GM] a swirlie!", "[user] starts to give [GM] a swirlie...") swirlie = GM - if(do_after(user, 30, 5, 0, target = src)) + if(do_after(user, 30, 0, target = src)) GM.visible_message("[user] gives [GM] a swirlie!", "[user] gives [GM] a swirlie!", "You hear a toilet flushing.") if(iscarbon(GM)) var/mob/living/carbon/C = GM diff --git a/code/modules/mob/living/say.dm b/code/modules/mob/living/say.dm index daa0f9571fc..6f40c678432 100644 --- a/code/modules/mob/living/say.dm +++ b/code/modules/mob/living/say.dm @@ -430,7 +430,9 @@ proc/get_radio_key_from_channel(var/channel) speech_bubble_recipients.Add(M.client) spawn(0) - flick_overlay(image('icons/mob/talk.dmi', src, "h[speech_bubble_test]",MOB_LAYER+1), speech_bubble_recipients, 30) + var/image/I = image('icons/mob/talk.dmi', src, "h[speech_bubble_test]", MOB_LAYER + 1) + I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA + flick_overlay(I, speech_bubble_recipients, 30) if(watching.len) var/rendered = "[src.name] [not_heard]." @@ -441,4 +443,6 @@ proc/get_radio_key_from_channel(var/channel) return 1 /mob/living/speech_bubble(var/bubble_state = "",var/bubble_loc = src, var/list/bubble_recipients = list()) - flick_overlay(image('icons/mob/talk.dmi', bubble_loc, bubble_state,MOB_LAYER+1), bubble_recipients, 30) \ No newline at end of file + var/image/I = image('icons/mob/talk.dmi', bubble_loc, bubble_state, MOB_LAYER + 1) + I.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA + flick_overlay(, bubble_recipients, 30) \ No newline at end of file diff --git a/code/modules/mob/living/simple_animal/hostile/spaceworms.dm b/code/modules/mob/living/simple_animal/hostile/spaceworms.dm index f07b2ed1794..2f477b45482 100644 --- a/code/modules/mob/living/simple_animal/hostile/spaceworms.dm +++ b/code/modules/mob/living/simple_animal/hostile/spaceworms.dm @@ -165,7 +165,7 @@ src.visible_message("\the [src] starts to eat \the [noms]!","You start to eat \the [noms]. (This will take about [ufnomDelay] seconds.)","You hear gnashing.") //inform everyone what the fucking worm is doing. - if(do_after(src, nomDelay,5,0, target = noms)) + if(do_after(src, nomDelay, 0, target = noms)) if(noms && Adjacent(noms) && (currentlyEating == noms))//It exists, were next to it, and it's still the thing were eating if(W) W.ChangeTurf(/turf/simulated/floor/plating) diff --git a/code/modules/paperwork/paper.dm b/code/modules/paperwork/paper.dm index 98c50af7dad..635d8f1bd8e 100644 --- a/code/modules/paperwork/paper.dm +++ b/code/modules/paperwork/paper.dm @@ -131,7 +131,7 @@ else user.visible_message("[user] begins to wipe [H]'s face clean with \the [src].", \ "You begin to wipe off [H]'s face.") - if(do_after(user, 10, target = H) && do_after(H, 10, 5, 0)) //user needs to keep their active hand, H does not. + if(do_after(user, 10, target = H) && do_after(H, 10, 0)) //user needs to keep their active hand, H does not. user.visible_message("[user] wipes [H]'s face clean with \the [src].", \ "You wipe off [H]'s face.") H.lip_style = null diff --git a/icons/effects/doafter_icon.dmi b/icons/effects/doafter_icon.dmi deleted file mode 100644 index 9fce3af3353eb8ee2f842951e2ca5e7784ac648b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 913 zcmeAS@N?(olHy`uVBq!ia0vp^4M3d0!3HF+R#kZdsfkq~5hX6E#mPmP1tppJc?=8{ zbArPPib}tK2`>2f^@*0ZuGYCT=Yuzd8eBAf@JQ#pkLF2+qMqIz7REuwmyNv?<~*8o zWKxJi@X7@m_O^DK8#V4Zbaor7ZeAgwk#XYa%&;jlW^*MbYniHe>T-7VdIV(qG(`yu zU70m$!L=TitXFB%CDpN9J16((6AN*L`BX5!Jah-to19%tMD9R_={n$*FwY zs#!Wo$DZ7sdzbU%d(HmT|L@P(%{-&KXY#wx*W;}%Vyc!kFeor^Ffb9M8vY7BxcT_D z{VWda+K(G|pDq1#`}F&zhx+sHos#fS{GR{d$rbS`|1)Z)mH(L>xb&m`N^Aa=AJxAzY`&@Unk8m;m2JsigJRi-e-iIK z{eE{zaOR(#^W3xkcrvmzJ6_|QQNNob*8XgayG4CeS+UvKKQ=*+-!I*#KkElySIqAh z=jQ);(0qF8{)kQGNq@Yv&N*xC-=4R8#|<49u5&xNr`^x1TYql9wy)y;y*2txd@@V| z3@i+c4h#gS1OGS|*x&!j@ar@G-!-}W!@T6y&5__1~BM!gF7MP4jo#%JywwwyZL9^PtN~S?&t0a`K$`eV+@|I KelF{r5}E*Oo1sAf diff --git a/icons/effects/progessbar.dmi b/icons/effects/progessbar.dmi new file mode 100644 index 0000000000000000000000000000000000000000..99284060aa60676fcf3dc85db670633d6c262f5f GIT binary patch literal 571 zcmV-B0>u4^P)005u_0{{R3dEt5<0000gP)t-skE-z! z5)>{hG&VIm%m6bYAt(O;Gt6c)|CuuY%rgN0Gc#uYW|{wws`1a*B7Oh>00DGTPE!Ct z=GbNc006LhR9JLGWpiV4X>fFDZ*Bkpc$}5fy$ZrG6b0Zpd5X~P(){#qaFG`2U|*p` z8k-EYk_3HygB?ZiZ0BAs-*P!QJN4&bWZh+;Pve8z?(E3ap`hgD=4jI(1tr$F#m0RI zQAd+v_VC*>UA3QzjFQ>;kd~a1o7bz^^Y>}_|0xGp4!8nv1>j1+m4K@NR{?H`ybW+G zz^wqc2HYBO8^CPcvkuXZ_fHy8H$=bs4s(5=rj>009F@L_t(&f$i3@4T3-z zhT(GqaRXez5o85NkOeGm0+Z{l7{G?slG=`;j2`*H&(hxz%=>h2av>Ke_(A{x0RL=N zn6*cTVrvSI4x61RU%i*EwD;20TZhfT7;$0?nCbzvJU|Oz>F5K52MYgyr!C`i*%!Xk#5F) zm~8On1MSmQy4Ai)x8pwaz9IV%007Kr0sFAAIhEH`H_*OGciOjM&b2o9@_~M!eV6XF z@8xf9$UX!B05fv`^M7oUZ;k7zD}5el`>uC-p!W^k-=XhUegMJ