VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
void AVR.UEditor.Core.AVR_Settings_Editor.OnGUI ( )
inlineprivate

Definition at line 21 of file AVR_Settings_Editor.cs.

22  {
23  EditorGUILayout.LabelField("AVR SETTINGS");
24 
25  EditorGUILayout.BeginVertical();
26  scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
28  EditorGUILayout.EndScrollView();
29  EditorGUILayout.EndVertical();
30 
31  if(GUILayout.Button("Save")) {
32  // All settings excluding any changes made now as well as changes in ~overridesettings.avr
33  Dictionary<string, string> entries_pre = AVR_SettingsParser.AutoParseSettingFiles(true);
34 
35  // This will be all settings entries *including* any changes made now as well as in ~overridesettings.avr
36  Dictionary<string, string> entries_post = AVR_SettingsParser.AutoParseSettingFiles(false);
37 
38  // Scan SettingsTree for any changes in entries_post. Apply these if found.
39  root.traverse((SettingsTreeNode n) => { if(n.is_leaf() && entries_post[n.fullname]!=n.value) entries_post[n.fullname] = n.value; });
40 
41  // Keys that differ between pre and post
42  Dictionary<string, string> entries_diff = new Dictionary<string, string>();
43 
44  // Look for differences
45  foreach(string k in entries_post.Keys) {
46  //if k is not a key in entries or the entry is different
47  if(!entries_pre.ContainsKey(k) || entries_pre[k]!=entries_post[k]) {
48  entries_diff.Add(k, entries_post[k]);
49  }
50  }
51 
52 
53  // Re-insert these into ~overridesettings.avr
54  string content = "";
55  string filepath = "";
56  foreach (string k in entries_diff.Keys)
57  {
58  content += k.Substring(1) + " = \"" + entries_diff[k] + "\"\n";
59  }
60  try {
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);
66  }
67  System.IO.File.WriteAllText(filepath, content);
68 
69  // reload settings
70  AVR_Settings.settings = AVR_SettingsParser.AutoParseSettingFiles();
71  }
72  }
SettingsTreeNode[] get_children()
void OnGUISettingsNode(SettingsTreeNode node)
Class representing a node from a settings-tree returned by AVR_Settings.build_tree() ...