diff options
Diffstat (limited to 'Source/Main.cpp')
-rw-r--r-- | Source/Main.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/Source/Main.cpp b/Source/Main.cpp index e6b149f..28bc472 100644 --- a/Source/Main.cpp +++ b/Source/Main.cpp | |||
@@ -1,10 +1,13 @@ | |||
1 | #include "windows.h" | ||
1 | #include "resource.h" | 2 | #include "resource.h" |
2 | #include <Richedit.h> | 3 | #include <Richedit.h> |
4 | |||
3 | #include <ctime> | 5 | #include <ctime> |
4 | #include <string> | 6 | #include <string> |
7 | |||
5 | #include "Randomizer.h" | 8 | #include "Randomizer.h" |
6 | #include "windows.h" | ||
7 | #include "Version.h" | 9 | #include "Version.h" |
10 | #include "Random.h" | ||
8 | 11 | ||
9 | #define IDC_RANDOMIZE 0x401 | 12 | #define IDC_RANDOMIZE 0x401 |
10 | #define IDC_TOGGLESPEED 0x402 | 13 | #define IDC_TOGGLESPEED 0x402 |
@@ -37,9 +40,8 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |||
37 | GetWindowText(hwndSeed, &text[0], 100); | 40 | GetWindowText(hwndSeed, &text[0], 100); |
38 | int seed = 0; | 41 | int seed = 0; |
39 | if (wasSeedRandomlyGenerated || wcslen(text.c_str()) == 0) { | 42 | if (wasSeedRandomlyGenerated || wcslen(text.c_str()) == 0) { |
40 | srand(static_cast<unsigned int>(time(nullptr))); // Seed from the time in milliseconds | 43 | Random::SetSeed(time(nullptr)); // Seed from the time in milliseconds |
41 | rand(); // Increment RNG so that RNG isn't still using the time | 44 | seed = Random::RandInt(0, 100000); |
42 | seed = rand() % 100000; | ||
43 | std::wstring seedString = std::to_wstring(seed); | 45 | std::wstring seedString = std::to_wstring(seed); |
44 | SetWindowText(hwndSeed, seedString.c_str()); | 46 | SetWindowText(hwndSeed, seedString.c_str()); |
45 | wasSeedRandomlyGenerated = true; | 47 | wasSeedRandomlyGenerated = true; |
@@ -47,7 +49,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |||
47 | seed = _wtoi(text.c_str()); | 49 | seed = _wtoi(text.c_str()); |
48 | wasSeedRandomlyGenerated = false; | 50 | wasSeedRandomlyGenerated = false; |
49 | } | 51 | } |
50 | srand(seed); | 52 | Random::SetSeed(seed); |
51 | Randomizer randomizer; | 53 | Randomizer randomizer; |
52 | randomizer.Randomize(); | 54 | randomizer.Randomize(); |
53 | if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { | 55 | if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { |
@@ -79,8 +81,10 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd | |||
79 | }; | 81 | }; |
80 | RegisterClassW(&wndClass); | 82 | RegisterClassW(&wndClass); |
81 | 83 | ||
84 | RECT rect; | ||
85 | GetClientRect(GetDesktopWindow(), &rect); | ||
82 | HWND hwnd = CreateWindow(WINDOW_CLASS, PRODUCT_NAME, WS_OVERLAPPEDWINDOW, | 86 | HWND hwnd = CreateWindow(WINDOW_CLASS, PRODUCT_NAME, WS_OVERLAPPEDWINDOW, |
83 | 400, 200, 500, 500, nullptr, nullptr, hInstance, nullptr); | 87 | rect.right - 550, 200, 500, 500, nullptr, nullptr, hInstance, nullptr); |
84 | 88 | ||
85 | CreateWindow(L"STATIC", L"Version: " VERSION_STR, | 89 | CreateWindow(L"STATIC", L"Version: " VERSION_STR, |
86 | WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, | 90 | WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, |