|
|
@@ -157,6 +157,40 @@ class 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
|
|
|
@@ -284,6 +318,14 @@ interface AceEditorSettings {
|
|
|
tabSize: number;
|
|
|
}
|
|
|
|
|
|
+interface UserInterfaceData {
|
|
|
+ skinPath : string;
|
|
|
+ defaultSkinPath : string;
|
|
|
+ fontFile : string;
|
|
|
+ fontName : string;
|
|
|
+ fontSize : number;
|
|
|
+}
|
|
|
+
|
|
|
class PreferencesFormat {
|
|
|
|
|
|
constructor() {
|
|
|
@@ -321,6 +363,15 @@ class PreferencesFormat {
|
|
|
useSoftTabs: true,
|
|
|
tabSize: 4
|
|
|
};
|
|
|
+
|
|
|
+ this.uiData = {
|
|
|
+ skinPath : "AtomicEditor/editor/skin/",
|
|
|
+ defaultSkinPath : "AtomicEditor/resources/default_skin/",
|
|
|
+ fontFile : "AtomicEditor/resources/vera.ttf",
|
|
|
+ fontName : "Vera",
|
|
|
+ fontSize : 12
|
|
|
+ };
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -351,6 +402,11 @@ class PreferencesFormat {
|
|
|
updatedMissingDefaults = true;
|
|
|
}
|
|
|
|
|
|
+ if (!prefs.uiData) {
|
|
|
+ prefs.uiData = this.uiData;
|
|
|
+ updatedMissingDefaults = true;
|
|
|
+ }
|
|
|
+
|
|
|
return updatedMissingDefaults;
|
|
|
}
|
|
|
|
|
|
@@ -358,6 +414,7 @@ class PreferencesFormat {
|
|
|
editorWindow: WindowData;
|
|
|
playerWindow: WindowData;
|
|
|
codeEditorSettings: AceEditorSettings;
|
|
|
+ uiData : UserInterfaceData;
|
|
|
}
|
|
|
|
|
|
export = Preferences;
|