From caeb34b96707457f9ef675f0f8b7d334cd34f8d3 Mon Sep 17 00:00:00 2001 From: KouKouChan <1010433454@qq.com> Date: Sun, 18 Sep 2022 12:56:06 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E7=AA=97=E5=8F=A3=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=85=A8=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarcraftHelper/showhpbar.cpp | 6 ++--- WarcraftHelper/widescreen.cpp | 42 +++++++++-------------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/WarcraftHelper/showhpbar.cpp b/WarcraftHelper/showhpbar.cpp index 0b9797d..8737c36 100644 --- a/WarcraftHelper/showhpbar.cpp +++ b/WarcraftHelper/showhpbar.cpp @@ -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); diff --git a/WarcraftHelper/widescreen.cpp b/WarcraftHelper/widescreen.cpp index 511b57b..22d0bf5 100644 --- a/WarcraftHelper/widescreen.cpp +++ b/WarcraftHelper/widescreen.cpp @@ -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) { @@ -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: