mirror of
https://github.com/VOREStation/VOREStation.git
synced 2026-08-26 05:27:39 +01:00
Refactors do_after w/ TG's do_after (#18282)
* part1 * keeps range ability * no cog vore
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
var/client/client_user = user
|
||||
user = client_user.mob
|
||||
src.user = user
|
||||
RegisterSignal(user, COMSIG_PARENT_QDELETING, PROC_REF(user_deleted))
|
||||
RegisterSignal(user, COMSIG_QDELETING, PROC_REF(user_deleted))
|
||||
src.window_id = window_id
|
||||
if (title)
|
||||
src.title = strip_improper(title)
|
||||
|
||||
@@ -80,7 +80,7 @@ var/list/runechat_image_cache = list()
|
||||
|
||||
/datum/chatmessage/Destroy()
|
||||
if(istype(owned_by, /client)) // hopefully the PARENT_QDELETING on client should beat this if it's a disconnect
|
||||
UnregisterSignal(owned_by, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(owned_by, COMSIG_QDELETING)
|
||||
if(owned_by.seen_messages)
|
||||
LAZYREMOVEASSOC(owned_by.seen_messages, message_loc, src)
|
||||
owned_by.images.Remove(message)
|
||||
@@ -112,7 +112,7 @@ var/list/runechat_image_cache = list()
|
||||
|
||||
// Register client who owns this message
|
||||
owned_by = owner.client
|
||||
RegisterSignal(owned_by, COMSIG_PARENT_QDELETING, PROC_REF(unregister_qdel_self)) // this should only call owned_by if the client is destroyed
|
||||
RegisterSignal(owned_by, COMSIG_QDELETING, PROC_REF(unregister_qdel_self)) // this should only call owned_by if the client is destroyed
|
||||
|
||||
var/extra_length = owned_by.prefs?.read_preference(/datum/preference/toggle/runechat_long_messages)
|
||||
var/maxlen = extra_length ? CHAT_MESSAGE_EXT_LENGTH : CHAT_MESSAGE_LENGTH
|
||||
@@ -202,7 +202,7 @@ var/list/runechat_image_cache = list()
|
||||
if(!owned_by)
|
||||
qdel(src)
|
||||
return
|
||||
RegisterSignal(message_loc, COMSIG_PARENT_QDELETING, PROC_REF(qdel_self))
|
||||
RegisterSignal(message_loc, COMSIG_QDELETING, PROC_REF(qdel_self))
|
||||
if(owned_by.seen_messages)
|
||||
var/idx = 1
|
||||
var/combined_height = approx_lines
|
||||
@@ -294,7 +294,7 @@ var/list/runechat_image_cache = list()
|
||||
|
||||
/datum/chatmessage/proc/unregister_qdel_self() // this should only call owned_by if the client is destroyed
|
||||
SIGNAL_HANDLER
|
||||
UnregisterSignal(owned_by, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(owned_by, COMSIG_QDELETING)
|
||||
owned_by = null
|
||||
qdel_self()
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
watching += watching_client
|
||||
watching_mob.overlay_fullscreen("cinematic", /obj/screen/fullscreen/cinematic_backdrop)
|
||||
watching_client.screen += screen
|
||||
RegisterSignal(watching_client, COMSIG_PARENT_QDELETING, PROC_REF(remove_watcher))
|
||||
RegisterSignal(watching_client, COMSIG_QDELETING, PROC_REF(remove_watcher))
|
||||
|
||||
/// Simple helper for playing sounds from the cinematic.
|
||||
/datum/cinematic/proc/play_cinematic_sound(sound_to_play)
|
||||
@@ -170,7 +170,7 @@
|
||||
if(!(no_longer_watching in watching))
|
||||
CRASH("cinematic remove_watcher was passed a client which wasn't watching.")
|
||||
|
||||
UnregisterSignal(no_longer_watching, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(no_longer_watching, COMSIG_QDELETING)
|
||||
// We'll clear the cinematic if they have a mob which has one,
|
||||
// but we won't remove TRAIT_NO_TRANSFORM. Wait for the cinematic end to do that.
|
||||
no_longer_watching.mob?.clear_fullscreen("cinematic")
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#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
|
||||
/// Icon path of the cog
|
||||
var/cogicon
|
||||
/// The icon state
|
||||
var/cogiconstate
|
||||
|
||||
|
||||
/datum/cogbar/New(mob/user, cogicon, cogiconstate)
|
||||
src.user = user
|
||||
src.user_client = user.client
|
||||
src.cogicon = cogicon
|
||||
src.cogiconstate = cogiconstate
|
||||
var/list/icon_offsets = user.get_oversized_icon_offsets()
|
||||
offset_y = icon_offsets["y"]
|
||||
if(isnull(cogicon))
|
||||
stack_trace("/datum/cogbar was created with a null icon.")
|
||||
qdel(src)
|
||||
return
|
||||
if(isnull(cogiconstate))
|
||||
stack_trace("/datum/cogbar was created with a null icon state.")
|
||||
qdel(src)
|
||||
return
|
||||
|
||||
add_cog_to_user()
|
||||
|
||||
RegisterSignal(user, COMSIG_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 = cogicon,
|
||||
iconstate = cogiconstate,
|
||||
plane = ABOVE_PLANE,
|
||||
add_appearance_flags = APPEARANCE_UI_IGNORE_ALPHA,
|
||||
unique = TRUE,
|
||||
alpha = 0,
|
||||
)
|
||||
cog.pixel_y = ICON_SIZE_Y + offset_y
|
||||
animate(cog, alpha = user.alpha, time = COGBAR_ANIMATION_TIME)
|
||||
|
||||
if(isnull(user_client))
|
||||
return
|
||||
|
||||
blank = image('icons/blanks/32x32.dmi', cog, "nothing")
|
||||
blank.plane = ABOVE_PLANE //Change to SET_PLANE_EXPLICIT(blank, HIGH_GAME_PLANE, user)
|
||||
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
|
||||
@@ -19,20 +19,20 @@
|
||||
|
||||
/datum/component/connect_loc_behalf/RegisterWithParent()
|
||||
RegisterSignal(tracked, COMSIG_MOVABLE_MOVED, PROC_REF(on_moved))
|
||||
RegisterSignal(tracked, COMSIG_PARENT_QDELETING, PROC_REF(handle_tracked_qdel))
|
||||
RegisterSignal(tracked, COMSIG_QDELETING, PROC_REF(handle_tracked_qdel))
|
||||
update_signals()
|
||||
|
||||
/datum/component/connect_loc_behalf/UnregisterFromParent()
|
||||
unregister_signals()
|
||||
UnregisterSignal(tracked, list(
|
||||
COMSIG_MOVABLE_MOVED,
|
||||
COMSIG_PARENT_QDELETING,
|
||||
COMSIG_QDELETING,
|
||||
))
|
||||
|
||||
tracked = null
|
||||
|
||||
/datum/component/connect_loc_behalf/proc/handle_tracked_qdel()
|
||||
SIGNAL_HANDLER // COMSIG_PARENT_QDELETING
|
||||
SIGNAL_HANDLER // COMSIG_QDELETING
|
||||
qdel(src)
|
||||
|
||||
/datum/component/connect_loc_behalf/proc/update_signals()
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
src.tracked = tracked
|
||||
|
||||
/datum/component/connect_mob_behalf/RegisterWithParent()
|
||||
RegisterSignal(tracked, COMSIG_PARENT_QDELETING, PROC_REF(handle_tracked_qdel))
|
||||
RegisterSignal(tracked, COMSIG_QDELETING, PROC_REF(handle_tracked_qdel))
|
||||
update_signals()
|
||||
|
||||
/datum/component/connect_mob_behalf/UnregisterFromParent()
|
||||
unregister_signals()
|
||||
UnregisterSignal(tracked, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(tracked, COMSIG_QDELETING)
|
||||
|
||||
tracked = null
|
||||
tracked_mob = null
|
||||
|
||||
@@ -227,15 +227,15 @@
|
||||
parent_attached_to = new_parent_attached_to
|
||||
if(.)
|
||||
var/atom/movable/old_parent_attached_to = .
|
||||
UnregisterSignal(old_parent_attached_to, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
UnregisterSignal(old_parent_attached_to, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
if(old_parent_attached_to == current_holder)
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_PARENT_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_MOVABLE_MOVED, PROC_REF(on_holder_moved))
|
||||
RegisterSignal(old_parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
if(parent_attached_to)
|
||||
if(parent_attached_to == current_holder)
|
||||
UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
RegisterSignal(parent_attached_to, COMSIG_PARENT_QDELETING, PROC_REF(on_parent_attached_to_qdel))
|
||||
UnregisterSignal(current_holder, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
RegisterSignal(parent_attached_to, COMSIG_QDELETING, PROC_REF(on_parent_attached_to_qdel))
|
||||
RegisterSignal(parent_attached_to, COMSIG_MOVABLE_MOVED, PROC_REF(on_parent_attached_to_moved))
|
||||
RegisterSignal(parent_attached_to, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
check_holder()
|
||||
@@ -249,7 +249,7 @@
|
||||
new_holder = null // Forbid crates from holding lights, this only applies to contents 'holding', when you put a flashlight into a crate for example. Not crates with lights... Not that there are any.
|
||||
if(current_holder)
|
||||
if(current_holder != parent && current_holder != parent_attached_to)
|
||||
UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
UnregisterSignal(current_holder, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED, COMSIG_LIGHT_EATER_QUEUE))
|
||||
if(directional)
|
||||
UnregisterSignal(current_holder, COMSIG_ATOM_DIR_CHANGE)
|
||||
if(overlay_lighting_flags & LIGHTING_ON)
|
||||
@@ -259,7 +259,7 @@
|
||||
clean_old_turfs()
|
||||
return
|
||||
if(new_holder != parent && new_holder != parent_attached_to)
|
||||
RegisterSignal(new_holder, COMSIG_PARENT_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(new_holder, COMSIG_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(new_holder, COMSIG_MOVABLE_MOVED, PROC_REF(on_holder_moved))
|
||||
RegisterSignal(new_holder, COMSIG_LIGHT_EATER_QUEUE, PROC_REF(on_light_eater))
|
||||
if(directional)
|
||||
@@ -288,7 +288,7 @@
|
||||
///Called when the current_holder is qdeleted, to remove the light effect.
|
||||
/datum/component/overlay_lighting/proc/on_holder_qdel(atom/movable/source, force)
|
||||
SIGNAL_HANDLER
|
||||
UnregisterSignal(current_holder, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED))
|
||||
UnregisterSignal(current_holder, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED))
|
||||
if(directional)
|
||||
UnregisterSignal(current_holder, COMSIG_ATOM_DIR_CHANGE)
|
||||
set_holder(null)
|
||||
@@ -317,7 +317,7 @@
|
||||
///Called when the current_holder is qdeleted, to remove the light effect.
|
||||
/datum/component/overlay_lighting/proc/on_parent_attached_to_qdel(atom/movable/source, force)
|
||||
SIGNAL_HANDLER
|
||||
UnregisterSignal(parent_attached_to, list(COMSIG_PARENT_QDELETING, COMSIG_MOVABLE_MOVED))
|
||||
UnregisterSignal(parent_attached_to, list(COMSIG_QDELETING, COMSIG_MOVABLE_MOVED))
|
||||
if(directional)
|
||||
UnregisterSignal(parent_attached_to, COMSIG_ATOM_DIR_CHANGE)
|
||||
if(parent_attached_to == current_holder)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/datum/component/recursive_move/RegisterWithParent()
|
||||
. = ..()
|
||||
holder = parent
|
||||
RegisterSignal(holder, COMSIG_PARENT_QDELETING, PROC_REF(on_holder_qdel))
|
||||
RegisterSignal(holder, COMSIG_QDELETING, PROC_REF(on_holder_qdel))
|
||||
spawn(0) // Delayed action if our holder is spawned in nullspace and then loc = target, hopefully this catches it. VV Add item does this, for example.
|
||||
if(!QDELETED(src))
|
||||
setup_parents()
|
||||
@@ -35,7 +35,7 @@
|
||||
recursion++
|
||||
parents += cur_parent
|
||||
RegisterSignal(cur_parent, COMSIG_ATOM_EXITED, PROC_REF(heirarchy_changed))
|
||||
RegisterSignal(cur_parent, COMSIG_PARENT_QDELETING, PROC_REF(on_qdel))
|
||||
RegisterSignal(cur_parent, COMSIG_QDELETING, PROC_REF(on_qdel))
|
||||
|
||||
cur_parent = cur_parent.loc
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
if(!length(parents))
|
||||
return
|
||||
for(var/atom/movable/cur_parent in parents)
|
||||
UnregisterSignal(cur_parent, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(cur_parent, COMSIG_QDELETING)
|
||||
UnregisterSignal(cur_parent, COMSIG_ATOM_EXITED)
|
||||
|
||||
UnregisterSignal(parents[parents.len], COMSIG_ATOM_ENTERING)
|
||||
@@ -93,7 +93,7 @@
|
||||
|
||||
/datum/component/recursive_move/proc/on_holder_qdel()
|
||||
SIGNAL_HANDLER
|
||||
UnregisterSignal(holder, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(holder, COMSIG_QDELETING)
|
||||
reset_parents()
|
||||
holder = null
|
||||
qdel(src)
|
||||
@@ -101,7 +101,7 @@
|
||||
/datum/component/recursive_move/Destroy()
|
||||
. = ..()
|
||||
reset_parents()
|
||||
if(holder) UnregisterSignal(holder, COMSIG_PARENT_QDELETING)
|
||||
if(holder) UnregisterSignal(holder, COMSIG_QDELETING)
|
||||
holder = null
|
||||
|
||||
/datum/component/recursive_move/proc/reset_parents()
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
owner = user
|
||||
if(owner.vore_selected)
|
||||
target = owner.vore_selected
|
||||
RegisterSignal(owner, COMSIG_PARENT_QDELETING, PROC_REF(drop_everything_and_delete))
|
||||
RegisterSignal(owner, COMSIG_QDELETING, PROC_REF(drop_everything_and_delete))
|
||||
has_signal = TRUE
|
||||
SK = owner.get_shadekin_component()
|
||||
|
||||
@@ -112,7 +112,7 @@
|
||||
STOP_PROCESSING(SSobj, src)
|
||||
if(owner)
|
||||
if(has_signal)
|
||||
UnregisterSignal(owner, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(owner, COMSIG_QDELETING)
|
||||
var/datum/component/shadekin/SK = owner.get_shadekin_component()
|
||||
if(SK)
|
||||
SK.active_dark_maws -= src
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
to_chat(owner, span_warning("You can't weave here!"))
|
||||
return
|
||||
|
||||
if(do_after(owner, desired_result.time, exclusive = TASK_USER_EXCLUSIVE))
|
||||
if(do_after(owner, desired_result.time))
|
||||
if(desired_result.cost > silk_reserve)
|
||||
to_chat(owner, span_warning("You don't have enough silk to weave that!"))
|
||||
return
|
||||
@@ -168,7 +168,7 @@
|
||||
to_chat(owner, span_warning("You can't weave here!"))
|
||||
return
|
||||
|
||||
if(do_after(owner, desired_result.time, exclusive = TASK_USER_EXCLUSIVE))
|
||||
if(do_after(owner, desired_result.time))
|
||||
if(desired_result.cost > silk_reserve)
|
||||
to_chat(owner, span_warning("You don't have enough silk to weave that!"))
|
||||
return
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
return ELEMENT_INCOMPATIBLE
|
||||
SEND_SIGNAL(target, COMSIG_ELEMENT_ATTACH, src)
|
||||
if(element_flags & ELEMENT_DETACH_ON_HOST_DESTROY)
|
||||
RegisterSignal(target, COMSIG_PARENT_QDELETING, PROC_REF(OnTargetDelete), override = TRUE)
|
||||
RegisterSignal(target, COMSIG_QDELETING, PROC_REF(OnTargetDelete), override = TRUE)
|
||||
|
||||
/datum/element/proc/OnTargetDelete(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
@@ -38,7 +38,7 @@
|
||||
SHOULD_CALL_PARENT(TRUE)
|
||||
|
||||
SEND_SIGNAL(source, COMSIG_ELEMENT_DETACH, src)
|
||||
UnregisterSignal(source, COMSIG_PARENT_QDELETING)
|
||||
UnregisterSignal(source, COMSIG_QDELETING)
|
||||
|
||||
/datum/element/Destroy(force)
|
||||
if(!force)
|
||||
|
||||
+139
-50
@@ -1,69 +1,158 @@
|
||||
#define PROGRESSBAR_HEIGHT 6
|
||||
#define PROGRESSBAR_ANIMATION_TIME 5
|
||||
|
||||
/datum/progressbar
|
||||
var/goal = 1
|
||||
///The progress bar visual element.
|
||||
var/image/bar
|
||||
var/shown = 0
|
||||
///The target where this progress bar is applied and where it is shown.
|
||||
var/atom/bar_loc
|
||||
///The mob whose client sees the progress bar.
|
||||
var/mob/user
|
||||
var/client/client
|
||||
var/listindex
|
||||
///The client seeing the progress bar.
|
||||
var/client/user_client
|
||||
///Effectively the number of steps the progress bar will need to do before reaching completion.
|
||||
var/goal = 1
|
||||
///Control check to see if the progress was interrupted before reaching its goal.
|
||||
var/last_progress = 0
|
||||
///Variable to ensure smooth visual stacking on multiple progress bars.
|
||||
var/listindex = 0
|
||||
///The type of our last value for bar_loc, for debugging
|
||||
var/location_type
|
||||
///Where to draw the progress bar above the icon
|
||||
var/offset_y
|
||||
|
||||
/datum/progressbar/New(mob/User, goal_number, atom/target)
|
||||
/datum/progressbar/New(mob/User, goal_number, atom/target, starting_amount)
|
||||
. = ..()
|
||||
if(!istype(target))
|
||||
target = User
|
||||
if(goal_number)
|
||||
goal = goal_number
|
||||
bar = image('icons/effects/progressbar.dmi', target, "prog_bar_0")
|
||||
bar.alpha = 0
|
||||
bar.plane = PLANE_PLAYER_HUD
|
||||
if (!istype(target))
|
||||
stack_trace("Invalid target [target] passed in")
|
||||
qdel(src)
|
||||
return
|
||||
if(QDELETED(User) || !istype(User))
|
||||
stack_trace("/datum/progressbar created with [isnull(User) ? "null" : "invalid"] user")
|
||||
qdel(src)
|
||||
return
|
||||
if(!isnum(goal_number))
|
||||
stack_trace("/datum/progressbar created with [isnull(User) ? "null" : "invalid"] goal_number")
|
||||
qdel(src)
|
||||
return
|
||||
goal = goal_number
|
||||
bar_loc = target
|
||||
location_type = bar_loc.type
|
||||
|
||||
var/list/icon_offsets = target.get_oversized_icon_offsets()
|
||||
var/offset_x = icon_offsets["x"]
|
||||
offset_y = icon_offsets["y"]
|
||||
|
||||
bar = image('icons/effects/progressbar.dmi', bar_loc, "prog_bar_0", pixel_x = offset_x)
|
||||
bar.plane = PLANE_PLAYER_HUD //Swap to SET_PLANE_EXPLICIT(bar, LAYER_HUD_ITEM, User) if we ever get the plane update
|
||||
bar.appearance_flags = APPEARANCE_UI_IGNORE_ALPHA
|
||||
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)
|
||||
LAZYADDASSOCLIST(user.progressbars, bar_loc, src)
|
||||
var/list/bars = user.progressbars[bar_loc]
|
||||
listindex = bars.len
|
||||
animate(bar, pixel_y = 32 + (PROGRESSBAR_HEIGHT * (listindex - 1)), alpha = 255, time = 5, easing = SINE_EASING)
|
||||
|
||||
/datum/progressbar/proc/update(progress)
|
||||
if(!user || !user.client)
|
||||
shown = 0
|
||||
return
|
||||
if(user.client != client)
|
||||
if(client)
|
||||
client.images -= bar
|
||||
if(user.client)
|
||||
user.client.images += bar
|
||||
if(user.client)
|
||||
user_client = user.client
|
||||
add_prog_bar_image_to_client()
|
||||
|
||||
progress = CLAMP(progress, 0, goal)
|
||||
bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]"
|
||||
if(!shown && user.client?.prefs?.read_preference(/datum/preference/toggle/show_progress_bar))
|
||||
user.client.images += bar
|
||||
shown = 1
|
||||
RegisterSignal(user, COMSIG_QDELETING, PROC_REF(on_user_delete))
|
||||
RegisterSignal(user, COMSIG_MOB_LOGOUT, PROC_REF(clean_user_client))
|
||||
RegisterSignal(user, COMSIG_MOB_LOGIN, PROC_REF(on_user_login))
|
||||
|
||||
/datum/progressbar/proc/shiftDown()
|
||||
--listindex
|
||||
var/shiftheight = bar.pixel_y - PROGRESSBAR_HEIGHT
|
||||
animate(bar, pixel_y = shiftheight, time = 5, easing = SINE_EASING)
|
||||
if(starting_amount)
|
||||
update(starting_amount)
|
||||
|
||||
/datum/progressbar/Destroy()
|
||||
for(var/datum/progressbar/P as anything in user.progressbars[bar.loc])
|
||||
if(P != src && P.listindex > listindex)
|
||||
P.shiftDown()
|
||||
if(user)
|
||||
for(var/pb in user.progressbars[bar_loc])
|
||||
var/datum/progressbar/progress_bar = pb
|
||||
if(progress_bar == src || progress_bar.listindex <= listindex)
|
||||
continue
|
||||
progress_bar.listindex--
|
||||
|
||||
var/list/bars = user.progressbars[bar.loc]
|
||||
bars.Remove(src)
|
||||
if(!bars.len)
|
||||
LAZYREMOVE(user.progressbars, bar.loc)
|
||||
animate(bar, alpha = 0, time = 5)
|
||||
spawn(5)
|
||||
if(client)
|
||||
client.images -= bar
|
||||
qdel(bar)
|
||||
. = ..()
|
||||
progress_bar.bar.pixel_z = ICON_SIZE_Y + offset_y + (PROGRESSBAR_HEIGHT * (progress_bar.listindex - 1))
|
||||
var/dist_to_travel = ICON_SIZE_Y + offset_y + (PROGRESSBAR_HEIGHT * (progress_bar.listindex - 1)) - PROGRESSBAR_HEIGHT
|
||||
animate(progress_bar.bar, pixel_z = dist_to_travel, time = PROGRESSBAR_ANIMATION_TIME, easing = SINE_EASING)
|
||||
|
||||
LAZYREMOVEASSOC(user.progressbars, bar_loc, src)
|
||||
user = null
|
||||
|
||||
if(user_client)
|
||||
clean_user_client()
|
||||
|
||||
bar_loc = null
|
||||
bar = null
|
||||
|
||||
return ..()
|
||||
|
||||
|
||||
///Called right before the user's Destroy()
|
||||
/datum/progressbar/proc/on_user_delete(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
user.progressbars = null //We can simply nuke the list and stop worrying about updating other prog bars if the user itself is gone.
|
||||
user = null
|
||||
qdel(src)
|
||||
|
||||
|
||||
///Removes the progress bar image from the user_client and nulls the variable, if it exists.
|
||||
/datum/progressbar/proc/clean_user_client(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(!user_client) //Disconnected, already gone.
|
||||
return
|
||||
user_client.images -= bar
|
||||
user_client = null
|
||||
|
||||
|
||||
///Called by user's Login(), it transfers the progress bar image to the new client.
|
||||
/datum/progressbar/proc/on_user_login(datum/source)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(user_client)
|
||||
if(user_client == user.client) //If this was not client handling I'd condemn this sanity check. But clients are fickle things.
|
||||
return
|
||||
clean_user_client()
|
||||
if(!user.client) //Clients can vanish at any time, the bastards.
|
||||
return
|
||||
user_client = user.client
|
||||
add_prog_bar_image_to_client()
|
||||
|
||||
|
||||
///Adds a smoothly-appearing progress bar image to the player's screen.
|
||||
/datum/progressbar/proc/add_prog_bar_image_to_client()
|
||||
bar.pixel_z = 0
|
||||
bar.alpha = 0
|
||||
user_client.images += bar
|
||||
animate(bar, pixel_z = ICON_SIZE_Y + offset_y + (PROGRESSBAR_HEIGHT * (listindex - 1)), alpha = 255, time = PROGRESSBAR_ANIMATION_TIME, easing = SINE_EASING)
|
||||
|
||||
|
||||
///Updates the progress bar image visually.
|
||||
/datum/progressbar/proc/update(progress)
|
||||
progress = clamp(progress, 0, goal)
|
||||
if(progress == last_progress)
|
||||
return
|
||||
last_progress = progress
|
||||
bar.icon_state = "prog_bar_[round(((progress / goal) * 100), 5)]"
|
||||
|
||||
|
||||
///Called on progress end, be it successful or a failure. Wraps up things to delete the datum and bar.
|
||||
/datum/progressbar/proc/end_progress()
|
||||
if(last_progress != goal)
|
||||
bar.icon_state = "[bar.icon_state]_fail"
|
||||
|
||||
animate(bar, alpha = 0, time = PROGRESSBAR_ANIMATION_TIME)
|
||||
|
||||
QDEL_IN(src, PROGRESSBAR_ANIMATION_TIME)
|
||||
|
||||
///Progress bars are very generic, and what hangs a ref to them depends heavily on the context in which they're used
|
||||
///So let's make hunting harddels easier yeah?
|
||||
/datum/progressbar/dump_harddel_info()
|
||||
if(harddel_deets_dumped)
|
||||
return
|
||||
harddel_deets_dumped = TRUE
|
||||
return "Owner's type: [location_type]"
|
||||
|
||||
#undef PROGRESSBAR_ANIMATION_TIME
|
||||
#undef PROGRESSBAR_HEIGHT
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
* adding it to an atom's contents or vis_contents, giving it a key (if it's a mob), attaching it to an atom (if it's an image),
|
||||
* or assigning it to a datum or list referenced somewhere other than a temporary value.
|
||||
*
|
||||
* Unless you're resolving a weakref to a datum in a COMSIG_PARENT_QDELETING signal handler registered on that very same datum,
|
||||
* Unless you're resolving a weakref to a datum in a COMSIG_QDELETING signal handler registered on that very same datum,
|
||||
* just use resolve instead.
|
||||
*/
|
||||
/datum/weakref/proc/hard_resolve()
|
||||
|
||||
Reference in New Issue
Block a user