Browse Source

Merge pull request #1443 from JimMarlowe/JM-LIVER-THEME

Real time theme switching in editor
JoshEngebretson 8 years ago
parent
commit
85c2e91013

+ 20 - 0
Script/AtomicEditor/editor/Preferences.ts

@@ -149,6 +149,26 @@ class Preferences {
         this.write();
         this.write();
     }
     }
 
 
+    saveEditorUiData(uiData: UserInterfaceData) {
+        this._prefs.uiData = uiData;
+        this.write();
+    }
+
+    toggleTheme() : void { // swap the themes
+        var uiData = this.uiData;
+        if ( this.uiData.defaultSkinPath == "AtomicEditor/resources/default_skin/" ) {
+            this.uiData.defaultSkinPath = "AtomicEditor/resources/default_skin_light/";
+            this.uiData.skinPath = "AtomicEditor/editor/skin_light/";
+        }
+        else {
+            this.uiData.defaultSkinPath = "AtomicEditor/resources/default_skin/";
+            this.uiData.skinPath = "AtomicEditor/editor/skin/";
+        }
+        var ui = Atomic.ui; // install the new skins, live action
+        ui.loadSkin(this.uiData.skinPath + "/skin.tb.txt", this.uiData.defaultSkinPath + "/skin.tb.txt");
+        this.saveEditorUiData(this.uiData); // save preferences
+    }
+
     useDefaultConfig(): void {
     useDefaultConfig(): void {
         this._prefs = new PreferencesFormat();
         this._prefs = new PreferencesFormat();
     }
     }

+ 16 - 0
Script/AtomicEditor/ui/frames/menus/MainFrameMenu.ts

@@ -220,6 +220,20 @@ class MainFrameMenu extends Atomic.ScriptObject {
 
 
         } else if (target.id == "menu developer popup") {
         } else if (target.id == "menu developer popup") {
 
 
+            if (refid == "toggle theme") {
+                Preferences.getInstance().toggleTheme();
+                return true;
+            }
+
+            if (refid == "toggle codeeditor") {
+                var ctheme = EditorUI.getEditor().getApplicationPreference( "codeEditor","theme", "");
+                if ( ctheme == "vs-dark" )
+                    EditorUI.getEditor().setApplicationPreference( "codeEditor","theme","vs");
+                else
+                    EditorUI.getEditor().setApplicationPreference( "codeEditor","theme","vs-dark");
+                return true;
+            }
+
             if (refid == "developer show console") {
             if (refid == "developer show console") {
                 Atomic.ui.showConsole(true);
                 Atomic.ui.showConsole(true);
                 return true;
                 return true;
@@ -393,6 +407,8 @@ var buildItems = {
 
 
 var developerItems = {
 var developerItems = {
 
 
+    "Toggle Theme": ["toggle theme"],
+    "Toggle Code Editor Theme": ["toggle codeeditor"],
     "Show Console": ["developer show console"],
     "Show Console": ["developer show console"],
     "Clear Preferences": ["developer clear preferences"], //Adds clear preference to developer menu items list
     "Clear Preferences": ["developer clear preferences"], //Adds clear preference to developer menu items list
     "Debug": {
     "Debug": {