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

Feat/ancestry sheets #12 #56

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
88c6fc4
chore: Fixed custom fonts
zithith Sep 27, 2024
c37424f
feat(ancestry sheets): Aded basic Ancestry sheets and advancement dat…
zithith Sep 27, 2024
38fe4db
feat(culture sheet): updated culture sheets to use prosemirror editor…
zithith Sep 28, 2024
6da5640
chore: minor item header style update
zithith Sep 28, 2024
0714a38
Merge branch 'release-0.1.0' of https://github.com/zithith/cosmere-rp…
zithith Sep 28, 2024
24d81ce
chore: post merge alignment. Updated Connection, injury, loot, path &…
zithith Sep 29, 2024
6a2c1b2
chore: item sheets tab styling alignment
zithith Sep 29, 2024
e6332a9
feat(item sheets): refactored description enrichment to base item sheets
zithith Sep 29, 2024
8a84d4c
feat(ancestry sheets): removed custom prose-mirror component
zithith Sep 29, 2024
41b43fe
Merge branch 'release-0.1.0' of https://github.com/zithith/cosmere-rp…
zithith Sep 29, 2024
13b5b84
chore: updated armor and trait items to use description placeholders
zithith Sep 29, 2024
20f663b
feat(item sheets): ancestry details tab added, with some placeholder …
zithith Sep 30, 2024
b96fe43
chore: updated missed label localisation
zithith Sep 30, 2024
7df46c8
Merge branch 'release-0.1.0' of https://github.com/zithith/cosmere-rp…
zithith Oct 2, 2024
9ad1328
feat(item sheets): updated new sheet types to include description pla…
zithith Oct 2, 2024
41f14c2
feat(item sheets): Ancestry details tab placeholders replaced with va…
zithith Oct 6, 2024
bc8d5c8
css tweaks
zithith Oct 6, 2024
3b8dcd4
Merge branch 'release-0.1.0' of https://github.com/zithith/cosmere-rp…
zithith Oct 6, 2024
d66f0cd
feat(item sheets): made item sheet tab display into a world setting
zithith Oct 7, 2024
e65b6cb
feat(item sheets): style tweaks
zithith Oct 8, 2024
60eeb7d
feat: add document ref input component
stanavdb Oct 10, 2024
7051959
feat(ancestry sheet): improve usability of advancement extra talents …
stanavdb Oct 11, 2024
e5767b1
feat(ancestry sheet): replace talent picks list with bonus talents ru…
stanavdb Oct 12, 2024
97a8dc9
Merge pull request #1 from zithith/ancestry-sheet-pr
zithith Oct 13, 2024
6dc15fa
Merge branch 'release-0.1.0' of https://github.com/zithith/cosmere-rp…
zithith Oct 13, 2024
39378bd
feat(ancestry-sheets): PR comments addressed:
zithith Oct 16, 2024
2027bbd
feat(item sheets): updated description tab to display read-only eleme…
zithith Oct 17, 2024
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
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Hooks.once('init', async () => {

Items.unregisterSheet('core', ItemSheet);
registerItemSheet(ItemType.Culture, applications.item.CultureItemSheet);
registerItemSheet(ItemType.Ancestry, applications.item.AncestrySheet);
registerItemSheet(ItemType.Path, applications.item.PathItemSheet);
registerItemSheet(
ItemType.Connection,
Expand Down
22 changes: 15 additions & 7 deletions src/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -275,23 +275,28 @@
},
"Loot": {
"label": "Loot",
"label_plural": "Loot"
"label_plural": "Loot",
"desc_placeholder": "Edit this to describe the item."
},
"Ancestry": {
"label": "Ancestry",
"label_plural": "Ancestries"
"label_plural": "Ancestries",
"desc_placeholder": "Edit this to define a potential heritage for a character. Also include any special rules text for players to read."
},
"Culture": {
"label": "Culture",
"label_plural": "Cultures"
"label_plural": "Cultures",
"desc_placeholder": "Edit this to define one of the many cultures in the setting. Also include any special rules text for players to read."
},
"Path": {
"label": "Path",
"label_plural": "Paths"
"label_plural": "Paths",
"desc_placeholder": "Edit this to describe this the sorts of characters this progression path represents."
},
"Specialty": {
"label": "Specialty",
"label_plural": "Specialties"
"label_plural": "Specialties",
"desc_placeholder": "Edit this to describe the unique subset of characters this specialty represents."
},
"Talent": {
"label": "Talent",
Expand All @@ -307,11 +312,13 @@
},
"Injury": {
"label": "Injury",
"label_plural": "Injuries"
"label_plural": "Injuries",
"desc_placeholder": "Edit this to describe how this injury affects a character."
},
"Connection": {
"label": "Connection",
"label_plural": "Connections"
"label_plural": "Connections",
"desc_placeholder": "Edit this to create a description of the NPC and how they are connected to the character."
}
},
"Weapon": {
Expand Down Expand Up @@ -652,6 +659,7 @@
},
"Item": {
"culture": "Culture",
"ancestry": "Ancestry",
"path": "Path",
"connection": "Connection",
"injury": "Injury",
Expand Down
16 changes: 11 additions & 5 deletions src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
--plotweaver-color-invest-front: #3e6abb;
--plotweaver-color-invest-back: #182845;

--font-primary: 'Laski Sans';

/* ----------------------------------------- */
/* Default Generic Theme */
/* ----------------------------------------- */
Expand Down Expand Up @@ -65,36 +67,40 @@
font-family: 'Penumbra Web Pro';
font-style: normal;
font-weight: 400;
src: url('../../fonts/penumbra-web-pro/PenumbraWebPro-Serif.woff2')
format('woff2');
src: url('assets/fonts/penumbra-web-pro/PenumbraWebPro-Serif.woff')
format('woff');
}

@font-face {
font-family: 'Laski Sans';
font-style: normal;
font-weight: 400;
src: url('../../fonts/laski-sans/Laski-Sans-Regular.woff2') format('woff2');
src: url('assets/fonts/laski-sans/Laski-Sans-Regular.woff2') format('woff2');
}

@font-face {
font-family: 'Laski Sans';
font-style: normal;
font-weight: 600;
src: url('../../fonts/laski-sans/Laski-Sans-SemiBold.woff2') format('woff2');
src: url('assets/fonts/laski-sans/Laski-Sans-SemiBold.woff2') format('woff2');
}

@font-face {
font-family: 'Laski Sans';
font-style: normal;
font-weight: 700;
src: url('../../fonts/laski-sans/Laski-Sans-Bold.woff2') format('woff2');
src: url('assets/fonts/laski-sans/Laski-Sans-Bold.woff2') format('woff2');
}

@font-face {
font-family: 'cosmere-dingbats';
src: url('https://dl.dropboxusercontent.com/scl/fi/9909gen4fd0oveyzfposx/CosmereDingbats-Regular.otf?rlkey=ig6odq9hxyo1st8kt3ujp1czz&st=72qrads3&raw=1');
}

.application h1, span.document-name {
font-family: 'Penumbra Web Pro';
zithith marked this conversation as resolved.
Show resolved Hide resolved
}

i.cosmere-icon {
font-family: 'cosmere-dingbats';
font-style: normal;
Expand Down
33 changes: 33 additions & 0 deletions src/style/sheets/item/module.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
.sheet.item {
overflow: visible;

.window-content {
overflow: visible;
}

.sheet-content {
display: flex;
flex-direction: column;
}

nav {
border: none;
flex-direction: column;
position: absolute;
left: 100%;
top: 15%;

> a {
background: rgba(11, 10, 19, 0.9);
width: 2.88867rem;
height: 2.5rem;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid #302831;
border-top-right-radius: 0.3rem;
border-bottom-right-radius: 0.3rem;

&.active {
background-color: rgb(45 41 77 / 90%);
}
}
}

.sheet-header {
position: relative;
border-bottom: 1px solid var(--plotweaver-color-grey-5);
padding-bottom: 0.5rem;

.document-name {
font-weight: bold;
Expand All @@ -32,6 +64,7 @@
.tab-body {
flex: 1;
display: flex;
margin-top: 0.5rem;

.tab {
height: 100%;
Expand Down
4 changes: 0 additions & 4 deletions src/style/sheets/module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,3 @@

@import './actor/module.scss';
@import './item/module.scss';

.prosemirror menu .pm-dropdown {
color: black;
}
5 changes: 3 additions & 2 deletions src/system/applications/actor/character-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ export class CharacterSheet extends BaseActorSheet {
paths: pathItems.filter((i) => i.system.type === type),
})),

// TODO: Default localization
ancestryLabel: ancestryItem?.name ?? 'DEFAULT_ANCESTRY_LABEL',
ancestryLabel:
ancestryItem?.name ??
game.i18n?.localize('COSMERE.Item.Type.Ancestry.label'),
};
}
}
59 changes: 59 additions & 0 deletions src/system/applications/item/ancestry-sheet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { AncestryItem } from '@system/documents/item';
import { DeepPartial } from '@system/types/utils';

import { BaseItemSheet } from './base';

export class AncestrySheet extends BaseItemSheet {
static DEFAULT_OPTIONS = foundry.utils.mergeObject(
foundry.utils.deepClone(super.DEFAULT_OPTIONS),
{
classes: ['cosmere-rpg', 'sheet', 'item', 'ancestry'],
position: {
width: 600,
height: 550,
},
window: {
resizable: true,
positioned: true,
title: '<i class="fas fa-timeline"></i> ' + this.name,
zithith marked this conversation as resolved.
Show resolved Hide resolved
},
},
);

static PARTS = foundry.utils.mergeObject(
foundry.utils.deepClone(super.PARTS),
{
'sheet-content': {
template:
'systems/cosmere-rpg/templates/item/ancestry/parts/sheet-content.hbs',
},
},
);

get item(): AncestryItem {
return super.document;
}

/* --- Context --- */

public async _prepareContext(
options: DeepPartial<foundry.applications.api.ApplicationV2.RenderOptions>,
) {
if (
this.item.system.description!.value ===
CONFIG.COSMERE.items.types.ancestry.desc_placeholder
) {
this.item.system.description!.value = game.i18n!.localize(
this.item.system.description!.value!,
);
}
const enrichedDescValue = await TextEditor.enrichHTML(
this.item.system.description!.value!,
);

return {
...(await super._prepareContext(options)),
descHtml: enrichedDescValue,
};
}
}
13 changes: 13 additions & 0 deletions src/system/applications/item/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ export class BaseItemSheet extends TabsApplicationMixin(
{
description: {
label: 'COSMERE.Item.Sheet.Tabs.Description',
icon: '<i class="fa-solid fa-feather-pointed"></i>',
},
effects: {
label: 'COSMERE.Item.Sheet.Tabs.Effects',
icon: '<i class="fa-solid fa-bolt"></i>',
},
},
);
Expand All @@ -54,6 +56,17 @@ export class BaseItemSheet extends TabsApplicationMixin(
form: HTMLFormElement,
formData: FormDataExtended,
) {
if (
!(event.target instanceof HTMLInputElement) &&
!(event.target instanceof HTMLTextAreaElement) &&
!(
event.target instanceof
foundry.applications.elements.HTMLProseMirrorElement
)
)
return;
if (!event.target.name) return;

if (this.item.isPhysical() && 'system.price.unit' in formData.object) {
// Get currency id
const [currencyId, denominationId] = (
Expand Down
14 changes: 14 additions & 0 deletions src/system/applications/item/connection-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@ export class ConnectionItemSheet extends BaseItemSheet {
public async _prepareContext(
options: DeepPartial<foundry.applications.api.ApplicationV2.RenderOptions>,
) {
if (
this.item.system.description!.value ===
CONFIG.COSMERE.items.types.connection.desc_placeholder
) {
this.item.system.description!.value = game.i18n!.localize(
this.item.system.description!.value!,
);
}

const enrichedDescValue = await TextEditor.enrichHTML(
this.item.system.description!.value!,
);

return {
...(await super._prepareContext(options)),
descHtml: enrichedDescValue,
};
}
}
14 changes: 14 additions & 0 deletions src/system/applications/item/culture-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,22 @@ export class CultureItemSheet extends BaseItemSheet {
public async _prepareContext(
options: DeepPartial<foundry.applications.api.ApplicationV2.RenderOptions>,
) {
if (
this.item.system.description!.value ===
CONFIG.COSMERE.items.types.culture.desc_placeholder
) {
this.item.system.description!.value = game.i18n!.localize(
this.item.system.description!.value!,
);
}

const enrichedDescValue = await TextEditor.enrichHTML(
this.item.system.description!.value!,
);

return {
...(await super._prepareContext(options)),
descHtml: enrichedDescValue,
};
}
}
1 change: 1 addition & 0 deletions src/system/applications/item/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import './components';

export * from './culture-sheet';
export * from './ancestry-sheet';
export * from './path-sheet';
export * from './connection-sheet';
export * from './injury-sheet';
Expand Down
15 changes: 15 additions & 0 deletions src/system/applications/item/injury-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class InjuryItemSheet extends BaseItemSheet {
{
details: {
label: 'COSMERE.Item.Sheet.Tabs.Details',
icon: '<i class="fa-solid fa-circle-info"></i>',
sortIndex: 15,
},
},
Expand All @@ -50,11 +51,25 @@ export class InjuryItemSheet extends BaseItemSheet {
public async _prepareContext(
options: DeepPartial<foundry.applications.api.ApplicationV2.RenderOptions>,
) {
if (
this.item.system.description!.value ===
CONFIG.COSMERE.items.types.injury.desc_placeholder
) {
this.item.system.description!.value = game.i18n!.localize(
this.item.system.description!.value!,
);
}

const enrichedDescValue = await TextEditor.enrichHTML(
this.item.system.description!.value!,
);

return {
...(await super._prepareContext(options)),
isPermanent:
this.item.system.type === InjuryType.PermanentInjury ||
this.item.system.type === InjuryType.Death,
descHtml: enrichedDescValue,
Copy link
Collaborator

@stanavdb stanavdb Sep 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we move the description enrichment into the base item? We can probably move the assignment of the placeholder value into the data model, since its acting more like an initial value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done the refactor to make the description code common. I don't think we can move the localisation of the values into the data models due to the way the mixin process works, the i18n objects isn't populated on the game object when the mixins are initialised (if I'm following your thought correctly).
I did try and provide the ancestry DescriptionItemMixin call the localised string when I was first implementing the initial values bit as it seemed more sense to me to just do it cleanly there, but alas it didn't work.

};
}
}
Loading