Update to spice2x-25-04-25 (pre-apply)
> broken commit
This commit is contained in:
+125
-100
@@ -7,18 +7,19 @@
|
||||
#include "hooks/graphics/graphics.h"
|
||||
#include "misc/eamuse.h"
|
||||
#include "touch/touch.h"
|
||||
#include "util/fileutils.h"
|
||||
#include "util/logging.h"
|
||||
#include "util/resutils.h"
|
||||
#include "build/resource.h"
|
||||
|
||||
#include "imgui/impl_dx9.h"
|
||||
#include "imgui/impl_spice.h"
|
||||
#include "imgui/impl_sw.h"
|
||||
#include "overlay/imgui/impl_dx9.h"
|
||||
#include "external/imgui/backends/imgui_impl_dx9.h"
|
||||
#include "overlay/imgui/impl_spice.h"
|
||||
#include "overlay/imgui/impl_sw.h"
|
||||
|
||||
#include "window.h"
|
||||
#ifdef SPICE64
|
||||
#include "windows/camera_control.h"
|
||||
#endif
|
||||
#include "windows/card_manager.h"
|
||||
#include "windows/screen_resize.h"
|
||||
#include "windows/config.h"
|
||||
@@ -27,16 +28,16 @@
|
||||
#include "windows/generic_sub.h"
|
||||
#include "windows/iidx_seg.h"
|
||||
#include "windows/iidx_sub.h"
|
||||
#include "windows/drs_dancefloor.h"
|
||||
#include "windows/iopanel.h"
|
||||
#include "windows/iopanel_ddr.h"
|
||||
#include "windows/iopanel_gfdm.h"
|
||||
#include "windows/iopanel_iidx.h"
|
||||
#include "windows/sdvx_sub.h"
|
||||
#include "windows/keypad.h"
|
||||
#include "windows/kfcontrol.h"
|
||||
#include "windows/log.h"
|
||||
#include "windows/patch_manager.h"
|
||||
#include "windows/vr.h"
|
||||
#include "windows/exitprompt.cpp"
|
||||
|
||||
static inline ImVec4 operator*(const ImVec4& lhs, const ImVec4& rhs) \
|
||||
{ return ImVec4(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z, lhs.w * rhs.w); }
|
||||
@@ -53,10 +54,13 @@ namespace overlay {
|
||||
|
||||
bool USE_WM_CHAR_FOR_IMGUI_CHAR_INPUT = false;
|
||||
|
||||
bool FPS_SHOULD_FLIP = false;
|
||||
|
||||
// global
|
||||
std::mutex OVERLAY_MUTEX;
|
||||
std::unique_ptr<overlay::SpiceOverlay> OVERLAY = nullptr;
|
||||
ImFont* DSEG_FONT = nullptr;
|
||||
bool SHOW_DEBUG_LOG_WINDOW = false;
|
||||
}
|
||||
|
||||
static void *ImGui_Alloc(size_t sz, void *user_data) {
|
||||
@@ -175,7 +179,7 @@ void overlay::SpiceOverlay::init() {
|
||||
|
||||
// colors[ImGuiCol_WindowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.94f);
|
||||
// colors[ImGuiCol_ChildBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
// colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f);
|
||||
colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.f, 0.f, 0.94f);
|
||||
|
||||
colors[ImGuiCol_Border] = ImVec4(0.00f, 0.00f, 0.00f, 0.50f);
|
||||
colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
@@ -224,7 +228,7 @@ void overlay::SpiceOverlay::init() {
|
||||
colors[ImGuiCol_TableBorderStrong] = ImVec4(0.31f, 0.31f, 0.35f, 1.00f);
|
||||
colors[ImGuiCol_TableBorderLight] = ImVec4(0.23f, 0.23f, 0.25f, 1.00f);
|
||||
colors[ImGuiCol_TableRowBg] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.07f);
|
||||
colors[ImGuiCol_TableRowBgAlt] = ImVec4(1.00f, 1.00f, 1.00f, 0.04f);
|
||||
colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f);
|
||||
colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f);
|
||||
colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f);
|
||||
@@ -237,13 +241,20 @@ void overlay::SpiceOverlay::init() {
|
||||
io.UserData = this;
|
||||
io.ConfigFlags = ImGuiConfigFlags_NavEnableKeyboard
|
||||
| ImGuiConfigFlags_NavEnableGamepad
|
||||
| ImGuiConfigFlags_NavEnableSetMousePos
|
||||
| ImGuiConfigFlags_DockingEnable
|
||||
| ImGuiConfigFlags_ViewportsEnable;
|
||||
if (is_touch_available()) {
|
||||
| ImGuiConfigFlags_NavEnableSetMousePos;
|
||||
|
||||
if (!cfg::CONFIGURATOR_STANDALONE) {
|
||||
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;
|
||||
}
|
||||
if (is_touch_available("SpiceOverlay::init")) {
|
||||
io.ConfigFlags |= ImGuiConfigFlags_IsTouchScreen;
|
||||
}
|
||||
|
||||
// temporarily turn this off as it can cause crashes during font load failures
|
||||
// turns back on in ImGui_ImplSpice_Init
|
||||
io.ConfigErrorRecoveryEnableTooltip = false;
|
||||
|
||||
io.MouseDrawCursor = !GRAPHICS_SHOW_CURSOR;
|
||||
|
||||
// disable config
|
||||
@@ -258,20 +269,14 @@ void overlay::SpiceOverlay::init() {
|
||||
// add fallback fonts for missing glyph ranges
|
||||
ImFontConfig config {};
|
||||
config.MergeMode = true;
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\simsun.ttc)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\arial.ttf)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesCyrillic());
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\meiryu.ttc)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesJapanese());
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\meiryo.ttc)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesJapanese());
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\gulim.ttc)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesKorean());
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\cordia.ttf)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesThai());
|
||||
io.Fonts->AddFontFromFileTTF(R"(C:\Windows\Fonts\arial.ttf)",
|
||||
13.0f, &config, io.Fonts->GetGlyphRangesVietnamese());
|
||||
|
||||
add_font("simsun.ttc", &config, io.Fonts->GetGlyphRangesChineseSimplifiedCommon());
|
||||
add_font("arial.ttc", &config, io.Fonts->GetGlyphRangesCyrillic());
|
||||
add_font("meiryu.ttc", &config, io.Fonts->GetGlyphRangesJapanese());
|
||||
add_font("meiryo.ttc", &config, io.Fonts->GetGlyphRangesJapanese());
|
||||
add_font("gulim.ttc", &config, io.Fonts->GetGlyphRangesKorean());
|
||||
add_font("cordia.ttc", &config, io.Fonts->GetGlyphRangesThai());
|
||||
add_font("arial.ttc", &config, io.Fonts->GetGlyphRangesVietnamese());
|
||||
|
||||
// add special font
|
||||
if (avs::game::is_model("LDJ")) {
|
||||
@@ -319,51 +324,56 @@ void overlay::SpiceOverlay::init() {
|
||||
set_overlay_active = true;
|
||||
}
|
||||
|
||||
this->window_add(window_main_menu = new overlay::windows::ExitPrompt(this));
|
||||
|
||||
// add default windows
|
||||
this->window_add(new overlay::windows::Config(this));
|
||||
this->window_add(new overlay::windows::Control(this));
|
||||
this->window_add(new overlay::windows::Log(this));
|
||||
this->window_add(new overlay::windows::CardManager(this));
|
||||
this->window_add(window_config = new overlay::windows::Config(this));
|
||||
this->window_add(window_control = new overlay::windows::Control(this));
|
||||
this->window_add(window_log = new overlay::windows::Log(this));
|
||||
#ifdef SPICE64
|
||||
if (avs::game::is_model("LDJ")) {
|
||||
this->window_add(window_camera = new overlay::windows::CameraControl(this));
|
||||
}
|
||||
#endif
|
||||
this->window_add(window_cards = new overlay::windows::CardManager(this));
|
||||
if (!cfg::CONFIGURATOR_STANDALONE) {
|
||||
this->window_add(new overlay::windows::ScreenResize(this));
|
||||
this->window_add(window_resize = new overlay::windows::ScreenResize(this));
|
||||
}
|
||||
this->window_add(new overlay::windows::PatchManager(this));
|
||||
this->window_add(new overlay::windows::KFControl(this));
|
||||
this->window_add(new overlay::windows::VRWindow(this));
|
||||
|
||||
{
|
||||
const auto keypad_p1 = new overlay::windows::Keypad(this, 0);
|
||||
this->window_add(keypad_p1);
|
||||
window_keypad1 = new overlay::windows::Keypad(this, 0);
|
||||
this->window_add(window_keypad1);
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && AUTO_SHOW_KEYPAD_P1) {
|
||||
keypad_p1->set_active(true);
|
||||
window_keypad1->set_active(true);
|
||||
set_overlay_active = true;
|
||||
}
|
||||
}
|
||||
if (eamuse_get_game_keypads() > 1) {
|
||||
const auto keypad_p2 = new overlay::windows::Keypad(this, 1);
|
||||
this->window_add(keypad_p2);
|
||||
window_keypad2 = new overlay::windows::Keypad(this, 1);
|
||||
this->window_add(window_keypad2);
|
||||
if (!cfg::CONFIGURATOR_STANDALONE && AUTO_SHOW_KEYPAD_P2) {
|
||||
keypad_p2->set_active(true);
|
||||
window_keypad2->set_active(true);
|
||||
set_overlay_active = true;
|
||||
}
|
||||
}
|
||||
|
||||
// IO panel needs to know what game is running
|
||||
if (!cfg::CONFIGURATOR_STANDALONE) {
|
||||
overlay::Window *iopanel = nullptr;
|
||||
window_iopanel = nullptr;
|
||||
if (avs::game::is_model("LDJ")) {
|
||||
iopanel = new overlay::windows::IIDXIOPanel(this);
|
||||
window_iopanel = new overlay::windows::IIDXIOPanel(this);
|
||||
} else if (avs::game::is_model("MDX")) {
|
||||
iopanel = new overlay::windows::DDRIOPanel(this);
|
||||
window_iopanel = new overlay::windows::DDRIOPanel(this);
|
||||
} else if (avs::game::is_model({"J32", "J33", "K32", "K33", "L32", "L33", "M32"})) {
|
||||
iopanel = new overlay::windows::GitadoraIOPanel(this);
|
||||
window_iopanel = new overlay::windows::GitadoraIOPanel(this);
|
||||
} else {
|
||||
iopanel = new overlay::windows::IOPanel(this);
|
||||
window_iopanel = new overlay::windows::IOPanel(this);
|
||||
}
|
||||
if (iopanel) {
|
||||
this->window_add(iopanel);
|
||||
if (window_iopanel) {
|
||||
this->window_add(window_iopanel);
|
||||
if (AUTO_SHOW_IOPANEL) {
|
||||
iopanel->set_active(true);
|
||||
window_iopanel->set_active(true);
|
||||
set_overlay_active = true;
|
||||
}
|
||||
}
|
||||
@@ -371,20 +381,22 @@ void overlay::SpiceOverlay::init() {
|
||||
|
||||
// subscreens need DirectX, so don't try to initialize them in standalone
|
||||
if (!cfg::CONFIGURATOR_STANDALONE) {
|
||||
overlay::Window *subscreen = nullptr;
|
||||
window_sub = nullptr;
|
||||
if (avs::game::is_model("LDJ")) {
|
||||
if (games::iidx::TDJ_MODE) {
|
||||
subscreen = new overlay::windows::IIDXSubScreen(this);
|
||||
window_sub = new overlay::windows::IIDXSubScreen(this);
|
||||
} else {
|
||||
subscreen = new overlay::windows::IIDXSegmentDisplay(this);
|
||||
window_sub = new overlay::windows::IIDXSegmentDisplay(this);
|
||||
}
|
||||
} else if (avs::game::is_model("REC")) {
|
||||
window_sub = new overlay::windows::DRSDanceFloorDisplay(this);
|
||||
} else if (avs::game::is_model("KFC")) {
|
||||
subscreen = new overlay::windows::SDVXSubScreen(this);
|
||||
window_sub = new overlay::windows::SDVXSubScreen(this);
|
||||
}
|
||||
if (subscreen) {
|
||||
this->window_add(subscreen);
|
||||
if (window_sub) {
|
||||
this->window_add(window_sub);
|
||||
if (AUTO_SHOW_SUBSCREEN) {
|
||||
subscreen->set_active(true);
|
||||
window_sub->set_active(true);
|
||||
set_overlay_active = true;
|
||||
}
|
||||
}
|
||||
@@ -441,57 +453,15 @@ void overlay::SpiceOverlay::new_frame() {
|
||||
}
|
||||
ImGui::NewFrame();
|
||||
|
||||
// animated background
|
||||
if (cfg::CONFIGURATOR_STANDALONE) {
|
||||
auto flags = ImGuiWindowFlags_NoResize |
|
||||
ImGuiWindowFlags_NoMove |
|
||||
ImGuiWindowFlags_NoTitleBar |
|
||||
ImGuiWindowFlags_NoCollapse |
|
||||
ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoBackground |
|
||||
ImGuiWindowFlags_NoBringToFrontOnFocus |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_NoInputs;
|
||||
if (ImGui::Begin("Background", nullptr, flags)) {
|
||||
ImGui::SetWindowPos(ImVec2(0, 0));
|
||||
ImGui::SetWindowSize(ImGui::GetIO().DisplaySize);
|
||||
|
||||
static const int EDGES[] = { 3, 4, 5, 6, 18 };
|
||||
|
||||
auto &io = ImGui::GetIO();
|
||||
auto display_x = std::ceil(io.DisplaySize.x);
|
||||
auto display_y = std::ceil(io.DisplaySize.y);
|
||||
auto spacing = (display_x + display_y) * 0.1f;
|
||||
auto max_x = static_cast<int>(display_x / spacing + 1.f);
|
||||
auto max_y = static_cast<int>(display_y / spacing + 1.f);
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
for (int i_x = -1; i_x < max_x; i_x++) {
|
||||
for (int i_y = -1; i_y < max_y; i_y++) {
|
||||
auto x = static_cast<float>(i_x);
|
||||
auto y = static_cast<float>(i_y);
|
||||
draw->AddCircleFilled(
|
||||
ImVec2(
|
||||
x * spacing + sinf(total_elapsed * 0.5f + x - y) * spacing * 0.8f,
|
||||
y * spacing + cosf(total_elapsed * 0.5f - x + y) * spacing * 0.8f
|
||||
),
|
||||
spacing * 0.3f + sinf(total_elapsed * 0.2f - x - y) * spacing * 0.05f,
|
||||
ImColor(
|
||||
0.1f,
|
||||
0.1f,
|
||||
0.1f,
|
||||
1.f),
|
||||
EDGES[static_cast<size_t>(i_x + i_y) % std::size(EDGES)]);
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
|
||||
// build windows
|
||||
for (auto &window : this->windows) {
|
||||
window->build();
|
||||
}
|
||||
|
||||
if (SHOW_DEBUG_LOG_WINDOW) {
|
||||
ImGui::ShowDebugLogWindow(&SHOW_DEBUG_LOG_WINDOW);
|
||||
}
|
||||
|
||||
// end frame
|
||||
ImGui::EndFrame();
|
||||
}
|
||||
@@ -557,6 +527,15 @@ void overlay::SpiceOverlay::update() {
|
||||
}
|
||||
this->toggle_down = toggle_down_new;
|
||||
|
||||
// check main menu
|
||||
const auto main_menu_down_new = overlay_buttons
|
||||
&& this->hotkeys_triggered()
|
||||
&& GameAPI::Buttons::getState(RI_MGR, overlay_buttons->at(games::OverlayButtons::ToggleMainMenu));
|
||||
if (main_menu_down_new && !this->main_menu_down) {
|
||||
show_main_menu();
|
||||
}
|
||||
this->main_menu_down = main_menu_down_new;
|
||||
|
||||
// update windows
|
||||
for (auto &window : this->windows) {
|
||||
window->update();
|
||||
@@ -584,12 +563,40 @@ void overlay::SpiceOverlay::toggle_active(bool overlay_key) {
|
||||
// invert active state
|
||||
this->active = !this->active;
|
||||
|
||||
// get rid of main menu if it was visible
|
||||
if (this->window_main_menu) {
|
||||
this->window_main_menu->set_active(false);
|
||||
}
|
||||
|
||||
// show FPS window if toggled with overlay key
|
||||
if (overlay_key) {
|
||||
this->window_fps->set_active(this->active);
|
||||
}
|
||||
}
|
||||
|
||||
void overlay::SpiceOverlay::show_main_menu() {
|
||||
if (!this->window_main_menu) {
|
||||
return;
|
||||
}
|
||||
if (this->window_main_menu->get_active()) {
|
||||
// window already visible - close the window
|
||||
this->window_main_menu->set_active(false);
|
||||
return;
|
||||
}
|
||||
if (ImGui::IsPopupOpen(0, ImGuiPopupFlags_AnyPopup)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->get_active()) {
|
||||
if (!ImGui::IsAnyItemActive() && !ImGui::IsAnyItemFocused()) {
|
||||
this->window_main_menu->set_active(true);
|
||||
}
|
||||
} else {
|
||||
this->set_active(true);
|
||||
this->window_main_menu->set_active(true);
|
||||
}
|
||||
}
|
||||
|
||||
void overlay::SpiceOverlay::set_active(bool new_active) {
|
||||
|
||||
// toggle if different
|
||||
@@ -690,3 +697,21 @@ uint32_t *overlay::SpiceOverlay::sw_get_pixel_data(int *width, int *height) {
|
||||
*height = this->pixel_data_height;
|
||||
return &this->pixel_data[0];
|
||||
}
|
||||
|
||||
void overlay::SpiceOverlay::add_font(const char* font, ImFontConfig* config, const ImWchar* glyphs) {
|
||||
CHAR fonts_dir[MAX_PATH];
|
||||
ExpandEnvironmentStringsA(R"(%SYSTEMROOT%\Fonts\)", fonts_dir, MAX_PATH);
|
||||
std::filesystem::path full_path = fonts_dir;
|
||||
full_path += font;
|
||||
|
||||
if (fileutils::file_exists(full_path)) {
|
||||
log_misc("overlay", "loading font: {}", full_path.string());
|
||||
ImGui::GetIO().Fonts->AddFontFromFileTTF(
|
||||
full_path.string().c_str(),
|
||||
13.0f,
|
||||
config,
|
||||
glyphs);
|
||||
} else {
|
||||
log_misc("overlay", "font not found: {}", full_path.string());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user