1 using System.Collections;
2 using System.Collections.Generic;
8 namespace AVR.UEditor.Core {
14 [MenuItem(
"AVR/Settings",
false, 999)]
17 root = AVR_Settings.build_tree();
23 EditorGUILayout.LabelField(
"AVR SETTINGS");
25 EditorGUILayout.BeginVertical();
26 scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
28 EditorGUILayout.EndScrollView();
29 EditorGUILayout.EndVertical();
31 if(GUILayout.Button(
"Save")) {
33 Dictionary<string, string> entries_pre = AVR_SettingsParser.AutoParseSettingFiles(
true);
36 Dictionary<string, string> entries_post = AVR_SettingsParser.AutoParseSettingFiles(
false);
42 Dictionary<string, string> entries_diff =
new Dictionary<string, string>();
45 foreach(
string k
in entries_post.Keys) {
47 if(!entries_pre.ContainsKey(k) || entries_pre[k]!=entries_post[k]) {
48 entries_diff.Add(k, entries_post[k]);
56 foreach (
string k
in entries_diff.Keys)
58 content += k.Substring(1) +
" = \"" + entries_diff[k] +
"\"\n";
61 filepath = System.IO.Directory.GetFiles(Application.dataPath+
"/..",
"~overridesettings.avr", System.IO.SearchOption.AllDirectories)[0];
62 }
catch(System.Exception) {
63 AVR_DevConsole.cwarn(
"Could not find ~overridesettings.avr. Creating new file at directory: " + Application.dataPath,
"AVR_Settings_Editor");
64 filepath = Application.dataPath +
"/~overridesettings.avr";
65 System.IO.File.Create(filepath);
67 System.IO.File.WriteAllText(filepath, content);
70 AVR_Settings.settings = AVR_SettingsParser.AutoParseSettingFiles();
76 string data = node.value;
77 if(
bool.TryParse(data, out
bool b)) {
78 node.value = EditorGUILayout.Toggle(node.name, b).ToString();
80 else if(
float.TryParse(data, out
float f)) {
81 node.value = EditorGUILayout.FloatField(node.name, f).ToString();
84 node.value = EditorGUILayout.TextField(node.name, data);
88 node.foldout = EditorGUILayout.Foldout(node.foldout, node.name,
true);
89 EditorGUI.indentLevel++;
91 EditorGUI.indentLevel--;
SettingsTreeNode[] get_children()
static SettingsTreeNode root
void OnGUISettingsNode(SettingsTreeNode node)
Class representing a node from a settings-tree returned by AVR_Settings.build_tree() ...