Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Welcome journal no content v12 #64

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 53 additions & 50 deletions scripts/system/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,11 @@ export class LitmHooks {
const tokenImg = actor.prototypeToken?.texture?.src;
const prototypeToken = isCharacter
? {
sight: { enabled: true },
actorLink: true,
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
texture: { src: tokenImg || img },
}
sight: { enabled: true },
actorLink: true,
disposition: CONST.TOKEN_DISPOSITIONS.FRIENDLY,
texture: { src: tokenImg || img },
}
: null;
actor.updateSource({ prototypeToken, img });
});
Expand Down Expand Up @@ -376,49 +376,47 @@ export class LitmHooks {
</button>
</li>
<li>
<button type="button" data-click="render-character" aria-label="${
game.user.character
? game.user.character.name
: t("PLAYER.SelectedCharacter")
}"
data-tooltip="${
game.user.character
? game.user.character.name
: t("PLAYER.SelectedCharacter")
}">
<button type="button" data-click="render-character" aria-label="${game.user.character
? game.user.character.name
: t("PLAYER.SelectedCharacter")
}"
data-tooltip="${game.user.character
? game.user.character.name
: t("PLAYER.SelectedCharacter")
}">
<i class="fas fa-user"></i>
</button>
</li>
<li>
<button type="button" data-click="render-roll" aria-label="${t(
"Litm.ui.roll-title",
)}"
"Litm.ui.roll-title",
)}"
data-tooltip="${t("Litm.ui.roll-title")}">
<i class="fas fa-dice"></i>
</button>
</li>
</menu>
`).on("click", "[data-click]", (event) => {
const { click } = event.currentTarget.dataset;
switch (click) {
case "toggle-rendered":
if (!app.rendered) app.render(true);
else app.close();
break;
case "render-character":
if (!game.user.character)
return ui.notifications.warn(t("Litm.ui.warn-no-character"));
if (!game.user.character.sheet.rendered)
game.user.character.sheet.render(true);
else game.user.character.sheet.close();
break;
case "render-roll":
if (!game.user.character)
return ui.notifications.warn(t("Litm.ui.warn-no-character"));
game.user.character.sheet.renderRollDialog({ toggle: true });
break;
}
});
const { click } = event.currentTarget.dataset;
switch (click) {
case "toggle-rendered":
if (!app.rendered) app.render(true);
else app.close();
break;
case "render-character":
if (!game.user.character)
return ui.notifications.warn(t("Litm.ui.warn-no-character"));
if (!game.user.character.sheet.rendered)
game.user.character.sheet.render(true);
else game.user.character.sheet.close();
break;
case "render-roll":
if (!game.user.character)
return ui.notifications.warn(t("Litm.ui.warn-no-character"));
game.user.character.sheet.renderRollDialog({ toggle: true });
break;
}
});

html.before(buttonSection);
});
Expand Down Expand Up @@ -523,12 +521,10 @@ export class LitmHooks {

static #rendeWelcomeScreen() {
Hooks.once("ready", async () => {
let scene = game.scenes.getName("Legend in the Mist");
if (scene) return;

ui.sidebar.activateTab("actors");
if (game.settings.get("litm", "welcomed")) return;
if (!game.user.isGM) return;

scene = await Scene.create({
const scene = await Scene.create({
name: "Legend in the Mist",
permission: { default: 2 },
navigation: true,
Expand Down Expand Up @@ -557,8 +553,10 @@ export class LitmHooks {
const entry = await JournalEntry.create({
name: "Legend in the Mist",
permission: { default: 2 },
content: /*html */ `
<h1 style="text-align:center"><span style="font-family: PackardAntique">Welcome!</span></h1>
pages: [{
name: "Welcome!",
text: {
content: /* html */ `
<p style="text-align: center"><em>I am thrilled to have you try out this system</em></p>
<p></p>
<blockquote style="padding:0.5em 10px;background:var(--litm-color-primary-bg);color:var(--litm-color-weakness)">
Expand Down Expand Up @@ -626,7 +624,7 @@ export class LitmHooks {
<p>Thanks to <strong>@Altervayne </strong>for creating the online character creator and setting up a Discord community for us.</p>
</li>
<li>
<p>Thanks to @<strong>erizocosmico</strong> for our first Localisation effort (Spanish).</p>
<p>Thanks to @<strong>erizocosmico</strong> (Spanish), @<strong>imiri78</strong> (German), and @<strong>0rac1e404</strong> (Chinese) for our first localisation efforts.</p>
</li>
<li>
<p>Thanks to the <em><strong>City of Mist </strong>Discord </em>for contributing feedback, bug reports and generally being awesome about me barging in the door like I did.</p>
Expand All @@ -638,20 +636,22 @@ export class LitmHooks {
<p><strong>See you in the mist…</strong></p>
</blockquote>
`,
}
}
]
});

// Create a "welcome" chat message
ChatMessage.create({
title: "Welcome to Legend in the Mist!",
content: /* html */ `
<p><strong>Welcome to Legend in the Mist</strong></p>
<p>Before you start playing, you should want to read the <a class="content-link" draggable="true" data-uuid="${
entry.uuid
}" data-id="${entry._id}" data-type="JournalEntryPage" data-tooltip="User Manual"><i class="fas fa-file-lines"></i>Legend in the Mist</a> journal entry. It contains some important information about the system, and what to expect.</p>
<p>Before you start playing, you should want to read the <a class="content-link" draggable="true" data-uuid="${entry.uuid
}" data-id="${entry._id}" data-type="JournalEntryPage" data-tooltip="User Manual"><i class="fas fa-file-lines"></i>Legend in the Mist</a> journal entry. It contains some important information about the system, and what to expect.</p>
<p>Once you've read the journal entry, you can click the button below to import all the rules and content required to play the Tinderbox Demo.</p>
<button type="button" id="litm--import-adventure" style="background: var(--litm-color-status-bg);"><strong>${t(
"Litm.ui.import-adventure",
)}</strong></button>
"Litm.ui.import-adventure",
)}</strong></button>
<p style="text-align:center;">Good luck, and have fun!</p>
`,
});
Expand All @@ -664,6 +664,9 @@ export class LitmHooks {
width: 600,
height: 600,
});

// We're done!
game.settings.set("litm", "welcomed", true);
});

Hooks.on("renderChatMessage", (_app, html) => {
Expand Down
9 changes: 9 additions & 0 deletions scripts/system/settings.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
export class LitmSettings {
static register() {
game.settings.register("litm", "welcomed", {
name: "Welcome Screen",
hint: "Welcome Scene, Message, and Journal Entry has been created and displayed.",
scope: "world",
config: false,
type: Boolean,
default: false,
});

game.settings.register("litm", "storytags", {
name: "Story Tags",
hint: "Tags that are shared between all users.",
Expand Down