ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/RomCheater/trunk/RomCheater/RomCheaterConfigDialog.cs
(Generate patch)

Comparing trunk/RomCheater/RomCheaterConfigDialog.cs (file contents):
Revision 721 by william, Mon Jun 17 10:29:30 2013 UTC vs.
Revision 722 by william, Tue Jun 18 19:18:05 2013 UTC

--- trunk/RomCheater/RomCheaterConfigDialog.cs	2013/06/18 11:40:50	721
+++ trunk/RomCheater/RomCheaterConfigDialog.cs	2013/06/18 19:18:05	722
@@ -23,6 +23,7 @@ using System.Windows.Forms;
 using RomCheater.Logging;
 using RomCheater.PluginFramework.Core;
 using RomCheater.Core;
+using RomCheater.UserSettingsSupport;
 
 
 namespace RomCheater
@@ -33,6 +34,9 @@ namespace RomCheater
         private loggerflags lFlags;
 #endif
 
+        SettingSubscriber MainSettingsSubscriber;
+        SettingSubscriber LoggingettingsSubscriber;
+
         private PluginLoader loader = null;
         public RomCheaterConfigDialog()
         {
@@ -45,6 +49,10 @@ namespace RomCheater
             //    flags = (ushort)(lFlags.Value & ~loggerflags.VERBOSE_DEBUG.Value);
             //    logger.SetLoggingFlags(flags);                
             //}
+            MainSettingsSubscriber = new SettingSubscriber();
+            LoggingettingsSubscriber = new SettingSubscriber();
+            MainSettingsSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default);
+            LoggingettingsSubscriber.AddSubscriber(this, RomCheater.Logging.Properties.Settings.Default);
         }
         public RomCheaterConfigDialog(PluginLoader loader)
             : this()
@@ -77,7 +85,7 @@ namespace RomCheater
             {
                 if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastConfigPlugin: {0}", RomCheater.Properties.Settings.Default.LastConfigPlugin);
+                    logger.VerboseDebug.WriteLine("    loading LastConfigPlugin: {0}", MainSettingsSubscriber.GetValue("LastConfigPlugin"));
                     comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -86,7 +94,7 @@ namespace RomCheater
             {
                 if (item == RomCheater.Properties.Settings.Default.LastInputPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastInputPlugin: {0}", RomCheater.Properties.Settings.Default.LastInputPlugin);
+                    logger.VerboseDebug.WriteLine("    loading LastInputPlugin: {0}", MainSettingsSubscriber.GetValue("LastInputPlugin"));
                     comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -95,7 +103,7 @@ namespace RomCheater
             {
                 if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin)
                 {
-                    logger.VerboseDebug.WriteLine("    loading LastWindowPlugin: {0}", RomCheater.Properties.Settings.Default.LastWindowPlugin);
+                    logger.VerboseDebug.WriteLine("    loading LastWindowPlugin: {0}", MainSettingsSubscriber.GetValue("LastWindowPlugin"));
                     comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item);
                     break;
                 }
@@ -106,8 +114,8 @@ namespace RomCheater
         private void load_loggerflags()
         {
             logger.Info.WriteLine("  Loading logger flags...");
-            loggerflags logflags = Logging.Properties.Settings.Default.LoggingFlags;
-
+            object o_flags = LoggingettingsSubscriber.GetValue("LoggingFlags");
+            loggerflags logflags = (ushort)Convert.ChangeType(o_flags, typeof(ushort));
             if (logflags != logger.GetLoggingFlags())
             {
                 logflags = logger.GetLoggingFlags(); // we apparently have forced the logging flags (possible for testing)
@@ -170,18 +178,22 @@ namespace RomCheater
         {
             SaveLoggingFlags();
             SaveSelectedPlugins();
-            RomCheater.Properties.Settings.Default.Save();
-            Logging.Properties.Settings.Default.Save();
+            MainSettingsSubscriber.SaveSettings();
+            LoggingettingsSubscriber.SaveSettings();
+            //RomCheater.Properties.Settings.Default.Save();
+            //Logging.Properties.Settings.Default.Save();
             logger.Info.WriteLine("Saved user settings.");
         }
         private void SaveSelectedPlugins()
         {
             logger.VerboseDebug.WriteLine("    Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
-            RomCheater.Properties.Settings.Default.LastConfigPlugin = comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString();
-            logger.VerboseDebug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
-            RomCheater.Properties.Settings.Default.LastInputPlugin = comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString();
-            logger.VerboseDebug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
-            RomCheater.Properties.Settings.Default.LastWindowPlugin = comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString();
+            MainSettingsSubscriber.SetValue("LastConfigPlugin",comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString());
+
+            logger.VerboseDebug.WriteLine("    Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());            
+            MainSettingsSubscriber.SetValue("LastInputPlugin", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString());
+
+            logger.VerboseDebug.WriteLine("    Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());            
+            MainSettingsSubscriber.SetValue("LastWindowPlugin", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString());
         }
         private void SaveLoggingFlags()
         {
@@ -194,7 +206,8 @@ namespace RomCheater
                 logflags = (ushort)(logflags | value);
                 logger.VerboseDebug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags);                
             }
-            Logging.Properties.Settings.Default.LoggingFlags = (ushort)logflags;
+
+            LoggingettingsSubscriber.SetValue("LoggingFlags", (ushort)logflags);
             logger.Debug.WriteLine("Saved Logger flags.");
         }