|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.ComponentModel; |
| 4 | +using System.Data; |
| 5 | +using System.Drawing; |
| 6 | +using System.Linq; |
| 7 | +using System.Text; |
| 8 | +using System.Threading.Tasks; |
| 9 | +using System.Windows.Forms; |
| 10 | +using System.Timers; |
| 11 | +using System.IO; |
| 12 | +using Timer = System.Timers.Timer; |
| 13 | + |
| 14 | +namespace WitcherDebug |
| 15 | +{ |
| 16 | + public partial class Form1 : Form |
| 17 | + { |
| 18 | + private Timer _findAppTimer; |
| 19 | + private XmlConfig _config; |
| 20 | + private bool _activated; |
| 21 | + private string _findingProcess = "Поиск процесса игры..."; |
| 22 | + |
| 23 | + public Form1() |
| 24 | + { |
| 25 | + InitializeComponent(); |
| 26 | + } |
| 27 | + |
| 28 | + private void Form1_Load(object sender, EventArgs e) |
| 29 | + { |
| 30 | + title.BackColor = Color.Transparent; |
| 31 | + title.ForeColor = Color.Gray; |
| 32 | + Selo.SetStyleRefl(title, ControlStyles.SupportsTransparentBackColor, true); |
| 33 | + activate.BackColor = Color.Transparent; |
| 34 | + activate.ForeColor = Color.White; |
| 35 | + Selo.SetStyleRefl(activate, ControlStyles.SupportsTransparentBackColor, true); |
| 36 | + label2.BackColor = Color.Transparent; |
| 37 | + label2.ForeColor = Color.White; |
| 38 | + Selo.SetStyleRefl(label2, ControlStyles.SupportsTransparentBackColor, true); |
| 39 | + label4.BackColor = Color.Transparent; |
| 40 | + label4.ForeColor = Color.White; |
| 41 | + Selo.SetStyleRefl(label4, ControlStyles.SupportsTransparentBackColor, true); |
| 42 | + findProc.BackColor = Color.Transparent; |
| 43 | + findProc.ForeColor = Color.White; |
| 44 | + Selo.SetStyleRefl(findProc, ControlStyles.SupportsTransparentBackColor, true); |
| 45 | + FormBorderStyle = FormBorderStyle.FixedSingle; |
| 46 | + activateDisableGUI.BackColor = Color.Transparent; |
| 47 | + activateDisableGUI.ForeColor = Color.White; |
| 48 | + Selo.SetStyleRefl(activateDisableGUI, ControlStyles.SupportsTransparentBackColor, true); |
| 49 | + activateFreeCamera.BackColor = Color.Transparent; |
| 50 | + activateFreeCamera.ForeColor = Color.White; |
| 51 | + Selo.SetStyleRefl(activateFreeCamera, ControlStyles.SupportsTransparentBackColor, true); |
| 52 | + |
| 53 | + _config = new XmlConfig(); |
| 54 | + if (File.Exists("config.xml")) |
| 55 | + _config = XmlParser.Parse<XmlConfig>(File.ReadAllText("config.xml")); |
| 56 | + |
| 57 | + switch (_config.Language) |
| 58 | + { |
| 59 | + case "en": |
| 60 | + title.Text = "The Witcher: Enhanced Edition Developer Console Activator"; |
| 61 | + activate.Text = "Activate"; |
| 62 | + activateFreeCamera.Text = "Free Camera"; |
| 63 | + activateDisableGUI.Text = "Disable GUI"; |
| 64 | + findProc.Text = _findingProcess = "Searching for the process..."; |
| 65 | + Text = "Developer Console Activator"; |
| 66 | + break; |
| 67 | + case "ru": |
| 68 | + break; |
| 69 | + } |
| 70 | + |
| 71 | + _findAppTimer = new Timer(_config.Interval); |
| 72 | + _findAppTimer.Elapsed += OnAppTimerElapsed; |
| 73 | + _findAppTimer.AutoReset = true; |
| 74 | + _findAppTimer.Enabled = true; |
| 75 | + findProc.Text = string.Empty; |
| 76 | + |
| 77 | + WDCActivator.Load(); |
| 78 | + if (WDCActivator.PId == 0 || WDCActivator.Mem.mProc.Process == null) |
| 79 | + { |
| 80 | + ResetButtons(); |
| 81 | + findProc.Text = _findingProcess; |
| 82 | + WDCActivator.IsLoaded = false; |
| 83 | + } |
| 84 | + } |
| 85 | + |
| 86 | + private void OnAppTimerElapsed(object sender, ElapsedEventArgs e) |
| 87 | + { |
| 88 | + WDCActivator.Load(); |
| 89 | + if (WDCActivator.PId == 0 || WDCActivator.Mem.mProc.Process == null) |
| 90 | + { |
| 91 | + findProc.Text = _findingProcess; |
| 92 | + ResetButtons(); |
| 93 | + _activated = false; |
| 94 | + WDCActivator.IsLoaded = false; |
| 95 | + } |
| 96 | + else |
| 97 | + { |
| 98 | + findProc.Text = string.Empty; |
| 99 | + EnableButtons(); |
| 100 | + if (_config.Auto && !_activated) |
| 101 | + { |
| 102 | + activate.Checked = true; |
| 103 | + AutoActivate(); |
| 104 | + _activated = true; |
| 105 | + } |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + private void activate_CheckedChanged(object sender, EventArgs e) |
| 110 | + { |
| 111 | + if (WDCActivator.PId == 0 || WDCActivator.Mem.mProc.Process == null) |
| 112 | + { |
| 113 | + ResetButtons(); |
| 114 | + findProc.Text = _findingProcess; |
| 115 | + _activated = false; |
| 116 | + WDCActivator.IsLoaded = false; |
| 117 | + return; |
| 118 | + } |
| 119 | + WDCActivator.Activate(activate.Checked ? "1" : "0"); |
| 120 | + } |
| 121 | + |
| 122 | + private async void AutoActivate() |
| 123 | + { |
| 124 | + await Task.Delay(3000); |
| 125 | + WDCActivator.Activate("1"); |
| 126 | + } |
| 127 | + |
| 128 | + private void activateFreeCamera_CheckedChanged(object sender, EventArgs e) |
| 129 | + { |
| 130 | + if (WDCActivator.PId == 0 || WDCActivator.Mem.mProc.Process == null) |
| 131 | + { |
| 132 | + ResetButtons(); |
| 133 | + findProc.Text = _findingProcess; |
| 134 | + _activated = false; |
| 135 | + WDCActivator.IsLoaded = false; |
| 136 | + return; |
| 137 | + } |
| 138 | + WDCActivator.ActivateFreeCamera(activateFreeCamera.Checked ? "1" : "0"); |
| 139 | + } |
| 140 | + |
| 141 | + private void disableGUI_CheckedChanged(object sender, EventArgs e) |
| 142 | + { |
| 143 | + if (WDCActivator.PId == 0 || WDCActivator.Mem.mProc.Process == null) |
| 144 | + { |
| 145 | + ResetButtons(); |
| 146 | + findProc.Text = _findingProcess; |
| 147 | + _activated = false; |
| 148 | + WDCActivator.IsLoaded = false; |
| 149 | + return; |
| 150 | + } |
| 151 | + WDCActivator.DisableGUI(activateDisableGUI.Checked ? "1" : "0"); |
| 152 | + } |
| 153 | + |
| 154 | + private void ResetButtons() |
| 155 | + { |
| 156 | + activate.Enabled = activate.Checked = false; |
| 157 | + activateFreeCamera.Enabled = activateFreeCamera.Checked = false; |
| 158 | + activateDisableGUI.Enabled = activateDisableGUI.Checked = false; |
| 159 | + } |
| 160 | + |
| 161 | + private void EnableButtons() => activate.Enabled = activateFreeCamera.Enabled = activateDisableGUI.Enabled = true; |
| 162 | + } |
| 163 | +} |
0 commit comments