mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-07-14 16:44:33 +01:00
Merge pull request #6425 from Markolie/stackprogressbars
Progress bars now stack vertically
This commit is contained in:
@@ -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,15 +14,21 @@
|
||||
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)
|
||||
// to_chat(world, "Update [progress] - [goal] - [(progress / goal)] - [((progress / goal) * 100)] - [round(((progress / goal) * 100), 5)]")
|
||||
if(!user || !user.client)
|
||||
shown = 0
|
||||
return
|
||||
@@ -35,8 +44,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
|
||||
Reference in New Issue
Block a user