1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-12-14 10:41:52 +00:00

Merge pull request #44 from tobspr-games/fix/tgs-fallback

Fix TextualGameState HTML string fallback
This commit is contained in:
Даниїл Григор'єв 2024-09-23 23:48:10 +03:00 committed by GitHub
commit 7814c3a15a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,7 +19,11 @@ export abstract class TextualGameState extends GameState {
* @deprecated * @deprecated
*/ */
getInnerHTML(): string { getInnerHTML(): string {
return ""; return `
<div class="content mainContent">
${this.getMainContentHTML()}
</div>
`;
} }
/** /**
@ -36,21 +40,8 @@ export abstract class TextualGameState extends GameState {
* title, and content returned by {@link getInitialContent}. * title, and content returned by {@link getInitialContent}.
*/ */
protected override getContentLayout(): Node { protected override getContentLayout(): Node {
let content = this.getInitialContent(); const initialContent = this.getInitialContent();
const content = initialContent !== null && <div class="content mainContent">{initialContent}</div>;
if (content === null) {
// Fall back either to getMainContentHTML or getInnerHTML (if not "")
let html = this.getInnerHTML();
if (html === "") {
html = `
<div class="content mainContent">
${this.getMainContentHTML()}
</div>
`;
}
content = super.getContentLayout();
}
return ( return (
<> <>
@ -60,7 +51,7 @@ export abstract class TextualGameState extends GameState {
{this.getStateHeaderTitle() ?? ""} {this.getStateHeaderTitle() ?? ""}
</h1> </h1>
</div> </div>
<div class="container">{content}</div> <div class="container">{content || super.getContentLayout()}</div>
</> </>
); );
} }