summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--App2/App2.rc7
-rw-r--r--App2/Main.cpp147
-rw-r--r--App2/Version.h4
-rw-r--r--Installer/Installer.vdproj54
4 files changed, 64 insertions, 148 deletions
diff --git a/App2/App2.rc b/App2/App2.rc new file mode 100644 index 0000000..760bba0 --- /dev/null +++ b/App2/App2.rc
@@ -0,0 +1,7 @@
1#include "winres.h"
2#include "Version.h"
3
4VS_VERSION_INFO VERSIONINFO
5 FILEVERSION VERSION
6BEGIN
7END
diff --git a/App2/Main.cpp b/App2/Main.cpp index 30deff2..554aab5 100644 --- a/App2/Main.cpp +++ b/App2/Main.cpp
@@ -5,35 +5,12 @@
5#include "Memory.h" 5#include "Memory.h"
6#include "Random.h" 6#include "Random.h"
7#include "Randomizer.h" 7#include "Randomizer.h"
8#include "Randomizer2.h"
9#include "Panels_.h" 8#include "Panels_.h"
10 9
11#define HEARTBEAT 0x401 10#define HEARTBEAT 0x401
12#define RANDOMIZE_READY 0x402 11#define RANDOMIZE_READY 0x402
13#define RANDOMIZING 0403 12#define RANDOMIZING 0403
14#define RANDOMIZE_DONE 0x404
15#define RANDOMIZE_CHALLENGE_DONE 0x405 13#define RANDOMIZE_CHALLENGE_DONE 0x405
16#define CHALLENGE_ONLY 0x406
17#define DISABLE_SNIPES 0x407
18#define SPEED_UP_AUTOSCROLLERS 0x408
19
20/* ------- Temp ------- */
21#include "Solver.h"
22#include "PuzzleSerializer.h"
23#include <sstream>
24#include <iomanip>
25
26#define TMP1 0x501
27#define TMP2 0x502
28#define TMP3 0x503
29#define TMP4 0x504
30
31HWND g_panelId;
32Puzzle g_puzzle;
33
34HWND g_rngDebug;
35#define TMP5 0x505
36/* ------- Temp ------- */
37 14
38// Globals 15// Globals
39HWND g_hwnd; 16HWND g_hwnd;
@@ -42,7 +19,6 @@ HWND g_randomizerStatus;
42HINSTANCE g_hInstance; 19HINSTANCE g_hInstance;
43auto g_witnessProc = std::make_shared<Memory>(L"witness64_d3d11.exe"); 20auto g_witnessProc = std::make_shared<Memory>(L"witness64_d3d11.exe");
44std::shared_ptr<Randomizer> g_randomizer; 21std::shared_ptr<Randomizer> g_randomizer;
45std::shared_ptr<Randomizer2> g_randomizer2;
46void SetRandomSeed(); 22void SetRandomSeed();
47 23
48LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { 24LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
@@ -64,14 +40,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
64 // Shut down randomizer, wait for startup 40 // Shut down randomizer, wait for startup
65 if (g_randomizer) { 41 if (g_randomizer) {
66 g_randomizer = nullptr; 42 g_randomizer = nullptr;
67 g_randomizer2 = nullptr;
68 EnableWindow(g_randomizerStatus, FALSE); 43 EnableWindow(g_randomizerStatus, FALSE);
69 } 44 }
70 break; 45 break;
71 case ProcStatus::Running: 46 case ProcStatus::Running:
72 if (!g_randomizer) { 47 if (!g_randomizer) {
73 g_randomizer = std::make_shared<Randomizer>(g_witnessProc); 48 g_randomizer = std::make_shared<Randomizer>(g_witnessProc);
74 g_randomizer2 = std::make_shared<Randomizer2>(g_witnessProc);
75 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL); 49 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL);
76 } 50 }
77 break; 51 break;
@@ -83,11 +57,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
83 break; 57 break;
84 case RANDOMIZE_READY: 58 case RANDOMIZE_READY:
85 EnableWindow(g_randomizerStatus, TRUE); 59 EnableWindow(g_randomizerStatus, TRUE);
86 if (IsDlgButtonChecked(hwnd, CHALLENGE_ONLY)) { 60 SetWindowText(g_randomizerStatus, L"Randomize Challenge");
87 SetWindowText(g_randomizerStatus, L"Randomize Challenge");
88 } else {
89 SetWindowText(g_randomizerStatus, L"Randomize");
90 }
91 break; 61 break;
92 case RANDOMIZING: 62 case RANDOMIZING:
93 if (!g_randomizer) break; // E.g. an enter press at the wrong time 63 if (!g_randomizer) break; // E.g. an enter press at the wrong time
@@ -95,27 +65,11 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
95 65
96 SetRandomSeed(); 66 SetRandomSeed();
97 std::thread([]{ 67 std::thread([]{
98 if (IsDlgButtonChecked(g_hwnd, DISABLE_SNIPES)) { 68 SetWindowText(g_randomizerStatus, L"Randomizing Challenge...");
99 MEMORY_CATCH(g_randomizer->PreventSnipes()); 69 MEMORY_CATCH(g_randomizer->RandomizeChallenge());
100 } 70 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL);
101 if (IsDlgButtonChecked(g_hwnd, SPEED_UP_AUTOSCROLLERS)) {
102 MEMORY_CATCH(g_randomizer->AdjustSpeed());
103 }
104 if (IsDlgButtonChecked(g_hwnd, CHALLENGE_ONLY)) {
105 SetWindowText(g_randomizerStatus, L"Randomizing Challenge...");
106 MEMORY_CATCH(g_randomizer->RandomizeChallenge());
107 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL);
108 } else {
109 SetWindowText(g_randomizerStatus, L"Randomizing...");
110 MEMORY_CATCH(g_randomizer->Randomize());
111 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_DONE, NULL);
112 }
113 }).detach(); 71 }).detach();
114 break; 72 break;
115 case RANDOMIZE_DONE:
116 EnableWindow(g_randomizerStatus, FALSE);
117 SetWindowText(g_randomizerStatus, L"Randomized!");
118 break;
119 case RANDOMIZE_CHALLENGE_DONE: 73 case RANDOMIZE_CHALLENGE_DONE:
120 EnableWindow(g_randomizerStatus, FALSE); 74 EnableWindow(g_randomizerStatus, FALSE);
121 SetWindowText(g_randomizerStatus, L"Randomized Challenge!"); 75 SetWindowText(g_randomizerStatus, L"Randomized Challenge!");
@@ -125,80 +79,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
125 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL); 79 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL);
126 }).detach(); 80 }).detach();
127 break; 81 break;
128 case CHALLENGE_ONLY:
129 CheckDlgButton(hwnd, CHALLENGE_ONLY, !IsDlgButtonChecked(hwnd, CHALLENGE_ONLY));
130 if (IsWindowEnabled(g_randomizerStatus)) {
131 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL);
132 }
133 break;
134 case DISABLE_SNIPES:
135 CheckDlgButton(hwnd, DISABLE_SNIPES, !IsDlgButtonChecked(hwnd, DISABLE_SNIPES));
136 break;
137 case SPEED_UP_AUTOSCROLLERS:
138 CheckDlgButton(hwnd, SPEED_UP_AUTOSCROLLERS, !IsDlgButtonChecked(hwnd, SPEED_UP_AUTOSCROLLERS));
139 break;
140 case TMP1:
141 {
142 std::wstring text(128, L'\0');
143 int length = GetWindowText(g_panelId, text.data(), static_cast<int>(text.size()));
144 text.resize(length);
145 std::wstringstream s;
146 int panelId;
147 s << text;
148 s >> std::hex >> panelId;
149 g_puzzle = PuzzleSerializer(g_witnessProc).ReadPuzzle(panelId);
150 }
151 break;
152 case TMP2:
153 {
154 std::wstring text(128, L'\0');
155 int length = GetWindowText(g_panelId, text.data(), static_cast<int>(text.size()));
156 text.resize(length);
157 std::wstringstream s;
158 int panelId;
159 s << text;
160 s >> std::hex >> panelId;
161 PuzzleSerializer(g_witnessProc).WritePuzzle(g_puzzle, panelId);
162 }
163 break;
164 case TMP3:
165 {
166 for (auto [key, value] : PANELS) {
167 std::stringstream out;
168 std::string name(value);
169 out << " {'id': 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(5) << key << ", 'area':'";
170 int k;
171 for (k=0; name[k] != ' '; k++) out << name[k];
172 if (name[k+2] == ' ') {
173 out << name[k] << name[k+1];
174 k += 2;
175 }
176 out << "', 'name':'";
177 k++;
178 for (k; k < name.size(); k++) out << name[k];
179 out << "', 'data':'";
180 auto puzzle = PuzzleSerializer(g_witnessProc).ReadPuzzle(key);
181 out << puzzle.Serialize();
182 out << "'},\r\n";
183 DebugPrint(out.str());
184 }
185 }
186
187 // Solver::Solve(g_puzzle);
188 break;
189 case TMP4:
190 SetRandomSeed();
191 g_randomizer2->Randomize();
192 case TMP5:
193 {
194 std::wstring text;
195 for (int i=0; i<10; i++) {
196 Random::SetSeed(i);
197 int rng = Random::RandInt(0, 999999);
198 text += std::to_wstring(rng) + L"\n";
199 }
200 SetWindowText(g_rngDebug, text.c_str());
201 }
202 } 82 }
203 } 83 }
204 return DefWindowProc(hwnd, message, wParam, lParam); 84 return DefWindowProc(hwnd, message, wParam, lParam);
@@ -278,25 +158,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
278 PostMessage(g_seed, EM_SETEVENTMASK, 0, ENM_KEYEVENTS); 158 PostMessage(g_seed, EM_SETEVENTMASK, 0, ENM_KEYEVENTS);
279 g_randomizerStatus = CreateButton(120, 10, 180, L"Randomize", RANDOMIZING); 159 g_randomizerStatus = CreateButton(120, 10, 180, L"Randomize", RANDOMIZING);
280 EnableWindow(g_randomizerStatus, FALSE); 160 EnableWindow(g_randomizerStatus, FALSE);
281 CreateCheckbox(10, 300, CHALLENGE_ONLY);
282 CreateLabel(30, 300, 200, L"Randomize the challenge only");
283 CreateCheckbox(10, 320, DISABLE_SNIPES);
284 CheckDlgButton(g_hwnd, DISABLE_SNIPES, TRUE);
285 CreateLabel(30, 320, 240, L"Disable Swamp and Shadows snipes");
286 CreateCheckbox(10, 340, SPEED_UP_AUTOSCROLLERS);
287 CreateLabel(30, 340, 205, L"Speed up various autoscrollers");
288
289 // CreateButton(200, 50, 200, L"Test RNG", TMP5);
290 // g_rngDebug = CreateWindow(L"STATIC", L"",
291 // WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
292 // 200, 80, 200, 200, g_hwnd, NULL, g_hInstance, NULL);
293//#ifndef NDEBUG
294// g_panelId = CreateText(200, 100, 100, L"59");
295// CreateButton(200, 130, 100, L"Read", TMP1);
296// CreateButton(200, 160, 100, L"Write", TMP2);
297 CreateButton(200, 190, 100, L"Solve", TMP3);
298// CreateButton(200, 220, 100, L"Randomize2", TMP4);
299//#endif
300 161
301 g_witnessProc->StartHeartbeat(g_hwnd, HEARTBEAT); 162 g_witnessProc->StartHeartbeat(g_hwnd, HEARTBEAT);
302 163
diff --git a/App2/Version.h b/App2/Version.h index 0afb03f..87786c4 100644 --- a/App2/Version.h +++ b/App2/Version.h
@@ -10,5 +10,5 @@
10#define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH) 10#define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH)
11#define VERSION MAJOR, MINOR, PATCH 11#define VERSION MAJOR, MINOR, PATCH
12 12
13#define PRODUCT_NAME L"Witness Challenge Randomizer" 13#define PRODUCT_NAME L"Challenge Randomizer"
14#define WINDOW_CLASS L"WitnessChallengeRandomizer" 14#define WINDOW_CLASS L"ChallengeRandomizer"
diff --git a/Installer/Installer.vdproj b/Installer/Installer.vdproj index 61df575..0518a7b 100644 --- a/Installer/Installer.vdproj +++ b/Installer/Installer.vdproj
@@ -15,6 +15,12 @@
15 { 15 {
16 "Entry" 16 "Entry"
17 { 17 {
18 "MsmKey" = "8:_337D614C2826496689F0B32275720028"
19 "OwnerKey" = "8:_UNDEFINED"
20 "MsmSig" = "8:_UNDEFINED"
21 }
22 "Entry"
23 {
18 "MsmKey" = "8:_9D683AD9CFDD4F1E90EB22DB4509B5E4" 24 "MsmKey" = "8:_9D683AD9CFDD4F1E90EB22DB4509B5E4"
19 "OwnerKey" = "8:_UNDEFINED" 25 "OwnerKey" = "8:_UNDEFINED"
20 "MsmSig" = "8:_UNDEFINED" 26 "MsmSig" = "8:_UNDEFINED"
@@ -163,7 +169,7 @@
163 "Name" = "8:Microsoft Visual Studio" 169 "Name" = "8:Microsoft Visual Studio"
164 "ProductName" = "8:Witness Randomizer" 170 "ProductName" = "8:Witness Randomizer"
165 "ProductCode" = "8:{45A4772A-100E-4B94-B73A-F2F0C355D0F0}" 171 "ProductCode" = "8:{45A4772A-100E-4B94-B73A-F2F0C355D0F0}"
166 "PackageCode" = "8:{9D15D892-3C9C-4007-86A4-AA6BA2138CE9}" 172 "PackageCode" = "8:{7C07A624-B098-4E43-95DB-4B1F7FF3D8EC}"
167 "UpgradeCode" = "8:{4CB5496B-A47E-41D3-B4A7-677E29AB7513}" 173 "UpgradeCode" = "8:{4CB5496B-A47E-41D3-B4A7-677E29AB7513}"
168 "AspNetVersion" = "8:2.0.50727.0" 174 "AspNetVersion" = "8:2.0.50727.0"
169 "RestartWWWService" = "11:FALSE" 175 "RestartWWWService" = "11:FALSE"
@@ -283,6 +289,20 @@
283 } 289 }
284 "Shortcut" 290 "Shortcut"
285 { 291 {
292 "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_A0E6262ED2254331BB8D75147DF48C2F"
293 {
294 "Name" = "8:ChallengeRandomizer"
295 "Arguments" = "8:"
296 "Description" = "8:"
297 "ShowCmd" = "3:1"
298 "IconIndex" = "3:0"
299 "Transitive" = "11:FALSE"
300 "Target" = "8:_337D614C2826496689F0B32275720028"
301 "Folder" = "8:_F60DCEC4FEDB4941B597F30EB2903A5C"
302 "WorkingFolder" = "8:_CC86D8CA6D3943FAB5F6A91D54540360"
303 "Icon" = "8:"
304 "Feature" = "8:"
305 }
286 "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_ED6B4CE62E6A437CB3D6CA1CB759E6BD" 306 "{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_ED6B4CE62E6A437CB3D6CA1CB759E6BD"
287 { 307 {
288 "Name" = "8:WitnessRandomizer" 308 "Name" = "8:WitnessRandomizer"
@@ -696,12 +716,40 @@
696 } 716 }
697 "ProjectOutput" 717 "ProjectOutput"
698 { 718 {
719 "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_337D614C2826496689F0B32275720028"
720 {
721 "SourcePath" = "8:..\\x64\\Debug\\ChallengeRandomizer.exe"
722 "TargetName" = "8:"
723 "Tag" = "8:"
724 "Folder" = "8:_F60DCEC4FEDB4941B597F30EB2903A5C"
725 "Condition" = "8:"
726 "Transitive" = "11:FALSE"
727 "Vital" = "11:TRUE"
728 "ReadOnly" = "11:FALSE"
729 "Hidden" = "11:FALSE"
730 "System" = "11:FALSE"
731 "Permanent" = "11:FALSE"
732 "SharedLegacy" = "11:FALSE"
733 "PackageAs" = "3:1"
734 "Register" = "3:1"
735 "Exclude" = "11:FALSE"
736 "IsDependency" = "11:FALSE"
737 "IsolateTo" = "8:"
738 "ProjectOutputGroupRegister" = "3:1"
739 "OutputConfiguration" = "8:"
740 "OutputGroupCanonicalName" = "8:Built"
741 "OutputProjectGuid" = "8:{5A4E859A-9756-463E-86E6-6EADBBA23021}"
742 "ShowKeyOutput" = "11:TRUE"
743 "ExcludeFilters"
744 {
745 }
746 }
699 "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_9D683AD9CFDD4F1E90EB22DB4509B5E4" 747 "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_9D683AD9CFDD4F1E90EB22DB4509B5E4"
700 { 748 {
701 "SourcePath" = "8:..\\GithubPackage\\WitnessRandomizer.exe" 749 "SourcePath" = "8:..\\x64\\Debug\\WitnessRandomizer.exe"
702 "TargetName" = "8:" 750 "TargetName" = "8:"
703 "Tag" = "8:" 751 "Tag" = "8:"
704 "Folder" = "8:_CC86D8CA6D3943FAB5F6A91D54540360" 752 "Folder" = "8:_F60DCEC4FEDB4941B597F30EB2903A5C"
705 "Condition" = "8:" 753 "Condition" = "8:"
706 "Transitive" = "11:FALSE" 754 "Transitive" = "11:FALSE"
707 "Vital" = "11:TRUE" 755 "Vital" = "11:TRUE"