diff --git a/src/spice2x/hooks/graphics/graphics.h b/src/spice2x/hooks/graphics/graphics.h index 1724015..7c69ee0 100644 --- a/src/spice2x/hooks/graphics/graphics.h +++ b/src/spice2x/hooks/graphics/graphics.h @@ -101,6 +101,8 @@ void graphics_capture_initial_window(HWND hWnd); void graphics_update_window_style(HWND hWnd); void graphics_update_z_order(HWND hWnd, bool always_on_top); void graphics_move_resize_window(HWND hWnd); -bool graphics_window_change_crashes_game(); +bool graphics_window_options_breaks_game(); +bool graphics_window_decoration_change_crashes_game(); bool graphics_window_resize_breaks_game(); +bool graphics_window_move_and_resize_breaks_game(); void graphics_load_windowed_subscreen_parameters(); diff --git a/src/spice2x/hooks/graphics/graphics_windowed.cpp b/src/spice2x/hooks/graphics/graphics_windowed.cpp index 841f5c2..9fac847 100644 --- a/src/spice2x/hooks/graphics/graphics_windowed.cpp +++ b/src/spice2x/hooks/graphics/graphics_windowed.cpp @@ -96,6 +96,9 @@ void graphics_capture_initial_window(HWND hWnd) { cfg::SCREENRESIZE->client_width = client_w; cfg::SCREENRESIZE->client_height = client_h; } + if (graphics_window_move_and_resize_breaks_game()) { + cfg::SCREENRESIZE->enable_window_resize = false; + } // if there was no user-supplied dimension, seed it with the current size // so that the next resize operation will work @@ -386,7 +389,7 @@ void graphics_update_window_style(HWND hWnd) { if (!GRAPHICS_WINDOWED) { return; } - if (graphics_window_change_crashes_game()) { + if (graphics_window_decoration_change_crashes_game()) { return; } @@ -496,12 +499,19 @@ void graphics_move_resize_window(HWND hWnd) { log_debug("graphics-windowed", "graphics_move_resize_window returned"); } -bool graphics_window_change_crashes_game() { +bool graphics_window_decoration_change_crashes_game() { static std::once_flag flag; static bool result = false; std::call_once(flag, []() { // ddr crashes when frame style changes result = avs::game::is_model("MDX"); + + // changing window decoration also changes dimensions and position + // so this must be prevented + if (graphics_window_move_and_resize_breaks_game()) { + result = true; + } + if (result) { log_warning( "graphics-windowed", @@ -511,14 +521,33 @@ bool graphics_window_change_crashes_game() { return result; } +bool graphics_window_move_and_resize_breaks_game() { + static std::once_flag flag; + static bool result = false; + + std::call_once(flag, []() { + // games like reflec beat in use spice touch overlay for windowed mode + // and mouse input breaks if window is moved as the overlay does not + // currently support window moves/resizes + result = avs::game::is_model({"KBR", "LBR", "MBR"}); + if (result) { + log_warning( + "graphics-windowed", + "ignoring changes to window properties due to incompatibility with this game"); + } + }); + return result; +} + bool graphics_window_resize_breaks_game() { - bool is_gitadora = avs::game::is_model({ "J32", "J33", "K32", "K33", "L32", "L33", "M32" }); - bool is_arena = games::gitadora::is_arena_model(); // for whatever reason, gitadora games on dx/sd/sd2 cabs behave poorly when window is resized // (eihter at launch or while it's running) // usually results in: soft lock during scene transtions or really long transitions, // backgrounds of menus not rendering, etc. - bool result = is_gitadora && !is_arena; + bool is_gitadora = avs::game::is_model({ "J32", "J33", "K32", "K33", "L32", "L33", "M32" }); + bool is_arena = games::gitadora::is_arena_model(); + + bool result = graphics_window_move_and_resize_breaks_game() || (is_gitadora && !is_arena); static std::once_flag flag; std::call_once(flag, [&result]() { diff --git a/src/spice2x/overlay/windows/screen_resize.cpp b/src/spice2x/overlay/windows/screen_resize.cpp index ed637e5..af8ab78 100644 --- a/src/spice2x/overlay/windows/screen_resize.cpp +++ b/src/spice2x/overlay/windows/screen_resize.cpp @@ -202,7 +202,7 @@ namespace overlay::windows { return; } - ImGui::BeginDisabled(graphics_window_change_crashes_game()); + ImGui::BeginDisabled(graphics_window_decoration_change_crashes_game()); if (ImGui::Combo( "Window Style", &cfg::SCREENRESIZE->window_decoration, @@ -227,52 +227,60 @@ namespace overlay::windows { "Reduces pixelated scaling artifacts. Works great on some games, but completely broken on others.\n\n" "This can't be changed in-game; instead, set -windowscale option in spicecfg and restart."); - ImGui::Checkbox("Keep Aspect Ratio", &cfg::SCREENRESIZE->client_keep_aspect_ratio); - ImGui::Checkbox("Manual window move/resize", &cfg::SCREENRESIZE->enable_window_resize); + + ImGui::BeginDisabled(graphics_window_move_and_resize_breaks_game()); + { + ImGui::Checkbox("Keep Aspect Ratio", &cfg::SCREENRESIZE->client_keep_aspect_ratio); + ImGui::Checkbox("Manual window move/resize", &cfg::SCREENRESIZE->enable_window_resize); + } + ImGui::EndDisabled(); + ImGui::BeginDisabled(!cfg::SCREENRESIZE->enable_window_resize); bool changed = false; const uint32_t step = 1; const uint32_t step_fast = 10; - if (graphics_window_resize_breaks_game()) { - ImGui::TextColored(ImVec4(1, 0.5f, 0.5f, 1.f), - "GITADORA tends to hang or have graphical\n" - "glitches when window is resized; resize\n" - "controls are disabled."); - } ImGui::BeginDisabled(graphics_window_resize_breaks_game()); - ImGui::BeginDisabled(cfg::SCREENRESIZE->client_keep_aspect_ratio); - ImGui::InputScalar( - "Width", - ImGuiDataType_U32, - &cfg::SCREENRESIZE->client_width, - &step, &step_fast, nullptr); - changed |= ImGui::IsItemDeactivatedAfterEdit(); + { + ImGui::BeginDisabled(cfg::SCREENRESIZE->client_keep_aspect_ratio); + { + ImGui::InputScalar( + "Width", + ImGuiDataType_U32, + &cfg::SCREENRESIZE->client_width, + &step, &step_fast, nullptr); + changed |= ImGui::IsItemDeactivatedAfterEdit(); + } + ImGui::EndDisabled(); + + ImGui::InputScalar( + "Height", + ImGuiDataType_U32, + &cfg::SCREENRESIZE->client_height, + &step, &step_fast, nullptr); + changed |= ImGui::IsItemDeactivatedAfterEdit(); + } ImGui::EndDisabled(); - ImGui::InputScalar( - "Height", - ImGuiDataType_U32, - &cfg::SCREENRESIZE->client_height, - &step, &step_fast, nullptr); - changed |= ImGui::IsItemDeactivatedAfterEdit(); + ImGui::BeginDisabled(graphics_window_move_and_resize_breaks_game()); + { + ImGui::InputScalar( + "X Offset", + ImGuiDataType_S32, + &cfg::SCREENRESIZE->window_offset_x, + &step, &step_fast, nullptr); + changed |= ImGui::IsItemDeactivatedAfterEdit(); + + ImGui::InputScalar( + "Y Offset", + ImGuiDataType_S32, + &cfg::SCREENRESIZE->window_offset_y, + &step, &step_fast, nullptr); + changed |= ImGui::IsItemDeactivatedAfterEdit(); + } ImGui::EndDisabled(); - ImGui::InputScalar( - "X Offset", - ImGuiDataType_S32, - &cfg::SCREENRESIZE->window_offset_x, - &step, &step_fast, nullptr); - changed |= ImGui::IsItemDeactivatedAfterEdit(); - - ImGui::InputScalar( - "Y Offset", - ImGuiDataType_S32, - &cfg::SCREENRESIZE->window_offset_y, - &step, &step_fast, nullptr); - changed |= ImGui::IsItemDeactivatedAfterEdit(); - if (changed) { if (cfg::SCREENRESIZE->client_keep_aspect_ratio) { cfg::SCREENRESIZE->client_width =