Skip to content

Commit

Permalink
credits refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Legendaxe committed Dec 21, 2023
1 parent ff54f87 commit bc96462
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 51 deletions.
5 changes: 4 additions & 1 deletion modular_ss220/credits/code/SScredits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SUBSYSTEM_DEF(credits)
runlevels = RUNLEVEL_POSTGAME
flags = SS_NO_FIRE

var/datum/cinematic/credits/current_cinematic

var/datum/credits/end_titles
var/title_music = ""

Expand All @@ -25,7 +27,7 @@ SUBSYSTEM_DEF(credits)

title_music = end_titles.soundtrack

play_cinematic(cinematic_type, world)
current_cinematic = play_cinematic(cinematic_type, world)

/datum/controller/subsystem/credits/proc/roll_credits_for_clients(list/clients)
end_titles.roll_credits_for_clients(clients)
Expand All @@ -35,4 +37,5 @@ SUBSYSTEM_DEF(credits)
return

for(var/credit in client.credits)
client.screen -= credit
QDEL_NULL(credit)
84 changes: 46 additions & 38 deletions modular_ss220/credits/code/credits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/datum/credits
var/list/credits = list()
var/list/screen_credits = list()

var/playing_time
var/delay_time = 5 SECONDS
Expand Down Expand Up @@ -36,21 +37,17 @@
playing_time -= credit_spawn_speed
playing_time += credit_roll_speed

/datum/credits/proc/roll_credits_for_clients(list/clients)
/datum/credits/proc/roll_credits_for_clients(list/client/clients)
for(var/client/client in clients)
setup_credits_for_client(client)
LAZYINITLIST(client.credits)

addtimer(CALLBACK(src, PROC_REF(start_rolling_credits_for_clients), clients), delay_time)

/datum/credits/proc/setup_credits_for_client(client/client)
LAZYINITLIST(client.credits)

var/obj/screen/credit/logo = new /obj/screen/credit/logo(null, "", client)
var/obj/screen/credit/logo = new /obj/screen/credit/logo(null, "", clients)
screen_credits += logo

client.credits += logo
addtimer(CALLBACK(src, PROC_REF(start_rolling_credits_for_clients), clients), delay_time)

/datum/credits/proc/start_rolling_credits_for_clients(list/clients)
addtimer(CALLBACK(src, PROC_REF(start_rolling_logo_for_clients), clients,), SScredits.credit_roll_speed / 2.5)
/datum/credits/proc/start_rolling_credits_for_clients(list/client/clients)
addtimer(CALLBACK(src, PROC_REF(start_rolling_logo)), SScredits.credit_roll_speed / 2.5)

for(var/datum/credit/credit in credits)
for(var/item in credit.content)
Expand All @@ -59,30 +56,26 @@

addtimer(CALLBACK(src, PROC_REF(clear_credits_for_clients), clients), SScredits.credit_roll_speed)

/datum/credits/proc/start_rolling_logo_for_clients(list/clients)
for(var/client/client in clients)
if(!client?.credits)
continue

var/obj/screen/credit/logo/logo = client.credits[1]
logo.rollem()
/datum/credits/proc/start_rolling_logo()
var/obj/screen/credit/logo/logo = screen_credits[1]
logo.rollem()

/datum/credits/proc/start_rolling_credit_item(list/clients, credit_item)
for(var/client/client in clients)
if(!client?.credits)
continue
var/obj/screen/credit/title = new(null, credit_item, clients)
screen_credits += title

var/obj/screen/credit/title = new(null, credit_item, client)
client.credits += title
title.rollem()
title.rollem()

/datum/credits/proc/clear_credits_for_clients(list/clients)
screen_credits.Cut()

for(var/client/client in clients)
if(!client?.credits)
continue

SScredits.clear_credits(client)

SScredits.current_cinematic = null

/datum/credits/default

Expand Down Expand Up @@ -171,8 +164,13 @@
return

var/datum/db_query/ranks_ckey_read = SSdbcore.NewQuery(
"SELECT ckey FROM admin WHERE admin_rank=:rank",
list("rank" = "Банда"))
"SELECT ckey FROM admin WHERE admin_rank=:rank OR admin_rank=:rank1 OR admin_rank=:rank2 OR admin_rank=:rank3",
list(
"rank" = "Банда",
"rank1" = "Братюня",
"rank2" = "Максон",
"rank3" = "Сестрюня"
))

if(!ranks_ckey_read.warn_execute())
qdel(ranks_ckey_read)
Expand Down Expand Up @@ -216,7 +214,7 @@
for(var/client/client in GLOB.clients)
if(!client.donator_level)
continue
if(client.holder)
if(client.donator_level > DONATOR_LEVEL_MAX)
continue
if(!length(donators))
donators += "<hr>"
Expand Down Expand Up @@ -379,12 +377,21 @@
screen_loc = "CENTER-7,CENTER-7"
plane = CREDITS_PLANE

var/client/parent
var/list/client/watchers = list()

/obj/screen/credit/Initialize(mapload, credited, client/client)
/obj/screen/credit/Initialize(mapload, credited, list/client/clients)
. = ..()

parent = client
for(var/client/watcher in clients)
if(!watcher)
continue
if(!watcher.credits)
continue
watcher.credits += src
watcher.screen += src
watchers += watcher


maptext = {"<div style="font:'Small Fonts'">[credited]</div>"}
maptext_height = world.icon_size * 2
maptext_width = world.icon_size * 14
Expand All @@ -396,17 +403,20 @@
matrix.Translate(0, SScredits.credit_animate_height)
animate(src, transform = matrix, time = SScredits.credit_roll_speed)
addtimer(CALLBACK(src, PROC_REF(delete_credit)), SScredits.credit_roll_speed, TIMER_CLIENT_TIME)
parent.screen += src

/obj/screen/credit/proc/delete_credit()
if(!QDELETED(src))
qdel(src)

/obj/screen/credit/Destroy()
if(parent)
parent.screen -= src
LAZYREMOVE(parent.credits, src)
parent = null
for(var/client/watcher in watchers)
if(!watcher)
continue
watcher.screen -= src
LAZYREMOVE(watcher.credits, src)

watchers.Cut()

return ..()

/obj/screen/credit/logo
Expand All @@ -416,15 +426,13 @@
alpha = 100


/obj/screen/credit/logo/Initialize(mapload, credited, client/client)
/obj/screen/credit/logo/Initialize(mapload, credited, list/client/clients)
. = ..()
animate(src, alpha = 220, time = 3 SECONDS)
maptext = "<center><h1>Playing music - [SScredits.title_music]</h1></center>"
maptext_height = 10 * world.icon_size
maptext_x -= 5 * world.icon_size
maptext_y += 6 * world.icon_size
parent.screen += src


/obj/screen/credit/logo/rollem()
var/matrix/matrix = matrix(transform)
Expand Down
29 changes: 17 additions & 12 deletions modular_ss220/credits/code/halloween_credits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,24 @@
credits += new /datum/credit/staff/halloween()
credits += new /datum/credit/disclaimer()

/datum/credits/halloween/setup_credits_for_client(client/client)
LAZYINITLIST(client.credits)
/datum/credits/halloween/roll_credits_for_clients(list/client/clients)
for(var/client/client in clients)
LAZYINITLIST(client.credits)

var/obj/screen/credit/logo = new /obj/screen/credit/halloween(null, "", client)
client.credits += logo
var/obj/screen/credit/logo = new /obj/screen/credit/halloween(null, "", clients)
screen_credits += logo

/datum/credits/halloween/start_rolling_logo_for_clients(list/clients)
for(var/client/client in clients)
if(!client?.credits)
continue
addtimer(CALLBACK(src, PROC_REF(start_rolling_credits_for_clients), clients), delay_time)

var/obj/screen/credit/logo/logo = client.credits[1]
logo.rollem()
/datum/credits/halloween/start_rolling_credits_for_clients(list/client/clients)
addtimer(CALLBACK(src, PROC_REF(start_rolling_logo)), SScredits.credit_roll_speed / 2.5)

for(var/datum/credit/credit in credits)
for(var/item in credit.content)
start_rolling_credit_item(clients, item)
sleep(SScredits.credit_spawn_speed)

addtimer(CALLBACK(src, PROC_REF(clear_credits_for_clients), clients), SScredits.credit_roll_speed)

/datum/credit/episode_title/halloween

Expand Down Expand Up @@ -176,9 +181,9 @@
appearance_flags = NO_CLIENT_COLOR | TILE_BOUND | PIXEL_SCALE
alpha = 255

/obj/screen/credit/halloween/Initialize(mapload, credited, client/client)
/obj/screen/credit/halloween/Initialize(mapload, credited, list/client/clients)
. = ..()
parent.screen += src

plane++

transform = transform.Scale(1.5)
Expand Down

0 comments on commit bc96462

Please sign in to comment.