Browse Source

editor skin preferences

JimMarlowe 9 years ago
parent
commit
a76dea0b3e
2 changed files with 9 additions and 44 deletions
  1. 5 10
      Script/AtomicEditor/editor/Editor.ts
  2. 4 34
      Script/AtomicEditor/editor/Preferences.ts

+ 5 - 10
Script/AtomicEditor/editor/Editor.ts

@@ -103,18 +103,13 @@ class Editor extends Atomic.ScriptObject {
         this.parseArguments();
     }
 
-    initUI() { 
-        var defSkin = Preferences.getInstance().getApplicationPreference("uiData", "skinPath", "AtomicEditor/editor/skin/");
-        var defDefaultSkin = Preferences.getInstance().getApplicationPreference("uiData", "defaultSkinPath", "AtomicEditor/resources/default_skin/");
-        var defFontFile = Preferences.getInstance().getApplicationPreference("uiData", "fontFile", "AtomicEditor/resources/vera.ttf");
-        var defFontName = Preferences.getInstance().getApplicationPreference("uiData", "fontName", "Vera");
-        var defFontSize = Preferences.getInstance().getApplicationPreference("uiData", "fontSize", 12);
-
+    initUI() {
+        var uiData = Preferences.getInstance().uiData;
         var ui = Atomic.ui;
-        ui.loadSkin(defDefaultSkin + "/skin.tb.txt", defSkin + "/skin.tb.txt");
-        ui.addFont(defFontFile, defFontName);
+        ui.loadSkin(uiData.skinPath + "/skin.tb.txt", uiData.defaultSkinPath + "/skin.tb.txt");
+        ui.addFont(uiData.fontFile, uiData.fontName);
         ui.addFont("AtomicEditor/resources/MesloLGS-Regular.ttf", "Monaco");
-        ui.setDefaultFont(defFontName, defFontSize);
+        ui.setDefaultFont(uiData.fontName, uiData.fontSize);
     }
 
     saveWindowPreferences(data: Atomic.ScreenModeEvent): boolean {

+ 4 - 34
Script/AtomicEditor/editor/Preferences.ts

@@ -153,44 +153,14 @@ class Preferences {
         return this._prefs.recentProjects;
     }
 
+    get uiData(): UserInterfaceData {
+        return this._prefs.uiData;
+    }
+
     static getInstance(): Preferences {
         return Preferences.instance;
     }
 
-    /**
-     * Return a preference value or the provided default from the user settings file
-     * @param  {string} settignsGroup name of the group the preference lives under
-     * @param  {string} preferenceName name of the preference to retrieve
-     * @param  {number | boolean | string} defaultValue value to return if pref doesn't exist
-     * @return {number|boolean|string}
-     */
-    getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: number): number;
-    getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: string): string;
-    getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: boolean): boolean;
-    getApplicationPreference(settingsGroup: string, preferenceName: string, defaultValue?: any): any {
-
-        // Cache the settings so we don't keep going out to the file
-        if (this._prefs == null) {
-            const prefsAppFileLoc = this.getPreferencesFullPath();
-            if (Atomic.fileSystem.fileExists(prefsAppFileLoc)) {
-                let prefsAppFile = new Atomic.File(prefsAppFileLoc, Atomic.FILE_READ);
-                try {
-                    let prefs = JSON.parse(prefsAppFile.readText());
-                    this._prefs = prefs;
-                } finally {
-                    prefsAppFile.close();
-                }
-            }
-        }
-
-        if (this._prefs && this._prefs[settingsGroup]) {
-            return this._prefs[settingsGroup][preferenceName] || defaultValue;
-        }
-
-        // if all else fails
-        return defaultValue;
-    }
-    
     /**
      * Return a preference value or the provided default from the user settings file located in the project
      * @param  {string} settingsGroup name of the group these settings should fall under