Upload files
This commit is contained in:
@@ -42,6 +42,8 @@
|
||||
RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/on_drop)
|
||||
if(istype(parent, /obj/item/clothing/shoes))
|
||||
RegisterSignal(parent, COMSIG_SHOES_STEP_ACTION, .proc/step_squeak)
|
||||
else if(isstructure(parent))
|
||||
RegisterSignal(parent, COMSIG_ATOM_ATTACK_HAND, .proc/use_squeak)
|
||||
|
||||
override_squeak_sounds = custom_sounds
|
||||
if(chance_override)
|
||||
|
||||
@@ -54,11 +54,14 @@
|
||||
|
||||
/datum/element/art/rev
|
||||
|
||||
/datum/element/art/rev/apply_moodlet(atom/source, mob/M, impress)
|
||||
M.visible_message("<span class='notice'>[M] stops to inspect [source].</span>", \
|
||||
"<span class='notice'>You take in [source], inspecting the fine craftsmanship of the proletariat.</span>")
|
||||
|
||||
if(M.mind && M.mind.has_antag_datum(/datum/antagonist/rev))
|
||||
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artgreat", /datum/mood_event/artgreat)
|
||||
/datum/element/art/rev/apply_moodlet(atom/source, mob/user, impress)
|
||||
var/msg
|
||||
if(user.mind?.has_antag_datum(/datum/antagonist/rev))
|
||||
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "artgreat", /datum/mood_event/artgreat)
|
||||
msg = "What \a [pick("masterpiece", "chef-d'oeuvre")] [source.p_theyre()]. So [pick("subversive", "revolutionary", "unitizing", "egalitarian")]!"
|
||||
else
|
||||
SEND_SIGNAL(M, COMSIG_ADD_MOOD_EVENT, "artbad", /datum/mood_event/artbad)
|
||||
SEND_SIGNAL(user, COMSIG_ADD_MOOD_EVENT, "artbad", /datum/mood_event/artbad)
|
||||
msg = "Wow, [source.p_they()] sucks."
|
||||
|
||||
user.visible_message(span_notice("[user] stops to inspect [source]."), \
|
||||
span_notice("You appraise [source], inspecting the fine craftsmanship of the proletariat... [msg]"))
|
||||
|
||||
+118
-46
@@ -1,67 +1,139 @@
|
||||
#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
|
||||
|
||||
|
||||
/datum/progressbar/New(mob/User, goal_number, atom/target)
|
||||
. = ..()
|
||||
if (!istype(target))
|
||||
CRASH("Invalid target given")
|
||||
if (goal_number)
|
||||
goal = goal_number
|
||||
bar = image('icons/effects/progessbar.dmi', target, "prog_bar_0", HUD_LAYER)
|
||||
bar.plane = HUD_PLANE
|
||||
EXCEPTION("Invalid target given")
|
||||
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
|
||||
bar = image('icons/effects/progessbar.dmi', bar_loc, "prog_bar_0")
|
||||
bar.plane = ABOVE_HUD_PLANE
|
||||
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
|
||||
bar.pixel_y = 32 + (PROGRESSBAR_HEIGHT * (listindex - 1))
|
||||
|
||||
/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.images += bar
|
||||
shown = 1
|
||||
|
||||
/datum/progressbar/proc/shiftDown()
|
||||
--listindex
|
||||
bar.pixel_y -= PROGRESSBAR_HEIGHT
|
||||
RegisterSignal(user, COMSIG_PARENT_QDELETING, .proc/on_user_delete)
|
||||
RegisterSignal(user, COMSIG_MOB_CLIENT_LOGOUT, .proc/clean_user_client)
|
||||
RegisterSignal(user, COMSIG_MOB_CLIENT_LOGIN, .proc/on_user_login)
|
||||
|
||||
/datum/progressbar/Destroy()
|
||||
for(var/I in user.progressbars[bar.loc])
|
||||
var/datum/progressbar/P = I
|
||||
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)
|
||||
progress_bar.bar.pixel_y = 32 + (PROGRESSBAR_HEIGHT * (progress_bar.listindex - 1))
|
||||
var/dist_to_travel = 32 + (PROGRESSBAR_HEIGHT * (progress_bar.listindex - 1)) - PROGRESSBAR_HEIGHT
|
||||
animate(progress_bar.bar, pixel_y = dist_to_travel, time = PROGRESSBAR_ANIMATION_TIME, easing = SINE_EASING)
|
||||
|
||||
if (client)
|
||||
client.images -= bar
|
||||
qdel(bar)
|
||||
. = ..()
|
||||
LAZYREMOVEASSOC(user.progressbars, bar_loc, src)
|
||||
user = null
|
||||
|
||||
if(user_client)
|
||||
clean_user_client()
|
||||
|
||||
bar_loc = null
|
||||
|
||||
if(bar)
|
||||
QDEL_NULL(bar)
|
||||
|
||||
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_y = 0
|
||||
bar.alpha = 0
|
||||
user_client.images += bar
|
||||
animate(bar, pixel_y = 32 + (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)
|
||||
|
||||
|
||||
#undef PROGRESSBAR_ANIMATION_TIME
|
||||
#undef PROGRESSBAR_HEIGHT
|
||||
|
||||
Reference in New Issue
Block a user