Added an app to work on campaign frame things in

This commit is contained in:
WBHarry 2026-05-22 17:17:21 +02:00
parent bae9006f64
commit 044ecd9d55
12 changed files with 187 additions and 1 deletions

View file

@ -104,6 +104,7 @@ Hooks.once('init', () => {
fields
};
game.system.campaignFrames = new game.system.api.data.CampaignFrames();
game.system.registeredTriggers = new game.system.api.data.RegisteredTriggers();
const { DocumentSheetConfig } = foundry.applications.apps;
@ -318,6 +319,28 @@ Hooks.on('ready', async () => {
}
}
/* Temporary for testing */
game.system.campaignFrames.register({
witherwild: {
name: 'Witherwild',
img: 'CampaignFrameStuff/Witherwild.png',
complexityRating: 1,
pitch: `<div>Fanewick was once a place of great abundance and peace
dangerous to those unfamiliar with the land, but a cornucopia
to those who respected its ways. When Haven invaded the
wilds and forced the land into eternal spring, a dangerous
bloom known as the Witherwild took hold and now threatens
the lives of all who live there. In a Witherwild campaign,
youll play unlikely heroes from humble beginnings who are
reckoning with their newfound duty to save Fanewicks people
from dangerous corruption.</div>`,
toneAndFeel: 'Adventurous, Dynamic, Epic, Heroic, Thrilling, Uncanny, Whimsical',
themes: 'Cultural Clash, Ends Justify Means, Grief, People vs. Nature, Transformation and Change, Survival',
touchstones: 'Princess Mononoke, The Legend of Zelda, The Dark Crystal, Nausicaä of the Valley of the Wind'
}
});
/* Temporary for testing */
runMigrations();
});

View file

@ -354,6 +354,9 @@
"Attribution": {
"title": "Attribution"
},
"CampaignFrames": {
"title": "Campaign Frames"
},
"CharacterCreation": {
"tabs": {
"ancestry": "Ancestry",

View file

@ -1,3 +1,4 @@
export * as campaignFrame from './campaignFrame/_module.mjs';
export * as characterCreation from './characterCreation/_module.mjs';
export * as dialogs from './dialogs/_module.mjs';
export * as hud from './hud/_module.mjs';

View file

@ -0,0 +1 @@
export { default as CampaignFrames } from './campaignFrames.mjs';

View file

@ -0,0 +1,46 @@
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class DhCampaignFrames extends HandlebarsApplicationMixin(ApplicationV2) {
constructor() {
super({});
}
get title() {
return game.i18n.format('DAGGERHEART.APPLICATIONS.CampaignFrames.title');
}
static DEFAULT_OPTIONS = {
classes: ['daggerheart', 'dh-style', 'campaign-frame'],
position: { width: 640, height: 'auto' },
window: { icon: 'fa-solid fa-globe' },
actions: {}
};
static PARTS = {
application: {
id: 'campaign-frames',
template: 'systems/daggerheart/templates/campaignFrames/campaign-frames.hbs'
}
};
getCampaignFrameTabs(frames) {
for (const v of Object.values(frames)) {
v.active = this.tabGroups[v.group]
? this.tabGroups[v.group] === v.id
: this.tabGroups.primary !== 'equipment'
? v.active
: false;
v.cssClass = v.active ? 'active' : '';
}
return tabs;
}
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.campaignFrames = game.system.campaignFrames.frames;
// context.campaignFrameTabs = this.getCampaignFrameTabs(context.campaignFrames);
return context;
}
}

View file

@ -32,7 +32,8 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
actions: {
selectRefreshable: DaggerheartMenu.#selectRefreshable,
refreshActors: DaggerheartMenu.#refreshActors,
createFallCollisionDamage: DaggerheartMenu.#createFallCollisionDamage
createFallCollisionDamage: DaggerheartMenu.#createFallCollisionDamage,
openCampaignFrames: DaggerheartMenu.#openCampaignFrames
}
};
@ -91,4 +92,8 @@ export default class DaggerheartMenu extends HandlebarsApplicationMixin(Abstract
sound: CONFIG.sounds.dice
});
}
static async #openCampaignFrames() {
new game.system.api.applications.campaignFrame.CampaignFrames().render({ force: true });
}
}

View file

@ -1,3 +1,4 @@
export { default as CampaignFrames } from './campaignFrames.mjs';
export { default as DhCombat } from './combat.mjs';
export { default as DhCombatant } from './combatant.mjs';
export { default as DhRollTable } from './rollTable.mjs';

View file

@ -0,0 +1,29 @@
export default class DhCampaignFrames extends foundry.abstract.TypeDataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
frames: new fields.TypedObjectField(new fields.EmbeddedDataField(DhCampaignFrame))
};
}
register(frames) {
this.updateSource({ frames });
}
}
class DhCampaignFrame extends foundry.abstract.DataModel {
static defineSchema() {
const fields = foundry.data.fields;
return {
name: new fields.StringField({ required: true }),
img: new fields.FilePathField({ initial: 'icons/svg/mountain.svg', categories: ['IMAGE'], base64: false }),
complexityRating: new fields.NumberField({ required: true, integer: true }),
pitch: new fields.HTMLField(),
toneAndFeel: new fields.StringField(),
themes: new fields.StringField(),
touchstones: new fields.StringField()
};
}
}

View file

@ -0,0 +1,32 @@
.application.daggerheart.dh-style.campaign-frame {
.campaign-frames-container {
display: flex;
flex-direction: column;
gap: 8px;
.campaign-frame-container {
display: flex;
flex-direction: column;
gap: 8px;
.information-container {
display: flex;
flex-direction: column;
gap: 4px;
label {
font-size: var(--font-size-20);
}
.subtext {
color: var(--beige-50);
font-style: italic;
}
.italic {
font-style: italic;
}
}
}
}
}

View file

@ -42,3 +42,5 @@
@import './character-reset/sheet.less';
@import './compendiumBrowserPackDialog/sheet.less';
@import './campaign-frame/sheet.less';

View file

@ -0,0 +1,41 @@
<div>
{{!-- <nav class='feature-tab tabs' data-group='frames'>
{{#each tabs as |tab|}}
<button class='{{tab.id}} {{tab.cssClass}}' data-action='tab' data-group='{{tab.group}}' data-tab='{{tab.id}}' {{disabled tab.disabled}}>
{{localize tab.label}}
</button>
{{/each}}
</nav> --}}
<div class="campaign-frames-container">
{{#each campaignFrames as |frame|}}
{{> ".frame" }}
{{/each}}
</div>
</div>
{{#*inline ".frame"}}
<fieldset>
<legend>{{name}}</legend>
<div class="campaign-frame-container">
<img src="{{img}}" />
<div class="information-container">
<label>{{localize "The Pitch"}}</label>
<div class="subtext">{{localize "Read this section to your players to to introduce them to the campaign."}}</div>
<div>{{{pitch}}}</div>
</div>
<div class="information-container">
<label>{{localize "Tone & Feel"}}</label>
<div>{{toneAndFeel}}</div>
</div>
<div class="information-container">
<label>{{localize "Themes"}}</label>
<div>{{themes}}</div>
</div>
<div class="information-container">
<label>{{localize "Touchstones"}}</label>
<div class="italic">{{touchstones}}</div>
</div>
</div>
</fieldset>
{{/inline}}

View file

@ -35,4 +35,6 @@
</div>
</div>
</fieldset>
<button data-action="openCampaignFrames">Campaign Frames</button>
</div>