From ab6ac076a5f811cb01a6ff4eff092ace69aa25b4 Mon Sep 17 00:00:00 2001 From: Shatyuka <958182453@qq.com> Date: Fri, 20 Aug 2021 20:43:46 +0800 Subject: [PATCH] Add all files to repo --- README.md | 18 ++- lua/Borderless Windowed Updated.lua | 174 ++++++++++++++++++++++++++++ lua/loc/danish.json | 5 + lua/loc/dutch.json | 5 + lua/loc/english.json | 5 + lua/loc/finnish.json | 5 + lua/loc/french.json | 5 + lua/loc/german.json | 5 + lua/loc/italian.json | 5 + lua/loc/japanese.json | 5 + lua/loc/korean.json | 5 + lua/loc/norwegian.json | 5 + lua/loc/polish.json | 5 + lua/loc/portuguese.json | 5 + lua/loc/russian.json | 5 + lua/loc/schinese.json | 5 + lua/loc/spanish.json | 5 + lua/loc/swedish.json | 5 + lua/loc/tchinese.json | 5 + lua/loc/turkish.json | 5 + lua/mod.txt | 18 +++ lua/supermod.xml | 4 + src/main.cpp | 11 +- 23 files changed, 308 insertions(+), 7 deletions(-) create mode 100644 lua/Borderless Windowed Updated.lua create mode 100644 lua/loc/danish.json create mode 100644 lua/loc/dutch.json create mode 100644 lua/loc/english.json create mode 100644 lua/loc/finnish.json create mode 100644 lua/loc/french.json create mode 100644 lua/loc/german.json create mode 100644 lua/loc/italian.json create mode 100644 lua/loc/japanese.json create mode 100644 lua/loc/korean.json create mode 100644 lua/loc/norwegian.json create mode 100644 lua/loc/polish.json create mode 100644 lua/loc/portuguese.json create mode 100644 lua/loc/russian.json create mode 100644 lua/loc/schinese.json create mode 100644 lua/loc/spanish.json create mode 100644 lua/loc/swedish.json create mode 100644 lua/loc/tchinese.json create mode 100644 lua/loc/turkish.json create mode 100644 lua/mod.txt create mode 100644 lua/supermod.xml diff --git a/README.md b/README.md index 36b352f..309bf93 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lua/Borderless Windowed Updated.lua b/lua/Borderless Windowed Updated.lua new file mode 100644 index 0000000..a3231d9 --- /dev/null +++ b/lua/Borderless Windowed Updated.lua @@ -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) diff --git a/lua/loc/danish.json b/lua/loc/danish.json new file mode 100644 index 0000000..2709b1a --- /dev/null +++ b/lua/loc/danish.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Skærmtilstand", + "menu_windowed" : "I vindue", + "menu_fullscreen_windowed" : "Fuldskærm i vindue" +} diff --git a/lua/loc/dutch.json b/lua/loc/dutch.json new file mode 100644 index 0000000..2c7b95b --- /dev/null +++ b/lua/loc/dutch.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Weergavemodus", + "menu_windowed" : "Venster", + "menu_fullscreen_windowed" : "Volledig scherm (in venster)" +} diff --git a/lua/loc/english.json b/lua/loc/english.json new file mode 100644 index 0000000..5317fd3 --- /dev/null +++ b/lua/loc/english.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Display Mode", + "menu_windowed" : "Windowed", + "menu_fullscreen_windowed" : "Fullscreen Windowed" +} diff --git a/lua/loc/finnish.json b/lua/loc/finnish.json new file mode 100644 index 0000000..d25b24c --- /dev/null +++ b/lua/loc/finnish.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Näyttötila", + "menu_windowed" : "Ikkuna", + "menu_fullscreen_windowed" : "Koko näyttö ikkunoitu" +} diff --git a/lua/loc/french.json b/lua/loc/french.json new file mode 100644 index 0000000..a9538d5 --- /dev/null +++ b/lua/loc/french.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Affichage", + "menu_windowed" : "Fenêtré", + "menu_fullscreen_windowed" : "Plein écran fenêtré" +} diff --git a/lua/loc/german.json b/lua/loc/german.json new file mode 100644 index 0000000..cd7fe6d --- /dev/null +++ b/lua/loc/german.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Anzeigemodus", + "menu_windowed" : "Fenstermodus", + "menu_fullscreen_windowed" : "Vollbildfenster" +} diff --git a/lua/loc/italian.json b/lua/loc/italian.json new file mode 100644 index 0000000..77cbd76 --- /dev/null +++ b/lua/loc/italian.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Modalità di visualizzazione", + "menu_windowed" : "In finestra", + "menu_fullscreen_windowed" : "Schermo intero in finestra" +} diff --git a/lua/loc/japanese.json b/lua/loc/japanese.json new file mode 100644 index 0000000..b6eb7c3 --- /dev/null +++ b/lua/loc/japanese.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "ディスプレイモード", + "menu_windowed" : "ウィンドウ", + "menu_fullscreen_windowed" : "全画面ウィンドウ" +} diff --git a/lua/loc/korean.json b/lua/loc/korean.json new file mode 100644 index 0000000..3bc3ae8 --- /dev/null +++ b/lua/loc/korean.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "화면 모드", + "menu_windowed" : "창 모드", + "menu_fullscreen_windowed" : "창 있는 전체 화면" +} diff --git a/lua/loc/norwegian.json b/lua/loc/norwegian.json new file mode 100644 index 0000000..ee08d84 --- /dev/null +++ b/lua/loc/norwegian.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Skjermmodus", + "menu_windowed" : "I vindu", + "menu_fullscreen_windowed" : "Fullskjerm i vindu" +} diff --git a/lua/loc/polish.json b/lua/loc/polish.json new file mode 100644 index 0000000..ae9b3bd --- /dev/null +++ b/lua/loc/polish.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Tryb wyświetlania", + "menu_windowed" : "W oknie", + "menu_fullscreen_windowed" : "Pełny ekran, w oknie" +} diff --git a/lua/loc/portuguese.json b/lua/loc/portuguese.json new file mode 100644 index 0000000..cdbcd86 --- /dev/null +++ b/lua/loc/portuguese.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Modo de Exibição", + "menu_windowed" : "Em Janela", + "menu_fullscreen_windowed" : "Tela cheia em janela" +} diff --git a/lua/loc/russian.json b/lua/loc/russian.json new file mode 100644 index 0000000..2f84ecf --- /dev/null +++ b/lua/loc/russian.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Режим отображения", + "menu_windowed" : "В окне", + "menu_fullscreen_windowed" : "Полноэкранный в окне" +} diff --git a/lua/loc/schinese.json b/lua/loc/schinese.json new file mode 100644 index 0000000..176e15d --- /dev/null +++ b/lua/loc/schinese.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "显示模式", + "menu_windowed" : "窗口模式", + "menu_fullscreen_windowed" : "全屏窗口模式" +} diff --git a/lua/loc/spanish.json b/lua/loc/spanish.json new file mode 100644 index 0000000..7e6d0e5 --- /dev/null +++ b/lua/loc/spanish.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Modo de presentación", + "menu_windowed" : "Modo ventana", + "menu_fullscreen_windowed" : "Ventana a pantalla completa" +} diff --git a/lua/loc/swedish.json b/lua/loc/swedish.json new file mode 100644 index 0000000..6b73b17 --- /dev/null +++ b/lua/loc/swedish.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Visningsläge", + "menu_windowed" : "Fönster", + "menu_fullscreen_windowed" : "Helskärm i fönsterläge" +} diff --git a/lua/loc/tchinese.json b/lua/loc/tchinese.json new file mode 100644 index 0000000..9ed6bfd --- /dev/null +++ b/lua/loc/tchinese.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "顯示模式", + "menu_windowed" : "視窗化", + "menu_fullscreen_windowed" : "全螢幕視窗化" +} diff --git a/lua/loc/turkish.json b/lua/loc/turkish.json new file mode 100644 index 0000000..e283b7d --- /dev/null +++ b/lua/loc/turkish.json @@ -0,0 +1,5 @@ +{ + "menu_display_mode" : "Görüntü Modu", + "menu_windowed" : "Pencereli", + "menu_fullscreen_windowed" : "Tam Ekran Pencereli" +} diff --git a/lua/mod.txt b/lua/mod.txt new file mode 100644 index 0000000..5f43724 --- /dev/null +++ b/lua/mod.txt @@ -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" + } + ] +} diff --git a/lua/supermod.xml b/lua/supermod.xml new file mode 100644 index 0000000..829c9c1 --- /dev/null +++ b/lua/supermod.xml @@ -0,0 +1,4 @@ + + + + diff --git a/src/main.cpp b/src/main.cpp index 3924d85..d1456a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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) { @@ -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); @@ -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; @@ -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; } @@ -80,6 +81,6 @@ int Plugin_PushLua(lua_State* L) lua_pushcfunction(L, ChangeDisplayMode); lua_setfield(L, -2, "change_display_mode"); - + return 1; }