Skip to content

Commit

Permalink
hmmm
Browse files Browse the repository at this point in the history
  • Loading branch information
jbzdarkid committed Jan 18, 2021
1 parent e78c8a3 commit b8d472f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 148 deletions.
7 changes: 7 additions & 0 deletions App2/App2.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "winres.h"
#include "Version.h"

VS_VERSION_INFO VERSIONINFO
FILEVERSION VERSION
BEGIN
END
147 changes: 4 additions & 143 deletions App2/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,12 @@
#include "Memory.h"
#include "Random.h"
#include "Randomizer.h"
#include "Randomizer2.h"
#include "Panels_.h"

#define HEARTBEAT 0x401
#define RANDOMIZE_READY 0x402
#define RANDOMIZING 0403
#define RANDOMIZE_DONE 0x404
#define RANDOMIZE_CHALLENGE_DONE 0x405
#define CHALLENGE_ONLY 0x406
#define DISABLE_SNIPES 0x407
#define SPEED_UP_AUTOSCROLLERS 0x408

/* ------- Temp ------- */
#include "Solver.h"
#include "PuzzleSerializer.h"
#include <sstream>
#include <iomanip>

#define TMP1 0x501
#define TMP2 0x502
#define TMP3 0x503
#define TMP4 0x504

HWND g_panelId;
Puzzle g_puzzle;

HWND g_rngDebug;
#define TMP5 0x505
/* ------- Temp ------- */

// Globals
HWND g_hwnd;
Expand All @@ -42,7 +19,6 @@ HWND g_randomizerStatus;
HINSTANCE g_hInstance;
auto g_witnessProc = std::make_shared<Memory>(L"witness64_d3d11.exe");
std::shared_ptr<Randomizer> g_randomizer;
std::shared_ptr<Randomizer2> g_randomizer2;
void SetRandomSeed();

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
Expand All @@ -64,14 +40,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
// Shut down randomizer, wait for startup
if (g_randomizer) {
g_randomizer = nullptr;
g_randomizer2 = nullptr;
EnableWindow(g_randomizerStatus, FALSE);
}
break;
case ProcStatus::Running:
if (!g_randomizer) {
g_randomizer = std::make_shared<Randomizer>(g_witnessProc);
g_randomizer2 = std::make_shared<Randomizer2>(g_witnessProc);
PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL);
}
break;
Expand All @@ -83,39 +57,19 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
break;
case RANDOMIZE_READY:
EnableWindow(g_randomizerStatus, TRUE);
if (IsDlgButtonChecked(hwnd, CHALLENGE_ONLY)) {
SetWindowText(g_randomizerStatus, L"Randomize Challenge");
} else {
SetWindowText(g_randomizerStatus, L"Randomize");
}
SetWindowText(g_randomizerStatus, L"Randomize Challenge");
break;
case RANDOMIZING:
if (!g_randomizer) break; // E.g. an enter press at the wrong time
EnableWindow(g_randomizerStatus, FALSE);

SetRandomSeed();
std::thread([]{
if (IsDlgButtonChecked(g_hwnd, DISABLE_SNIPES)) {
MEMORY_CATCH(g_randomizer->PreventSnipes());
}
if (IsDlgButtonChecked(g_hwnd, SPEED_UP_AUTOSCROLLERS)) {
MEMORY_CATCH(g_randomizer->AdjustSpeed());
}
if (IsDlgButtonChecked(g_hwnd, CHALLENGE_ONLY)) {
SetWindowText(g_randomizerStatus, L"Randomizing Challenge...");
MEMORY_CATCH(g_randomizer->RandomizeChallenge());
PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL);
} else {
SetWindowText(g_randomizerStatus, L"Randomizing...");
MEMORY_CATCH(g_randomizer->Randomize());
PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_DONE, NULL);
}
SetWindowText(g_randomizerStatus, L"Randomizing Challenge...");
MEMORY_CATCH(g_randomizer->RandomizeChallenge());
PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_CHALLENGE_DONE, NULL);
}).detach();
break;
case RANDOMIZE_DONE:
EnableWindow(g_randomizerStatus, FALSE);
SetWindowText(g_randomizerStatus, L"Randomized!");
break;
case RANDOMIZE_CHALLENGE_DONE:
EnableWindow(g_randomizerStatus, FALSE);
SetWindowText(g_randomizerStatus, L"Randomized Challenge!");
Expand All @@ -125,80 +79,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL);
}).detach();
break;
case CHALLENGE_ONLY:
CheckDlgButton(hwnd, CHALLENGE_ONLY, !IsDlgButtonChecked(hwnd, CHALLENGE_ONLY));
if (IsWindowEnabled(g_randomizerStatus)) {
PostMessage(g_hwnd, WM_COMMAND, RANDOMIZE_READY, NULL);
}
break;
case DISABLE_SNIPES:
CheckDlgButton(hwnd, DISABLE_SNIPES, !IsDlgButtonChecked(hwnd, DISABLE_SNIPES));
break;
case SPEED_UP_AUTOSCROLLERS:
CheckDlgButton(hwnd, SPEED_UP_AUTOSCROLLERS, !IsDlgButtonChecked(hwnd, SPEED_UP_AUTOSCROLLERS));
break;
case TMP1:
{
std::wstring text(128, L'\0');
int length = GetWindowText(g_panelId, text.data(), static_cast<int>(text.size()));
text.resize(length);
std::wstringstream s;
int panelId;
s << text;
s >> std::hex >> panelId;
g_puzzle = PuzzleSerializer(g_witnessProc).ReadPuzzle(panelId);
}
break;
case TMP2:
{
std::wstring text(128, L'\0');
int length = GetWindowText(g_panelId, text.data(), static_cast<int>(text.size()));
text.resize(length);
std::wstringstream s;
int panelId;
s << text;
s >> std::hex >> panelId;
PuzzleSerializer(g_witnessProc).WritePuzzle(g_puzzle, panelId);
}
break;
case TMP3:
{
for (auto [key, value] : PANELS) {
std::stringstream out;
std::string name(value);
out << " {'id': 0x" << std::hex << std::uppercase << std::setfill('0') << std::setw(5) << key << ", 'area':'";
int k;
for (k=0; name[k] != ' '; k++) out << name[k];
if (name[k+2] == ' ') {
out << name[k] << name[k+1];
k += 2;
}
out << "', 'name':'";
k++;
for (k; k < name.size(); k++) out << name[k];
out << "', 'data':'";
auto puzzle = PuzzleSerializer(g_witnessProc).ReadPuzzle(key);
out << puzzle.Serialize();
out << "'},\r\n";
DebugPrint(out.str());
}
}

// Solver::Solve(g_puzzle);
break;
case TMP4:
SetRandomSeed();
g_randomizer2->Randomize();
case TMP5:
{
std::wstring text;
for (int i=0; i<10; i++) {
Random::SetSeed(i);
int rng = Random::RandInt(0, 999999);
text += std::to_wstring(rng) + L"\n";
}
SetWindowText(g_rngDebug, text.c_str());
}
}
}
return DefWindowProc(hwnd, message, wParam, lParam);
Expand Down Expand Up @@ -278,25 +158,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance
PostMessage(g_seed, EM_SETEVENTMASK, 0, ENM_KEYEVENTS);
g_randomizerStatus = CreateButton(120, 10, 180, L"Randomize", RANDOMIZING);
EnableWindow(g_randomizerStatus, FALSE);
CreateCheckbox(10, 300, CHALLENGE_ONLY);
CreateLabel(30, 300, 200, L"Randomize the challenge only");
CreateCheckbox(10, 320, DISABLE_SNIPES);
CheckDlgButton(g_hwnd, DISABLE_SNIPES, TRUE);
CreateLabel(30, 320, 240, L"Disable Swamp and Shadows snipes");
CreateCheckbox(10, 340, SPEED_UP_AUTOSCROLLERS);
CreateLabel(30, 340, 205, L"Speed up various autoscrollers");

// CreateButton(200, 50, 200, L"Test RNG", TMP5);
// g_rngDebug = CreateWindow(L"STATIC", L"",
// WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT,
// 200, 80, 200, 200, g_hwnd, NULL, g_hInstance, NULL);
//#ifndef NDEBUG
// g_panelId = CreateText(200, 100, 100, L"59");
// CreateButton(200, 130, 100, L"Read", TMP1);
// CreateButton(200, 160, 100, L"Write", TMP2);
CreateButton(200, 190, 100, L"Solve", TMP3);
// CreateButton(200, 220, 100, L"Randomize2", TMP4);
//#endif

g_witnessProc->StartHeartbeat(g_hwnd, HEARTBEAT);

Expand Down
4 changes: 2 additions & 2 deletions App2/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
#define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH)
#define VERSION MAJOR, MINOR, PATCH

#define PRODUCT_NAME L"Witness Challenge Randomizer"
#define WINDOW_CLASS L"WitnessChallengeRandomizer"
#define PRODUCT_NAME L"Challenge Randomizer"
#define WINDOW_CLASS L"ChallengeRandomizer"
54 changes: 51 additions & 3 deletions Installer/Installer.vdproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
"SccProvider" = "8:"
"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_337D614C2826496689F0B32275720028"
"OwnerKey" = "8:_UNDEFINED"
"MsmSig" = "8:_UNDEFINED"
}
"Entry"
{
"MsmKey" = "8:_9D683AD9CFDD4F1E90EB22DB4509B5E4"
Expand Down Expand Up @@ -163,7 +169,7 @@
"Name" = "8:Microsoft Visual Studio"
"ProductName" = "8:Witness Randomizer"
"ProductCode" = "8:{45A4772A-100E-4B94-B73A-F2F0C355D0F0}"
"PackageCode" = "8:{9D15D892-3C9C-4007-86A4-AA6BA2138CE9}"
"PackageCode" = "8:{7C07A624-B098-4E43-95DB-4B1F7FF3D8EC}"
"UpgradeCode" = "8:{4CB5496B-A47E-41D3-B4A7-677E29AB7513}"
"AspNetVersion" = "8:2.0.50727.0"
"RestartWWWService" = "11:FALSE"
Expand Down Expand Up @@ -283,6 +289,20 @@
}
"Shortcut"
{
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_A0E6262ED2254331BB8D75147DF48C2F"
{
"Name" = "8:ChallengeRandomizer"
"Arguments" = "8:"
"Description" = "8:"
"ShowCmd" = "3:1"
"IconIndex" = "3:0"
"Transitive" = "11:FALSE"
"Target" = "8:_337D614C2826496689F0B32275720028"
"Folder" = "8:_F60DCEC4FEDB4941B597F30EB2903A5C"
"WorkingFolder" = "8:_CC86D8CA6D3943FAB5F6A91D54540360"
"Icon" = "8:"
"Feature" = "8:"
}
"{970C0BB2-C7D0-45D7-ABFA-7EC378858BC0}:_ED6B4CE62E6A437CB3D6CA1CB759E6BD"
{
"Name" = "8:WitnessRandomizer"
Expand Down Expand Up @@ -696,12 +716,40 @@
}
"ProjectOutput"
{
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_337D614C2826496689F0B32275720028"
{
"SourcePath" = "8:..\\x64\\Debug\\ChallengeRandomizer.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_F60DCEC4FEDB4941B597F30EB2903A5C"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:FALSE"
"IsolateTo" = "8:"
"ProjectOutputGroupRegister" = "3:1"
"OutputConfiguration" = "8:"
"OutputGroupCanonicalName" = "8:Built"
"OutputProjectGuid" = "8:{5A4E859A-9756-463E-86E6-6EADBBA23021}"
"ShowKeyOutput" = "11:TRUE"
"ExcludeFilters"
{
}
}
"{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_9D683AD9CFDD4F1E90EB22DB4509B5E4"
{
"SourcePath" = "8:..\\GithubPackage\\WitnessRandomizer.exe"
"SourcePath" = "8:..\\x64\\Debug\\WitnessRandomizer.exe"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_CC86D8CA6D3943FAB5F6A91D54540360"
"Folder" = "8:_F60DCEC4FEDB4941B597F30EB2903A5C"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
Expand Down

0 comments on commit b8d472f

Please sign in to comment.