Mod archive model
This commit is contained in:
parent
14037ecc93
commit
fca467a427
@ -1,6 +1,6 @@
|
||||
import { Component, ReactNode } from "react";
|
||||
import { Icon } from '@fluentui/react/lib/Icon';
|
||||
import { useStatus, IMixinStatusProps } from "@Context/Status";
|
||||
import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status";
|
||||
import { useSetting, IMixinSettingProps } from "@Context/Setting";
|
||||
import { Theme, BackgroundLevel, FontLevel } from "@Component/Theme/Theme";
|
||||
import { LocalizationTooltipHost } from "@Component/Localization/LocalizationTooltipHost";
|
||||
@ -20,7 +20,7 @@ interface HeaderBarState {
|
||||
* 头部信息栏
|
||||
*/
|
||||
@useSetting
|
||||
@useStatus
|
||||
@useStatusWithEvent("fileChange")
|
||||
class HeaderBar extends Component<
|
||||
IHeaderBarProps & IMixinStatusProps & IMixinSettingProps,
|
||||
HeaderBarState
|
||||
@ -63,7 +63,6 @@ class HeaderBar extends Component<
|
||||
setting.on("language", this.changeListener);
|
||||
}
|
||||
if (status) {
|
||||
status.archive.on("save", this.changeListener);
|
||||
status.on("physicsLoop", this.physicsFpsCalc);
|
||||
status.on("renderLoop", this.renderFpsCalc);
|
||||
}
|
||||
@ -75,7 +74,6 @@ class HeaderBar extends Component<
|
||||
setting.off("language", this.changeListener);
|
||||
}
|
||||
if (status) {
|
||||
status.archive.off("save", this.changeListener);
|
||||
status.off("physicsLoop", this.physicsFpsCalc);
|
||||
status.off("renderLoop", this.renderFpsCalc);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ function randomColor(unNormal: boolean = false) {
|
||||
}
|
||||
|
||||
interface IStatusEvent {
|
||||
fileChange: void;
|
||||
renderLoop: number;
|
||||
physicsLoop: number;
|
||||
mouseModChange: void;
|
||||
@ -148,6 +149,9 @@ class Status extends Emitter<IStatusEvent> {
|
||||
this.on("groupLabelChange", updateBehaviorParameter);
|
||||
this.on("rangeLabelChange", updateBehaviorParameter);
|
||||
this.on("behaviorAttrChange", updateBehaviorParameter);
|
||||
|
||||
// 映射文件状态改变事件
|
||||
this.archive.on("fileChange", () => this.emit("fileChange"));
|
||||
}
|
||||
|
||||
public bindRenderer(renderer: AbstractRenderer) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
import { Emitter, EventType } from "@Model/Emitter";
|
||||
import { Model } from "./Model";
|
||||
|
||||
interface IArchiveEvent {
|
||||
save: Archive;
|
||||
load: Archive;
|
||||
fileChange: Archive;
|
||||
}
|
||||
|
||||
class Archive<
|
||||
@ -34,13 +34,28 @@ class Archive<
|
||||
* 保存文件
|
||||
* 模型转换为文件
|
||||
*/
|
||||
public save() {};
|
||||
public save(model: Model): string {
|
||||
let fileData: Record<string, any> = {};
|
||||
|
||||
// 保存 Next ID
|
||||
fileData.idIndex = model.idIndex;
|
||||
|
||||
// 保存对象
|
||||
fileData.objects = [];
|
||||
|
||||
// 记录
|
||||
model.objectPool.map((object) => {
|
||||
|
||||
})
|
||||
|
||||
return JSON.stringify(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载文件为模型
|
||||
* return Model
|
||||
*/
|
||||
public load() {};
|
||||
public load(model: Model, data: string) {};
|
||||
}
|
||||
|
||||
export { Archive };
|
||||
|
@ -33,7 +33,7 @@ class Model extends Emitter<ModelEvent> {
|
||||
/**
|
||||
* 下一个需要分配的 ID
|
||||
*/
|
||||
private idIndex: number = 1;
|
||||
public idIndex: number = 1;
|
||||
public nextId(label: string = "U"): string {
|
||||
return `${label}-${this.idIndex ++}`;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user