|
|
@@ -2,120 +2,74 @@
|
|
|
import strings = require("./EditorStrings");
|
|
|
import EditorEvents = require("../editor/EditorEvents");
|
|
|
import EditorUI = require("./EditorUI");
|
|
|
+import MenuItemSources = require("./menus/MenuItemSources");
|
|
|
|
|
|
class MainFrameMenu extends Atomic.ScriptObject {
|
|
|
|
|
|
- constructor() {
|
|
|
+ constructor() {
|
|
|
|
|
|
- super();
|
|
|
+ super();
|
|
|
|
|
|
- this.srcLookup["menu atomic editor"] = this.createMenuItemSource(editorItems);
|
|
|
- this.srcLookup["menu edit"] = this.createMenuItemSource(editItems);
|
|
|
- this.srcLookup["menu file"] = this.createMenuItemSource(fileItems);
|
|
|
+ MenuItemSources.createMenuItemSource("menu atomic editor", editorItems);
|
|
|
+ MenuItemSources.createMenuItemSource("menu edit", editItems);
|
|
|
+ MenuItemSources.createMenuItemSource("menu file", fileItems);
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
|
|
|
+ handlePopupMenu(target: Atomic.UIWidget, refid: string): boolean {
|
|
|
|
|
|
- if (target.id == "menu atomic editor popup") {
|
|
|
+ if (target.id == "menu atomic editor popup") {
|
|
|
|
|
|
- if (refid == "quit") {
|
|
|
+ if (refid == "quit") {
|
|
|
|
|
|
- this.sendEvent(EditorEvents.Quit);
|
|
|
- return true;
|
|
|
+ this.sendEvent(EditorEvents.Quit);
|
|
|
+ return true;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- } else if (target.id == "menu edit popup") {
|
|
|
+ } else if (target.id == "menu edit popup") {
|
|
|
|
|
|
- if (refid == "edit play") {
|
|
|
+ if (refid == "edit play") {
|
|
|
|
|
|
- new ToolCore.PlayCmd().run();
|
|
|
- return true;
|
|
|
+ new ToolCore.PlayCmd().run();
|
|
|
+ return true;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- return false;
|
|
|
+ return false;
|
|
|
|
|
|
- } else if (target.id == "menu file popup") {
|
|
|
+ } else if (target.id == "menu file popup") {
|
|
|
|
|
|
- if (refid == "file new project") {
|
|
|
+ if (refid == "file new project") {
|
|
|
|
|
|
- var mo = EditorUI.getModelOps();
|
|
|
- mo.showNewProject();
|
|
|
+ var mo = EditorUI.getModelOps();
|
|
|
+ mo.showNewProject();
|
|
|
|
|
|
- return true;
|
|
|
+ return true;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- if (refid == "file save file") {
|
|
|
+ if (refid == "file save file") {
|
|
|
|
|
|
- //TODO: this is horrible
|
|
|
- //if (this.resourceframe.currentResourceEditor)
|
|
|
- // this.resourceframe.currentResourceEditor.save();
|
|
|
+ //TODO: this is horrible
|
|
|
+ //if (this.resourceframe.currentResourceEditor)
|
|
|
+ // this.resourceframe.currentResourceEditor.save();
|
|
|
|
|
|
- return true;
|
|
|
+ return true;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- return false;
|
|
|
- }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- getMenuItemSource(id: string): Atomic.UIMenuItemSource {
|
|
|
-
|
|
|
- return this.srcLookup[id];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- createMenuItemSource(items: any): Atomic.UIMenuItemSource {
|
|
|
-
|
|
|
- var src = new UIMenuItemSource();
|
|
|
-
|
|
|
- for (var key in items) {
|
|
|
-
|
|
|
- if (items.hasOwnProperty(key)) {
|
|
|
-
|
|
|
- var value = items[key];
|
|
|
-
|
|
|
- if (typeof value === 'string') {
|
|
|
-
|
|
|
- src.addItem(new UIMenuItem(key, value));
|
|
|
-
|
|
|
- } else if (value == null) {
|
|
|
-
|
|
|
- src.addItem(new UIMenuItem(key));
|
|
|
-
|
|
|
- }
|
|
|
- else if (typeof value === 'object' && value.length == 1) {
|
|
|
-
|
|
|
- src.addItem(new UIMenuItem(key, value[0]));
|
|
|
-
|
|
|
- } else if (typeof value === 'object' && value.length == 2) {
|
|
|
-
|
|
|
- src.addItem(new UIMenuItem(key, value[0], strings.EditorString.GetString(value[1])));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return src;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- srcLookup = {};
|
|
|
|
|
|
}
|
|
|
|
|
|
export = MainFrameMenu;
|
|
|
|
|
|
// initialization
|
|
|
-
|
|
|
-var UIMenuItemSource = Atomic.UIMenuItemSource;
|
|
|
-var UIMenuItem = Atomic.UIMenuItem;
|
|
|
var StringID = strings.StringID;
|
|
|
|
|
|
var editorItems = {
|
|
|
@@ -150,12 +104,12 @@ var editItems = {
|
|
|
|
|
|
var fileItems = {
|
|
|
|
|
|
- "New Project": ["file new project"],
|
|
|
- "Open Project": ["file open project"],
|
|
|
- "Save Project": ["file save project"],
|
|
|
- "-1": null,
|
|
|
- "Close Project": ["file close project"],
|
|
|
- "-2": null,
|
|
|
- "Save File": ["file save file"],
|
|
|
- "Close File": ["file close file"]
|
|
|
+ "New Project": ["file new project"],
|
|
|
+ "Open Project": ["file open project"],
|
|
|
+ "Save Project": ["file save project"],
|
|
|
+ "-1": null,
|
|
|
+ "Close Project": ["file close project"],
|
|
|
+ "-2": null,
|
|
|
+ "Save File": ["file save file"],
|
|
|
+ "Close File": ["file close file"]
|
|
|
}
|