Files
spice2x.github.io/src/spice2x/overlay/windows/exitprompt.cpp
T
bicarus 9936088286 popn: subscreen overlay (#631)
## Link to GitHub Issue or related Pull Request, if one exists
#618 

## Description of change

Add overlay for subscreen.

Add an option for no subscreen window.

Use the same "force redraw subscreen" logic we used in SDVX to fix the
same issue.

Known issues:

* still crashing when running windowed if there is only one monitor
* having only one monitor causes sunscreen overlay to not work
(NumberOfAdaptersInGroup issue?)

## Testing
2026-04-12 02:11:24 -07:00

162 lines
5.8 KiB
C++

#include "exitprompt.h"
#include "avs/game.h"
#include "misc/eamuse.h"
#include "util/logging.h"
#include "games/iidx/iidx.h"
#include "games/gitadora/gitadora.h"
#include "games/popn/popn.h"
namespace overlay::windows {
ExitPrompt::ExitPrompt(SpiceOverlay *overlay) : Window(overlay) {
this->title = "spice2x";
this->init_size = ImVec2(
(ImGui::GetFontSize() * 14) + (ImGui::GetStyle().ItemSpacing.x * 2),
overlay::apply_scaling(120));
this->init_pos = ImVec2(
ImGui::GetIO().DisplaySize.x / 2 - this->init_size.x / 2,
overlay::apply_scaling(10));
this->flags = ImGuiWindowFlags_NoResize
| ImGuiWindowFlags_NoCollapse
| ImGuiWindowFlags_AlwaysAutoResize
| ImGuiWindowFlags_NoDocking;
}
void ExitPrompt::build_button(
Window *window, std::string label, const ImVec2 &size, NextItem next, bool is_toggle) {
if (window == nullptr) {
return;
}
if (ImGui::Button(label.c_str(), size)) {
if (is_toggle) {
window->toggle_active();
} else {
window->set_active(true);
this->set_active(false);
}
}
if (next == NextItem::NEW_LINE) {
ImGui::Spacing();
} else {
ImGui::SameLine();
}
}
void ExitPrompt::build_content() {
const ImVec2 size(ImGui::GetFontSize() * 14, ImGui::GetFontSize() * 1.9f);
const ImVec2 size_half(
(size.x - ImGui::GetStyle().ItemSpacing.x) / 2,
ImGui::GetFontSize() * 1.9f);
const ImVec2 size_third(
(size.x - (ImGui::GetStyle().ItemSpacing.x * 2)) / 3,
ImGui::GetFontSize() * 2.5f);
if (ImGui::Button("Hide overlay", size)) {
overlay::OVERLAY->set_active(false);
}
ImGui::Spacing();
build_button(this->overlay->window_config, "Show Config", size, NextItem::NEW_LINE, false);
std::string sub = "Show Subscreen";
if (avs::game::is_model("LDJ")) {
if (games::iidx::TDJ_MODE) {
sub = "Show TDJ Subscreen";
} else {
sub = "Show LDJ LED Ticker";
}
} else if (avs::game::is_model("KFC")) {
sub = "Show Valkyrie Subscreen";
} else if (avs::game::is_model("REC")) {
sub = "Show DRS Dance Floor";
} else if (games::gitadora::is_arena_model() && games::gitadora::ARENA_SINGLE_WINDOW) {
sub = "Show GITADORA Subscreen";
} else if (games::popn::is_pikapika_model()) {
sub = "Show Pop'n Subscreen";
}
build_button(this->overlay->window_sub, sub, size, NextItem::NEW_LINE, false);
ImGui::TextDisabled("Graphics");
build_button(this->overlay->window_camera, "Camera control", size, NextItem::NEW_LINE);
build_button(this->overlay->window_fps, "FPS", size_half, NextItem::SAME_LINE);
build_button(this->overlay->window_resize, "Resize", size_half, NextItem::NEW_LINE);
ImGui::TextDisabled("I/O");
build_button(this->overlay->window_cards, "Card Manager", size, NextItem::NEW_LINE);
if (this->overlay->window_keypad2 == nullptr) {
// 1p only
build_button(this->overlay->window_keypad1, "Keypad", size_half, NextItem::SAME_LINE);
build_button(this->overlay->window_iopanel, "I/O panel", size_half, NextItem::NEW_LINE);
} else {
// 1p and 2p
build_button(this->overlay->window_keypad1, "Keypad\n P1", size_third, NextItem::SAME_LINE);
build_button(this->overlay->window_iopanel, " I/O\npanel", size_third, NextItem::SAME_LINE);
build_button(this->overlay->window_keypad2, "Keypad\n P2", size_third, NextItem::NEW_LINE);
}
ImGui::TextDisabled("Debug");
build_button(this->overlay->window_control, "Control", size_half, NextItem::SAME_LINE);
build_button(this->overlay->window_log, "Log", size_half, NextItem::NEW_LINE);
ImGui::TextDisabled("Windows audio volume");
if (ImGui::Button("-", size_third)) {
INPUT keys = {};
keys.type = INPUT_KEYBOARD;
keys.ki.wVk = VK_VOLUME_DOWN;
SendInput(1, &keys, sizeof(keys));
}
ImGui::SameLine();
if (ImGui::Button("Mute", size_third)) {
INPUT keys = {};
keys.type = INPUT_KEYBOARD;
keys.ki.wVk = VK_VOLUME_MUTE;
SendInput(1, &keys, sizeof(keys));
}
ImGui::SameLine();
if (ImGui::Button("+", size_third)) {
INPUT keys = {};
keys.type = INPUT_KEYBOARD;
keys.ki.wVk = VK_VOLUME_UP;
SendInput(1, &keys, sizeof(keys));
}
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
// quit
if (ImGui::Button("Exit Game", size)) {
ImGui::OpenPopup("spice2x##quitdialog");
}
if (ImGui::BeginPopupModal(
"spice2x##quitdialog",
nullptr,
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoDocking |
ImGuiWindowFlags_AlwaysAutoResize)) {
ImGui::TextUnformatted("Exit the game now?");
ImGui::Spacing();
ImGui::Separator();
ImGui::Spacing();
if (ImGui::Button("Exit")) {
log_info("exitprompt", "user chose to quit game...");
launcher::shutdown();
}
ImGui::SameLine();
if (ImGui::Button("Cancel")) {
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
ImGui::Spacing();
}
}