From 314f89567d3f3ab432a13d7f4dd0e1228fdf32c1 Mon Sep 17 00:00:00 2001 From: Lurkars Date: Mon, 15 Jul 2024 18:43:58 +0200 Subject: [PATCH] hotfix broken undo history, adress #596, #597 --- package-lock.json | 4 ++-- package.json | 2 +- src/app/game/businesslogic/StorageManager.ts | 2 +- src/app/ui/figures/character/character.html | 2 ++ .../entity-menu/entity-menu-dialog.html | 10 ++++++++++ .../entity-menu/entity-menu-dialog.scss | 9 +++++++-- .../figures/entity-menu/entity-menu-dialog.ts | 18 ++++++++++++++++-- src/app/ui/tools/error-handler.ts | 2 +- src/assets/locales/de.json | 1 + src/assets/locales/en.json | 1 + 10 files changed, 42 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9878a6fcc..7ee7fed65 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gloomhavensecretariat", - "version": "0.99.15", + "version": "0.99.16", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gloomhavensecretariat", - "version": "0.99.15", + "version": "0.99.16", "license": "AGPL3", "dependencies": { "@angular/animations": "^18.1.0", diff --git a/package.json b/package.json index 336663684..f3988e9a0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gloomhavensecretariat", - "version": "0.99.15", + "version": "0.99.16", "license": "AGPL3", "description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.", "homepage": "https://gloomhaven-secretariat.de", diff --git a/src/app/game/businesslogic/StorageManager.ts b/src/app/game/businesslogic/StorageManager.ts index 28320e18e..588a3cb19 100644 --- a/src/app/game/businesslogic/StorageManager.ts +++ b/src/app/game/businesslogic/StorageManager.ts @@ -219,8 +219,8 @@ export class StorageManager { for (let index = 0; index < objects.length; index++) { const object = objects[index]; await this.write(store, undefined, object).catch(() => reject()); - resolve(); }; + resolve(); } else { try { localStorage.setItem("ghs-" + store, JSON.stringify(objects)); diff --git a/src/app/ui/figures/character/character.html b/src/app/ui/figures/character/character.html index 7adff54de..22ea6bf3f 100644 --- a/src/app/ui/figures/character/character.html +++ b/src/app/ui/figures/character/character.html @@ -294,6 +294,8 @@
+
+
+ + + +
+ diff --git a/src/app/ui/figures/entity-menu/entity-menu-dialog.scss b/src/app/ui/figures/entity-menu/entity-menu-dialog.scss index 66aa6d489..8b9d6ceb1 100644 --- a/src/app/ui/figures/entity-menu/entity-menu-dialog.scss +++ b/src/app/ui/figures/entity-menu/entity-menu-dialog.scss @@ -320,7 +320,8 @@ } - .marker-container { + .marker-container, + .identities-container { display: grid; grid-template-columns: repeat(3, calc(var(--ghs-unit) * 7 * var(--ghs-dialog-factor))); row-gap: calc(var(--ghs-unit) * 1 * var(--ghs-dialog-factor)); @@ -330,7 +331,6 @@ grid-column: 1 / span 3; .item { - position: relative; display: flex; align-items: center; @@ -349,6 +349,11 @@ border-radius: 100%; } + &.disabled img { + filter: grayscale(0.7); + opacity: 0.7; + } + } } diff --git a/src/app/ui/figures/entity-menu/entity-menu-dialog.ts b/src/app/ui/figures/entity-menu/entity-menu-dialog.ts index 9c3558f80..f593b0a91 100644 --- a/src/app/ui/figures/entity-menu/entity-menu-dialog.ts +++ b/src/app/ui/figures/entity-menu/entity-menu-dialog.ts @@ -6,6 +6,7 @@ import { SettingsManager, settingsManager } from "src/app/game/businesslogic/Set import { Character } from "src/app/game/model/Character"; import { Entity, EntityValueFunction } from "src/app/game/model/Entity"; import { Figure } from "src/app/game/model/Figure"; +import { GameState } from "src/app/game/model/Game"; import { Monster } from "src/app/game/model/Monster"; import { MonsterEntity } from "src/app/game/model/MonsterEntity"; import { OBJECTIV_MARKERS, ObjectiveContainer } from "src/app/game/model/ObjectiveContainer"; @@ -837,9 +838,20 @@ export class EntityMenuDialogComponent { this.titles[index] = event.target.value; } + setIdentity(index: number) { + if (this.data.entity instanceof Character && index != this.data.entity.identity) { + let timeTokens = this.data.entity.tags.find((tag) => tag === 'time_tokens') && this.data.entity.primaryToken == 0; + if ((gameManager.game.state == GameState.next || gameManager.game.state == GameState.draw && this.data.entity.identity == 0 && this.data.entity.tokenValues[0] == 0) && timeTokens) { + return; + } + + gameManager.stateManager.before("setIdentity", gameManager.characterManager.characterName(this.data.entity, false, false, false), this.data.entity.name, this.data.entity.identities[index]); + this.data.entity.identity = index; + gameManager.stateManager.after(); + } + } + close(): void { - this.closeConditions(); - this.closeAMs(); if (this.data.entity instanceof Character) { this.closeCharacter(); } else if (this.data.figure instanceof Monster) { @@ -851,6 +863,8 @@ export class EntityMenuDialogComponent { } else if (this.data.figure instanceof ObjectiveContainer) { this.closeObjectiveContainer(); } + this.closeAMs(); + this.closeConditions(); } closeCharacter(): void { diff --git a/src/app/ui/tools/error-handler.ts b/src/app/ui/tools/error-handler.ts index 15036a1d2..05846d98e 100644 --- a/src/app/ui/tools/error-handler.ts +++ b/src/app/ui/tools/error-handler.ts @@ -22,7 +22,7 @@ export class GhsErrorHandler extends ErrorHandler { window.document.body.classList.remove('server-sync'); const errorId = error.message + (error.stack ? error.stack.split('\n')[0] : ''); - if (!FILTER_ERRORS.some((msg) => error.message.startsWith(msg)) && (!settingsManager.settings.feedbackErrorsIgnore || settingsManager.settings.feedbackErrorsIgnore.indexOf(errorId) == -1)) { + if (error.message && error.message.trim() && !FILTER_ERRORS.some((msg) => error.message.startsWith(msg)) && (!settingsManager.settings.feedbackErrorsIgnore || settingsManager.settings.feedbackErrorsIgnore.indexOf(errorId) == -1)) { this.dialog.open(FeedbackDialogComponent, { panelClass: ['dialog'], data: error diff --git a/src/assets/locales/de.json b/src/assets/locales/de.json index 502059b1a..08aac8d26 100644 --- a/src/assets/locales/de.json +++ b/src/assets/locales/de.json @@ -2476,6 +2476,7 @@ "setEntitySummonState": "Beschwörung {3} für {1} Aufsteller {2} von {0}", "setExhausted": "{0} erschöpft", "setGold": "Gold {1} für {0}", + "setIdentity": "Setze Form auf %data.character.{1}.{2}% für {0}", "setInitiative": "Initiative {1} für {0}", "setLevel": "Level {1} für {0}", "setNotes": "Notizen \"{1}\" für {0} ", diff --git a/src/assets/locales/en.json b/src/assets/locales/en.json index 3021051d1..e505607c2 100644 --- a/src/assets/locales/en.json +++ b/src/assets/locales/en.json @@ -2686,6 +2686,7 @@ "setEntitySummonState": "Set summon {3} for {1} standee {2} of {0}", "setExhausted": "{0} exhausted", "setGold": "Gold {1} for {0}", + "setIdentity": "Set form of {0} to %data.character.{1}.{2}%", "setInitiative": "Initiative {1} for {0}", "setLevel": "Level {1} for {0}", "setNotes": "Notes \"{1}\" for {0}",