diff options
author | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-06 09:19:21 -0800 |
---|---|---|
committer | jbzdarkid <jbzdarkid@gmail.com> | 2019-11-06 09:19:21 -0800 |
commit | 3a03f478e407f35bfafd192c22f82bc8c6e25a38 (patch) | |
tree | 0af1c7ec125b098d5cf3c0e19ccf03b511f6d5b9 /App/Main.cpp | |
parent | 66b2bc177853d33f4559eb240fbbca354b173fa2 (diff) | |
download | witness-tutorializer-3a03f478e407f35bfafd192c22f82bc8c6e25a38.tar.gz witness-tutorializer-3a03f478e407f35bfafd192c22f82bc8c6e25a38.tar.bz2 witness-tutorializer-3a03f478e407f35bfafd192c22f82bc8c6e25a38.zip |
And... it works?
Diffstat (limited to 'App/Main.cpp')
-rw-r--r-- | App/Main.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/App/Main.cpp b/App/Main.cpp index 89765fb..f8b7422 100644 --- a/App/Main.cpp +++ b/App/Main.cpp | |||
@@ -8,18 +8,8 @@ | |||
8 | #include <thread> | 8 | #include <thread> |
9 | 9 | ||
10 | #include "Memory.h" | 10 | #include "Memory.h" |
11 | #include <Random.h> | 11 | #include "Random.h" |
12 | class Randomizer { | 12 | #include "Randomizer.h" |
13 | public: | ||
14 | Randomizer(const std::shared_ptr<Memory>&) {} | ||
15 | void Randomize(int seed) { | ||
16 | std::this_thread::sleep_for(std::chrono::milliseconds(1000)); | ||
17 | } | ||
18 | |||
19 | void RandomizeChallenge(int seed) { | ||
20 | Randomize(seed); | ||
21 | } | ||
22 | }; | ||
23 | 13 | ||
24 | // Heartbeat is defined to 0x401 by Memory.h | 14 | // Heartbeat is defined to 0x401 by Memory.h |
25 | #define RANDOMIZE_READY 0x402 | 15 | #define RANDOMIZE_READY 0x402 |
@@ -45,7 +35,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |||
45 | switch ((ProcStatus)lParam) { | 35 | switch ((ProcStatus)lParam) { |
46 | case ProcStatus::NotRunning: | 36 | case ProcStatus::NotRunning: |
47 | // Shut down randomizer, wait for startup | 37 | // Shut down randomizer, wait for startup |
48 | if (g_randomizer) g_randomizer = nullptr; | 38 | if (g_randomizer) { |
39 | g_randomizer = nullptr; | ||
40 | EnableWindow(g_randomizerStatus, FALSE); | ||
41 | } | ||
49 | break; | 42 | break; |
50 | case ProcStatus::Running: | 43 | case ProcStatus::Running: |
51 | if (!g_randomizer) { | 44 | if (!g_randomizer) { |
@@ -85,14 +78,15 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |||
85 | SetWindowText(g_seed, std::to_wstring(seed).c_str()); | 78 | SetWindowText(g_seed, std::to_wstring(seed).c_str()); |
86 | RedrawWindow(g_seed, NULL, NULL, RDW_UPDATENOW); | 79 | RedrawWindow(g_seed, NULL, NULL, RDW_UPDATENOW); |
87 | } | 80 | } |
88 | std::thread([hwnd, seed]{ | 81 | Random::SetSeed(seed); |
82 | std::thread([hwnd]{ | ||
89 | if (IsDlgButtonChecked(hwnd, CHALLENGE_ONLY)) { | 83 | if (IsDlgButtonChecked(hwnd, CHALLENGE_ONLY)) { |
90 | SetWindowText(g_randomizerStatus, L"Randomizing Challenge..."); | 84 | SetWindowText(g_randomizerStatus, L"Randomizing Challenge..."); |
91 | g_randomizer->RandomizeChallenge(seed); | 85 | g_randomizer->RandomizeChallenge(); |
92 | PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL); | 86 | PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL); |
93 | } else { | 87 | } else { |
94 | SetWindowText(g_randomizerStatus, L"Randomizing..."); | 88 | SetWindowText(g_randomizerStatus, L"Randomizing..."); |
95 | g_randomizer->Randomize(seed); | 89 | g_randomizer->Randomize(); |
96 | PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_DONE, NULL); | 90 | PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_DONE, NULL); |
97 | } | 91 | } |
98 | }).detach(); | 92 | }).detach(); |