Skip to content

Commit

Permalink
possible Safari fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lurkars committed Nov 26, 2024
1 parent 6e17e67 commit a79771e
Show file tree
Hide file tree
Showing 16 changed files with 52 additions and 51 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gloomhavensecretariat",
"version": "0.104.0",
"version": "0.104.1",
"license": "AGPL3",
"description": "Gloomhaven Secretariat is a Gloomhaven/Frosthaven Companion app.",
"homepage": "https://gloomhaven-secretariat.de",
Expand Down
4 changes: 2 additions & 2 deletions src/app/game/businesslogic/SettingsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class SettingsManager {
} else {
loadDefault = true;
}
} catch {
} catch (e) {
loadDefault = true;
}

Expand All @@ -65,7 +65,7 @@ export class SettingsManager {
}).then((value: Settings) => {
this.setSettings(Object.assign(new Settings(), value));
});
} catch {
} catch (e) {
this.setSettings(new Settings());
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/app/game/businesslogic/StateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export class StateManager {
const gameModel = await storageManager.readGameModel();
gameModel.server = false;
this.game.fromModel(gameModel);
} catch {
} catch (e) {
if (!tool) {
storageManager.writeGameModel(this.game.toModel());
}
Expand Down Expand Up @@ -109,7 +109,7 @@ export class StateManager {
this.redos = await storageManager.readAll<GameModel>('redo');
this.undoInfos = await storageManager.readAll<string[]>('undo-infos');
this.updatePermissions();
} catch {
} catch (e) {
this.updatePermissions();
}
}
Expand Down Expand Up @@ -638,7 +638,7 @@ export class StateManager {
downloadButton.click();
document.body.removeChild(downloadButton);
}
} catch {
} catch (e) {
console.warn("Could not create autobackup");
}
window.document.body.classList.remove('working');
Expand Down
2 changes: 1 addition & 1 deletion src/app/game/businesslogic/StorageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ export class StorageManager {
document.body.appendChild(downloadButton);
downloadButton.click();
document.body.removeChild(downloadButton);
} catch {
} catch (e) {
console.warn("Could not read datadump");
}

Expand Down
24 changes: 12 additions & 12 deletions src/app/game/model/ActionHex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ export class ActionHex {
this.value = value;
}

public static fromString(string: string): ActionHex | null {
}

let groups: RegExpExecArray | null = new RegExp(/^\((\d+),(\d+),(active|target|conditional|ally|blank|invisible)(\:(\w*))?\)$/).exec(string);
export function ActionHexFromString(string: string): ActionHex | null {

if (groups == null) {
return null;
}
let groups: RegExpExecArray | null = new RegExp(/^\((\d+),(\d+),(active|target|conditional|ally|blank|invisible)(\:(\w*))?\)$/).exec(string);

let value = "";
if (groups.length > 5 && groups[5]) {
value = groups[5];
}
return new ActionHex(+groups[1], +groups[2], groups[3] as ActionHexType, value);
if (groups == null) {
return null;
}

public static toString(actionHex: ActionHex): string {
return "(" + actionHex.x + "," + actionHex.y + "," + ActionHexType[actionHex.type] + (actionHex.value ? ":" + actionHex.value : "") + ")"
let value = "";
if (groups.length > 5 && groups[5]) {
value = groups[5];
}
return new ActionHex(+groups[1], +groups[2], groups[3] as ActionHexType, value);
}

export function ActionHexToString(actionHex: ActionHex): string {
return "(" + actionHex.x + "," + actionHex.y + "," + ActionHexType[actionHex.type] + (actionHex.value ? ":" + actionHex.value : "") + ")"
}
2 changes: 1 addition & 1 deletion src/app/ui/figures/actions/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class ActionComponent implements OnInit, OnDestroy {
} else {
try {
statValue = EntityValueFunction(stat.attack, this.level);
} catch {
} catch (e) {
sign = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/figures/actions/area/action-hex.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="hex-grid" [style.--ghs-hex-size]="size" [ngClass]="{'small' : action.small}">
<div class="hex" *ngFor="let hex of hexes" [style.grid-column-start]="hex.x * 2 + 1 + (hex.y % 2)"
[style.grid-column-end]="hex.x * 2 + 3 + (hex.y % 2)" [style.grid-row-start]="hex.y + 1"
[style.grid-row-end]="hex.y + 1" [title]="ActionHex.toString(hex)" (click)="click(hex)">
[style.grid-row-end]="hex.y + 1" [title]="ActionHexToString(hex)" (click)="click(hex)">
<img [src]="'./assets/images/action/hex/' + hex.type + '.svg'" [alt]="action.small">

<span class="condition" *ngIf="hasCondition(hex)">
Expand Down
5 changes: 3 additions & 2 deletions src/app/ui/figures/actions/area/action-hex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, EventEmitter, Input, OnChanges, Output } from "@angular/core";
import { ActionHex, ActionHexFromString, ActionHexToString } from "src/app/game/model/ActionHex";
import { Action } from "src/app/game/model/data/Action";
import { ConditionName } from "src/app/game/model/data/Condition";
import { ActionHex } from "src/app/game/model/ActionHex";

@Component({
selector: 'ghs-action-hex',
Expand All @@ -17,6 +17,7 @@ export class ActionHexComponent implements OnChanges {
@Output() doubleclickCallback: EventEmitter<ActionHex> = new EventEmitter<ActionHex>();
hexes: ActionHex[] = [];
ActionHex = ActionHex;
ActionHexToString = ActionHexToString;

doubleClick: any = null;

Expand All @@ -26,7 +27,7 @@ export class ActionHexComponent implements OnChanges {
this.value = '' + this.action.value;
}
this.value.split('|').forEach((hexValue) => {
const hex: ActionHex | null = ActionHex.fromString(hexValue);
const hex: ActionHex | null = ActionHexFromString(hexValue);
if (hex != null) {
this.hexes.push(hex);
}
Expand Down
12 changes: 6 additions & 6 deletions src/app/ui/header/menu/datamanagement/datamanagement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class DatamanagementMenuComponent implements OnInit {
if (backups && backups.length > 0) {
this.backups = backups.length;
}
} catch {
} catch (e) {
this.backups = 0;
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ export class DatamanagementMenuComponent implements OnInit {
downloadButton.click();
document.body.removeChild(downloadButton);
}
} catch {
} catch (e) {
console.warn("No game found");
}
}
Expand All @@ -159,7 +159,7 @@ export class DatamanagementMenuComponent implements OnInit {
downloadButton.click();
document.body.removeChild(downloadButton);
}
} catch {
} catch (e) {
console.warn("No backup found");
}
}
Expand All @@ -177,7 +177,7 @@ export class DatamanagementMenuComponent implements OnInit {
document.body.removeChild(downloadButton);
})
}
} catch {
} catch (e) {
console.warn("No backups found");
}
}
Expand Down Expand Up @@ -248,7 +248,7 @@ export class DatamanagementMenuComponent implements OnInit {
downloadButton.click();
document.body.removeChild(downloadButton);
}
} catch {
} catch (e) {
console.warn("No settings found");
}
}
Expand Down Expand Up @@ -360,7 +360,7 @@ export class DatamanagementMenuComponent implements OnInit {
gameManager.stateManager.storageBlocked = true;
console.info("Reload...");
window.location.reload();
} catch {
} catch (e) {
console.error("Could clear storage");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/helper/label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Directive, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChang
import { Subscription } from "rxjs";
import { gameManager } from "src/app/game/businesslogic/GameManager";
import { settingsManager } from "src/app/game/businesslogic/SettingsManager";
import { ActionHex } from "src/app/game/model/ActionHex";
import { ActionHex, ActionHexFromString } from "src/app/game/model/ActionHex";
import { Character } from "src/app/game/model/Character";
import { ActionType } from "src/app/game/model/data/Action";
import { AttackModifierValueType } from "src/app/game/model/data/AttackModifier";
Expand Down Expand Up @@ -90,7 +90,7 @@ export const applyPlaceholder = function (value: string, placeholder: string[] =
}

value.split('|').forEach((hexValue) => {
const hex: ActionHex | null = ActionHex.fromString(hexValue);
const hex: ActionHex | null = ActionHexFromString(hexValue);
if (hex != null) {
replace += '<span class="hex" style="grid-column-start : ' + (hex.x * 2 + 1 + (hex.y % 2)) + ';grid-column-end:' + (hex.x * 2 + 3 + (hex.y % 2)) + ';grid-row-start:' + (hex.y + 1) + ';grid-row-end:' + (hex.y + 1) + '"><img src="./assets/images/action/hex/' + hex.type + '.svg"></span>';
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/helper/valueCalc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function valueCalc(value: string | number, level: number | undefined = un
if (settingsManager.settings.calculate && (value.match(EntityExpressionRegex) || value.match(EntityValueRegex))) {
try {
return EntityValueFunction(value, L)
} catch {
} catch (e) {
console.error("Could not calculate value for: ", value);
return value;
}
Expand Down
4 changes: 2 additions & 2 deletions src/app/ui/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class MainComponent implements OnInit {
document.body.classList.add('no-select');
try {
await storageManager.init();
} catch {
} catch (e) {
// continue
}
await settingsManager.init(!environment.production);
Expand Down Expand Up @@ -606,7 +606,7 @@ export class MainComponent implements OnInit {
document.body.appendChild(downloadButton);
downloadButton.click();
document.body.removeChild(downloadButton);
} catch {
} catch (e) {
console.warn("Could not read datadump");
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/app/ui/tools/editor/action/action.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Dialog, DialogRef, DIALOG_DATA } from "@angular/cdk/dialog";
import { Dialog, DIALOG_DATA, DialogRef } from "@angular/cdk/dialog";
import { CdkDragDrop, moveItemInArray } from "@angular/cdk/drag-drop";
import { Component, EventEmitter, Inject, Input, OnInit, Output } from "@angular/core";
import { gameManager } from "src/app/game/businesslogic/GameManager";
import { settingsManager } from "src/app/game/businesslogic/SettingsManager";
import { ActionHex, ActionHexFromString, ActionHexToString, ActionHexType } from "src/app/game/model/ActionHex";
import { Action, ActionCardType, ActionSpecialTarget, ActionType, ActionValueType } from "src/app/game/model/data/Action";
import { Condition, ConditionName, ConditionType } from "src/app/game/model/data/Condition";
import { SummonData } from "src/app/game/model/data/SummonData";
import { Element } from "src/app/game/model/data/Element";
import { MonsterType } from "src/app/game/model/data/MonsterType";
import { ActionHex, ActionHexType } from "src/app/game/model/ActionHex";
import { SummonData } from "src/app/game/model/data/SummonData";

@Component({
selector: 'ghs-editor-action',
Expand Down Expand Up @@ -45,13 +45,13 @@ export class EditorActionComponent implements OnInit {
this.hexAction.value = '' + this.action.value;
let hexes: ActionHex[] = [];
this.hexAction.value.split('|').forEach((hexValue) => {
const hex: ActionHex | null = ActionHex.fromString(hexValue);
const hex: ActionHex | null = ActionHexFromString(hexValue);
if (hex != null) {
hexes.push(hex);
}
})
hexes.forEach((other) => this.fillHexes(other, hexes));
this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|');
this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|');
this.change();
} else if (this.action.type == ActionType.condition || this.action.type == ActionType.specialTarget || this.action.type == ActionType.card) {
if (('' + this.action.value).indexOf(':') != -1) {
Expand Down Expand Up @@ -144,7 +144,7 @@ export class EditorActionComponent implements OnInit {

let hexes: ActionHex[] = [];
('' + this.hexAction.value).split('|').forEach((hexValue) => {
const hex: ActionHex | null = ActionHex.fromString(hexValue);
const hex: ActionHex | null = ActionHexFromString(hexValue);
if (hex != null) {
hexes.push(hex);
}
Expand All @@ -160,22 +160,22 @@ export class EditorActionComponent implements OnInit {

this.fillHexes(hex, hexes);

this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|');
this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHex.toString(hex)).join('|');
this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|');
this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHexToString(hex)).join('|');
this.change();
}

changeHex() {
let hexes: ActionHex[] = [];
('' + this.hexAction.value).split('|').forEach((hexValue) => {
const hex: ActionHex | null = ActionHex.fromString(hexValue);
const hex: ActionHex | null = ActionHexFromString(hexValue);
if (hex != null) {
hexes.push(hex);
}
})

this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|');
this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHex.toString(hex)).join('|');
this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|');
this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHexToString(hex)).join('|');
this.change();
}

Expand All @@ -184,7 +184,7 @@ export class EditorActionComponent implements OnInit {

let hexes: ActionHex[] = [];
('' + this.hexAction.value).split('|').forEach((hexValue) => {
const hex: ActionHex | null = ActionHex.fromString(hexValue);
const hex: ActionHex | null = ActionHexFromString(hexValue);
if (hex != null) {
hexes.push(hex);
}
Expand Down Expand Up @@ -212,8 +212,8 @@ export class EditorActionComponent implements OnInit {

hexes.filter((other) => other.type != ActionHexType.invisible).forEach((other) => this.fillHexes(other, hexes));

this.hexAction.value = hexes.map((hex) => ActionHex.toString(hex)).join('|');
this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHex.toString(hex)).join('|');
this.hexAction.value = hexes.map((hex) => ActionHexToString(hex)).join('|');
this.action.value = hexes.filter((hex) => hex.type != ActionHexType.invisible).map((hex) => ActionHexToString(hex)).join('|');
this.change();
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/tools/feedback/feedback-dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class FeedbackDialogComponent {
document.body.appendChild(downloadButton);
downloadButton.click();
document.body.removeChild(downloadButton);
} catch {
} catch (e) {
console.warn("Could not read datadump");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/tools/standalone/attackmodifier-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AttackModifierStandaloneComponent implements OnInit {
async ngOnInit() {
try {
await storageManager.init();
} catch {
} catch (e) {
// continue
}
await settingsManager.init(!environment.production);
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/tools/standalone/loot-deck-standalone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class LootDeckStandaloneComponent implements OnInit {
async ngOnInit() {
try {
await storageManager.init();
} catch {
} catch (e) {
// continue
}
await settingsManager.init(!environment.production);
Expand Down

0 comments on commit a79771e

Please sign in to comment.