Restyled character creation dialog.

Added dialog factory.
This commit is contained in:
Aaron Lutomski
2026-05-29 21:14:23 -07:00
parent 9282cdb334
commit 46a5fb0cd6
43 changed files with 2340 additions and 1112 deletions
+13 -6
View File
@@ -16,9 +16,8 @@ import {
hasActiveStimulantEffect,
} from "../utils/stimulant-effect.js";
import { assignProfessionToAgent } from "../applications/profession-setup-flow.js";
import { showDgDialog } from "../applications/dg-dialog.js";
import { PROFESSION_OPTION_PICKS_KEY } from "../data/item/profession.js";
const { DialogV2 } = foundry.applications.api;
const { renderTemplate } = foundry.applications.handlebars;
const AgentSheetBase = EffectsTabMixin(DGActorSheet);
@@ -362,7 +361,8 @@ export default class DGAgentSheet extends AgentSheetBase {
);
let penalty = null;
const confirmed = await DialogV2.wait({
const confirmed = await showDgDialog({
modifier: "exhaust-agent",
content,
window: {
title: game.i18n.localize("DG.Physical.ExhaustDialogTitle"),
@@ -401,6 +401,7 @@ export default class DGAgentSheet extends AgentSheetBase {
await createAgentResourceChatMessage({
actor,
token: this.token,
roll: wpRoll,
contentKey: "DG.Physical.Chat.Exhausted",
labelKey: "DG.Physical.Chat.ExhaustedLabel",
i18nData: {
@@ -424,6 +425,7 @@ export default class DGAgentSheet extends AgentSheetBase {
return;
}
const wasExhausted = DGAgentSheet._isActorExhausted(actor);
const wpRoll = await new Roll("1d6").evaluate();
const gain = wpRoll.total;
const currentWp = Number(actor.system.wp.value) || 0;
@@ -441,8 +443,12 @@ export default class DGAgentSheet extends AgentSheetBase {
await createAgentResourceChatMessage({
actor,
token: this.token,
roll: wpRoll,
contentKey: "DG.Physical.Chat.Rested",
labelKey: "DG.Physical.Chat.RestedLabel",
extraContentKey: wasExhausted
? "DG.Physical.Chat.RestedNoLongerExhausted"
: null,
i18nData: {
name: actor.name,
gain,
@@ -477,12 +483,12 @@ export default class DGAgentSheet extends AgentSheetBase {
{},
);
const choice = await DialogV2.wait({
const choice = await showDgDialog({
modifier: "stimulants",
content,
window: {
title: game.i18n.localize("DG.Physical.StimulantsDialogTitle"),
},
classes: ["stimulants-dialog-app"],
buttons: [
{
action: "regular",
@@ -639,7 +645,8 @@ export default class DGAgentSheet extends AgentSheetBase {
},
);
return foundry.applications.api.DialogV2.wait({
return showDgDialog({
modifier: "apply-skill-improvements",
content,
window: {
title: game.i18n.localize("DG.Skills.ApplySkillImprovements.Title"),
@@ -8,8 +8,11 @@ import {
prepareProfessionSkillRows,
splitProfessionSkillMap,
} from "../../utils/profession-skills.js";
import {
getDialogContentRoot,
showDgDialog,
} from "../../applications/dg-dialog.js";
const { DialogV2 } = foundry.applications.api;
const { renderTemplate } = foundry.applications.handlebars;
const { ForcedDeletion } = foundry.data.operators;
@@ -69,16 +72,16 @@ export default function ProfessionItemMixin(Base) {
{ catalog, isTyped: false },
);
const confirmed = await DialogV2.wait({
const confirmed = await showDgDialog({
modifier: "add-profession-skill",
content,
position: { width: 300 },
classes: ["add-profession-skill-dialog-app"],
window: {
title: game.i18n.localize("DG.ItemWindow.Profession.AddSkillTitle"),
},
form: { closeOnSubmit: false },
render: (_event, dialog) => {
const root = dialog.element?.querySelector(".dialog-content");
onRender: (dialog) => {
const root = getDialogContentRoot(dialog);
const select = root?.querySelector('[name="skillCatalogId"]');
const typedGroup = root?.querySelector(".profession-typed-label-group");
const typeInput = root?.querySelector('[name="typedSkillLabel"]');
@@ -116,7 +119,7 @@ export default function ProfessionItemMixin(Base) {
label: game.i18n.localize("DG.Profession.Dialog.Submit"),
default: true,
callback: async (_event, _button, dialog) => {
const root = dialog.element.querySelector(".dialog-content");
const root = getDialogContentRoot(dialog);
const select = root?.querySelector('[name="skillCatalogId"]');
const ratingInput = root?.querySelector('[name="skillRating"]');
const typeInput = root?.querySelector('[name="typedSkillLabel"]');
+49 -74
View File
@@ -1,5 +1,11 @@
import DG from "../../config.js";
import { reorderForColumnSorting } from "../../utils/skill-layout.js";
import { getRollTargetDisplayClassFromModifier } from "../../utils/active-effect-derived.js";
import {
applySkillTooltipDisplayMode,
buildAgentSpecialTrainingTooltip,
buildSkillTooltip,
} from "../../utils/skill-tooltip.js";
/** @param {typeof foundry.applications.api.ApplicationV2} Base */
export default function SkillPrepMixin(Base) {
@@ -81,6 +87,13 @@ export default function SkillPrepMixin(Base) {
skill.sortLabel = skill.key;
}
skill.tooltip = buildSkillTooltip(
"sheet",
this.actor,
{ kind: "typed", group: skill.group, label: skill.label },
{ proficiency: Number(skill.proficiency) || 0 },
);
sortedCustomSkills.push(skill);
}
@@ -113,13 +126,12 @@ export default function SkillPrepMixin(Base) {
/** @returns {void} */
_prepareSkillTooltips() {
for (const skill of Object.values(this.actor.system.sortedSkills)) {
skill.tooltip = game.i18n.localize(`DG.Skills.Tooltip.${skill.key}`);
if (!skill.proficiency) {
skill.tooltip = skill.tooltip.concat(
"<br><br>",
game.i18n.localize("DG.Tooltip.CannotRollSkillLabel"),
);
}
skill.tooltip = buildSkillTooltip(
"sheet",
this.actor,
{ kind: "fixed", key: skill.key },
{ proficiency: Number(skill.proficiency) || 0 },
);
}
}
@@ -166,8 +178,37 @@ export default function SkillPrepMixin(Base) {
simplifiedTraining.attributeLabel = attributeLabel;
simplifiedTraining.attributeTooltip = attributeTooltip;
if (this.actor.type === "agent") {
const rollTarget = this.actor.system.rollTarget;
let modifier = 0;
if (rollTarget) {
if (DG.statistics.includes(training.attribute)) {
modifier = Number(rollTarget.statistics) || 0;
} else {
modifier = Number(rollTarget.allSkills) || 0;
}
}
simplifiedTraining.rollTargetDisplayClass =
getRollTargetDisplayClassFromModifier(modifier);
}
simplifiedTraining.displayLabel = `${simplifiedTraining.name} (${attributeLabel}, ${simplifiedTraining.targetNumber}%)`;
if (this.actor.type === "agent" && attributeTooltip) {
const rollTargetKey = DG.statistics.includes(training.attribute)
? "system.rollTarget.statistics"
: "system.rollTarget.allSkills";
simplifiedTraining.tooltip = buildAgentSpecialTrainingTooltip(
this.actor,
attributeTooltip,
rollTargetKey,
simplifiedTraining.targetNumber,
);
}
return simplifiedTraining;
});
}
@@ -201,73 +242,7 @@ export default function SkillPrepMixin(Base) {
* @param {HTMLElement} root
*/
_tooltipsSettings(root) {
const mode = game.settings.get("deltagreen", "skillTooltipDisplay");
if (mode !== "hoverShift" && mode !== "never") return;
const nodes = root.querySelectorAll("[data-tooltip],[title]");
if (mode === "never") {
nodes.forEach((el) => {
if (el.dataset.shiftTooltipInstalled === "true") return;
el.removeAttribute("data-tooltip");
el.removeAttribute("title");
el.dataset.shiftTooltipInstalled = "true";
});
return;
}
nodes.forEach((el) => {
if (el.dataset.shiftTooltipInstalled === "true") return;
let html = el.getAttribute("data-tooltip");
let isHtml = true;
if (!html) {
const title = el.getAttribute("title");
if (title) {
html = foundry.utils.escapeHTML(title);
isHtml = false;
}
}
if (!html) return;
el.removeAttribute("data-tooltip");
el.removeAttribute("title");
el.dataset.shiftTooltipInstalled = "true";
const opts = isHtml ? { html } : { text: html };
const show = () => game.tooltip.activate(el, opts);
const hide = () => game.tooltip.deactivate();
const onKey = (ev) => {
if (ev.key !== "Shift") return;
if (!document.body.contains(el)) {
window.removeEventListener("keydown", onKey);
window.removeEventListener("keyup", onKey);
return;
}
if (ev.type === "keydown") show();
else hide();
};
const onEnter = (ev) => {
if (ev.shiftKey) show();
window.addEventListener("keydown", onKey);
window.addEventListener("keyup", onKey);
};
const onLeave = () => {
hide();
window.removeEventListener("keydown", onKey);
window.removeEventListener("keyup", onKey);
};
el.addEventListener("pointerenter", onEnter, { passive: true });
el.addEventListener("pointerleave", onLeave, { passive: true });
});
applySkillTooltipDisplayMode(root);
}
};
}