Skip to content

Commit

Permalink
fix: 🐛 Adventure Site creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aMediocreDad committed Jul 21, 2024
1 parent 21e6a1a commit d226ca5
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 266 deletions.
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

0 comments on commit d226ca5

Please sign in to comment.