Skip to content

Commit

Permalink
add: 窗口化自动全屏
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveBeforT committed Sep 18, 2022
1 parent 267615c commit caeb34b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
6 changes: 3 additions & 3 deletions WarcraftHelper/showhpbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ void ShowHPBar::Start(DWORD m_GamedllBase, Version m_War3Version) {
}


DWORD is_showfps = ReadDwordFromReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay", "healthbars");
WriteDwordToReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay", "healthbars", is_showfps);
if (!is_showfps) {
DWORD is_showhp = ReadDwordFromReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay", "healthbars");
WriteDwordToReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Gameplay", "healthbars", is_showhp);
if (!is_showhp) {
return;
}
this->thread = CreateThread(NULL, NULL, ShowBar, NULL, NULL, NULL);
Expand Down
42 changes: 11 additions & 31 deletions WarcraftHelper/widescreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,6 @@
bool WideScreen_Hooked = false;
HWND g_hWnd = NULL;

struct handle_data {
unsigned long process_id;
HWND best_handle;
};

BOOL IsMainWindow(HWND handle)
{
return GetWindow(handle, GW_OWNER) == (HWND)0 && IsWindowVisible(handle);
}

BOOL CALLBACK EnumWindowsCallback(HWND handle, LPARAM lParam)
{
handle_data& data = *(handle_data*)lParam;
unsigned long process_id = 0;
GetWindowThreadProcessId(handle, &process_id);
if (data.process_id != process_id || !IsMainWindow(handle)) {
return TRUE;
}
data.best_handle = handle;
return FALSE;
}

HWND FindMainWindow(unsigned long process_id)
{
handle_data data;
data.process_id = process_id;
data.best_handle = 0;
EnumWindows(EnumWindowsCallback, (LPARAM)&data);
return data.best_handle;
}

void(__fastcall* p_orgCreateMatrixPerspectiveFov) (uint32_t outMatrix, uint32_t unused, float fovY, float aspectRatio, float nearZ, float farZ) = 0;
void __fastcall CreateMatrixPerspectiveFov(uint32_t outMatrix, uint32_t unused, float fovY, float aspectRatio, float nearZ, float farZ)
{
Expand Down Expand Up @@ -86,6 +55,17 @@ void WideScreen::Start(DWORD m_GamedllBase, Version m_War3Version) {
MessageBoxA(0, "War3窗口获取失败", "WideScreen", 0);
return;
}
// 设置全屏
DWORD auto_fullscreem = ReadDwordFromReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Video", "autofullscreen");
WriteDwordToReg("SOFTWARE\\Blizzard Entertainment\\Warcraft III\\Video", "autofullscreen", auto_fullscreem);
if (auto_fullscreem) {
int w = GetSystemMetrics(SM_CXSCREEN);
int h = GetSystemMetrics(SM_CYSCREEN);
DWORD last_style = GetWindowLong(g_hWnd, GWL_STYLE);
SetWindowLongPtr(g_hWnd, GWL_STYLE, last_style ^ 0xCF0000);
SetWindowPos(g_hWnd, NULL, 0, 0, w, h, SWP_NOZORDER);
}
// 设置宽屏
DWORD offset = m_GamedllBase;
switch (m_War3Version) {
case Version::v120e:
Expand Down

0 comments on commit caeb34b

Please sign in to comment.