Fix dynamic character sheet loading.

This commit is contained in:
Clément Pons
2026-03-09 17:27:18 +01:00
parent 974989abd3
commit 3bafc14255
10 changed files with 329 additions and 14505 deletions

View File

@@ -6,11 +6,11 @@ export type HistoryHandler = {
interface HistoryEvent
{
source: string;
event: string;
actions: HistoryAction[];
}
interface HistoryAction
{
event: string;
element: any;
from?: any;
to?: any;
@@ -47,8 +47,8 @@ export class History
return;
last.actions.forEach(e => {
this.handlers[last.source] && this.handlers[last.source].handlers[last.event]?.undo(e)
this.handlers[last.source] && this.handlers[last.source].any && this.handlers[last.source].any!(e);
this.handlers[last.source] && this.handlers[last.source]?.handlers[e.event]?.undo(e)
this.handlers[last.source] && this.handlers[last.source]?.any && this.handlers[last.source]?.any!(e);
});
this.position--;
@@ -68,18 +68,18 @@ export class History
}
last.actions.forEach(e => {
this.handlers[last.source] && this.handlers[last.source].handlers[last.event]?.redo(e)
this.handlers[last.source] && this.handlers[last.source].any && this.handlers[last.source].any!(e);
this.handlers[last.source] && this.handlers[last.source]?.handlers[e.event]?.redo(e)
this.handlers[last.source] && this.handlers[last.source]?.any && this.handlers[last.source]?.any!(e);
});
}
add(source: string, event: string, actions: HistoryAction[], apply: boolean = false)
add(source: string, actions: HistoryAction[], apply: boolean = false)
{
this.position++;
this.history.splice(this.position, history.length - this.position, { source, event, actions });
this.history.splice(this.position, history.length - this.position, { source, actions });
if(apply)
actions.forEach(e => {
this.handlers[source] && this.handlers[source].handlers[event]?.redo(e);
this.handlers[source] && this.handlers[source].handlers[e.event]?.redo(e);
this.handlers[source] && this.handlers[source].any && this.handlers[source].any(e);
});
}