Skip to content

Commit

Permalink
Add -borderless command line argument (#21)
Browse files Browse the repository at this point in the history
If user passes `-borderless` to the game exe start with borderless mode enabled.
Steam Deck doesn't have a keyboard so it is helpful here.
#20
  • Loading branch information
chreden authored Jun 15, 2024
1 parent 49dd958 commit 0804956
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This is a custom d3d9.dll that enables more display modes for the three second e

### Switch display modes
1. Start the game
2. Press F5 to switch the mode
2. Press F5 to switch between bordered and borderless windowed mode.

### Toggle Always on Top
1. Start the game
Expand All @@ -26,6 +26,9 @@ This is a custom d3d9.dll that enables more display modes for the three second e

This can be useful if you want to interact with the TRAE Menu Hook.

### Command Line Arguments
Passing `-borderless` to the game exe will launch the game in borderless window mode (as if you had started the game and pressed the toggle button). This can be set via "Launch Options" in Steam.

## Information for developers
### Build
You need Visual Studio to compile the dll. Just import the ```trashim.sln``` project file. Before you start the build you have to change the active configuration to "Release" and "Win32" as target platform.
Expand Down
13 changes: 13 additions & 0 deletions trashim/TRAWindowed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <detours.h>
#include <windowsx.h>
#include <shellapi.h>
#include <algorithm>

namespace trashim
{
Expand Down Expand Up @@ -252,6 +254,13 @@ namespace trashim
}
return CallWindowProc(original_wndproc, window, msg, wParam, lParam);
}

bool should_start_borderless()
{
int number_of_arguments = 0;
const auto const args = CommandLineToArgvW(GetCommandLine(), &number_of_arguments);
return args != nullptr && std::any_of(args, args + number_of_arguments, [](auto str) { return wcsstr(str, L"-borderless") != nullptr; });
}
}

void initialise_shim(HWND window, uint32_t back_buffer_width, uint32_t back_buffer_height, uint32_t display_width, uint32_t display_height, bool vsync, uint32_t framerate)
Expand All @@ -261,6 +270,10 @@ namespace trashim
{
game_window = window;
SetWindowLongPtr(game_window, GWL_STYLE, windowed_style);
if (should_start_borderless())
{
toggle_border();
}
original_wndproc = (WNDPROC)SetWindowLongPtr(window, GWLP_WNDPROC, (LONG_PTR)subclass_wndproc);

// Only detour the first time.
Expand Down
10 changes: 5 additions & 5 deletions trashim/trashim.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,0,0
PRODUCTVERSION 1,4,0,0
FILEVERSION 1,5,0,0
PRODUCTVERSION 1,5,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "https://github.com/chreden/trawindowed"
VALUE "FileDescription", "Windowed DLL for TR LAU"
VALUE "FileVersion", "1.4.0.0"
VALUE "FileVersion", "1.5.0.0"
VALUE "InternalName", "d3d9.dll"
VALUE "LegalCopyright", "Copyright (C) 2022"
VALUE "LegalCopyright", "Copyright (C) 2024"
VALUE "OriginalFilename", "d3d9.dll"
VALUE "ProductName", "chreden/trawindowed"
VALUE "ProductVersion", "1.4.0.0"
VALUE "ProductVersion", "1.5.0.0"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 0804956

Please sign in to comment.