Skip to content

Commit

Permalink
hotfix + refactor to cinematic
Browse files Browse the repository at this point in the history
  • Loading branch information
Legendaxe committed Oct 15, 2023
1 parent ac11162 commit c2eaf9c
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 103 deletions.
1 change: 1 addition & 0 deletions code/controllers/subsystem/SSticker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ SUBSYSTEM_DEF(ticker)
for(var/datum/team/team in GLOB.antagonist_teams)
team.on_round_end()

play_cinematic(/datum/cinematic/credits, world)

// Display the scoreboard window
score.scoreboard()
Expand Down
1 change: 1 addition & 0 deletions modular_ss220/_defines220/_defines220.dme
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
#include "code/cult_defines_ss220.dm"
#include "code/hud_ss220.dm"
#include "code/layers_ss220.dm"
#include "code/signals_cinematic.dm"
1 change: 1 addition & 0 deletions modular_ss220/_defines220/code/signals_cinematic.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define COMSIG_GLOB_CINEMATIC_WAITING_TO_PLAY "!cinematic_waiting_to_play"
2 changes: 2 additions & 0 deletions modular_ss220/cinematics/code/_cinematics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@

qdel(src)

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CINEMATIC_WAITING_TO_PLAY, null)

/// Locks a mob, preventing them from moving, being hurt, or acting
/datum/cinematic/proc/lock_mob(mob/to_lock)
locked += to_lock
Expand Down
81 changes: 16 additions & 65 deletions modular_ss220/cinematics/code/cinematics/credits.dm
Original file line number Diff line number Diff line change
@@ -1,82 +1,33 @@
/datum/cinematic/credits
cleanup_time = 20 SECONDS
is_global = TRUE

/datum/cinematic/New(watcher, datum/callback/special_callback)
/datum/cinematic/credits/New(watcher, datum/callback/special_callback)
. = ..()
screen = new/obj/screen/cinematic/credits(src)

/datum/cinematic/credits/play_cinematic()
if(!SScredits.end_titles || SScredits.end_titles.len == 0)
SScredits.end_titles = SScredits.generate_titles()

var/list/credits = list()
/datum/cinematic/credits/start_cinematic(list/watchers)

play_cinematic_sound(SScredits.title_music)
watching = watchers
if(SEND_GLOBAL_SIGNAL(COMSIG_GLOB_PLAY_CINEMATIC, src) & COMPONENT_GLOB_BLOCK_CINEMATIC)
RegisterSignal(SSdcs, COMSIG_GLOB_CINEMATIC_WAITING_TO_PLAY, PROC_REF(queue_gone))
return
. = ..()

play_credits_for_all_watchers(credits)
/datum/cinematic/credits/proc/queue_gone(datum/source, datum/cinematic/other)
SIGNAL_HANDLER

stoplag(SScredits.credit_roll_speed)
start_cinematic(src.watching)

QDEL_NULL(credits)
/datum/cinematic/credits/play_cinematic()
play_cinematic_sound(sound(SScredits.title_music))
SScredits.roll_credits_for_clients(watching)

special_callback?.Invoke()

stop_cinematic()

/datum/cinematic/credits/proc/play_credits_for_all_watchers(list/credits)
for(var/client/client in watching)
play_credits_for_watcher(credits,client)

/datum/cinematic/credits/proc/play_credits_for_watcher(list/credits, client/client)
for(var/end_title in SScredits.end_titles)
if(!client)
return
var/obj/screen/credit/title = new(null, end_title, client)
title.rollem()
credits += title
stoplag(SScredits.credit_spawn_speed)

stoplag(SScredits.credit_roll_speed)

/obj/screen/cinematic/credits
icon = 'icons/mob/screen_gen.dmi'
icon_state = "black"
screen_loc = "WEST,SOUTH to EAST,NORTH"
plane = 30

/obj/screen/credit
icon_state = "blank"
mouse_opacity = 0
alpha = 0
screen_loc = "CENTER-7,CENTER-7"
plane = 21

var/matrix/target
var/client/parent

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

parent = client
maptext = {"<div style="font:'Small Fonts'">[credited]</div>"}
maptext_height = world.icon_size * 2
maptext_width = world.icon_size * 14

/obj/screen/credit/proc/rollem()
var/matrix/M = matrix(transform)
M.Translate(0, SScredits.credit_animate_height)
animate(src, transform = M, time = SScredits.credit_roll_speed)
target = M
animate(src, alpha = 255, time = SScredits.credit_ease_duration, flags = ANIMATION_PARALLEL)
spawn(SScredits.credit_roll_speed - SScredits.credit_ease_duration)
if(!QDELETED(src))
animate(src, alpha = 0, transform = target, time = SScredits.credit_ease_duration)
sleep(SScredits.credit_ease_duration)
qdel(src)
parent.screen += src
plane = SPLASHSCREEN_PLANE

/obj/screen/credit/Destroy()
if(parent)
parent.screen -= src
LAZYREMOVE(parent.credits, src)
parent = null
return ..()
97 changes: 59 additions & 38 deletions modular_ss220/credits/code/SScredits.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#define CREDITS_BACKGROUND_PLANE 25
#define CREDITS_PLANE 26

SUBSYSTEM_DEF(credits)
Expand All @@ -13,43 +12,36 @@ SUBSYSTEM_DEF(credits)
var/credit_animate_height
var/credit_ease_duration = 22

// /datum/controller/subsystem/credits/Initialize()
// credit_animate_height = 14 * world.icon_size
// title_music = pick(file2list("config/credits/sounds/title_music.txt"))
/datum/controller/subsystem/credits/Initialize()
credit_animate_height = 14 * world.icon_size
title_music = pick(file2list("config/credits/sounds/title_music.txt"))

// /datum/controller/subsystem/credits/proc/roll_credits_for_all_clients()
// for(var/client/client in GLOB.clients)
// SScredits.roll_credits(client)
/datum/controller/subsystem/credits/proc/roll_credits_for_clients(list/clients)
if(length(end_titles) == 0)
end_titles = generate_titles()

// /datum/controller/subsystem/credits/proc/roll_credits(client/client)
// LAZYINITLIST(client.credits)
for(var/client/client in clients)
SScredits.roll_credits(client)

// if(end_titles)
// end_titles = generate_titles()
/datum/controller/subsystem/credits/proc/roll_credits(client/client)
LAZYINITLIST(client.credits)

// addtimer(CALLBACK(src, PROC_REF(roll_credits_for_client), client), 30 SECONDS, TIMER_CLIENT_TIME)
var/list/_credits = client.credits

// /datum/controller/subsystem/credits/proc/roll_credits_for_client(client/client)
// var/list/_credits = client.credits
for(var/item in end_titles)
if(!client || !client.credits)
return
var/obj/screen/credit/title = new(null, item, client)
_credits += title
title.rollem()
sleep(credit_spawn_speed)

// if(client.mob)
// client.mob.overlay_fullscreen("black",/obj/screen/fullscreen/black)
// SEND_SOUND(client, sound(title_music, repeat = FALSE, wait = FALSE, volume = 85 * client.prefs.get_channel_volume(CHANNEL_LOBBYMUSIC), channel = CHANNEL_LOBBYMUSIC))
addtimer(CALLBACK(src, PROC_REF(clear_credits), client), (credit_roll_speed), TIMER_CLIENT_TIME)

// for(var/item in end_titles)
// if(!client.credits)
// return
// var/obj/screen/credit/title = new(null, item, client)
// _credits += title
// title.rollem()
// sleep(credit_spawn_speed)

// addtimer(CALLBACK(src, PROC_REF(clear_credits), client), (credit_roll_speed), TIMER_CLIENT_TIME)

// /datum/controller/subsystem/credits/proc/clear_credits(client/client)
// QDEL_NULL(client.credits)
// client.mob.clear_fullscreen("black")
// SEND_SOUND(client, sound(null, repeat = FALSE, wait = FALSE, volume = 85 * client.prefs.get_channel_volume(CHANNEL_LOBBYMUSIC), channel = CHANNEL_LOBBYMUSIC))
/datum/controller/subsystem/credits/proc/clear_credits(client/client)
if(!client)
return
QDEL_NULL(client.credits)

/datum/controller/subsystem/credits/proc/generate_titles()
RETURN_TYPE(/list)
Expand Down Expand Up @@ -151,18 +143,47 @@ SUBSYSTEM_DEF(credits)

return titles

/obj/screen/credit
icon_state = "blank"
mouse_opacity = 0
alpha = 0
screen_loc = "CENTER-7,CENTER-7"
plane = 25

var/matrix/target
var/client/parent

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

parent = client
maptext = {"<div style="font:'Small Fonts'">[credited]</div>"}
maptext_height = world.icon_size * 2
maptext_width = world.icon_size * 14

/obj/screen/credit/proc/rollem()
var/matrix/M = matrix(transform)
M.Translate(0, SScredits.credit_animate_height)
animate(src, transform = M, time = SScredits.credit_roll_speed)
target = M
animate(src, alpha = 255, time = SScredits.credit_ease_duration, flags = ANIMATION_PARALLEL)
spawn(SScredits.credit_roll_speed - SScredits.credit_ease_duration)
if(!QDELETED(src))
animate(src, alpha = 0, transform = target, time = SScredits.credit_ease_duration)
sleep(SScredits.credit_ease_duration)
qdel(src)
parent.screen += src

/obj/screen/fullscreen/black
icon = 'icons/mob/screen_gen.dmi'
icon_state = "black"
screen_loc = "WEST,SOUTH to EAST,NORTH"
plane = CREDITS_BACKGROUND_PLANE
show_when_dead = TRUE
/obj/screen/credit/Destroy()
if(parent)
parent.screen -= src
LAZYREMOVE(parent.credits, src)
parent = null
return ..()




/client/var/list/credits

#undef CREDITS_PLANE
#undef CREDITS_BACKGROUND_PLANE

0 comments on commit c2eaf9c

Please sign in to comment.