7 |
using System.Text; |
using System.Text; |
8 |
using System.Windows.Forms; |
using System.Windows.Forms; |
9 |
using RomCheater.Logging; |
using RomCheater.Logging; |
10 |
|
using RomCheater.PluginFramework.Core; |
11 |
|
using RomCheater.PluginFramework.Interfaces; |
12 |
|
|
13 |
namespace RomCheater |
namespace RomCheater |
14 |
{ |
{ |
15 |
public partial class RomCheaterConfigDialog : Form |
public partial class RomCheaterConfigDialog : Form |
16 |
{ |
{ |
17 |
|
private PluginLoader loader = null; |
18 |
public RomCheaterConfigDialog() |
public RomCheaterConfigDialog() |
19 |
{ |
{ |
20 |
InitializeComponent(); |
InitializeComponent(); |
21 |
} |
} |
22 |
|
public RomCheaterConfigDialog(PluginLoader loader) : this() |
23 |
|
{ |
24 |
|
this.loader = loader; |
25 |
|
} |
26 |
private void RomCheaterConfigDialog_Load(object sender, EventArgs e) |
private void RomCheaterConfigDialog_Load(object sender, EventArgs e) |
27 |
{ |
{ |
28 |
logger.Info.WriteLine("Loading user settings..."); |
logger.Info.WriteLine("Loading user settings..."); |
29 |
load_loggerflags(); |
load_loggerflags(); |
30 |
|
setup_plugin_entries(); |
31 |
logger.Info.WriteLine("Loaded user settings."); |
logger.Info.WriteLine("Loaded user settings."); |
32 |
} |
} |
33 |
|
|
34 |
|
private void setup_plugin_entries() |
35 |
|
{ |
36 |
|
foreach (IConfigPlugin c in loader.LoadedConfigPlugins) { comboConfigPlugins.Items.Add(string.Format("{0} [{1}]",c.Name, c.Id.ToString())); } |
37 |
|
foreach (IInputPlugin c in loader.LoadedInputPlugins) { comboInputPlugins.Items.Add(string.Format("{0} [{1}]", c.Name, c.Id.ToString())); } |
38 |
|
foreach (IWindowPlugin c in loader.LoadedWindowPlugins) { comboWindowPlugins.Items.Add(string.Format("{0} [{1}]", c.Name, c.Id.ToString())); } |
39 |
|
if (loader.LoadedConfigPlugins.Count == 0) { comboConfigPlugins.Items.Add(string.Format("{0} [{1}]", "None", new Guid().ToString())); } |
40 |
|
if (loader.LoadedInputPlugins.Count == 0) { comboInputPlugins.Items.Add(string.Format("{0} [{1}]", "None", new Guid().ToString())); } |
41 |
|
if (loader.LoadedWindowPlugins.Count == 0) { comboWindowPlugins.Items.Add(string.Format("{0} [{1}]", "None", new Guid().ToString())); } |
42 |
|
|
43 |
|
comboConfigPlugins.SelectedIndex = 0; |
44 |
|
comboInputPlugins.SelectedIndex = 0; |
45 |
|
comboWindowPlugins.SelectedIndex = 0; |
46 |
|
|
47 |
|
// select each plugin base on the last plugin |
48 |
|
foreach (string item in comboConfigPlugins.Items) |
49 |
|
{ |
50 |
|
if (item == RomCheater.Properties.Settings.Default.LastConfigPlugin) |
51 |
|
{ |
52 |
|
logger.Debug.WriteLine(" loading LastConfigPlugin: {0}", RomCheater.Properties.Settings.Default.LastConfigPlugin); |
53 |
|
comboConfigPlugins.SelectedIndex = comboConfigPlugins.Items.IndexOf(item); |
54 |
|
break; |
55 |
|
} |
56 |
|
} |
57 |
|
foreach (string item in comboInputPlugins.Items) |
58 |
|
{ |
59 |
|
if (item == RomCheater.Properties.Settings.Default.LastInputPlugin) |
60 |
|
{ |
61 |
|
logger.Debug.WriteLine(" loading LastInputPlugin: {0}", RomCheater.Properties.Settings.Default.LastInputPlugin); |
62 |
|
comboInputPlugins.SelectedIndex = comboInputPlugins.Items.IndexOf(item); |
63 |
|
break; |
64 |
|
} |
65 |
|
} |
66 |
|
foreach (string item in comboWindowPlugins.Items) |
67 |
|
{ |
68 |
|
if (item == RomCheater.Properties.Settings.Default.LastWindowPlugin) |
69 |
|
{ |
70 |
|
logger.Debug.WriteLine(" loading LastWindowPlugin: {0}", RomCheater.Properties.Settings.Default.LastWindowPlugin); |
71 |
|
comboWindowPlugins.SelectedIndex = comboWindowPlugins.Items.IndexOf(item); |
72 |
|
break; |
73 |
|
} |
74 |
|
} |
75 |
|
|
76 |
|
} |
77 |
|
|
78 |
private void load_loggerflags() |
private void load_loggerflags() |
79 |
{ |
{ |
80 |
logger.Debug.WriteLine("Loading logger flags..."); |
logger.Debug.WriteLine("Loading logger flags..."); |
115 |
private void btnCancel_Click(object sender, EventArgs e) |
private void btnCancel_Click(object sender, EventArgs e) |
116 |
{ |
{ |
117 |
this.Close(); |
this.Close(); |
118 |
|
object c; |
119 |
} |
} |
120 |
private void SaveSettings() |
private void SaveSettings() |
121 |
{ |
{ |
122 |
SaveLoggingFlags(); |
SaveLoggingFlags(); |
123 |
|
SaveSelectedPlugins(); |
124 |
RomCheater.Properties.Settings.Default.Save(); |
RomCheater.Properties.Settings.Default.Save(); |
125 |
Logging.Properties.Settings.Default.Save(); |
Logging.Properties.Settings.Default.Save(); |
126 |
logger.Info.WriteLine("Saved user settings."); |
logger.Info.WriteLine("Saved user settings."); |
127 |
} |
} |
128 |
|
private void SaveSelectedPlugins() |
129 |
|
{ |
130 |
|
logger.Debug.WriteLine(" Setting LastConfigPlugin to {0}", comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString()); |
131 |
|
RomCheater.Properties.Settings.Default.LastConfigPlugin = comboConfigPlugins.Items[comboConfigPlugins.SelectedIndex].ToString(); |
132 |
|
logger.Debug.WriteLine(" Setting LastInputPlugin to {0}", comboInputPlugins.Items[comboConfigPlugins.SelectedIndex].ToString()); |
133 |
|
RomCheater.Properties.Settings.Default.LastInputPlugin = comboInputPlugins.Items[comboConfigPlugins.SelectedIndex].ToString(); |
134 |
|
logger.Debug.WriteLine(" Setting LastWindowPlugin to {0}", comboWindowPlugins.Items[comboConfigPlugins.SelectedIndex].ToString()); |
135 |
|
RomCheater.Properties.Settings.Default.LastWindowPlugin = comboWindowPlugins.Items[comboConfigPlugins.SelectedIndex].ToString(); |
136 |
|
} |
137 |
private void SaveLoggingFlags() |
private void SaveLoggingFlags() |
138 |
{ |
{ |
139 |
logger.Debug.WriteLine("Saving Logger flags..."); |
logger.Debug.WriteLine("Saving Logger flags..."); |