summary refs log tree commit diff stats
path: root/App/Main.cpp
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-11-19 09:27:29 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2018-11-19 09:27:29 -0800
commiteb420604814dfdfa37fd542dda9ba7477c198b39 (patch)
tree449794ffbdbe111e48ec7d5dc05fe563339d8f3a /App/Main.cpp
parent0d4ebf34bfb93dbb215f49e9ca64b58fd7284a2b (diff)
downloadwitness-tutorializer-eb420604814dfdfa37fd542dda9ba7477c198b39.tar.gz
witness-tutorializer-eb420604814dfdfa37fd542dda9ba7477c198b39.tar.bz2
witness-tutorializer-eb420604814dfdfa37fd542dda9ba7477c198b39.zip
Cleanup packaging story, add more settings
Diffstat (limited to 'App/Main.cpp')
-rw-r--r--App/Main.cpp63
1 files changed, 34 insertions, 29 deletions
diff --git a/App/Main.cpp b/App/Main.cpp index 7e802e9..82600bf 100644 --- a/App/Main.cpp +++ b/App/Main.cpp
@@ -18,8 +18,10 @@
18#define IDC_WRITE 0x407 18#define IDC_WRITE 0x407
19#define IDC_DUMP 0x408 19#define IDC_DUMP 0x408
20#define IDT_RANDOMIZED 0x409 20#define IDT_RANDOMIZED 0x409
21#define IDC_TOGGLELASERS 0x410
22#define IDC_TOGGLESNIPES 0x411
21 23
22HWND hwndSeed, hwndRandomize, hwndDebug; 24HWND hwndSeed, hwndRandomize;
23// int panel = 0x18AF; 25// int panel = 0x18AF;
24int panel = 0x33D4; 26int panel = 0x33D4;
25std::shared_ptr<Panel> _panel; 27std::shared_ptr<Panel> _panel;
@@ -38,13 +40,15 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
38 seedIsRNG = false; 40 seedIsRNG = false;
39 } 41 }
40 switch (LOWORD(wParam)) { 42 switch (LOWORD(wParam)) {
41 // Speed checkbox 43 // Checkboxes
42 case IDC_TOGGLESPEED: 44 case IDC_TOGGLESPEED:
43 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { 45 CheckDlgButton(hwnd, IDC_TOGGLESPEED, !IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED));
44 CheckDlgButton(hwnd, IDC_TOGGLESPEED, BST_UNCHECKED); 46 break;
45 } else { 47 case IDC_TOGGLELASERS:
46 CheckDlgButton(hwnd, IDC_TOGGLESPEED, BST_CHECKED); 48 CheckDlgButton(hwnd, IDC_TOGGLELASERS, !IsDlgButtonChecked(hwnd, IDC_TOGGLELASERS));
47 } 49 break;
50 case IDC_TOGGLESNIPES:
51 CheckDlgButton(hwnd, IDC_TOGGLESNIPES, !IsDlgButtonChecked(hwnd, IDC_TOGGLESNIPES));
48 break; 52 break;
49 53
50 // Randomize button 54 // Randomize button
@@ -70,30 +74,27 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
70 if (randomizer->GameIsRandomized()) break; 74 if (randomizer->GameIsRandomized()) break;
71 Random::SetSeed(seed); 75 Random::SetSeed(seed);
72 76
73 77 // Show seed and force redraw
74 std::wstringstream debug;
75
76 std::wstring seedString = std::to_wstring(seed); 78 std::wstring seedString = std::to_wstring(seed);
77 SetWindowText(hwndRandomize, L"Randomizing..."); 79 SetWindowText(hwndRandomize, L"Randomizing...");
78 SetWindowText(hwndSeed, seedString.c_str()); 80 SetWindowText(hwndSeed, seedString.c_str());
79 RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW); 81 RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW);
80 82
83 // Randomize, then apply settings
81 randomizer->Randomize(); 84 randomizer->Randomize();
82 debug << Random::RandInt(0, 1000) << " "; 85 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) randomizer->AdjustSpeed();
83 debug << Random::RandInt(0, 1000) << "\n"; 86 if (IsDlgButtonChecked(hwnd, IDC_TOGGLELASERS)) randomizer->RandomizeLasers();
84 debug << Random::RandInt(0, 1000) << " "; 87 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESNIPES)) randomizer->PreventSnipes();
85 debug << Random::RandInt(0, 1000); 88
86 SetWindowText(hwndDebug, debug.str().c_str()); 89 // Cleanup, and set timer for "randomization done"
87 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { 90 SetWindowText(hwndRandomize, L"Randomized!");
88 randomizer->AdjustSpeed();
89 }
90 SetWindowText(hwndRandomize, L"Randomized!");
91 SetTimer(hwnd, IDT_RANDOMIZED, 10000, NULL); 91 SetTimer(hwnd, IDT_RANDOMIZED, 10000, NULL);
92 break; 92 break;
93 } 93 }
94 94
95 case IDT_RANDOMIZED: 95 case IDT_RANDOMIZED:
96 SetWindowText(hwndRandomize, L"Randomize"); 96 SetWindowText(hwndRandomize, L"Randomize");
97 randomizer->GameIsRandomized(); // "Check" if the game is randomized to update the last known safe frame.
97 break; 98 break;
98 case IDC_READ: 99 case IDC_READ:
99 _panel = std::make_shared<Panel>(panel); 100 _panel = std::make_shared<Panel>(panel);
@@ -171,11 +172,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
171 10, 52, 12, 12, hwnd, (HMENU)IDC_TOGGLESPEED, hInstance, NULL); 172 10, 52, 12, 12, hwnd, (HMENU)IDC_TOGGLESPEED, hInstance, NULL);
172 CreateWindow(L"STATIC", L"Speed up various autoscrollers", 173 CreateWindow(L"STATIC", L"Speed up various autoscrollers",
173 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, 174 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
174 27, 50, 205, 16, hwnd, NULL, hInstance, NULL); 175 27, 50, 210, 16, hwnd, NULL, hInstance, NULL);
176
177 CreateWindow(L"BUTTON", L"",
178 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
179 10, 72, 12, 12, hwnd, (HMENU)IDC_TOGGLELASERS, hInstance, NULL);
180 CreateWindow(L"STATIC", L"Randomize laser activations",
181 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
182 27, 70, 210, 16, hwnd, NULL, hInstance, NULL);
175 183
176 hwndDebug = CreateWindow(L"STATIC", L"", 184 CreateWindow(L"BUTTON", L"",
185 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
186 10, 92, 12, 12, hwnd, (HMENU)IDC_TOGGLESNIPES, hInstance, NULL);
187 CheckDlgButton(hwnd, IDC_TOGGLESNIPES, TRUE);
188 CreateWindow(L"STATIC", L"Prevent sniping certain puzzles",
177 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, 189 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
178 200, 200, 100, 100, hwnd, NULL, hInstance, NULL); 190 27, 90, 210, 16, hwnd, NULL, hInstance, NULL);
179 191
180 /* 192 /*
181 CreateWindow(L"BUTTON", L"", 193 CreateWindow(L"BUTTON", L"",
@@ -206,13 +218,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
206 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, 218 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
207 27, 50, 205, 16, hwnd, NULL, hInstance, NULL); 219 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
208 220
209 CreateWindow(L"BUTTON", L"",
210 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
211 10, 52, 12, 12, hwnd, (HMENU)IDC_BANSNIPES, hInstance, NULL);
212 CreateWindow(L"STATIC", L"Prevent sniping certain puzzles",
213 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
214 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
215
216*/ 221*/
217 222
218 ShowWindow(hwnd, nCmdShow); 223 ShowWindow(hwnd, nCmdShow);