| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- //
- // Copyright (c) 2014-2016 THUNDERBEAST GAMES LLC
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- //
- import MainFrame = require("./frames/MainFrame");
- import ModalOps = require("./modal/ModalOps");
- import Shortcuts = require("./Shortcuts");
- import ServiceLocator from "../hostExtensions/ServiceLocator";
- import {default as AtomicEditor} from "editor/Editor";
- // this is designed with public get functions to solve
- // circular dependency issues in TS
- var editorUI:EditorUI;
- export function getMainFrame():MainFrame {
- return editorUI.mainframe;
- }
- export function getModelOps():ModalOps {
- return editorUI.modalOps;
- }
- export function getView():Atomic.UIView {
- return editorUI.view;
- }
- export function getShortcuts():Shortcuts {
- return editorUI.shortcuts;
- }
- export function initialize(editor: AtomicEditor) {
- editorUI = new EditorUI(editor);
- }
- export function getEditor(): AtomicEditor {
- return editorUI.editor;
- }
- export function shutdown() {
- editorUI.mainframe.shutdown();
- var view = editorUI.view;
- view.deleteAllChildren();
- view.parent.removeChild(view);
- }
- export function showModalError(windowText:string, message:string) {
- editorUI.showModalError(windowText, message);
- }
- export function showEditorStatus(message:string) {
- editorUI.showEditorStatus(message);
- }
- export function getCurrentResourceEditor():Editor.ResourceEditor {
- return getMainFrame().resourceframe.currentResourceEditor;
- }
- class EditorUI extends Atomic.ScriptObject {
- constructor(editor: AtomicEditor) {
- super();
- var graphics = Atomic.getGraphics();
- this.view = new Atomic.UIView();
- this.mainframe = new MainFrame();
- this.view.addChild(this.mainframe);
- this.editor = editor;
- this.subscribeToEvent(Atomic.ScreenModeEvent((ev:Atomic.ScreenModeEvent) => {
- this.mainframe.setSize(ev.width, ev.height);
- }));
- // set initial size
- this.mainframe.setSize(graphics.width, graphics.height);
- this.modalOps = new ModalOps();
- this.shortcuts = new Shortcuts();
- // Hook the service locator into the event system and give it the ui objects it needs
- ServiceLocator.uiServices.init(
- this.mainframe,
- this.modalOps);
- ServiceLocator.subscribeToEvents(this.mainframe);
- this.subscribeToEvent(Editor.EditorModalEvent((event:Editor.EditorModalEvent) => {
- if (event.type == Editor.EDITOR_MODALERROR)
- this.showModalError(event.title, event.message);
- else if ( event.type == Editor.EDITOR_MODALINFO)
- this.showEditorStatus(event.message);
- }));
- this.showEditorStatus("Ready.");
- }
- showModalError(windowText: string, message: string) {
- this.modalOps.showError(windowText, message);
- }
- showEditorStatus(message: string) {
- this.mainframe.showStatusText(message);
- }
- view: Atomic.UIView;
- mainframe: MainFrame;
- modalOps: ModalOps;
- shortcuts: Shortcuts;
- editor: AtomicEditor;
- }
|