Files
spice2x.github.io/src/spice2x/overlay/windows/exitprompt.cpp
T
bicarus 821a705a7d gitadora: (arena model) single window mode + subscreen overlay (#486)
## Link to GitHub Issue, if one exists
#477 

## Description of change
This is a work in progress.

What works:
- [x] subscreen overlay shows the touch screen image (in windowed mode)
- [x] touch works in the overlay
- [x] only the main window is shown, other windows are not launched

What doesn't:
- [ ] game occasionally crashes when entering test menu?
- [ ] full screen mode is not tested at all due to monitor requirements
- [ ] need more polish (various options to control the behavior)
2026-01-17 02:17:33 -08:00

159 lines
5.7 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"
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";
}
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();
}
}