fix(virtual-pet): OP5 care actions first and compact 2x2-style status rows
This commit is contained in:
parent
82abe08658
commit
35e4d7412d
3 changed files with 17 additions and 13 deletions
|
|
@ -163,7 +163,7 @@ async function buildPetContextMenuTemplate(action: { readonly label: string; rea
|
|||
group.commands.push(item);
|
||||
plugins.set(command.pluginId, group);
|
||||
}
|
||||
// Fully dynamic per-plugin menu sections (ui.menu.setItems) — show status labels first.
|
||||
// Fully dynamic per-plugin menu sections (ui.menu.setItems) — put care actions first, then status labels.
|
||||
const menuItems = await getDefaultPetPluginMenuItems();
|
||||
for (const item of menuItems) {
|
||||
const group = plugins.get(item.pluginId) ?? { name: item.pluginName, commands: [], menuItems: [] };
|
||||
|
|
@ -175,9 +175,9 @@ async function buildPetContextMenuTemplate(action: { readonly label: string; rea
|
|||
if (plugins.size > 0) {
|
||||
template.push(...[...plugins.values()].map((plugin) => {
|
||||
const submenu: Electron.MenuItemConstructorOptions[] = [];
|
||||
if (plugin.menuItems.length > 0) submenu.push(...plugin.menuItems);
|
||||
if (plugin.menuItems.length > 0 && plugin.commands.length > 0) submenu.push({ type: "separator" });
|
||||
if (plugin.commands.length > 0) submenu.push(...plugin.commands);
|
||||
if (plugin.commands.length > 0 && plugin.menuItems.length > 0) submenu.push({ type: "separator" });
|
||||
if (plugin.menuItems.length > 0) submenu.push(...plugin.menuItems);
|
||||
return { label: plugin.name, submenu };
|
||||
}), { type: "separator" });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,13 +103,17 @@ async function playActionSound(ctx) {
|
|||
|
||||
function buildStatusMenuItems(ctx, state, now = Date.now()) {
|
||||
const mood = getMood(state, now);
|
||||
const sep = " · ";
|
||||
const moodText = `${ctx.t("menu.mood")}: ${ctx.t(`mood.${mood}`)}`;
|
||||
const foodText = `${ctx.t("menu.food")}: ${Math.round(state.hunger)}%`;
|
||||
const energyText = `${ctx.t("menu.energy")}: ${Math.round(state.energy)}%`;
|
||||
const playText = `${ctx.t("menu.play")}: ${Math.round(state.happiness)}%`;
|
||||
const bondText = `${ctx.t("menu.bond")}: ${Math.round(state.affection)}%`;
|
||||
const levelText = `${ctx.t("menu.level")}: ${state.level}`;
|
||||
return [
|
||||
{ id: "mood", title: `${ctx.t("menu.mood")}: ${ctx.t(`mood.${mood}`)}`, enabled: false },
|
||||
{ id: "food", title: `${ctx.t("menu.food")}: ${Math.round(state.hunger)}%`, enabled: false },
|
||||
{ id: "energy", title: `${ctx.t("menu.energy")}: ${Math.round(state.energy)}%`, enabled: false },
|
||||
{ id: "play", title: `${ctx.t("menu.play")}: ${Math.round(state.happiness)}%`, enabled: false },
|
||||
{ id: "bond", title: `${ctx.t("menu.bond")}: ${Math.round(state.affection)}%`, enabled: false },
|
||||
{ id: "level", title: `${ctx.t("menu.level")}: ${state.level}`, enabled: false },
|
||||
{ id: "stats-row-1", title: `${moodText}${sep}${foodText}`, enabled: false },
|
||||
{ id: "stats-row-2", title: `${energyText}${sep}${playText}`, enabled: false },
|
||||
{ id: "stats-row-3", title: `${bondText}${sep}${levelText}`, enabled: false },
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ const LOCALES = { en: JSON.parse(await readFile(new URL("./locales/en.json", imp
|
|||
// Expect status labels in the dynamic context menu (no on-pet HUD overlay)
|
||||
const menu = h.calls.menuItems;
|
||||
assert.ok(menu.length > 0, "Should populate the context menu with status labels");
|
||||
assert.ok(menu.some((item) => item.id === "food" && item.title.includes("80%")), "Menu should show food status");
|
||||
assert.ok(menu.some((item) => item.id === "energy" && item.title.includes("80%")), "Menu should show energy status");
|
||||
assert.ok(menu.some((item) => item.id === "play" && item.title.includes("80%")), "Menu should show play status");
|
||||
assert.ok(menu.some((item) => item.id === "bond" && item.title.includes("50%")), "Menu should show bond status");
|
||||
assert.ok(menu.some((item) => item.id === "stats-row-1" && item.title.includes("80%")), "Menu should show food status");
|
||||
assert.ok(menu.some((item) => item.id === "stats-row-2" && item.title.includes("80%")), "Menu should show energy status");
|
||||
assert.ok(menu.some((item) => item.id === "stats-row-2" && item.title.includes("80%")), "Menu should show play status");
|
||||
assert.ok(menu.some((item) => item.id === "stats-row-3" && item.title.includes("50%")), "Menu should show bond status");
|
||||
|
||||
h.expectNoErrors();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue