diff --git a/src/spice2x/cfg/config.cpp b/src/spice2x/cfg/config.cpp index 9f2d4fb..27a56ef 100644 --- a/src/spice2x/cfg/config.cpp +++ b/src/spice2x/cfg/config.cpp @@ -11,6 +11,14 @@ // settings 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 /// @@ -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 // delete the node for to_delete 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); 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 // delete the node for to_delete 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); to_delete = nullptr; } diff --git a/src/spice2x/overlay/windows/config.cpp b/src/spice2x/overlay/windows/config.cpp index 44f41bf..16d423c 100644 --- a/src/spice2x/overlay/windows/config.cpp +++ b/src/spice2x/overlay/windows/config.cpp @@ -650,25 +650,30 @@ namespace overlay::windows { // column for key binding display ImGui::TableNextColumn(); ImGui::AlignTextToFramePadding(); - 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)); - ImGui::TextUnformatted(button_text.c_str()); - if (button_state) { - ImGui::PopStyleColor(); - } - if (ImGui::IsItemHovered() && button_display.size() > 0) { - ImGui::SameLine(); - ImGui::HelpTooltip(button_display.c_str()); + if (button_display.size() > 0) { + 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)); + ImGui::TextUnformatted(button_text.c_str()); + if (button_state) { + ImGui::PopStyleColor(); + } + if (ImGui::IsItemHovered()) { + ImGui::SameLine(); + ImGui::HelpTooltip(button_display.c_str()); + } + } else { + // placeholder + ImGui::TextDisabled("-"); } // clear button if (button_display.size() > 0) { ImGui::SameLine(); if (ImGui::DeleteButton("Unbind")) { - clear_button(*button); + clear_button(button); } } @@ -776,18 +781,18 @@ namespace overlay::windows { ImGui::PopID(); } - void Config::clear_button(Button &button) { - button.setDeviceIdentifier(""); - button.setVKey(0xFF); - button.setAnalogType(BAT_NONE); - button.setDebounceUp(0.0); - button.setDebounceDown(0.0); - button.setVelocityThreshold(0); - button.setInvert(false); - button.setLastState(GameAPI::Buttons::BUTTON_NOT_PRESSED); - button.setLastVelocity(0); + void Config::clear_button(Button *button) { + button->setDeviceIdentifier(""); + button->setVKey(0xFF); + button->setAnalogType(BAT_NONE); + button->setDebounceUp(0.0); + button->setDebounceDown(0.0); + button->setVelocityThreshold(0); + button->setInvert(false); + button->setLastState(GameAPI::Buttons::BUTTON_NOT_PRESSED); + button->setLastVelocity(0); ::Config::getInstance().updateBinding( - games_list[games_selected], button, + games_list[games_selected], *button, buttons_page - 1); } @@ -1742,12 +1747,16 @@ namespace overlay::windows { ImGui::TableNextColumn(); ImGui::AlignTextToFramePadding(); - std::string analog_text = ImGui::TruncateText( - analog_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20)); - ImGui::TextUnformatted(analog_text.c_str()); - if (ImGui::IsItemHovered() && analog_display.size() > 0) { - ImGui::SameLine(); - ImGui::HelpTooltip(analog_display.c_str()); + if (analog_display.size() > 0) { + std::string analog_text = ImGui::TruncateText( + analog_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20)); + ImGui::TextUnformatted(analog_text.c_str()); + if (ImGui::IsItemHovered()) { + ImGui::SameLine(); + ImGui::HelpTooltip(analog_display.c_str()); + } + } else { + ImGui::TextDisabled("-"); } // clear analog @@ -2191,9 +2200,6 @@ namespace overlay::windows { auto light_state = GameAPI::Lights::readLight(RI_MGR, *light); // list entry - if (light_display.empty()) { - ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.7f, 0.7f, 0.7f, 1.f)); - } ImGui::PushID(light); ImGui::TableNextRow(); @@ -2206,12 +2212,16 @@ namespace overlay::windows { // binding name ImGui::TableNextColumn(); ImGui::AlignTextToFramePadding(); - std::string light_text = ImGui::TruncateText( - light_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20)); - ImGui::TextUnformatted(light_text.c_str()); - if (ImGui::IsItemHovered() && light_display.size() > 0) { - ImGui::SameLine(); - ImGui::HelpTooltip(light_display.c_str()); + if (light_display.size() > 0) { + std::string light_text = ImGui::TruncateText( + light_display, ImGui::GetContentRegionAvail().x - overlay::apply_scaling(20)); + ImGui::TextUnformatted(light_text.c_str()); + if (ImGui::IsItemHovered()) { + ImGui::SameLine(); + ImGui::HelpTooltip(light_display.c_str()); + } + } else { + ImGui::TextDisabled("-"); } // clear light @@ -2228,9 +2238,6 @@ namespace overlay::windows { // bind button ImGui::TableNextColumn(); - if (light_display.empty()) { - ImGui::PopStyleColor(); - } // light binding if (ImGui::Button("Set")) { @@ -2790,8 +2797,8 @@ namespace overlay::windows { } else { ImGui::TextColored(TEXT_COLOR_GREEN, "%s", definition.title.c_str()); } - } else if (definition.hidden - || (!definition.game_name.empty() && definition.game_name != this->games_selected_name)) { + } else if (definition.hidden || + (!definition.game_name.empty() && definition.game_name != this->games_selected_name)) { // wrong game - grayed out ImGui::TextColored(ImVec4(0.5f, 0.5f, 0.5f, 1.f), "%s", definition.title.c_str()); } else { diff --git a/src/spice2x/overlay/windows/config.h b/src/spice2x/overlay/windows/config.h index dc6f3b2..fe6f2de 100644 --- a/src/spice2x/overlay/windows/config.h +++ b/src/spice2x/overlay/windows/config.h @@ -88,7 +88,7 @@ namespace overlay::windows { Button *button, const GameAPI::Buttons::State button_state, const float button_velocity); - void clear_button(Button &button); + void clear_button(Button *button); void build_analogs(const std::string &name, std::vector *analogs); void edit_analog_popup(Analog &analog);