Skip to content

Commit

Permalink
Add all files to repo
Browse files Browse the repository at this point in the history
  • Loading branch information
shatyuka committed Aug 20, 2021
1 parent 3a2dc42 commit ab6ac07
Show file tree
Hide file tree
Showing 23 changed files with 308 additions and 7 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
# PAYDAY2 Borderless Windowed Updated

This is an updated plugin to enable the fullscreen/borderless windowed feature of PAYDAY 2.
This is an updated [SuperBLT](https://superblt.znix.xyz/) native plugin to enable the fullscreen/borderless windowed feature of PAYDAY 2.

This plugin adds a new display mode called "Fullscreen Windowed", while the original windowed mode is also retained.

![Preview](https://modworkshop.net/mydownloads/previews/71629_1591175170_a641ddd30ca272bac8e75b9570073493.png)

## Installation

Simply extract the zip archive to "PAYDAY 2\mods".
- Before installing this mod, you should have [SuperBLT](https://superblt.znix.xyz/) installed first.
- Download and simply extract the zip archive to "PAYDAY 2\mods".

## Translations

This plugin provides every languages that of PAYDAY 2.

If you find something inappropriate, please contact me ASAP.

## TODO

Multi-monitor support.

## Credits

[mwSora](https://github.com/mwSora) for his initial version.
[gabsF](https://modworkshop.net/user/46901) Portuguese translation.

## License

Expand Down
174 changes: 174 additions & 0 deletions lua/Borderless Windowed Updated.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
FullscreenWindowed = FullscreenWindowed or {}

FullscreenWindowed.mod_path = ModPath
FullscreenWindowed.save_path = SavePath .. "FullscreenWindowed.json"
_, FullscreenWindowed.library = blt.load_native(FullscreenWindowed.mod_path .. "Borderless Windowed Updated.dll")

FullscreenWindowed._settings = {
display_mode = 0
}

function FullscreenWindowed:save_settings()
local file = io.open(self.save_path, "w+")
if file then
file:write(json.encode(self._settings))
file:close()
end
end

function FullscreenWindowed:load_settings()
local file = io.open(self.save_path, "r")
if file then
for k, v in pairs(json.decode(file:read("*all")) or {}) do
self._settings[k] = v
end
file:close()
end
end

Hooks:PostHook(__classes["Application"], "apply_render_settings", "FullscreenWindowedApplyRenderSettings", function(self)
FullscreenWindowed.library.change_display_mode(FullscreenWindowed._settings.display_mode, RenderSettings.resolution.x, RenderSettings.resolution.y)
end)

Hooks:PostHook(Setup, "init_managers", "FullscreenWindowedInit", function(self, managers)
if io.file_is_readable(FullscreenWindowed.save_path) then
FullscreenWindowed:load_settings()
FullscreenWindowed.library.change_display_mode(FullscreenWindowed._settings.display_mode, RenderSettings.resolution.x, RenderSettings.resolution.y)
else
FullscreenWindowed._settings.display_mode = managers.viewport:is_fullscreen() and 0 or 1
end
end)

Hooks:PostHook(MenuOptionInitiator, "modify_video", "FullscreenWindowedDisplayMode", function(self, node)
local br_item = node:item("brightness")
if br_item then
br_item:set_enabled(FullscreenWindowed._settings.display_mode == 0)
end

function MenuCallbackHandler:on_change_display_mode(dm_item)
local choice = dm_item:value()

if FullscreenWindowed._settings.display_mode == choice then
return
end

managers.viewport:set_fullscreen(choice == 0)
FullscreenWindowed.library.change_display_mode(choice, RenderSettings.resolution.x, RenderSettings.resolution.y)
local old_display_mode = FullscreenWindowed._settings.display_mode
FullscreenWindowed._settings.display_mode = choice
FullscreenWindowed:save_settings()
managers.menu:show_accept_gfx_settings_dialog(function ()
managers.viewport:set_fullscreen(old_display_mode == 0)
FullscreenWindowed.library.change_display_mode(old_display_mode, RenderSettings.resolution.x, RenderSettings.resolution.y)
FullscreenWindowed._settings.display_mode = old_display_mode
FullscreenWindowed:save_settings()
dm_item:set_value(FullscreenWindowed._settings.old_display_mode)
if br_item then
br_item:set_enabled(old_display_mode == 0)
end
self:refresh_node()
end)
if br_item then
br_item:set_enabled(choice == 0)
end
self:refresh_node()
end

local fs_item = node:item("toggle_fullscreen")
if not fs_item then
local dm_item = node:item("multi_display_mode")
if dm_item then
dm_item:set_value(FullscreenWindowed._settings.display_mode)
end
return
end

node:delete_item("toggle_fullscreen")
local params = {
name = "multi_display_mode",
text_id = "menu_display_mode",
help_id = "menu_fullscreen_help",
callback = "on_change_display_mode",
filter = true
}
local data_node = {
{
value = 0,
text_id = "menu_fullscreen",
_meta = "option"
},
{
value = 1,
text_id = "menu_windowed",
_meta = "option"
},
{
value = 2,
text_id = "menu_fullscreen_windowed",
_meta = "option"
},
type = "MenuItemMultiChoice"
}
local dm_item = node:create_item(data_node, params)
dm_item:set_value(FullscreenWindowed._settings.display_mode)
node:insert_item(dm_item, 3)
end)

function MenuCallbackHandler:change_resolution(item)
local old_resolution = RenderSettings.resolution

if item:parameters().resolution == old_resolution then
return
end

managers.viewport:set_resolution(item:parameters().resolution)
managers.viewport:set_aspect_ratio(item:parameters().resolution.x / item:parameters().resolution.y)
FullscreenWindowed.library.change_display_mode(FullscreenWindowed._settings.display_mode, item:parameters().resolution.x, item:parameters().resolution.y)

local function on_decline()
managers.viewport:set_resolution(old_resolution)
managers.viewport:set_aspect_ratio(old_resolution.x / old_resolution.y)
FullscreenWindowed.library.change_display_mode(FullscreenWindowed._settings.display_mode, old_resolution.x, old_resolution.y)
end

managers.menu:show_accept_gfx_settings_dialog(on_decline)
end

Hooks:Add("LocalizationManagerPostInit", "FullscreenWindowedAddLocalization", function(loc)
local languages = {
[Idstring("english"):key()] = "english",
[Idstring("french"):key()] = "french",
[Idstring("russian"):key()] = "russian",
[Idstring("dutch"):key()] = "dutch",
[Idstring("german"):key()] = "german",
[Idstring("italian"):key()] = "italian",
[Idstring("spanish"):key()] = "spanish",
[Idstring("japanese"):key()] = "japanese",
[Idstring("schinese"):key()] = "schinese",
[Idstring("tchinese"):key()] = "tchinese",
[Idstring("korean"):key()] = "korean",
[Idstring("finnish"):key()] = "finnish",
[Idstring("swedish"):key()] = "swedish",
[Idstring("portuguese"):key()] = "portuguese",
[Idstring("turkish"):key()] = "turkish",
[Idstring("danish"):key()] = "danish",
[Idstring("norwegian"):key()] = "norwegian",
[Idstring("polish"):key()] = "polish"
}

local lang = languages[SystemInfo:language():key()]
if lang == nil then
lang = "english"
end

local lang_exist = io.file_is_readable(FullscreenWindowed.mod_path .. "/loc/" .. lang .. ".json")
if not lang_exist then
loc:add_localized_strings({
["menu_display_mode"] = "Display Mode",
["menu_windowed"] = "Windowed",
["menu_fullscreen_windowed"] = "Fullscreen Windowed"
})
return
end
LocalizationManager:load_localization_file(FullscreenWindowed.mod_path .. "/loc/" .. lang .. ".json")
end)
5 changes: 5 additions & 0 deletions lua/loc/danish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Skærmtilstand",
"menu_windowed" : "I vindue",
"menu_fullscreen_windowed" : "Fuldskærm i vindue"
}
5 changes: 5 additions & 0 deletions lua/loc/dutch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Weergavemodus",
"menu_windowed" : "Venster",
"menu_fullscreen_windowed" : "Volledig scherm (in venster)"
}
5 changes: 5 additions & 0 deletions lua/loc/english.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Display Mode",
"menu_windowed" : "Windowed",
"menu_fullscreen_windowed" : "Fullscreen Windowed"
}
5 changes: 5 additions & 0 deletions lua/loc/finnish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Näyttötila",
"menu_windowed" : "Ikkuna",
"menu_fullscreen_windowed" : "Koko näyttö ikkunoitu"
}
5 changes: 5 additions & 0 deletions lua/loc/french.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Affichage",
"menu_windowed" : "Fenêtré",
"menu_fullscreen_windowed" : "Plein écran fenêtré"
}
5 changes: 5 additions & 0 deletions lua/loc/german.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Anzeigemodus",
"menu_windowed" : "Fenstermodus",
"menu_fullscreen_windowed" : "Vollbildfenster"
}
5 changes: 5 additions & 0 deletions lua/loc/italian.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Modalità di visualizzazione",
"menu_windowed" : "In finestra",
"menu_fullscreen_windowed" : "Schermo intero in finestra"
}
5 changes: 5 additions & 0 deletions lua/loc/japanese.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "ディスプレイモード",
"menu_windowed" : "ウィンドウ",
"menu_fullscreen_windowed" : "全画面ウィンドウ"
}
5 changes: 5 additions & 0 deletions lua/loc/korean.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "화면 모드",
"menu_windowed" : "창 모드",
"menu_fullscreen_windowed" : "창 있는 전체 화면"
}
5 changes: 5 additions & 0 deletions lua/loc/norwegian.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Skjermmodus",
"menu_windowed" : "I vindu",
"menu_fullscreen_windowed" : "Fullskjerm i vindu"
}
5 changes: 5 additions & 0 deletions lua/loc/polish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Tryb wyświetlania",
"menu_windowed" : "W oknie",
"menu_fullscreen_windowed" : "Pełny ekran, w oknie"
}
5 changes: 5 additions & 0 deletions lua/loc/portuguese.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Modo de Exibição",
"menu_windowed" : "Em Janela",
"menu_fullscreen_windowed" : "Tela cheia em janela"
}
5 changes: 5 additions & 0 deletions lua/loc/russian.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Режим отображения",
"menu_windowed" : "В окне",
"menu_fullscreen_windowed" : "Полноэкранный в окне"
}
5 changes: 5 additions & 0 deletions lua/loc/schinese.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "显示模式",
"menu_windowed" : "窗口模式",
"menu_fullscreen_windowed" : "全屏窗口模式"
}
5 changes: 5 additions & 0 deletions lua/loc/spanish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Modo de presentación",
"menu_windowed" : "Modo ventana",
"menu_fullscreen_windowed" : "Ventana a pantalla completa"
}
5 changes: 5 additions & 0 deletions lua/loc/swedish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Visningsläge",
"menu_windowed" : "Fönster",
"menu_fullscreen_windowed" : "Helskärm i fönsterläge"
}
5 changes: 5 additions & 0 deletions lua/loc/tchinese.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "顯示模式",
"menu_windowed" : "視窗化",
"menu_fullscreen_windowed" : "全螢幕視窗化"
}
5 changes: 5 additions & 0 deletions lua/loc/turkish.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"menu_display_mode" : "Görüntü Modu",
"menu_windowed" : "Pencereli",
"menu_fullscreen_windowed" : "Tam Ekran Pencereli"
}
18 changes: 18 additions & 0 deletions lua/mod.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name" : "Fullscreen Windowed(Borderless Windowed Updated)",
"description" : "An updated version of Borderless Windowed plugin.",
"author" : "Shatyuka",
"contact" : "https://t.me/Shatyuka",
"version" : "1.4",
"blt_version" : 2,
"priority" : 0,
"color" : "255 255 255",
"undisablable" : true,
"disable_safe_mode" : true
"hooks" : [
{
"hook_id" : "lib/entry",
"script_path" : "Borderless Windowed Updated.lua"
}
]
}
4 changes: 4 additions & 0 deletions lua/supermod.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0"?>
<mod>
<native_module platform="mswindows" filename="Borderless Windowed Updated.dll" />
</mod>
11 changes: 6 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
HWND g_hWnd;

#define PAYDAY2_WINDOWED_STYLE (WS_CAPTION | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU | WS_MINIMIZEBOX)
#define PAYDAY2_FULLSCREEN_WINDOWED_STYLE (WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS)

void Windowed(int width, int height)
{
Expand All @@ -19,13 +20,13 @@ void Windowed(int width, int height)
rect.bottom = (rect.bottom + height) / 2;
AdjustWindowRectEx(&rect, PAYDAY2_WINDOWED_STYLE, FALSE, WS_EX_OVERLAPPEDWINDOW);
SetWindowPos(g_hWnd, HWND_NOTOPMOST, rect.left >= 0 ? rect.left : 0, rect.top >= 0 ? rect.top : 0,
rect.right - rect.left, rect.bottom - rect.top, SWP_FRAMECHANGED);
rect.right - rect.left, rect.bottom - rect.top, SWP_FRAMECHANGED);
}

void FullscreenWindowed()
{
Sleep(100);
SetWindowLong(g_hWnd, GWL_STYLE, WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS);
SetWindowLong(g_hWnd, GWL_STYLE, PAYDAY2_FULLSCREEN_WINDOWED_STYLE);
SetWindowLong(g_hWnd, GWL_EXSTYLE, 0);
RECT rect;
GetWindowRect(GetDesktopWindow(), &rect);
Expand All @@ -37,7 +38,7 @@ int ChangeDisplayMode(lua_State* L)
int mode = luaL_checkint(L, 1);
int width = luaL_checkint(L, 2);
int height = luaL_checkint(L, 3);
switch(mode)
switch (mode)
{
case 0:
break;
Expand All @@ -48,7 +49,7 @@ int ChangeDisplayMode(lua_State* L)
std::thread(FullscreenWindowed).detach();
break;
default:
PD2HOOK_LOG_ERROR("Parameter error");
PD2HOOK_LOG_ERROR("Invalid parameter");
}
return 0;
}
Expand Down Expand Up @@ -80,6 +81,6 @@ int Plugin_PushLua(lua_State* L)

lua_pushcfunction(L, ChangeDisplayMode);
lua_setfield(L, -2, "change_display_mode");

return 1;
}

0 comments on commit ab6ac07

Please sign in to comment.