diff --git a/modular_ss220/title_screen/_title_screen.dme b/modular_ss220/title_screen/_title_screen.dme index e7740ff637de..daf242c3a26f 100644 --- a/modular_ss220/title_screen/_title_screen.dme +++ b/modular_ss220/title_screen/_title_screen.dme @@ -3,6 +3,7 @@ #include "code/_title_screen_defines.dm" #include "code/dead.dm" #include "code/living.dm" +#include "code/asset_lobby.dm" #include "code/mob.dm" #include "code/new_player.dm" #include "code/title_screen_controls.dm" diff --git a/modular_ss220/title_screen/code/_title_screen_defines.dm b/modular_ss220/title_screen/code/_title_screen_defines.dm index 02bb9871eb24..820b4a647951 100644 --- a/modular_ss220/title_screen/code/_title_screen_defines.dm +++ b/modular_ss220/title_screen/code/_title_screen_defines.dm @@ -1,4 +1,4 @@ -#define DEFAULT_TITLE_SCREEN_IMAGE 'modular_ss220/title_screen/icons/default.dmi' +#define DEFAULT_TITLE_SCREEN_IMAGE "default.gif" #define DEFAULT_TITLE_HTML {" diff --git a/modular_ss220/title_screen/code/asset_lobby.dm b/modular_ss220/title_screen/code/asset_lobby.dm new file mode 100644 index 000000000000..bd7eb1d786f4 --- /dev/null +++ b/modular_ss220/title_screen/code/asset_lobby.dm @@ -0,0 +1,19 @@ +/datum/asset/group/lobby + children = list( + /datum/asset/simple/lobby_fonts, + /datum/asset/simple/lobby_title_screen_images + ) + +/datum/asset/simple/lobby_fonts + assets = list( + "FixedsysExcelsior3.01Regular.ttf" = 'modular_ss220/title_screen/html/browser/FixedsysExcelsior3.01Regular.ttf', + ) + +/datum/asset/simple/lobby_title_screen_images + assets = list( + DEFAULT_TITLE_SCREEN_IMAGE = 'modular_ss220/title_screen/icons/default.gif' + ) + +/datum/asset/simple/lobby_title_screen_images/register() + assets += SStitle.get_title_screens() + return ..() diff --git a/modular_ss220/title_screen/code/mob.dm b/modular_ss220/title_screen/code/mob.dm index 316772269203..0ef177f9c82f 100644 --- a/modular_ss220/title_screen/code/mob.dm +++ b/modular_ss220/title_screen/code/mob.dm @@ -1,5 +1,3 @@ -#define TITLE_SCREEN_BG_FILE_NAME "bg_file_name" - /** * Shows the titlescreen to a new player. */ @@ -9,17 +7,17 @@ winset(src, "title_browser", "is-disabled=true;is-visible=true") winset(src, "status_bar", "is-visible=false") - var/datum/asset/assets = get_asset_datum(/datum/asset/simple/lobby) //Sending pictures to the client - assets.send(src) + var/datum/asset/lobby_asset = get_asset_datum(/datum/asset/group/lobby) + lobby_asset.send(src) - update_title_screen() + src << browse(get_title_html(), "window=title_browser") /** * Get the HTML of title screen. */ /mob/proc/get_title_html() var/dat = SStitle.title_html - dat += {""} + dat += {""} if(SStitle.current_notice) dat += {" @@ -32,20 +30,6 @@ return dat -/** - * Hard updates the title screen HTML, it causes visual glitches if used. - */ -/mob/proc/update_title_screen() - var/dat = get_title_html() - - src << browse(SStitle.current_title_screen, "file=[TITLE_SCREEN_BG_FILE_NAME];display=0") - src << browse(dat, "window=title_browser") - -/datum/asset/simple/lobby - assets = list( - "FixedsysExcelsior3.01Regular.ttf" = 'modular_ss220/title_screen/html/browser/FixedsysExcelsior3.01Regular.ttf', - ) - /** * Removes the titlescreen entirely from a mob. */ @@ -53,5 +37,3 @@ if(client?.mob) winset(client, "title_browser", "is-disabled=true;is-visible=false") winset(client, "status_bar", "is-visible=true") - -#undef TITLE_SCREEN_BG_FILE_NAME diff --git a/modular_ss220/title_screen/code/title_screen_controls.dm b/modular_ss220/title_screen/code/title_screen_controls.dm index 579cba432ff5..beec742502d3 100644 --- a/modular_ss220/title_screen/code/title_screen_controls.dm +++ b/modular_ss220/title_screen/code/title_screen_controls.dm @@ -49,7 +49,7 @@ /client/verb/fix_title_screen() set name = "Fix Lobby Screen" set desc = "Lobbyscreen broke? Press this." - set category = "OOC" + set category = "Special Verbs" if(istype(mob, /mob/new_player)) mob.show_title_screen() diff --git a/modular_ss220/title_screen/code/title_screen_subsystem.dm b/modular_ss220/title_screen/code/title_screen_subsystem.dm index bf3288137af6..c78746662484 100644 --- a/modular_ss220/title_screen/code/title_screen_subsystem.dm +++ b/modular_ss220/title_screen/code/title_screen_subsystem.dm @@ -9,8 +9,8 @@ var/current_notice /// The preamble html that includes all styling and layout. var/title_html - /// The list of possible title screens to rotate through, as file path texts. - var/title_screens = list() + /// The list of possible title screens to rotate through, as: title_screen_name -> title_screen_path + var/list/title_screens = list() /datum/controller/subsystem/title/Initialize() if(!fexists("config/title_html.txt")) @@ -19,17 +19,7 @@ else title_html = file2text("config/title_html.txt") - var/list/local_title_screens = list() - for(var/screen in flist(TITLE_SCREENS_LOCATION)) - var/list/screen_name_parts = splittext(screen, "+") - if((LAZYLEN(screen_name_parts) == 1 && (screen_name_parts[1] != "exclude" && screen_name_parts[1] != "blank.png"))) - local_title_screens += screen - - for(var/title_screen in local_title_screens) - var/file_path = "[TITLE_SCREENS_LOCATION][title_screen]" - ASSERT(fexists(file_path)) - title_screens += fcopy_rsc(file_path) - + load_title_screens() change_title_screen() /datum/controller/subsystem/title/Recover() @@ -38,6 +28,52 @@ title_html = SStitle.title_html title_screens = SStitle.title_screens +/** + * Iterates over all files in `TITLE_SCREENS_LOCATION` and loads all valid title screens to `title_screens` var. + */ +/datum/controller/subsystem/title/proc/load_title_screens() + var/list/valid_title_screens = list() + for(var/screen in flist(TITLE_SCREENS_LOCATION)) + if(validate_title_screen(screen)) + valid_title_screens += screen + + for(var/title_screen_name in valid_title_screens) + var/file_path = "[TITLE_SCREENS_LOCATION][title_screen_name]" + ASSERT(fexists(file_path)) + title_screens[title_screen_name] = fcopy_rsc(file_path) + +/** + * Checks wheter passed title is valid + * Currently validates extension and checks whether it's special image like default title screen etc. + */ +/datum/controller/subsystem/title/proc/validate_title_screen(title_screen_to_validate) + var/static/list/title_screens_to_ignore = list("blank.png", DEFAULT_TITLE_SCREEN_IMAGE) + if(title_screen_to_validate in title_screens_to_ignore) + return FALSE + + var/list/name_parts = splittext(title_screen_to_validate, ".") + if(length(name_parts) < 2) + return FALSE + + var/static/list/supported_extensions = list("gif", "jpg", "jpeg","png", "svg") + var/extension = name_parts[length(name_parts)] + return (extension in supported_extensions) + +/** + * Returns the list of all loaded title screens, if no title screens present, tries to load them. + */ +/datum/controller/subsystem/title/proc/get_title_screens() + if(!length(title_screens)) + load_title_screens() + + return title_screens.Copy() + +/** + * Returns current title screen or if null, default one. + */ +/datum/controller/subsystem/title/proc/get_current_title_screen() + return current_title_screen || DEFAULT_TITLE_SCREEN_IMAGE + /** * Show the title screen to all new players. */ @@ -59,7 +95,7 @@ if(new_screen) current_title_screen = new_screen else - if(LAZYLEN(title_screens)) + if(length(title_screens)) current_title_screen = pick(title_screens) else current_title_screen = DEFAULT_TITLE_SCREEN_IMAGE diff --git a/modular_ss220/title_screen/icons/default.dmi b/modular_ss220/title_screen/icons/default.dmi deleted file mode 100644 index e8ede9793036..000000000000 Binary files a/modular_ss220/title_screen/icons/default.dmi and /dev/null differ diff --git a/modular_ss220/title_screen/icons/default.gif b/modular_ss220/title_screen/icons/default.gif new file mode 100644 index 000000000000..6b7519f1b5a9 Binary files /dev/null and b/modular_ss220/title_screen/icons/default.gif differ