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: 🐛 Adventure Site creation #434

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
5 changes: 5 additions & 0 deletions .changeset/clean-peas-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"forbidden-lands": patch
---

Fixes the Adventure Site creation mechanisms. Adventure Sites can now be created by using a button in the Journal Sidebar Tab
4 changes: 4 additions & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"ACTOR.TypeMonster": "Monster",
"ACTOR.TypeParty": "Party",
"ACTOR.TypeStronghold": "Stronghold",
"ADVENTURE_SITE.ADD_ROOM": "Add Room",
"ADVENTURE_SITE.CREATE_TITLE": "Create a new Adventure Site",
"ADVENTURE_SITE.CREATE_DESCRIPTION": "Choose what type of site you want to create.",
"ADVENTURE_SITE.LABEL": "Adventure Site",
"ARMOR.BODY": "Body",
"ARMOR.HELMET": "Helmet",
"ARMOR.OTHER": "Other",
Expand Down
2 changes: 1 addition & 1 deletion src/forbidden-lands.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

@import "system";
@import "changelog";
@import "journal";
@import "journal";
3 changes: 0 additions & 3 deletions src/forbidden-lands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
init,
utilities,
} from "@journal/adventure-sites/adventure-site-generator.js";
import { ForbiddenLandsJournalEntry } from "@journal/journal-document.js";
import FBL, { modifyConfig } from "@system/core/config.js";
import { initializeEditorEnrichers } from "@system/core/editor.js";
import { registerFonts } from "@system/core/fonts.js";
Expand Down Expand Up @@ -47,8 +46,6 @@ Hooks.once("init", () => {

CONFIG.Actor.documentClass = ForbiddenLandsActor;
CONFIG.Item.documentClass = ForbiddenLandsItem;
// @ts-expect-error - PF2 types Internal Type Error
CONFIG.JournalEntry.documentClass = ForbiddenLandsJournalEntry;
CONFIG.statusEffects = [
...CONFIG.statusEffects.filter(
(effect) => !["sleep", "frozen", "curse"].includes(effect.id),
Expand Down
54 changes: 54 additions & 0 deletions src/journal/adventure-sites/adventure-site-generator.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import t from "$utils/localize-string";

let ALL_TABLES = {};

// Utilities
Expand Down Expand Up @@ -185,6 +187,58 @@ const moldData = (data, type) => {
return typeFn(data, ALL_TABLES);
};

export const adventureSiteCreateDialog = async () => {
const titleCase = (string) =>
string.replace(/_/g, " ").replace(/\b\w/g, (char) => char.toUpperCase());

const types = Object.entries(CONFIG.fbl.adventureSites.types);

const type = await Dialog.wait({
title: t("ADVENTURE_SITE.CREATE_TITLE"),
content: `<form style="margin-block:12px;">
<p>${t("ADVENTURE_SITE.CREATE_DESCRIPTION")}</p>
<div class="form-group">
<div class="form-fields">
<label>${t("Type")}</label>
<select name="type">
${types.map(([key, value]) => {
return `<option value="${value}:${key}">${titleCase(key)}</option>`;
})}
</select>
</div>
</div>
</form>`,
buttons: {
ok: {
icon: '<i class="fas fa-check"></i>',
label: `${t("Create")}`,
callback: (jqhtml) => jqhtml.find("form")[0].type.value,
},
},
});

const [path, adventureSite] = type.split(":");

const content = await CONFIG.fbl.adventureSites.generate(path, adventureSite);

const entry = await JournalEntry.create({
name: `${t("ADVENTURE_SITE.LABEL")}: ${titleCase(adventureSite)}`,
pages: [
{
name: titleCase(adventureSite),
text: { content: `<div class="adventure-site">${content}</div>` },
title: { show: false },
},
],
flags: {
"forbidden-lands": {
adventureSiteType: adventureSite,
},
},
});
entry.sheet.render(true);
};

// Initialize random generation
export const init = async (path, adventureSite) => {
const registeredSites = Object.keys(CONFIG.fbl.adventureSites.types);
Expand Down
37 changes: 0 additions & 37 deletions src/journal/adventure-sites/adventure-site-sheet.js

This file was deleted.

19 changes: 9 additions & 10 deletions src/journal/adventure-sites/styles/_adventure-sites.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
/*

Journal Sheet Styles

*/
.app .journal-sheet-container {

.app .journal-sheet-container.adventure-site {
// Form content
.journal-entry-page.text {
& > * {
.journal-entry-page.text .adventure-site {
&>* {
margin-inline: auto;
}

Expand Down Expand Up @@ -35,7 +33,7 @@
font-weight: 600;
}

p + p {
p+p {
text-indent: 0;
}

Expand All @@ -61,7 +59,7 @@
background-color: #f0f0f0;
}

& > .index-tip {
&>.index-tip {
font-family: Branding, Ubuntu, sans-serif;
position: absolute;
top: 0;
Expand All @@ -77,6 +75,7 @@
}
}
}

.editable-tools {
position: absolute;
left: 50%;
Expand All @@ -89,7 +88,7 @@
gap: 4rem;

// Buttons
& > * {
&>* {
display: block;
margin: 0;
min-width: 14rem;
Expand All @@ -105,7 +104,7 @@
}

&:hover {
& > * {
&>* {
opacity: 1;

&:hover {
Expand All @@ -115,4 +114,4 @@
}
}
}
}
}
80 changes: 0 additions & 80 deletions src/journal/journal-document.js

This file was deleted.

13 changes: 3 additions & 10 deletions src/journal/styles/_journal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@
background-color: #eeed;
}
}

.pages-list .directory-item.active {
background-color: var(--color-theme-constrast);

.page-heading {
font-weight: 600;
}
}
}

// Force proper height
Expand Down Expand Up @@ -121,6 +113,7 @@

// Page header
.journal-page-header {

h1,
h2,
h3 {
Expand All @@ -144,7 +137,7 @@
}

// Page Content
:where(.journal-page-content,.editor-content) {
:where(.journal-page-content, .editor-content) {
font-family: var(--font-editor);
line-height: 1.75;
font-size: var(--font-size-16);
Expand Down Expand Up @@ -191,4 +184,4 @@
}
}
}
}
}
Loading
Loading