Skip to content

Commit

Permalink
wip: Hide window frame in windowed mode, disabled option for now
Browse files Browse the repository at this point in the history
  • Loading branch information
3vcloud committed Dec 14, 2024
1 parent ea726bb commit 80d28f7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
Binary file modified Dependencies/GWCA/bin/gwca.dll
Binary file not shown.
1 change: 0 additions & 1 deletion Dependencies/GWCA/include/GWCA/Context/GameplayContext.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <GWCA/GameContainers/Array.h>
#include <GWCA/Utilities/Export.h>

namespace GW {
Expand Down
1 change: 0 additions & 1 deletion Dependencies/GWCA/include/GWCA/Managers/SkillbarMgr.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <GWCA/GameContainers/Array.h>
#include <GWCA/Utilities/Hook.h>
#include <GWCA/Utilities/Export.h>

namespace GW {
Expand Down
1 change: 0 additions & 1 deletion Dependencies/GWCA/include/GWCA/Managers/TradeMgr.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <GWCA/Utilities/Export.h>
#include <GWCA/Utilities/Hook.h>

namespace GW {
struct Module;
Expand Down
4 changes: 1 addition & 3 deletions Dependencies/GWCA/include/GWCA/Managers/UIMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <GWCA/GameContainers/GamePos.h>
#include <GWCA/Managers/MerchantMgr.h>

#include "RenderMgr.h"

namespace GW {

struct Module;
Expand Down Expand Up @@ -1078,7 +1076,7 @@ namespace GW {
GWCA_API bool SetFrameLimit(uint32_t value);

//GWCA_API void SetPreference(Preference pref, uint32_t value);

GWCA_API bool SetFrameVisible(UI::Frame* frame, bool is_visible);

typedef HookCallback<uint32_t> KeyCallback;
// Listen for a gw hotkey press
Expand Down
Binary file modified Dependencies/GWCA/lib/gwca.lib
Binary file not shown.
44 changes: 42 additions & 2 deletions GWToolboxdll/Modules/GameSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ namespace {

bool automatically_flag_pet_to_fight_called_target = true;

bool remove_window_border_in_windowed_mode = false;

bool skip_fade_animations = false;
using FadeFrameContent_pt = void(__cdecl*)(uint32_t frame_id, float source_opacity, float target_opacity, float duration_seconds, uint32_t unk);
FadeFrameContent_pt FadeFrameContent_Func = nullptr, FadeFrameContent_Ret = nullptr;
Expand Down Expand Up @@ -1186,6 +1188,40 @@ namespace {
}
}

void CheckRemoveWindowBorder() {
// @TODO: When frame is removed, the game "expands" to fill the space, but the UI is still offset as if its factoring in the for title bar. Intercept SetWindowPos on the game side instead of doing this???
const auto pref = GW::UI::GetPreference(GW::UI::NumberPreference::ScreenBorderless);
Log::Log("Pref changed %d", pref);
if (remove_window_border_in_windowed_mode && pref == 0) {
const auto hwnd = GW::MemoryMgr::GetGWWindowHandle();
if (!hwnd) return;

auto remove_styles = (WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU);
auto lStyle = GetWindowLong(hwnd, GWL_STYLE);

if (!lStyle) return;
if ((lStyle & remove_styles) != 0) {
lStyle &= ~remove_styles;
SetWindowLong(hwnd, GWL_STYLE, lStyle);
}

remove_styles = (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
lStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
if ((lStyle & remove_styles) != 0) {
lStyle &= ~remove_styles;
//SetWindowLong(hwnd, GWL_EXSTYLE, lStyle);
}
//SetWindowLong(hwnd, GWL_EXSTYLE, lExStyle);

//SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER);

// Display close/restore/min buttons top right
GW::UI::SetFrameVisible(GW::UI::GetFrameByLabel(L"BtnMin"), true);
GW::UI::SetFrameVisible(GW::UI::GetFrameByLabel(L"BtnRestore"), true);
GW::UI::SetFrameVisible(GW::UI::GetFrameByLabel(L"BtnExit"), true);
}
}

GW::HookEntry OnPostUIMessage_HookEntry;
void OnPostUIMessage(GW::HookStatus* status, GW::UI::UIMessage message_id, void* wParam, void*) {
if (status->blocked)
Expand All @@ -1207,8 +1243,8 @@ namespace {
} break;
case GW::UI::UIMessage::kPreferenceValueChanged: {
const auto packet = (GW::UI::UIPacket::kPreferenceValueChanged*)wParam;
if (packet->preference_id == GW::UI::NumberPreference::TextLanguage)
FontLoader::LoadFonts(true);
if (packet->preference_id == GW::UI::NumberPreference::ScreenBorderless)
CheckRemoveWindowBorder();
} break;
case GW::UI::UIMessage::kPartyDefeated: {
if (auto_return_on_defeat && GW::PartyMgr::GetIsLeader() && !GW::PartyMgr::ReturnToOutpost())
Expand Down Expand Up @@ -1433,6 +1469,8 @@ void GameSettings::Initialize()
}
Log::Log("[GameSettings] ctrl_click_patch = %p\n", ctrl_click_patch.GetAddress());



SkillList_UICallback_Func = (GW::UI::UIInteractionCallback)GW::Scanner::ToFunctionStart(GW::Scanner::FindAssertion("GmCtlSkList.cpp", "!obj", 0xc71,0));
Log::Log("[GameSettings] SkillList_UICallback_Func = %p\n", SkillList_UICallback_Func);

Expand Down Expand Up @@ -1647,6 +1685,8 @@ void GameSettings::Initialize()

last_online_status = static_cast<uint32_t>(GW::FriendListMgr::GetMyStatus());

GW::GameThread::Enqueue(CheckRemoveWindowBorder);

#ifdef APRIL_FOOLS
AF::ApplyPatchesIfItsTime();
#endif
Expand Down

0 comments on commit 80d28f7

Please sign in to comment.