Skip to content

Commit

Permalink
fix: hope to fix title screen this time for sure (#801)
Browse files Browse the repository at this point in the history
## Что этот PR делает

Картинка в лобби всегда будет присутствовать (но это не точно)

## Почему это хорошо для игры

Не надо жать `Fix Lobby Screen`

## Изображения изменений
Нет.

## Тестирование
Запустил сервер, зашел до инициализации - картинка прогрузилась. 
Запустил сервер, зашел после инициализации - картинка прогрузилась. 

## Changelog

:cl:
fix: Картинка в лобби подгружается вовремя
/:cl:
  • Loading branch information
Gaxeer authored Dec 1, 2023
1 parent e0cbbfd commit e7ac3c3
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 54 deletions.
1 change: 0 additions & 1 deletion modular_ss220/title_screen/_title_screen.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
#include "code/mob.dm"
#include "code/new_player.dm"
#include "code/title_screen_controls.dm"
#include "code/title_screen_html.dm"
#include "code/title_screen_subsystem.dm"
1 change: 0 additions & 1 deletion modular_ss220/title_screen/code/_title_screen_defines.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#define DEFAULT_TITLE_SCREEN_IMAGE 'modular_ss220/title_screen/icons/default.dmi'
#define DEFAULT_TITLE_LOADING_SCREEN 'modular_ss220/title_screen/icons/loading_screen.gif'

#define DEFAULT_TITLE_HTML {"
<html>
Expand Down
24 changes: 23 additions & 1 deletion modular_ss220/title_screen/code/mob.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define TITLE_SCREEN_BG_FILE_NAME "bg_file_name"

/**
* Shows the titlescreen to a new player.
*/
Expand All @@ -12,13 +14,31 @@

update_title_screen()

/**
* Get the HTML of title screen.
*/
/mob/proc/get_title_html()
var/dat = SStitle.title_html
dat += {"<img src="[TITLE_SCREEN_BG_FILE_NAME]" class="bg" alt="">"}

if(SStitle.current_notice)
dat += {"
<div class="container_notice">
<p class="menu_notice">[SStitle.current_notice]</p>
</div>
"}

dat += "</body></html>"

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=loading_screen.gif;display=0")
src << browse(SStitle.current_title_screen, "file=[TITLE_SCREEN_BG_FILE_NAME];display=0")
src << browse(dat, "window=title_browser")

/datum/asset/simple/lobby
Expand All @@ -33,3 +53,5 @@
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
11 changes: 0 additions & 11 deletions modular_ss220/title_screen/code/new_player.dm
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
GLOBAL_LIST_EMPTY(new_player_list)

/mob/new_player/Initialize(mapload)
GLOB.new_player_list += src
show_title_screen()
. = ..()

/mob/new_player/Destroy()
GLOB.new_player_list -= src
. = ..()

/mob/new_player/Login()
. = ..()
show_title_screen()
2 changes: 1 addition & 1 deletion modular_ss220/title_screen/code/title_screen_controls.dm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
SStitle.set_notice(new_notice)
if(!new_notice)
return
for(var/mob/new_player/new_player in GLOB.new_player_list)
for(var/mob/new_player/new_player in GLOB.player_list)
to_chat(new_player, span_boldannounce("TITLE NOTICE UPDATED: [new_notice]"))
SEND_SOUND(new_player, sound('sound/items/bikehorn.ogg'))

Expand Down
16 changes: 0 additions & 16 deletions modular_ss220/title_screen/code/title_screen_html.dm

This file was deleted.

37 changes: 14 additions & 23 deletions modular_ss220/title_screen/code/title_screen_subsystem.dm
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/datum/controller/subsystem/title
flags = SS_NO_FIRE
init_order = INIT_ORDER_TITLE

var/file_path

/// The current title screen being displayed, as a file path text.
var/current_title_screen
/// The current notice text, or null.
Expand All @@ -14,35 +11,29 @@
var/title_screens = list()

/datum/controller/subsystem/title/Initialize()
var/dat
if(!fexists("config/title_html.txt"))
to_chat(world, span_boldwarning("CRITICAL ERROR: Unable to read title_html.txt, reverting to backup title html, please check your server config and ensure this file exists."))
dat = DEFAULT_TITLE_HTML
error(span_boldwarning("Unable to read title_html.txt, reverting to backup title html, please check your server config and ensure this file exists."))
title_html = DEFAULT_TITLE_HTML
else
dat = file2text("config/title_html.txt")

title_html = dat
title_html = file2text("config/title_html.txt")

var/list/provisional_title_screens = flist("config/title_screens/images/")
var/list/local_title_screens = list()

for(var/screen in provisional_title_screens)
var/list/formatted_list = splittext(screen, "+")
if((LAZYLEN(formatted_list) == 1 && (formatted_list[1] != "exclude" && formatted_list[1] != "blank.png")))
for(var/screen in flist("config/title_screens/images/"))
var/list/screen_name_parts = splittext(screen, "+")
if((LAZYLEN(screen_name_parts) == 1 && (screen_name_parts[1] != "exclude" && screen_name_parts[1] != "blank.png")))
message_admins("Screen: [screen]")
local_title_screens += screen

if(length(local_title_screens))
for(var/i in local_title_screens)
var/file_path = "config/title_screens/images/[i]"
ASSERT(fexists(file_path))
var/icon/title2use = new(fcopy_rsc(file_path))
title_screens += title2use
for(var/title_screen in local_title_screens)
var/file_path = "config/title_screens/images/[title_screen]"
ASSERT(fexists(file_path))

var/icon/title2use = new(fcopy_rsc(file_path))
title_screens += title2use

change_title_screen()

/datum/controller/subsystem/title/Recover()
file_path = SStitle.file_path

current_title_screen = SStitle.current_title_screen
current_notice = SStitle.current_notice
title_html = SStitle.title_html
Expand All @@ -52,7 +43,7 @@
* Show the title screen to all new players.
*/
/datum/controller/subsystem/title/proc/show_title_screen()
for(var/mob/new_player/new_player in GLOB.new_player_list)
for(var/mob/new_player/new_player in GLOB.player_list)
INVOKE_ASYNC(new_player, TYPE_PROC_REF(/mob/new_player, show_title_screen))

/**
Expand Down
Binary file removed modular_ss220/title_screen/icons/loading_screen.gif
Binary file not shown.

0 comments on commit e7ac3c3

Please sign in to comment.