summary refs log tree commit diff stats
path: root/App2
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2021-01-17 16:24:25 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2021-01-17 16:24:25 -0800
commitb8d472ff024ad5b13dfe0c33ae10d5fdf8a2c4cc (patch)
tree42912fe40ac3c84f57774e5adc83440615fea1f7 /App2
parente78c8a3236a071cb6bd156f985b26bb085ee7fe3 (diff)
downloadwitness-tutorializer-b8d472ff024ad5b13dfe0c33ae10d5fdf8a2c4cc.tar.gz
witness-tutorializer-b8d472ff024ad5b13dfe0c33ae10d5fdf8a2c4cc.tar.bz2
witness-tutorializer-b8d472ff024ad5b13dfe0c33ae10d5fdf8a2c4cc.zip
hmmm
Diffstat (limited to 'App2')
-rw-r--r--App2/App2.rc7
-rw-r--r--App2/Main.cpp147
-rw-r--r--App2/Version.h4
3 files changed, 13 insertions, 145 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"