23 |
using RomCheater.Logging; |
using RomCheater.Logging; |
24 |
using RomCheater.PluginFramework.Core; |
using RomCheater.PluginFramework.Core; |
25 |
using RomCheater.Core; |
using RomCheater.Core; |
26 |
|
using RomCheater.UserSettingsSupport; |
27 |
|
|
28 |
|
|
29 |
namespace RomCheater |
namespace RomCheater |
34 |
private loggerflags lFlags; |
private loggerflags lFlags; |
35 |
#endif |
#endif |
36 |
|
|
37 |
|
SettingSubscriber MainSettingsSubscriber; |
38 |
|
SettingSubscriber LoggingettingsSubscriber; |
39 |
|
|
40 |
private PluginLoader loader = null; |
private PluginLoader loader = null; |
41 |
public RomCheaterConfigDialog() |
public RomCheaterConfigDialog() |
42 |
{ |
{ |
49 |
// flags = (ushort)(lFlags.Value & ~loggerflags.VERBOSE_DEBUG.Value); |
// flags = (ushort)(lFlags.Value & ~loggerflags.VERBOSE_DEBUG.Value); |
50 |
// logger.SetLoggingFlags(flags); |
// logger.SetLoggingFlags(flags); |
51 |
//} |
//} |
52 |
|
MainSettingsSubscriber = new SettingSubscriber(); |
53 |
|
LoggingettingsSubscriber = new SettingSubscriber(); |
54 |
|
MainSettingsSubscriber.AddSubscriber(this, RomCheater.Properties.Settings.Default); |
55 |
|
LoggingettingsSubscriber.AddSubscriber(this, RomCheater.Logging.Properties.Settings.Default); |
56 |
} |
} |
57 |
public RomCheaterConfigDialog(PluginLoader loader) |
public RomCheaterConfigDialog(PluginLoader loader) |
58 |
: this() |
: this() |
85 |
{ |
{ |
86 |
if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin) |
if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin) |
87 |
{ |
{ |
88 |
logger.VerboseDebug.WriteLine(" loading LastConfigPlugin: {0}", RomCheater.Properties.Settings.Default.LastConfigPlugin); |
logger.VerboseDebug.WriteLine(" loading LastConfigPlugin: {0}", MainSettingsSubscriber.GetValue("LastConfigPlugin")); |
89 |
comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item); |
comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item); |
90 |
break; |
break; |
91 |
} |
} |
94 |
{ |
{ |
95 |
if (item == RomCheater.Properties.Settings.Default.LastInputPlugin) |
if (item == RomCheater.Properties.Settings.Default.LastInputPlugin) |
96 |
{ |
{ |
97 |
logger.VerboseDebug.WriteLine(" loading LastInputPlugin: {0}", RomCheater.Properties.Settings.Default.LastInputPlugin); |
logger.VerboseDebug.WriteLine(" loading LastInputPlugin: {0}", MainSettingsSubscriber.GetValue("LastInputPlugin")); |
98 |
comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item); |
comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item); |
99 |
break; |
break; |
100 |
} |
} |
103 |
{ |
{ |
104 |
if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin) |
if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin) |
105 |
{ |
{ |
106 |
logger.VerboseDebug.WriteLine(" loading LastWindowPlugin: {0}", RomCheater.Properties.Settings.Default.LastWindowPlugin); |
logger.VerboseDebug.WriteLine(" loading LastWindowPlugin: {0}", MainSettingsSubscriber.GetValue("LastWindowPlugin")); |
107 |
comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item); |
comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item); |
108 |
break; |
break; |
109 |
} |
} |
114 |
private void load_loggerflags() |
private void load_loggerflags() |
115 |
{ |
{ |
116 |
logger.Info.WriteLine(" Loading logger flags..."); |
logger.Info.WriteLine(" Loading logger flags..."); |
117 |
loggerflags logflags = Logging.Properties.Settings.Default.LoggingFlags; |
object o_flags = LoggingettingsSubscriber.GetValue("LoggingFlags"); |
118 |
|
loggerflags logflags = (ushort)Convert.ChangeType(o_flags, typeof(ushort)); |
119 |
if (logflags != logger.GetLoggingFlags()) |
if (logflags != logger.GetLoggingFlags()) |
120 |
{ |
{ |
121 |
logflags = logger.GetLoggingFlags(); // we apparently have forced the logging flags (possible for testing) |
logflags = logger.GetLoggingFlags(); // we apparently have forced the logging flags (possible for testing) |
178 |
{ |
{ |
179 |
SaveLoggingFlags(); |
SaveLoggingFlags(); |
180 |
SaveSelectedPlugins(); |
SaveSelectedPlugins(); |
181 |
RomCheater.Properties.Settings.Default.Save(); |
MainSettingsSubscriber.SaveSettings(); |
182 |
Logging.Properties.Settings.Default.Save(); |
LoggingettingsSubscriber.SaveSettings(); |
183 |
|
//RomCheater.Properties.Settings.Default.Save(); |
184 |
|
//Logging.Properties.Settings.Default.Save(); |
185 |
logger.Info.WriteLine("Saved user settings."); |
logger.Info.WriteLine("Saved user settings."); |
186 |
} |
} |
187 |
private void SaveSelectedPlugins() |
private void SaveSelectedPlugins() |
188 |
{ |
{ |
189 |
logger.VerboseDebug.WriteLine(" Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString()); |
logger.VerboseDebug.WriteLine(" Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString()); |
190 |
RomCheater.Properties.Settings.Default.LastConfigPlugin = comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString(); |
MainSettingsSubscriber.SetValue("LastConfigPlugin",comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString()); |
191 |
logger.VerboseDebug.WriteLine(" Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString()); |
|
192 |
RomCheater.Properties.Settings.Default.LastInputPlugin = comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString(); |
logger.VerboseDebug.WriteLine(" Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString()); |
193 |
logger.VerboseDebug.WriteLine(" Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString()); |
MainSettingsSubscriber.SetValue("LastInputPlugin", comboInputPlugins.Items[comboInputPlugins.SelectedIndex].ToString()); |
194 |
RomCheater.Properties.Settings.Default.LastWindowPlugin = comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString(); |
|
195 |
|
logger.VerboseDebug.WriteLine(" Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString()); |
196 |
|
MainSettingsSubscriber.SetValue("LastWindowPlugin", comboWindowPlugins.Items[comboWindowPlugins.SelectedIndex].ToString()); |
197 |
} |
} |
198 |
private void SaveLoggingFlags() |
private void SaveLoggingFlags() |
199 |
{ |
{ |
206 |
logflags = (ushort)(logflags | value); |
logflags = (ushort)(logflags | value); |
207 |
logger.VerboseDebug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags); |
logger.VerboseDebug.WriteLine("\tAdding flag: {0} value: 0x{1:x4} LoggingFlags=0x{2:x4}", cb.Text, value, (int)logflags); |
208 |
} |
} |
209 |
Logging.Properties.Settings.Default.LoggingFlags = (ushort)logflags; |
|
210 |
|
LoggingettingsSubscriber.SetValue("LoggingFlags", (ushort)logflags); |
211 |
logger.Debug.WriteLine("Saved Logger flags."); |
logger.Debug.WriteLine("Saved Logger flags."); |
212 |
} |
} |
213 |
|
|