mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-04-28 21:27:58 +03:00
remove color from UIWidgets::WidgetOptions (#5141)
This commit is contained in:
parent
0f81e6d82b
commit
7c227dcc42
8 changed files with 41 additions and 30 deletions
|
@ -303,21 +303,23 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me
|
|||
ImGui::Separator();
|
||||
} break;
|
||||
case WIDGET_SEPARATOR_TEXT: {
|
||||
if (widget.options->color != UIWidgets::Colors::NoColor) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(widget.options->color));
|
||||
auto options = std::static_pointer_cast<UIWidgets::TextOptions>(widget.options);
|
||||
if (options->color != UIWidgets::Colors::NoColor) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(options->color));
|
||||
}
|
||||
ImGui::SeparatorText(widget.name.c_str());
|
||||
if (widget.options->color != UIWidgets::Colors::NoColor) {
|
||||
if (options->color != UIWidgets::Colors::NoColor) {
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
} break;
|
||||
case WIDGET_TEXT: {
|
||||
if (widget.options->color != UIWidgets::Colors::NoColor) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(widget.options->color));
|
||||
auto options = std::static_pointer_cast<UIWidgets::TextOptions>(widget.options);
|
||||
if (options->color != UIWidgets::Colors::NoColor) {
|
||||
ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(options->color));
|
||||
}
|
||||
ImGui::AlignTextToFramePadding();
|
||||
ImGui::TextWrapped("%s", widget.name.c_str());
|
||||
if (widget.options->color != UIWidgets::Colors::NoColor) {
|
||||
if (options->color != UIWidgets::Colors::NoColor) {
|
||||
ImGui::PopStyleColor();
|
||||
}
|
||||
} break;
|
||||
|
|
|
@ -73,7 +73,7 @@ typedef enum {
|
|||
using CVarVariant = std::variant<int32_t, const char*, float, Color_RGBA8, Color_RGB8>;
|
||||
using OptionsVariant =
|
||||
std::variant<UIWidgets::ButtonOptions, UIWidgets::CheckboxOptions, UIWidgets::ComboboxOptions,
|
||||
UIWidgets::FloatSliderOptions, UIWidgets::IntSliderOptions, UIWidgets::WidgetOptions,
|
||||
UIWidgets::FloatSliderOptions, UIWidgets::IntSliderOptions, UIWidgets::TextOptions, UIWidgets::WidgetOptions,
|
||||
UIWidgets::WindowButtonOptions>;
|
||||
|
||||
// All the info needed for display and search of all widgets in the menu.
|
||||
|
@ -145,6 +145,8 @@ struct WidgetInfo {
|
|||
break;
|
||||
case WIDGET_TEXT:
|
||||
case WIDGET_SEPARATOR_TEXT:
|
||||
options = std::make_shared<UIWidgets::TextOptions>(std::get<UIWidgets::TextOptions>(options_));
|
||||
break;
|
||||
case WIDGET_SEPARATOR:
|
||||
default:
|
||||
options = std::make_shared<UIWidgets::WidgetOptions>(std::get<UIWidgets::WidgetOptions>(options_));
|
||||
|
|
|
@ -360,10 +360,10 @@ void RegisterResolutionWidgets() {
|
|||
WIDGET_TEXT)
|
||||
.PreFunc(
|
||||
[](WidgetInfo& info) { info.isHidden = !(!CVarGetInteger(CVAR_LOW_RES_MODE, 0) && IsDroppingFrames()); })
|
||||
.Options(WidgetOptions().Color(Colors::Orange));
|
||||
.Options(TextOptions().Color(Colors::Orange));
|
||||
mSohMenu->AddWidget(path, ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings.", WIDGET_TEXT)
|
||||
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_LOW_RES_MODE, 0); })
|
||||
.Options(WidgetOptions().Color(Colors::LightBlue));
|
||||
.Options(TextOptions().Color(Colors::LightBlue));
|
||||
mSohMenu->AddWidget(path, "Click to disable N64 mode", WIDGET_BUTTON)
|
||||
.PreFunc([](WidgetInfo& info) { info.isHidden = !CVarGetInteger(CVAR_LOW_RES_MODE, 0); })
|
||||
.Callback([](WidgetInfo& info) {
|
||||
|
@ -391,7 +391,7 @@ void RegisterResolutionWidgets() {
|
|||
}
|
||||
})
|
||||
.SameLine(true)
|
||||
.Options(WidgetOptions().Color(Colors::Gray));
|
||||
.Options(TextOptions().Color(Colors::Gray));
|
||||
// Presets
|
||||
mSohMenu->AddWidget(path, "Aspect Ratio", WIDGET_COMBOBOX)
|
||||
.ValuePointer(&item_aspectRatio)
|
||||
|
|
|
@ -64,10 +64,12 @@ WidgetInfo& SohMenu::AddWidget(WidgetPath& pathInfo, std::string widgetName, Wid
|
|||
case WIDGET_COLOR_24:
|
||||
case WIDGET_COLOR_32:
|
||||
break;
|
||||
case WIDGET_SEARCH:
|
||||
case WIDGET_SEPARATOR:
|
||||
case WIDGET_SEPARATOR_TEXT:
|
||||
case WIDGET_TEXT:
|
||||
widget.options = std::make_shared<TextOptions>();
|
||||
break;
|
||||
case WIDGET_SEARCH:
|
||||
case WIDGET_SEPARATOR:
|
||||
default:
|
||||
widget.options = std::make_shared<WidgetOptions>();
|
||||
}
|
||||
|
|
|
@ -1684,7 +1684,7 @@ void SohMenu::AddMenuEnhancements() {
|
|||
path.column = SECTION_COLUMN_3;
|
||||
AddWidget(path, "Save States", WIDGET_SEPARATOR_TEXT);
|
||||
AddWidget(path, ICON_FA_EXCLAMATION_TRIANGLE " WARNING!!!! " ICON_FA_EXCLAMATION_TRIANGLE, WIDGET_TEXT)
|
||||
.Options(WidgetOptions().Color(Colors::Orange));
|
||||
.Options(TextOptions().Color(Colors::Orange));
|
||||
AddWidget(path,
|
||||
"These are NOT like emulator states. They do not save your game progress "
|
||||
"and they WILL break across transitions and load zones (like doors). "
|
||||
|
|
|
@ -132,7 +132,7 @@ void SohMenu::AddMenuSettings() {
|
|||
.CVar(CVAR_SETTING("A11yDisableIdleCam"))
|
||||
.Options(CheckboxOptions().Tooltip("Disables the automatic re-centering of the camera when idle."));
|
||||
AddWidget(path, "EXPERIMENTAL", WIDGET_SEPARATOR_TEXT)
|
||||
.Options(WidgetOptions().Color(Colors::Orange));
|
||||
.Options(TextOptions().Color(Colors::Orange));
|
||||
AddWidget(path, "ImGui Menu Scaling", WIDGET_CVAR_COMBOBOX)
|
||||
.CVar(CVAR_SETTING("ImGuiScale"))
|
||||
.Options(ComboboxOptions().ComboMap(imguiScaleOptions).Tooltip("Changes the scaling of the ImGui menu elements.").DefaultIndex(1)
|
||||
|
|
|
@ -193,8 +193,8 @@ bool WindowButton(const char* label, const char* cvarName, std::shared_ptr<Ship:
|
|||
} else {
|
||||
buttonText = ICON_FA_EXTERNAL_LINK_SQUARE " " + buttonText;
|
||||
}
|
||||
if (Button(buttonText.c_str(), {{ options.tooltip, options.disabled, options.disabledTooltip, options.color },
|
||||
options.size, options.padding })) {
|
||||
if (Button(buttonText.c_str(), {{ options.tooltip, options.disabled, options.disabledTooltip },
|
||||
options.size, options.padding, options.color })) {
|
||||
windowPtr->ToggleVisibility();
|
||||
dirty = true;
|
||||
}
|
||||
|
|
|
@ -122,12 +122,7 @@ namespace UIWidgets {
|
|||
const char* tooltip = "";
|
||||
bool disabled = false;
|
||||
const char* disabledTooltip = "";
|
||||
Colors color = Colors::NoColor;
|
||||
|
||||
WidgetOptions& Color(Colors color_) {
|
||||
color = color = color_;
|
||||
return *this;
|
||||
}
|
||||
WidgetOptions& Tooltip(const char* tooltip_) {
|
||||
tooltip = tooltip_;
|
||||
return *this;
|
||||
|
@ -142,6 +137,15 @@ namespace UIWidgets {
|
|||
}
|
||||
};
|
||||
|
||||
struct TextOptions : WidgetOptions {
|
||||
Colors color = Colors::NoColor;
|
||||
|
||||
TextOptions& Color(Colors color_) {
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct ButtonOptions : WidgetOptions {
|
||||
ImVec2 size = Sizes::Fill;
|
||||
ImVec2 padding = ImVec2(10.0f, 8.0f);
|
||||
|
@ -160,7 +164,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
ButtonOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
@ -185,7 +189,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
WindowButtonOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
WindowButtonOptions& ShowButton(bool showButton_) {
|
||||
|
@ -202,7 +206,7 @@ namespace UIWidgets {
|
|||
bool defaultValue = false; // Only applicable to CVarCheckbox
|
||||
ComponentAlignment alignment = ComponentAlignment::Left;
|
||||
LabelPosition labelPosition = LabelPosition::Near;
|
||||
Colors color = WidgetOptions::color = Colors::LightBlue;
|
||||
Colors color = Colors::LightBlue;
|
||||
|
||||
CheckboxOptions& DefaultValue(bool defaultValue_) {
|
||||
defaultValue = defaultValue_;
|
||||
|
@ -221,7 +225,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
CheckboxOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
CheckboxOptions& DisabledTooltip(const char* disabledTooltip_) {
|
||||
|
@ -259,7 +263,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
ComboboxOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
@ -315,7 +319,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
IntSliderOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
IntSliderOptions& Size(ImVec2 size_) {
|
||||
|
@ -387,7 +391,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
FloatSliderOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
FloatSliderOptions& Size(ImVec2 size_) {
|
||||
|
@ -402,6 +406,7 @@ namespace UIWidgets {
|
|||
|
||||
struct RadioButtonsOptions : WidgetOptions {
|
||||
std::unordered_map<int32_t, const char*> buttonMap;
|
||||
Colors color = Colors::LightBlue;
|
||||
|
||||
RadioButtonsOptions& ButtonMap(std::unordered_map<int32_t, const char*> buttonMap_) {
|
||||
buttonMap = buttonMap_;
|
||||
|
@ -412,7 +417,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
RadioButtonsOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
@ -433,7 +438,7 @@ namespace UIWidgets {
|
|||
return *this;
|
||||
}
|
||||
InputOptions& Color(Colors color_) {
|
||||
WidgetOptions::color = color = color_;
|
||||
color = color_;
|
||||
return *this;
|
||||
}
|
||||
InputOptions& Size(ImVec2 size_) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue