Update to spice2x-25-04-25 (pre-apply)

> broken commit
This commit is contained in:
[ ]
2025-05-07 00:25:31 +09:00
parent 04dee88276
commit c94de456b5
543 changed files with 78491 additions and 91698 deletions
+49 -4
View File
@@ -5,10 +5,19 @@
#include <fmt/format.h>
#include "games/io.h"
#include "cfg/screen_resize.h"
#include "hooks/graphics/backends/d3d9/d3d9_backend.h"
#include "hooks/graphics/backends/d3d9/d3d9_device.h"
#include "hooks/graphics/graphics.h"
#include "util/logging.h"
#include "util/utils.h"
#include "touch/touch.h"
int GENERIC_SUB_WINDOW_X = 0;
int GENERIC_SUB_WINDOW_Y = 0;
int GENERIC_SUB_WINDOW_WIDTH = 0;
int GENERIC_SUB_WINDOW_HEIGHT = 0;
bool GENERIC_SUB_WINDOW_FULLSIZE = false;
// #define OVERLAYDBG 1
@@ -19,6 +28,7 @@ namespace overlay::windows {
GenericSubScreen::GenericSubScreen(SpiceOverlay *overlay) : Window(overlay), device(overlay->get_device()) {
this->remove_window_padding = true;
// ImGuiWindowFlags_NoBackground is needed as the background is drawn on top of the subscreen image
this->flags = ImGuiWindowFlags_NoScrollbar |
ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoBackground |
@@ -35,9 +45,34 @@ namespace overlay::windows {
overlay->set_subscreen_mouse_handler([this](LONG *x, LONG *y) -> bool {
// convert to normalized form (relative window coordinates 0.f-1.f)
ImVec2 xy(*x, *y);
xy.x = (xy.x - overlay_content_top_left.x) / overlay_content_size.x;
xy.y = (xy.y - overlay_content_top_left.y) / overlay_content_size.y;
ImVec2 xy;
// log_misc("sub::overlay", "mouse handler {} {}", to_string(*x), to_string(*y));
// log_misc("sub::overlay", "spicetouch coords {} {} {} {}", to_string(SPICETOUCH_TOUCH_X), to_string(SPICETOUCH_TOUCH_Y), to_string(SPICETOUCH_TOUCH_WIDTH), to_string(SPICETOUCH_TOUCH_HEIGHT));
float ratio_x, ratio_y;
if (GRAPHICS_WINDOWED) {
// input coords are relative to spicetouch wnd
ratio_x = (float)*x / SPICETOUCH_TOUCH_WIDTH;
ratio_y = (float)*y / SPICETOUCH_TOUCH_HEIGHT;
} else {
// inputs coords are relative to (0,0) for non-windowed mode
ratio_x = (float)*x / ImGui::GetIO().DisplaySize.x;
ratio_y = (float)*y / ImGui::GetIO().DisplaySize.y;
}
// log_misc("sub::overlay", "game coords {} {}", to_string(ratio_x), to_string(ratio_y));
// transform to subscreen overlay coords
if (!GENERIC_SUB_WINDOW_FULLSIZE) {
ratio_x = (ratio_x * ImGui::GetIO().DisplaySize.x - GENERIC_SUB_WINDOW_X) / GENERIC_SUB_WINDOW_WIDTH;
ratio_y = (ratio_y * ImGui::GetIO().DisplaySize.y - GENERIC_SUB_WINDOW_Y) / GENERIC_SUB_WINDOW_HEIGHT;
// log_misc("sub::overlay", "overlay coords {} {} {} {}", to_string(GENERIC_SUB_WINDOW_X), to_string(GENERIC_SUB_WINDOW_Y), to_string(GENERIC_SUB_WINDOW_WIDTH), to_string(GENERIC_SUB_WINDOW_HEIGHT));
}
xy.x = ratio_x;
xy.y = ratio_y;
// log_misc("sub::overlay", "ratio {} {}", to_string(xy.x), to_string(xy.y));
// x/y can be outside of window
if (xy.x < 0.f || 1.f < xy.x || xy.y < 0.f || 1.f < xy.y) {
@@ -53,6 +88,11 @@ namespace overlay::windows {
void GenericSubScreen::touch_transform(const ImVec2 xy_in, LONG *x_out, LONG *y_out) {}
void GenericSubScreen::build_content() {
if (this->disabled_message.has_value()) {
this->flags &= ~ImGuiWindowFlags_NoBackground;
ImGui::TextColored(YELLOW, "%s", this->disabled_message.value().c_str());
return;
}
this->draw_texture();
#if OVERLAYDBG
@@ -111,6 +151,11 @@ namespace overlay::windows {
overlay_content_size = ImGui::GetIO().DisplaySize;
}
GENERIC_SUB_WINDOW_X = overlay_content_top_left.x;
GENERIC_SUB_WINDOW_Y = overlay_content_top_left.y;
GENERIC_SUB_WINDOW_WIDTH = overlay_content_size.x;
GENERIC_SUB_WINDOW_HEIGHT = overlay_content_size.y;
if (this->draws_window &&
this->texture &&
((UINT)overlay_content_size.x != this->texture_width)) {
@@ -161,7 +206,7 @@ namespace overlay::windows {
bottom_right.x += overlay_content_top_left.x;
bottom_right.y += overlay_content_top_left.y;
ImGui::GetBackgroundDrawList()->AddImage(
reinterpret_cast<void *>(this->texture),
reinterpret_cast<ImTextureID>(this->texture),
overlay_content_top_left,
bottom_right);