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

Dnd5e 2.4.x Compatibility Release 1 #32

Merged
merged 30 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
77b28ea
Resolved deprecation warnings when using the character sheet.
kgar Nov 6, 2023
817824e
Updated github URL for "Item Type Not Found" view.
kgar Nov 6, 2023
370053c
Merge branch 'main' of github.com:kgar/foundry-tidy5e-sheet-2 into dn…
kgar Nov 8, 2023
dbe69b9
Merge branch 'main' of github.com:kgar/foundry-tidy5e-sheet-2 into dn…
kgar Nov 10, 2023
b24d37e
Merge branch 'main' into dnd5e-2.4.x-readiness
kgar Nov 15, 2023
f45a721
Changed module version compatibility to match 2.4.0 release. There ar…
kgar Nov 15, 2023
7241935
Merge branch 'main' of github.com:kgar/foundry-tidy5e-sheet-2 into dn…
kgar Nov 15, 2023
c46bab9
Implemented Source prototype.
kgar Nov 15, 2023
705710b
Added truncate class to span.
kgar Nov 15, 2023
18dc031
Removed `makeDefault: true` on the new Tidy 5e Sheets. I don't think …
kgar Nov 16, 2023
34c363d
Fixed visual issues with the Source component as it integrates with o…
kgar Nov 16, 2023
9df3cc7
Refined svelte inspector toggle so it doesn't interfere with ctrl+shi…
kgar Nov 16, 2023
a226268
Added source to all relevant items.
kgar Nov 16, 2023
80220bb
Fixed broken class item sheet by removing content that is no longer u…
kgar Nov 16, 2023
9b67a1c
Restored vehicle movement when in motion.
kgar Nov 16, 2023
0f3d5bc
Updated vehicle source.
kgar Nov 16, 2023
32b71a8
Added environment tooltip localization variable and leveraged in NPC …
kgar Nov 16, 2023
d12a199
Added lock file to dev server dist preparation to prevent updating th…
kgar Nov 16, 2023
e1f02a3
Updated source handling to show input when source label is blank. Thi…
kgar Nov 16, 2023
f1d1b2a
Fixed origin summary dialog breakage due to difference in how source …
kgar Nov 16, 2023
d5667e9
Removed source from the origin summary config dialog.
kgar Nov 16, 2023
7014fe6
Created InlineSource component to offer full Source configurability f…
kgar Nov 16, 2023
d943981
Adjusted placeholder text color to match input placeholders in Tidy s…
kgar Nov 16, 2023
286ce68
Swapped in InlineSource for vehicle source. Why not?
kgar Nov 16, 2023
de370f8
Fixed bug with character feature tab not hiding empty rows when the p…
kgar Nov 16, 2023
b21e9ff
Added a z-index, *sigh*, but it was necessary.
kgar Nov 16, 2023
41fcb74
Extracted creature type button to InlineCreateType component and upgr…
kgar Nov 16, 2023
8f552c0
Fixed the issue with changing creature type for PCs. They have specia…
kgar Nov 16, 2023
49db7fa
Adjusted character origin summary to make Background and Race readonl…
kgar Nov 16, 2023
4fff66a
Fixed effect label warning.
kgar Nov 17, 2023
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
2 changes: 2 additions & 0 deletions prepare-dist-for-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ function prepareDistForDev() {
fs.writeFileSync(path.join(distFolder, 'main.js'), `// ${message}`);

fs.writeFileSync(path.join(distFolder, 'style.css'), `/* ${message} */`);

fs.writeFileSync(path.join(distFolder, 'tidy5e-sheet-kgar.lock'), "🔒");
}

prepareDistForDev();
1 change: 1 addition & 0 deletions public/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"T5EK.Abilities": "Abilities",

"T5EK.Environment": "Environment",
"T5EK.EnvironmentTooltip": "Environment: {environment}",

"T5EK.Search": "search",
"T5EK.SearchClear": "clear search",
Expand Down
6 changes: 3 additions & 3 deletions public/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@
{
"id": "dnd5e",
"compatibility": {
"minimum": "2.3.0",
"verified": "2.3.1",
"maximum": "2.3.1"
"minimum": "2.4.0",
"verified": "2.4.0",
"maximum": "2.4.0"
}
}
],
Expand Down
51 changes: 24 additions & 27 deletions public/templates/tidy5e-origin-summary-config.hbs
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
<form>
{{#if isCharacter}}

<div class='form-group'>
<label>{{localize 'DND5E.Race'}}</label>
<textarea
rows='4'
cols='50'
name='race'
value='{{race}}'
placeholder='{{localize "DND5E.Race"}}'
>{{race}}</textarea>
</div>
{{#if canEditRace}}
<div class='form-group'>
<label>{{localize 'DND5E.Race'}}</label>
<textarea
rows='4'
cols='50'
name='race'
value='{{race}}'
placeholder='{{localize "DND5E.Race"}}'
>{{race}}</textarea>

</div>
{{/if}}
<div class='form-group'>
<label>{{localize 'DND5E.Background'}}</label>
<textarea
rows='4'
cols='50'
name='background'
value='{{background}}'
placeholder='{{localize "DND5E.Background"}}'
>{{background}}</textarea>
{{#if canEditBackground}}
<textarea
rows='4'
cols='50'
name='background'
value='{{background}}'
placeholder='{{localize "DND5E.Background"}}'
>{{background}}</textarea>
{{else}}
<span>{{background}}</span>
{{/if}}
</div>
<div class='form-group'>
<label>{{localize 'DND5E.Alignment'}}</label>
Expand Down Expand Up @@ -54,16 +61,6 @@
placeholder='{{localize "DND5E.Alignment"}}'
>{{alignment}}</textarea>
</div>
<div class='form-group'>
<label>{{localize 'DND5E.Source'}}</label>
<textarea
rows='4'
cols='50'
name='source'
value='{{source}}'
placeholder='{{localize "DND5E.Source"}}'
>{{source}}</textarea>
</div>

{{else if isVehicle}}

Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const CONSTANTS = {
ITEM_TYPE_SUBCLASS: 'subclass',
ITEM_TYPE_TOOL: 'tool',
ITEM_TYPE_WEAPON: 'weapon',
ITEM_TYPE_RACE: 'race',
/**
* Main button pressed, usually the left button or the un-initialized state
*/
Expand Down
4 changes: 2 additions & 2 deletions src/context-menu/tidy5e-context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function getActiveEffectContextOptions(effect: any) {
callback: () =>
effect.clone(
{
label: FoundryAdapter.localize('DOCUMENT.CopyOf', {
name: effect.label,
name: FoundryAdapter.localize('DOCUMENT.CopyOf', {
name: effect.name,
}),
},
{ save: true }
Expand Down
12 changes: 7 additions & 5 deletions src/dialogs/Tidy5eActorOriginSummaryConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,20 @@ export default class Tidy5eActorOriginSummaryConfig extends DocumentSheet {
/** @inheritdoc */
getData(options: any) {
return {
race: this.clone.system.details.race,
background: this.clone.system.details.background,
race:
this.clone.system.details.race?.name ?? this.clone.system.details.race,
background:
this.clone.system.details.background?.name ??
this.clone.system.details.background,
environment: this.clone.system.details.environment,
alignment: this.clone.system.details.alignment,
source: this.clone.system.details.source,
dimensions: this.clone.system.traits.dimensions,

isCharacter: this.document.type === CONSTANTS.SHEET_TYPE_CHARACTER,
isNPC: this.document.type === CONSTANTS.SHEET_TYPE_NPC,
isVehicle: this.document.type === CONSTANTS.SHEET_TYPE_VEHICLE,
canEditBackground: !this.clone.system.details.background?.name,
canEditRace: !this.clone.system.details.race?.name,
};
}

Expand All @@ -61,7 +65,6 @@ export default class Tidy5eActorOriginSummaryConfig extends DocumentSheet {
const background = FoundryAdapter.expandObject(formData).background;
const environment = FoundryAdapter.expandObject(formData).environment;
const alignment = FoundryAdapter.expandObject(formData).alignment;
const source = FoundryAdapter.expandObject(formData).source;

const dimensions = FoundryAdapter.expandObject(formData).dimensions;

Expand All @@ -79,7 +82,6 @@ export default class Tidy5eActorOriginSummaryConfig extends DocumentSheet {
return this.document.update({
'system.details.environment': environment,
'system.details.alignment': alignment,
'system.details.source': source,
});
} else if (isVehicle) {
return this.document.update({
Expand Down
85 changes: 37 additions & 48 deletions src/foundry/foundry-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,14 @@ export const FoundryAdapter = {
getActorCharacterSummaryEntries(actorContext: any): string[] {
const entries: string[] = [];

if (actorContext.system.details.race) {
if (actorContext.system.details.race?.name) {
entries.push(actorContext.system.details.race.name);
} else if (actorContext.system.details.race) {
entries.push(actorContext.system.details.race);
}

if (actorContext.labels.background) {
entries.push(actorContext.labels.background);
if (actorContext.system.details.background?.name) {
entries.push(actorContext.system.details.background.name);
} else if (actorContext.system.details.background) {
entries.push(actorContext.system.details.background);
}
Expand Down Expand Up @@ -578,13 +580,11 @@ export const FoundryAdapter = {
registerActorSheet(sheet: any, types: string[], label: string) {
Actors.registerSheet(CONSTANTS.DND5E_SYSTEM_ID, sheet, {
types,
makeDefault: true,
label,
});
},
registerItemSheet(sheet: any, label: string) {
Items.registerSheet(CONSTANTS.DND5E_SYSTEM_ID, sheet, {
makeDefault: true,
label,
});
},
Expand Down Expand Up @@ -893,6 +893,18 @@ export const FoundryAdapter = {
openActorTypeConfig(actor: Actor5e) {
return new dnd5e.applications.actor.ActorTypeConfig(actor).render(true);
},
openCharacterActorTypeConfig(actor: Actor5e) {
if (actor.system.details.race?.id) {
return new dnd5e.applications.actor.ActorTypeConfig(
actor.system.details.race,
{ keyPath: 'system.type' }
).render(true);
}

warn(
'Unable to open actor type config for player character because they do not have a race.'
);
},
playDiceSound() {
return AudioHelper.play({ src: CONFIG.sounds.dice });
},
Expand Down Expand Up @@ -939,49 +951,6 @@ export const FoundryAdapter = {
createContextMenu(...args: any[]): any {
return new ContextMenu(...args);
},
renderClassItemTraitSelector(
item: any,
target: string,
title: string,
trait: 'saves' | 'skills.choices' | 'skills'
) {
const options: Record<string, unknown> = {
name: target,
title,
choices: [],
allowCustom: false,
suppressWarning: true,
};
switch (trait) {
case 'saves':
options.choices = CONFIG.DND5E.abilities;
options.valueKey = null;
options.labelKey = 'label';
break;
case 'skills.choices':
options.choices = CONFIG.DND5E.skills;
options.valueKey = null;
options.labelKey = 'label';
break;
case 'skills':
const skills = item.system.skills;
const choices = skills.choices?.length
? skills.choices
: Object.keys(CONFIG.DND5E.skills);
options.choices = Object.fromEntries(
Object.entries(CONFIG.DND5E.skills).filter(([s]) =>
choices.includes(s)
)
);
options.maximum = skills.number;
options.labelKey = 'label';
break;
}

return new game.dnd5e.applications.TraitSelector(item, options).render(
true
);
},
createAdvancementSelectionDialog(item: any) {
return game.dnd5e.applications.advancement.AdvancementSelection.createDialog(
item
Expand Down Expand Up @@ -1075,4 +1044,24 @@ export const FoundryAdapter = {
key,
}).render(true);
},
renderItemTypeConfig(item: any) {
return new dnd5e.applications.actor.ActorTypeConfig(item, {
keyPath: 'system.type',
}).render(true);
},
renderItemMovementConfig(item: any) {
return new dnd5e.applications.actor.ActorMovementConfig(item, {
keyPath: 'system.movement',
}).render(true);
},
renderItemSensesConfig(item: any) {
return new dnd5e.applications.actor.ActorSensesConfig(item, {
keyPath: 'system.senses',
}).render(true);
},
renderSourceConfig(document: any, keyPath: string) {
return new dnd5e.applications.SourceConfig(document, {
keyPath,
}).render(true);
},
};
2 changes: 1 addition & 1 deletion src/scss/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
margin: unset;
}

.highlight-on-hover:hover {
.highlight-on-hover:is(:hover, :focus-visible) {
color: var(--t5ek-primary-accent-color);
}

Expand Down
17 changes: 17 additions & 0 deletions src/scss/partials/_items.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ input[type='checkbox'] {

.header-details {
align-items: center;
min-width: 0; // needed for flex children that truncate overflow
}

.charname {
Expand Down Expand Up @@ -186,7 +187,13 @@ input[type='checkbox'] {
border-left: 0.0625rem solid var(--t5ek-faint-color);
line-height: 1.25rem;
font-weight: 600;
min-width: 0; // needed for flex children that truncate overflow
padding-left: 0.325rem;

&:has(> input, > select) {
padding: 0;
}

input {
height: 1.25rem;
background: transparent;
Expand All @@ -201,6 +208,7 @@ input[type='checkbox'] {

&:first-child {
border: none;
padding-left: 0;
}

&:last-child {
Expand Down Expand Up @@ -242,6 +250,15 @@ input[type='checkbox'] {

.properties-header {
margin-top: 0.25rem;

.hidden-config-button {
visibility: hidden;
font-size: 0.75rem;
}

&:hover .hidden-config-button {
visibility: visible;
}
}

.properties-list {
Expand Down
7 changes: 7 additions & 0 deletions src/sheets/Tidy5eItemSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import SpellSheet from './item/SpellSheet.svelte';
import SubclassSheet from './item/SubclassSheet.svelte';
import ToolSheet from './item/ToolSheet.svelte';
import WeaponSheet from './item/WeaponSheet.svelte';
import RaceSheet from './item/RaceSheet.svelte';
import type { SheetStats, SheetTabCacheable } from 'src/types/types';
import { applyTitleToWindow } from 'src/utils/applications';
import { debug } from 'src/utils/logging';
Expand Down Expand Up @@ -134,6 +135,12 @@ export class Tidy5eKgarItemSheet
context: context,
});
break;
case CONSTANTS.ITEM_TYPE_RACE:
this.component = new RaceSheet({
target: node,
context: context,
});
break;
default:
this.component = new TypeNotFoundSheet({
target: node,
Expand Down
2 changes: 1 addition & 1 deletion src/sheets/actor/ActorEffectsTab.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
>
<ItemTableCell primary={true}>
<ItemImage src={effect.icon} />
<span class="align-self-center">{effect.label}</span>
<span class="align-self-center">{effect.name}</span>
</ItemTableCell>
<ItemTableCell baseWidth="12.5rem"
>{effect.sourceName ?? ''}</ItemTableCell
Expand Down
1 change: 1 addition & 0 deletions src/sheets/actor/AttributeBlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
height: 1.0625rem; // This is far too precise; can we make this more relative to its target?
padding: 0.1875rem 0.25rem 0.125rem 0.25rem; // this padding is providing the positioning of the text. Can we do this in flexbox?
white-space: nowrap;
z-index: 1;

&.ability-mod-label {
right: 1.5625rem; // This is far too precise; can we make this more relative to its target?
Expand Down
Loading