mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 15:28:29 +08:00
Use the new message log in QuestRunner.
This commit is contained in:
parent
7e99857baf
commit
b9e762fa6e
@ -2,9 +2,13 @@ import { ExecutionResult, VirtualMachine } from "./scripting/vm";
|
||||
import { QuestModel } from "./model/QuestModel";
|
||||
import { VirtualMachineIO } from "./scripting/vm/io";
|
||||
import { AsmToken } from "./scripting/instructions";
|
||||
import Logger from "js-logger";
|
||||
import { quest_editor_store } from "./stores/QuestEditorStore";
|
||||
|
||||
const logger = Logger.get("quest_editor/QuestRunner");
|
||||
const logger = quest_editor_store.get_logger("quest_editor/QuestRunner");
|
||||
|
||||
function srcloc_to_string(srcloc: AsmToken): string {
|
||||
return `[${srcloc.line_no}:${srcloc.col}]`;
|
||||
}
|
||||
|
||||
export class QuestRunner {
|
||||
private readonly vm: VirtualMachine;
|
||||
@ -62,11 +66,11 @@ export class QuestRunner {
|
||||
mesend: (): void => {},
|
||||
|
||||
warning: (msg: string, srcloc?: AsmToken): void => {
|
||||
logger.warn(msg);
|
||||
logger.warning(msg, srcloc && srcloc_to_string(srcloc));
|
||||
},
|
||||
|
||||
error: (err: Error, srcloc?: AsmToken): void => {
|
||||
logger.error(err);
|
||||
logger.error(err, srcloc && srcloc_to_string(srcloc));
|
||||
},
|
||||
};
|
||||
};
|
||||
|
@ -27,7 +27,6 @@ import { RemoveEntityAction } from "../actions/RemoveEntityAction";
|
||||
import { Euler, Vector3 } from "three";
|
||||
import { RotateEntityAction } from "../actions/RotateEntityAction";
|
||||
import { convert_quest_from_model, convert_quest_to_model } from "./model_conversion";
|
||||
import { QuestRunner } from "../QuestRunner";
|
||||
import Logger = require("js-logger");
|
||||
import { MessageLogStore, LogMessage, LogLevel, LogGroup } from "../../core/gui/MessageLog";
|
||||
import { ListProperty } from "../../core/observable/property/list/ListProperty";
|
||||
@ -37,7 +36,6 @@ const logger = Logger.get("quest_editor/gui/QuestEditorStore");
|
||||
|
||||
export class QuestEditorStore implements Disposable, MessageLogStore {
|
||||
private readonly disposer = new Disposer();
|
||||
private readonly quest_runner = new QuestRunner();
|
||||
|
||||
/**
|
||||
* Log levels as Record<name, LogLevel>
|
||||
@ -311,11 +309,15 @@ export class QuestEditorStore implements Disposable, MessageLogStore {
|
||||
};
|
||||
|
||||
run_current_quest = (): void => {
|
||||
const quest = this.current_quest.val;
|
||||
// workaround for circular dependency
|
||||
import("../QuestRunner").then(({ QuestRunner }) => {
|
||||
const quest = this.current_quest.val;
|
||||
const quest_runner = new QuestRunner();
|
||||
|
||||
if (quest) {
|
||||
this.quest_runner.run(quest);
|
||||
}
|
||||
if (quest) {
|
||||
quest_runner.run(quest);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
private log_message_predicate = (msg: LogMessage): boolean => {
|
||||
|
Loading…
Reference in New Issue
Block a user