diff --git a/code/datums/progressbar.dm b/code/datums/progressbar.dm index 559118c5be7..ec8cda24eb3 100644 --- a/code/datums/progressbar.dm +++ b/code/datums/progressbar.dm @@ -1,9 +1,12 @@ +#define PROGRESSBAR_HEIGHT 6 + /datum/progressbar var/goal = 1 var/image/bar var/shown = 0 var/mob/user var/client/client + var/listindex /datum/progressbar/New(mob/User, goal_number, atom/target) . = ..() @@ -11,13 +14,20 @@ EXCEPTION("Invalid target given") if (goal_number) goal = goal_number - bar = image('icons/effects/progessbar.dmi', target, "prog_bar_0") + bar = image('icons/effects/progessbar.dmi', target, "prog_bar_0", HUD_LAYER) + bar.plane = HUD_PLANE bar.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA - bar.pixel_y = 32 user = User if(user) client = user.client + LAZYINITLIST(user.progressbars) + LAZYINITLIST(user.progressbars[bar.loc]) + var/list/bars = user.progressbars[bar.loc] + bars.Add(src) + listindex = bars.len + bar.pixel_y = 32 + (PROGRESSBAR_HEIGHT * (listindex - 1)) + /datum/progressbar/proc/update(progress) //world << "Update [progress] - [goal] - [(progress / goal)] - [((progress / goal) * 100)] - [round(((progress / goal) * 100), 5)]" if (!user || !user.client) @@ -35,8 +45,24 @@ user.client.images += bar shown = 1 +/datum/progressbar/proc/shiftDown() + --listindex + bar.pixel_y -= PROGRESSBAR_HEIGHT + /datum/progressbar/Destroy() + for(var/I in user.progressbars[bar.loc]) + var/datum/progressbar/P = I + if(P != src && P.listindex > listindex) + P.shiftDown() + + var/list/bars = user.progressbars[bar.loc] + bars.Remove(src) + if(!bars.len) + LAZYREMOVE(user.progressbars, bar.loc) + if (client) client.images -= bar qdel(bar) . = ..() + +#undef PROGRESSBAR_HEIGHT \ No newline at end of file diff --git a/code/modules/mob/mob_defines.dm b/code/modules/mob/mob_defines.dm index e55963b7ec7..4cab0731dca 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -145,4 +145,6 @@ var/resize = 1 //Badminnery resize - var/list/observers = null //The list of people observing this mob. \ No newline at end of file + var/list/observers = null //The list of people observing this mob. + + var/list/progressbars = null //for stacking do_after bars \ No newline at end of file