Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Spawner.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@
<ClCompile Include="$(ThisDir)\src\Spawner\Spawner.Hook.cpp" />
<ClCompile Include="$(ThisDir)\src\Spawner\Statistics.cpp" />
<!-- UI -->
<ClCompile Include="$(ThisDir)\src\UI\Dialogs.cpp" />
<ClCompile Include="$(ThisDir)\src\UI\Hooks.cpp" />
<ResourceCompile Include="$(ThisDir)\src\UI\MultiplayerGameOptionsDialog.rc" />
<ClCompile Include="$(ThisDir)\src\UI\Hooks.SaveButton.cpp" />
<!-- Utilities -->
<ClCompile Include="$(ThisDir)\src\Utilities\Debug.cpp" />
<ClCompile Include="$(ThisDir)\src\Utilities\Patch.cpp" />
Expand All @@ -96,7 +94,6 @@
<ClInclude Include="$(ThisDir)\src\Spawner\Spawner.Config.h" />
<ClInclude Include="$(ThisDir)\src\Spawner\Spawner.h" />
<!-- UI -->
<ClInclude Include="$(ThisDir)\src\UI\Dialogs.h" />
<!-- Utilities -->
<ClInclude Include="$(ThisDir)\src\Utilities\Debug.h" />
<ClInclude Include="$(ThisDir)\src\Utilities\DumperTypes.h" />
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
"NOINTERFACE",
"NOMINMAX",
"NOWINDOWCHANGES",
"NOZORDER",
"ntdll",
"ntfnce",
"NTRLMD",
Expand Down
15 changes: 8 additions & 7 deletions src/Spawner/Spawner.Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ void SpawnerConfig::LoadFromINIFile(CCINIClass* pINI)
}

{ // SaveGame Options
LoadSaveGame = pINI->ReadBool(pSettingsSection, "LoadSaveGame", LoadSaveGame);
/* SavedGameDir */ pINI->ReadString(pSettingsSection, "SavedGameDir", SavedGameDir, SavedGameDir, sizeof(SavedGameDir));
/* SaveGameName */ pINI->ReadString(pSettingsSection, "SaveGameName", SaveGameName, SaveGameName, sizeof(SaveGameName));
CustomMissionID = pINI->ReadInteger(pSettingsSection, "CustomMissionID", 0);
AutoSaveCount = pINI->ReadInteger(pSettingsSection, "AutoSaveCount", AutoSaveCount);
AutoSaveInterval = pINI->ReadInteger(pSettingsSection, "AutoSaveInterval", AutoSaveInterval);
NextAutoSaveNumber = pINI->ReadInteger(pSettingsSection, "NextAutoSaveNumber", NextAutoSaveNumber);
LoadSaveGame = pINI->ReadBool(pSettingsSection, "LoadSaveGame", LoadSaveGame);
/* SavedGameDir */ pINI->ReadString(pSettingsSection, "SavedGameDir", SavedGameDir, SavedGameDir, sizeof(SavedGameDir));
/* SaveGameName */ pINI->ReadString(pSettingsSection, "SaveGameName", SaveGameName, SaveGameName, sizeof(SaveGameName));
CustomMissionID = pINI->ReadInteger(pSettingsSection, "CustomMissionID", 0);
AutoSaveCount = pINI->ReadInteger(pSettingsSection, "AutoSaveCount", AutoSaveCount);
AutoSaveInterval = pINI->ReadInteger(pSettingsSection, "AutoSaveInterval", AutoSaveInterval);
NextAutoSaveNumber = pINI->ReadInteger(pSettingsSection, "NextAutoSaveNumber", NextAutoSaveNumber);
ShowMPSaveGameButton = pINI->ReadBool(pSettingsSection, "ShowMPSaveGameButton", ShowMPSaveGameButton);
}

{ // Scenario Options
Expand Down
2 changes: 2 additions & 0 deletions src/Spawner/Spawner.Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ class SpawnerConfig
int AutoSaveCount;
int AutoSaveInterval;
int NextAutoSaveNumber;
bool ShowMPSaveGameButton;

// Scenario Options
int Seed;
Expand Down Expand Up @@ -179,6 +180,7 @@ class SpawnerConfig
, AutoSaveCount { 5 }
, AutoSaveInterval { 7200 }
, NextAutoSaveNumber { 0 }
, ShowMPSaveGameButton { true }

// Scenario Options
, Seed { 0 }
Expand Down
100 changes: 0 additions & 100 deletions src/UI/Dialogs.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions src/UI/Dialogs.h

This file was deleted.

80 changes: 80 additions & 0 deletions src/UI/Hooks.SaveButton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#include <Spawner/Spawner.h>
#include <Utilities/Macro.h>
#include <Unsorted.h>
#include <windows.h>

enum GameOptionsControlID
{
SaveGameButton = 1311,
GameControlsButton = 1313,
AbortMissionButton = 1314
};

// Create the button before StandardWndProc registers and formats the controls.
DEFINE_HOOK(0x4F11D6, MultiplayerGameOptionsDialog_AddSaveButton, 0x6)
{
enum { MultiplayerGameOptionsDialog = 3002 };

if (!Spawner::Enabled || !Spawner::GetConfig()->ShowMPSaveGameButton)
return 0;

GET(UINT, message, EBX);
GET(HWND, hDialog, ESI);
GET(const WORD*, initData, EBP);

if (message != WM_INITDIALOG || !initData || *initData != MultiplayerGameOptionsDialog)
return 0;

const auto hExistingSave = Imports::GetDlgItem(hDialog, SaveGameButton);
if (hExistingSave)
return 0;

const auto hControls = Imports::GetDlgItem(hDialog, GameControlsButton);
const auto hAbort = Imports::GetDlgItem(hDialog, AbortMissionButton);
if (!hControls || !hAbort)
return 0;

RECT controlsRect;
RECT abortRect;
const auto hasControlsRect = Imports::GetWindowRect(hControls, &controlsRect);
const auto hasAbortRect = Imports::GetWindowRect(hAbort, &abortRect);
if (!hasControlsRect || !hasAbortRect)
return 0;

const int buttonStepY = abortRect.top - controlsRect.top;
MapWindowPoints(nullptr, hDialog, reinterpret_cast<POINT*>(&abortRect), 2);
const int width = abortRect.right - abortRect.left;
const int height = abortRect.bottom - abortRect.top;
const auto hInstance = reinterpret_cast<HINSTANCE>(Imports::GetWindowLongA(hDialog, GWL_HINSTANCE));
const auto hSave = Imports::CreateWindowExA(0, "BUTTON", "GUI:SaveGame",
WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,
abortRect.left, abortRect.top, width, height, hDialog,
reinterpret_cast<HMENU>(SaveGameButton), hInstance, nullptr);

if (!hSave)
return 0;

const auto font = Imports::SendMessageA(hAbort, WM_GETFONT, 0, 0);
Imports::SendMessageA(hSave, WM_SETFONT, font, FALSE);

// Place the save button after game controls in the child window order.
Imports::SetWindowPos(hSave, hControls, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
Imports::SetWindowPos(hAbort, nullptr, abortRect.left, abortRect.top + buttonStepY,
0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

return 0;
}

DEFINE_HOOK(0x609299, UI_IsStaticAndOrOwnerDraw_MultiplayerGameOptionsDialog, 0x5)
{
if (!Spawner::Enabled)
return 0;

enum { RetTrue = 0x609693 };
GET(int, dlgCtrlID, EAX);

if (dlgCtrlID == SaveGameButton)
return RetTrue;

return 0;
}
17 changes: 0 additions & 17 deletions src/UI/Hooks.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions src/UI/MultiplayerGameOptionsDialog.rc

This file was deleted.