1 |
#define FORCE_ALL_LOGGING_FLAGS // when defined will force logging flags to ALL |
2 |
using System; |
3 |
using System.Collections.Generic; |
4 |
using System.ComponentModel; |
5 |
using System.Data; |
6 |
using System.Drawing; |
7 |
using System.Linq; |
8 |
using System.Text; |
9 |
using System.Windows.Forms; |
10 |
using RomCheater.Logging; |
11 |
using RomCheater.Properties; |
12 |
using RomCheater.UserSettingsSupport; |
13 |
using RomCheater.PluginFramework.Core; |
14 |
using System.Diagnostics; |
15 |
using RomCheater.PluginFramework.Interfaces; |
16 |
|
17 |
namespace RomCheater |
18 |
{ |
19 |
public partial class Main : Form |
20 |
{ |
21 |
private bool log_window_expanded = false; |
22 |
private double log_window_splitter_default_position = 1.4045; |
23 |
PluginLoader loader = null; |
24 |
IConfigPlugin ConfigPlugin = null; |
25 |
IInputPlugin InputPlugin = null; |
26 |
IWindowPlugin WindowPlugin = null; |
27 |
static Main() |
28 |
{ |
29 |
SettingSubscriber.AddSubscriber(Settings.Default); |
30 |
} |
31 |
private const string t = "RomCheater"; |
32 |
#region LogWriterSupport |
33 |
static LogWriter _LoggerInstance; |
34 |
static LogWriter LoggerInstance |
35 |
{ |
36 |
get { return _LoggerInstance; } |
37 |
set { _LoggerInstance = value; } |
38 |
} |
39 |
#endregion |
40 |
|
41 |
|
42 |
public Main() : this(false) { } |
43 |
public Main(bool no_console_redirect) |
44 |
{ |
45 |
InitializeComponent(); |
46 |
load_loggerflags(); |
47 |
LoggerInstance = logwriter; |
48 |
LoggerInstance.CreateNewLog(false); |
49 |
logger.ForceLog.Info.WriteLine("LoggingFlags = 0x{0:x4} ({1})", logger.GetLoggingFlags().Value, logger.GetLoggingFlags().Name); |
50 |
load_plugins(); |
51 |
if (no_console_redirect) |
52 |
LoggerInstance.RedirectConsoleOutput = false; |
53 |
} |
54 |
private void load_loggerflags() |
55 |
{ |
56 |
logger.SetLoggingFlags(Logging.Properties.Settings.Default.LoggingFlags); |
57 |
#if FORCE_ALL_LOGGING_FLAGS |
58 |
logger.SetLoggingFlags(loggerflags.ALL); |
59 |
#endif |
60 |
} |
61 |
private void load_plugins() |
62 |
{ |
63 |
loader = new PluginLoader(); |
64 |
loader.LoadPlugins(); |
65 |
|
66 |
ConfigPlugin = loader.GetConfigPlugin(RomCheater.Properties.Settings.Default.LastConfigPlugin); |
67 |
if (ConfigPlugin != null) |
68 |
logger.Info.WriteLine("Loaded Config Plugin: {0}", ConfigPlugin.ToString()); |
69 |
InputPlugin = loader.GetInputPlugin(RomCheater.Properties.Settings.Default.LastInputPlugin); |
70 |
if (InputPlugin != null) |
71 |
logger.Info.WriteLine("Loaded Input Plugin: {0}", InputPlugin.ToString()); |
72 |
WindowPlugin = loader.GetWindowPlugin(RomCheater.Properties.Settings.Default.LastWindowPlugin); |
73 |
if (WindowPlugin != null) |
74 |
logger.Info.WriteLine("Loaded Window Plugin: {0}", WindowPlugin.ToString()); |
75 |
|
76 |
} |
77 |
|
78 |
private void mnuItemExit_Click(object sender, EventArgs e) |
79 |
{ |
80 |
this.Close(); |
81 |
} |
82 |
|
83 |
private void btnCopyLogToClipboard_Click(object sender, EventArgs e) |
84 |
{ |
85 |
|
86 |
} |
87 |
|
88 |
private void Main_Load(object sender, EventArgs e) |
89 |
{ |
90 |
} |
91 |
|
92 |
private void mnuItemConfig_Click(object sender, EventArgs e) |
93 |
{ |
94 |
RomCheaterConfigDialog dlg = new RomCheaterConfigDialog(loader); |
95 |
dlg.ShowDialog(); |
96 |
// reload plugins |
97 |
load_plugins(); |
98 |
} |
99 |
|
100 |
private void mnuItemOpenProcess_Click(object sender, EventArgs e) |
101 |
{ |
102 |
//List<Process> procs = ConfigPlugin.ValidProcessesForPlugin; |
103 |
PIDSelector selector = new PIDSelector(ConfigPlugin); |
104 |
selector.ShowDialog(); |
105 |
} |
106 |
|
107 |
private void btnExapandCollapseLogWindow_Click(object sender, EventArgs e) |
108 |
{ |
109 |
if (log_window_expanded) |
110 |
{ |
111 |
// collapse |
112 |
main_split.SplitterDistance = (int)((double)this.Height/ log_window_splitter_default_position); |
113 |
log_window_expanded = false; |
114 |
btnExapandCollapseLogWindow.Text = "expand"; |
115 |
} |
116 |
else |
117 |
{ |
118 |
// expand |
119 |
main_split.SplitterDistance = 0; |
120 |
btnExapandCollapseLogWindow.Text = "collapse"; |
121 |
log_window_expanded = true; |
122 |
} |
123 |
} |
124 |
} |
125 |
} |