mirror of
https://github.com/spice2x/spice2x.github.io.git
synced 2026-08-02 06:40:42 -07:00
overlay: bring back "-" placeholder for unbound io, clean up code (#538)
This commit is contained in:
@@ -11,6 +11,14 @@
|
|||||||
// settings
|
// settings
|
||||||
std::string CONFIG_PATH_OVERRIDE = "";
|
std::string CONFIG_PATH_OVERRIDE = "";
|
||||||
|
|
||||||
|
#define CFG_DEBUG_VERBOSE 0
|
||||||
|
|
||||||
|
#if CFG_DEBUG_VERBOSE
|
||||||
|
#define log_debug(module, format_str, ...) logger::push( \
|
||||||
|
LOG_FORMAT("M", module, format_str, ## __VA_ARGS__), logger::Style::GREY)
|
||||||
|
#else
|
||||||
|
#define log_debug(module, format_str, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
///////////////////
|
///////////////////
|
||||||
/// Constructor ///
|
/// Constructor ///
|
||||||
@@ -595,7 +603,7 @@ bool Config::updateBinding(const Game &game, const Button &button, int alternati
|
|||||||
// found a node for this button, which means to_delete is not the first one
|
// found a node for this button, which means to_delete is not the first one
|
||||||
// delete the node for to_delete
|
// delete the node for to_delete
|
||||||
if (to_delete != nullptr) {
|
if (to_delete != nullptr) {
|
||||||
log_misc("cfg", "deleting excessive button binding for {}", name);
|
log_debug("cfg", "deleting excessive button binding for {}", name);
|
||||||
gameButtonsNode->DeleteChild(to_delete);
|
gameButtonsNode->DeleteChild(to_delete);
|
||||||
to_delete = nullptr;
|
to_delete = nullptr;
|
||||||
}
|
}
|
||||||
@@ -812,7 +820,7 @@ bool Config::updateBinding(const Game &game, const Light &light, int alternative
|
|||||||
// found a node for this button, which means to_delete is not the first one
|
// found a node for this button, which means to_delete is not the first one
|
||||||
// delete the node for to_delete
|
// delete the node for to_delete
|
||||||
if (to_delete != nullptr) {
|
if (to_delete != nullptr) {
|
||||||
log_misc("cfg", "deleting excessive light binding for {}", name);
|
log_debug("cfg", "deleting excessive light binding for {}", name);
|
||||||
gameLightsNode->DeleteChild(to_delete);
|
gameLightsNode->DeleteChild(to_delete);
|
||||||
to_delete = nullptr;
|
to_delete = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -650,25 +650,30 @@ namespace overlay::windows {
|
|||||||
// column for key binding display
|
// column for key binding display
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
if (button_state) {
|
if (button_display.size() > 0) {
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, TEXT_COLOR_GREEN);
|
if (button_state) {
|
||||||
}
|
ImGui::PushStyleColor(ImGuiCol_Text, TEXT_COLOR_GREEN);
|
||||||
std::string button_text = ImGui::TruncateText(
|
}
|
||||||
button_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
|
std::string button_text = ImGui::TruncateText(
|
||||||
ImGui::TextUnformatted(button_text.c_str());
|
button_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
|
||||||
if (button_state) {
|
ImGui::TextUnformatted(button_text.c_str());
|
||||||
ImGui::PopStyleColor();
|
if (button_state) {
|
||||||
}
|
ImGui::PopStyleColor();
|
||||||
if (ImGui::IsItemHovered() && button_display.size() > 0) {
|
}
|
||||||
ImGui::SameLine();
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::HelpTooltip(button_display.c_str());
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpTooltip(button_display.c_str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// placeholder
|
||||||
|
ImGui::TextDisabled("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear button
|
// clear button
|
||||||
if (button_display.size() > 0) {
|
if (button_display.size() > 0) {
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (ImGui::DeleteButton("Unbind")) {
|
if (ImGui::DeleteButton("Unbind")) {
|
||||||
clear_button(*button);
|
clear_button(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,18 +781,18 @@ namespace overlay::windows {
|
|||||||
ImGui::PopID();
|
ImGui::PopID();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Config::clear_button(Button &button) {
|
void Config::clear_button(Button *button) {
|
||||||
button.setDeviceIdentifier("");
|
button->setDeviceIdentifier("");
|
||||||
button.setVKey(0xFF);
|
button->setVKey(0xFF);
|
||||||
button.setAnalogType(BAT_NONE);
|
button->setAnalogType(BAT_NONE);
|
||||||
button.setDebounceUp(0.0);
|
button->setDebounceUp(0.0);
|
||||||
button.setDebounceDown(0.0);
|
button->setDebounceDown(0.0);
|
||||||
button.setVelocityThreshold(0);
|
button->setVelocityThreshold(0);
|
||||||
button.setInvert(false);
|
button->setInvert(false);
|
||||||
button.setLastState(GameAPI::Buttons::BUTTON_NOT_PRESSED);
|
button->setLastState(GameAPI::Buttons::BUTTON_NOT_PRESSED);
|
||||||
button.setLastVelocity(0);
|
button->setLastVelocity(0);
|
||||||
::Config::getInstance().updateBinding(
|
::Config::getInstance().updateBinding(
|
||||||
games_list[games_selected], button,
|
games_list[games_selected], *button,
|
||||||
buttons_page - 1);
|
buttons_page - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1742,12 +1747,16 @@ namespace overlay::windows {
|
|||||||
|
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
std::string analog_text = ImGui::TruncateText(
|
if (analog_display.size() > 0) {
|
||||||
analog_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
|
std::string analog_text = ImGui::TruncateText(
|
||||||
ImGui::TextUnformatted(analog_text.c_str());
|
analog_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
|
||||||
if (ImGui::IsItemHovered() && analog_display.size() > 0) {
|
ImGui::TextUnformatted(analog_text.c_str());
|
||||||
ImGui::SameLine();
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::HelpTooltip(analog_display.c_str());
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpTooltip(analog_display.c_str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGui::TextDisabled("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear analog
|
// clear analog
|
||||||
@@ -2191,9 +2200,6 @@ namespace overlay::windows {
|
|||||||
auto light_state = GameAPI::Lights::readLight(RI_MGR, *light);
|
auto light_state = GameAPI::Lights::readLight(RI_MGR, *light);
|
||||||
|
|
||||||
// list entry
|
// list entry
|
||||||
if (light_display.empty()) {
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.7f, 0.7f, 0.7f, 1.f));
|
|
||||||
}
|
|
||||||
ImGui::PushID(light);
|
ImGui::PushID(light);
|
||||||
ImGui::TableNextRow();
|
ImGui::TableNextRow();
|
||||||
|
|
||||||
@@ -2206,12 +2212,16 @@ namespace overlay::windows {
|
|||||||
// binding name
|
// binding name
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
ImGui::AlignTextToFramePadding();
|
ImGui::AlignTextToFramePadding();
|
||||||
std::string light_text = ImGui::TruncateText(
|
if (light_display.size() > 0) {
|
||||||
light_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
|
std::string light_text = ImGui::TruncateText(
|
||||||
ImGui::TextUnformatted(light_text.c_str());
|
light_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20));
|
||||||
if (ImGui::IsItemHovered() && light_display.size() > 0) {
|
ImGui::TextUnformatted(light_text.c_str());
|
||||||
ImGui::SameLine();
|
if (ImGui::IsItemHovered()) {
|
||||||
ImGui::HelpTooltip(light_display.c_str());
|
ImGui::SameLine();
|
||||||
|
ImGui::HelpTooltip(light_display.c_str());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ImGui::TextDisabled("-");
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear light
|
// clear light
|
||||||
@@ -2228,9 +2238,6 @@ namespace overlay::windows {
|
|||||||
|
|
||||||
// bind button
|
// bind button
|
||||||
ImGui::TableNextColumn();
|
ImGui::TableNextColumn();
|
||||||
if (light_display.empty()) {
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
}
|
|
||||||
|
|
||||||
// light binding
|
// light binding
|
||||||
if (ImGui::Button("Set")) {
|
if (ImGui::Button("Set")) {
|
||||||
@@ -2790,8 +2797,8 @@ namespace overlay::windows {
|
|||||||
} else {
|
} else {
|
||||||
ImGui::TextColored(TEXT_COLOR_GREEN, "%s", definition.title.c_str());
|
ImGui::TextColored(TEXT_COLOR_GREEN, "%s", definition.title.c_str());
|
||||||
}
|
}
|
||||||
} else if (definition.hidden
|
} else if (definition.hidden ||
|
||||||
|| (!definition.game_name.empty() && definition.game_name != this->games_selected_name)) {
|
(!definition.game_name.empty() && definition.game_name != this->games_selected_name)) {
|
||||||
// wrong game - grayed out
|
// wrong game - grayed out
|
||||||
ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.f), "%s", definition.title.c_str());
|
ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.f), "%s", definition.title.c_str());
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ namespace overlay::windows {
|
|||||||
Button *button,
|
Button *button,
|
||||||
const GameAPI::Buttons::State button_state,
|
const GameAPI::Buttons::State button_state,
|
||||||
const float button_velocity);
|
const float button_velocity);
|
||||||
void clear_button(Button &button);
|
void clear_button(Button *button);
|
||||||
|
|
||||||
void build_analogs(const std::string &name, std::vector<Analog> *analogs);
|
void build_analogs(const std::string &name, std::vector<Analog> *analogs);
|
||||||
void edit_analog_popup(Analog &analog);
|
void edit_analog_popup(Analog &analog);
|
||||||
|
|||||||
Reference in New Issue
Block a user