summary refs log tree commit diff stats
path: root/App
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-24 12:28:53 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-24 12:28:53 -0800
commit92084d06a5c87338cc988b5bc5868e617213e6b9 (patch)
tree314cbf8ee06821b9569a7b279bc39e2bf04abc87 /App
parent6059a1d1b99186a28bcd3c60822bc8310724bfd4 (diff)
downloadwitness-tutorializer-92084d06a5c87338cc988b5bc5868e617213e6b9.tar.gz
witness-tutorializer-92084d06a5c87338cc988b5bc5868e617213e6b9.tar.bz2
witness-tutorializer-92084d06a5c87338cc988b5bc5868e617213e6b9.zip
Try/catch, and select seed
Diffstat (limited to 'App')
-rw-r--r--App/Main.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/App/Main.cpp b/App/Main.cpp index edf0898..9e2757e 100644 --- a/App/Main.cpp +++ b/App/Main.cpp
@@ -12,7 +12,7 @@
12#include "Randomizer.h" 12#include "Randomizer.h"
13#include "Randomizer2.h" 13#include "Randomizer2.h"
14 14
15// Heartbeat is defined to 0x401 by Memory.h 15#define HEARTBEAT 0x401
16#define RANDOMIZE_READY 0x402 16#define RANDOMIZE_READY 0x402
17#define RANDOMIZING 0403 17#define RANDOMIZING 0403
18#define RANDOMIZE_DONE 0x404 18#define RANDOMIZE_DONE 0x404
@@ -100,18 +100,18 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
100 SetRandomSeed(); 100 SetRandomSeed();
101 std::thread([]{ 101 std::thread([]{
102 if (IsDlgButtonChecked(g_hwnd, DISABLE_SNIPES)) { 102 if (IsDlgButtonChecked(g_hwnd, DISABLE_SNIPES)) {
103 g_randomizer->PreventSnipes(); 103 MEMORY_CATCH(g_randomizer->PreventSnipes());
104 } 104 }
105 if (IsDlgButtonChecked(g_hwnd, SPEED_UP_AUTOSCROLLERS)) { 105 if (IsDlgButtonChecked(g_hwnd, SPEED_UP_AUTOSCROLLERS)) {
106 g_randomizer->AdjustSpeed(); 106 MEMORY_CATCH(g_randomizer->AdjustSpeed());
107 } 107 }
108 if (IsDlgButtonChecked(g_hwnd, CHALLENGE_ONLY)) { 108 if (IsDlgButtonChecked(g_hwnd, CHALLENGE_ONLY)) {
109 SetWindowText(g_randomizerStatus, L"Randomizing Challenge..."); 109 SetWindowText(g_randomizerStatus, L"Randomizing Challenge...");
110 g_randomizer->RandomizeChallenge(); 110 MEMORY_CATCH(g_randomizer->RandomizeChallenge());
111 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL); 111 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL);
112 } else { 112 } else {
113 SetWindowText(g_randomizerStatus, L"Randomizing..."); 113 SetWindowText(g_randomizerStatus, L"Randomizing...");
114 g_randomizer->Randomize(); 114 MEMORY_CATCH(g_randomizer->Randomize());
115 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_DONE, NULL); 115 PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_DONE, NULL);
116 } 116 }
117 }).detach(); 117 }).detach();
@@ -194,8 +194,13 @@ void SetRandomSeed() {
194 Random::SetSeed(_wtoi(text.c_str())); 194 Random::SetSeed(_wtoi(text.c_str()));
195 } else { // Random seed 195 } else { // Random seed
196 int seed = Random::RandInt(0, 999999); 196 int seed = Random::RandInt(0, 999999);
197 SetWindowText(g_seed, std::to_wstring(seed).c_str()); 197
198 RedrawWindow(g_seed, NULL, NULL, RDW_UPDATENOW); 198 text = std::to_wstring(seed);
199 SetWindowText(g_seed, text.c_str());
200 CHARRANGE range = {0, static_cast<long>(text.length())};
201 PostMessage(g_seed, EM_EXSETSEL, NULL, (LPARAM)&range);
202 SetFocus(g_seed);
203
199 Random::SetSeed(seed); 204 Random::SetSeed(seed);
200 } 205 }
201} 206}
@@ -275,7 +280,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
275 CreateButton(200, 220, 100, L"Randomize2", TMP4); 280 CreateButton(200, 220, 100, L"Randomize2", TMP4);
276#endif 281#endif
277 282
278 g_witnessProc->StartHeartbeat(g_hwnd); 283 g_witnessProc->StartHeartbeat(g_hwnd, HEARTBEAT);
279 284
280 ShowWindow(g_hwnd, nCmdShow); 285 ShowWindow(g_hwnd, nCmdShow);
281 UpdateWindow(g_hwnd); 286 UpdateWindow(g_hwnd);