about summary refs log tree commit diff stats
path: root/Source/Main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Main.cpp')
-rw-r--r--Source/Main.cpp193
1 files changed, 0 insertions, 193 deletions
diff --git a/Source/Main.cpp b/Source/Main.cpp deleted file mode 100644 index ce0e550..0000000 --- a/Source/Main.cpp +++ /dev/null
@@ -1,193 +0,0 @@
1#include "windows.h"
2#include <Richedit.h>
3
4#include <string>
5
6#include "Randomizer.h"
7#include "Version.h"
8#include "Random.h"
9#include "Panel.h"
10
11#define IDC_RANDOMIZE 0x401
12#define IDC_TOGGLESPEED 0x402
13#define IDC_SPEEDRUNNER 0x403
14#define IDC_HARDMODE 0x404
15#define IDC_READ 0x405
16#define IDC_RANDOM 0x406
17#define IDC_WRITE 0x407
18#define IDC_DUMP 0x408
19
20HWND hwndSeed, hwndRandomize;
21// int panel = 0x18AF;
22int panel = 0x33D4;
23std::shared_ptr<Panel> _panel;
24
25LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
26{
27 static bool wasSeedRandomlyGenerated;
28
29 if (message == WM_DESTROY) {
30 PostQuitMessage(0);
31 } else if (message == WM_COMMAND) {
32 switch (LOWORD(wParam)) {
33 // Speed checkbox
34 case IDC_TOGGLESPEED:
35 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) {
36 CheckDlgButton(hwnd, IDC_TOGGLESPEED, BST_UNCHECKED);
37 } else {
38 CheckDlgButton(hwnd, IDC_TOGGLESPEED, BST_CHECKED);
39 }
40 break;
41
42 // Randomize button
43 case IDC_RANDOMIZE:
44 {
45 std::wstring text(100, '\0');
46 GetWindowText(hwndSeed, &text[0], 100);
47 int seed = 0;
48 if (wasSeedRandomlyGenerated || wcslen(text.c_str()) == 0) {
49 seed = Random::RandInt(0, 100000);
50 wasSeedRandomlyGenerated = true;
51 } else {
52 seed = _wtoi(text.c_str());
53 wasSeedRandomlyGenerated = false;
54 }
55
56 Randomizer randomizer;
57 short metadata = randomizer.Randomize(seed);
58 if (metadata & 0x1) break; // Was already randomized
59
60 std::wstring seedString = std::to_wstring(seed);
61 SetWindowText(hwndSeed, seedString.c_str());
62 if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) {
63 randomizer.AdjustSpeed();
64 }
65 SetWindowText(hwndRandomize, L"Randomized!");
66 break;
67 }
68 case IDC_READ:
69 _panel = std::make_shared<Panel>(panel);
70 break;
71 case IDC_RANDOM:
72 _panel->Random();
73 break;
74 case IDC_WRITE:
75 _panel->Write(panel);
76 break;
77 case IDC_DUMP:
78 _panel->Serialize();
79 break;
80 }
81 }
82 return DefWindowProc(hwnd, message, wParam, lParam);
83}
84
85int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
86{
87 LoadLibrary(L"Msftedit.dll");
88
89 WNDCLASSW wndClass = {
90 CS_HREDRAW | CS_VREDRAW,
91 WndProc,
92 0,
93 0,
94 hInstance,
95 NULL,
96 LoadCursor(nullptr, IDC_ARROW),
97 (HBRUSH)(COLOR_WINDOW+1),
98 WINDOW_CLASS,
99 WINDOW_CLASS,
100 };
101 RegisterClassW(&wndClass);
102
103 RECT rect;
104 GetClientRect(GetDesktopWindow(), &rect);
105 HWND hwnd = CreateWindow(WINDOW_CLASS, PRODUCT_NAME, WS_OVERLAPPEDWINDOW,
106 rect.right - 550, 200, 500, 500, nullptr, nullptr, hInstance, nullptr);
107
108 CreateWindow(L"STATIC", L"Version: " VERSION_STR,
109 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
110 390, 15, 90, 16, hwnd, NULL, hInstance, NULL);
111
112 CreateWindow(L"STATIC", L"Enter a seed:",
113 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
114 10, 15, 90, 16, hwnd, NULL, hInstance, NULL);
115 hwndSeed = CreateWindow(MSFTEDIT_CLASS, L"",
116 WS_TABSTOP | WS_VISIBLE | WS_CHILD | WS_BORDER,
117 100, 10, 50, 26, hwnd, NULL, hInstance, NULL);
118 hwndRandomize = CreateWindow(L"BUTTON", L"Randomize",
119 WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
120 160, 10, 100, 26, hwnd, (HMENU)IDC_RANDOMIZE, hInstance, NULL);
121
122#if GLOBALS == 0x5B28C0
123 CreateWindow(L"BUTTON", L"READ",
124 WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
125 160, 100, 100, 26, hwnd, (HMENU)IDC_READ, hInstance, NULL);
126 CreateWindow(L"BUTTON", L"RANDOM",
127 WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
128 160, 130, 100, 26, hwnd, (HMENU)IDC_RANDOM, hInstance, NULL);
129 CreateWindow(L"BUTTON", L"WRITE",
130 WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
131 160, 160, 100, 26, hwnd, (HMENU)IDC_WRITE, hInstance, NULL);
132 CreateWindow(L"BUTTON", L"DUMP",
133 WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
134 160, 190, 100, 26, hwnd, (HMENU)IDC_DUMP, hInstance, NULL);
135#endif
136
137 CreateWindow(L"BUTTON", L"",
138 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
139 10, 52, 12, 12, hwnd, (HMENU)IDC_TOGGLESPEED, hInstance, NULL);
140 CreateWindow(L"STATIC", L"Speed up various autoscrollers",
141 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
142 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
143
144 /*
145 CreateWindow(L"BUTTON", L"",
146 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
147 10, 52, 12, 12, hwnd, (HMENU)IDC_SPEEDRUNNER, hInstance, NULL);
148 CreateWindow(L"STATIC", L"Allow hard-to-identify panels to be shuffled",
149 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
150 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
151
152 CreateWindow(L"BUTTON", L"",
153 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
154 10, 52, 12, 12, hwnd, (HMENU)IDC_HARDMODE, hInstance, NULL);
155 CreateWindow(L"STATIC", L"Place harder puzzles in annoying spots",
156 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
157 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
158
159 CreateWindow(L"BUTTON", L"",
160 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
161 10, 52, 12, 12, hwnd, (HMENU)IDC_NORANDOMIZE, hInstance, NULL);
162 CreateWindow(L"STATIC", L"Do not randomize any puzzles",
163 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
164 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
165
166 CreateWindow(L"BUTTON", L"",
167 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
168 10, 52, 12, 12, hwnd, (HMENU)IDC_CASUAL, hInstance, NULL);
169 CreateWindow(L"STATIC", L"Don't randomize context-based puzzles",
170 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
171 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
172
173 CreateWindow(L"BUTTON", L"",
174 WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
175 10, 52, 12, 12, hwnd, (HMENU)IDC_BANSNIPES, hInstance, NULL);
176 CreateWindow(L"STATIC", L"Prevent sniping certain puzzles",
177 WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
178 27, 50, 205, 16, hwnd, NULL, hInstance, NULL);
179
180*/
181
182 ShowWindow(hwnd, nCmdShow);
183 UpdateWindow(hwnd);
184
185 MSG msg;
186 while (!GetMessage(&msg, nullptr, 0, 0) == 0)
187 {
188 TranslateMessage(&msg);
189 DispatchMessage(&msg);
190 }
191
192 return (int) msg.wParam;
193}