summary refs log tree commit diff stats
path: root/App
diff options
context:
space:
mode:
Diffstat (limited to 'App')
-rw-r--r--App/Main.cpp26
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"
12class Randomizer { 12#include "Randomizer.h"
13public:
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();