/[RomCheater]/trunk/RomCheater.RVAScratchPad/Form1.cs
ViewVC logotype

Diff of /trunk/RomCheater.RVAScratchPad/Form1.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/RomCheater.RVAScratchPad/Form1.cs	2013/06/18 11:40:50	721
+++ trunk/RomCheater.RVAScratchPad/Form1.cs	2013/06/18 19:18:05	722
@@ -17,6 +17,7 @@
 {
     public partial class Form1 : Form
     {
+        private SettingSubscriber SettingsSubscriber = null;
         private bool m_bSaveLayout = true;
         PluginLoader loader = null;
         IConfigPlugin ConfigPlugin = null;
@@ -41,6 +42,8 @@
         public Form1(bool no_console_redirect)
         {
             InitializeComponent();
+            SettingsSubscriber = new SettingSubscriber();
+            SettingsSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default);              
             load_loggerflags();
             SetupDocks();
             LoggerInstance = m_LogWindow.Logwriter;
@@ -63,10 +66,19 @@
         {
             loader = new PluginLoader();
             loader.LoadPlugins(silent);
-            var config = PluginCollection.GetPluginByName(PluginNames.GenericConfig);
+
+            var LastConfigPlugin = SettingsSubscriber.GetValue("LastConfigPlugin").ToString();
+            if (LastConfigPlugin != null)
+            {
+                ConfigPlugin = loader.GetConfigPlugin(LastConfigPlugin.ToString());
+            }
+            else
+            {
+                var config = PluginCollection.GetPluginByName(PluginNames.GenericConfig);
+                ConfigPlugin = loader.GetPluginByGuid<IConfigPlugin>(config.ID.ToString());
+            }            
             var scratchpad = PluginCollection.GetPluginByName(PluginNames.ScratchPadPlugin);
-            var rvacalc = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);
-            ConfigPlugin = loader.GetPluginByGuid<IConfigPlugin>(config.ID.ToString());
+            var rvacalc = PluginCollection.GetPluginByName(PluginNames.RVACalculatorPlugin);            
             ScratchPadPlugin = loader.GetPluginByGuid<IUserControlPlugin>(scratchpad.ID.ToString());
             RVACalcPlugin = loader.GetPluginByGuid<IUserControlPlugin>(rvacalc.ID.ToString());
         }
@@ -135,6 +147,9 @@
             SetupWebBrowserWindowHandler();
             ShowPluginWindows();
             SetupPluginWindowHandlers();
+
+            if (RVACalcPlugin != null)
+                RVACalcPlugin.Activate();
         }
         public void ShowLogWindow()
         {
@@ -160,12 +175,13 @@
             // RVA Calc
             RVACalcPlugin.Show(dockPanel);
             // ScratchPad
-            ScratchPadPlugin.Show(dockPanel);
+            ScratchPadPlugin.Show(dockPanel);     
         }
         #endregion
 
         private void Form1_FormClosing(object sender, FormClosingEventArgs e)
         {
+            SettingsSubscriber.SaveSettings();
             string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RVAScratchPad-DockPanel.config");
             if (m_bSaveLayout)
                 dockPanel.SaveAsXml(configFile);
@@ -205,6 +221,8 @@
                 ShowDocks();
             }
 
+            if (RVACalcPlugin != null)
+                RVACalcPlugin.Activate();
             //dockPanel.ResumeLayout(true, true);
         }
 
@@ -215,7 +233,7 @@
 
         private void Form1_Load(object sender, EventArgs e)
         {
-            SettingSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default); 
+            SettingsSubscriber.SaveSettings();
         }
     }
 }

 

  ViewVC Help
Powered by ViewVC 1.1.22