From 9c28aec1af764fcd1d069f847fe32da32f694f33 Mon Sep 17 00:00:00 2001 From: Fluffy <65877598+FluffyGhoster@users.noreply.github.com> Date: Fri, 1 Sep 2023 03:05:41 +0200 Subject: [PATCH] Title screen timer (#17200) * Atomization * cl --------- Co-authored-by: FluffyGhost --- code/modules/mob/abstract/new_player/menu.dm | 15 ++++++- .../FluffyGhost-title_screen_timer.yml | 41 +++++++++++++++++++ 2 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 html/changelogs/FluffyGhost-title_screen_timer.yml diff --git a/code/modules/mob/abstract/new_player/menu.dm b/code/modules/mob/abstract/new_player/menu.dm index 1599feada63..a5677fd252d 100644 --- a/code/modules/mob/abstract/new_player/menu.dm +++ b/code/modules/mob/abstract/new_player/menu.dm @@ -66,6 +66,14 @@ name = "Title" screen_loc = "WEST,SOUTH" var/lobby_index = 1 + var/refresh_timer_id = null + +/obj/screen/new_player/title/Destroy(force) + if(refresh_timer_id) + deltimer(refresh_timer_id) + refresh_timer_id = null + . = ..() + /obj/screen/new_player/title/Initialize() if(SSatlas.current_sector.sector_lobby_art) @@ -87,7 +95,7 @@ spawn(current_map.lobby_transitions) Update() else - addtimer(CALLBACK(src, PROC_REF(Update)), current_map.lobby_transitions, TIMER_UNIQUE | TIMER_CLIENT_TIME | TIMER_OVERRIDE) + refresh_timer_id = addtimer(CALLBACK(src, PROC_REF(Update)), current_map.lobby_transitions, TIMER_UNIQUE | TIMER_CLIENT_TIME | TIMER_OVERRIDE | TIMER_STOPPABLE) else icon_state = pick(current_map.lobby_screens) else //This should basically never happen. @@ -99,6 +107,9 @@ return /obj/screen/new_player/title/proc/Update() + if(QDELING(src)) + return + if(!current_map.lobby_transitions && SSatlas.current_sector.sector_lobby_transitions) return if(!istype(hud) || !isnewplayer(hud.mymob)) @@ -112,7 +123,7 @@ spawn(current_map.lobby_transitions) Update() else - addtimer(CALLBACK(src, PROC_REF(Update)), current_map.lobby_transitions, TIMER_UNIQUE | TIMER_CLIENT_TIME | TIMER_OVERRIDE) + refresh_timer_id = addtimer(CALLBACK(src, PROC_REF(Update)), current_map.lobby_transitions, TIMER_UNIQUE | TIMER_CLIENT_TIME | TIMER_OVERRIDE | TIMER_STOPPABLE) /obj/screen/new_player/selection var/click_sound = 'sound/effects/menu_click.ogg' diff --git a/html/changelogs/FluffyGhost-title_screen_timer.yml b/html/changelogs/FluffyGhost-title_screen_timer.yml new file mode 100644 index 00000000000..7d5691eb2a9 --- /dev/null +++ b/html/changelogs/FluffyGhost-title_screen_timer.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "The title screen now uses an unique timer that is stopped upon deletion, and avoids refreshing if it's queued for it."