2022-09-03 00:00:04 -04:00
|
|
|
//
|
|
|
|
// UIWidgets.cpp
|
|
|
|
// soh
|
|
|
|
//
|
|
|
|
// Created by David Chavez on 25.08.22.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "UIWidgets.hpp"
|
|
|
|
|
|
|
|
#define IMGUI_DEFINE_MATH_OPERATORS
|
|
|
|
#include <ImGui/imgui_internal.h>
|
2022-11-14 05:22:34 -05:00
|
|
|
#include <ImGuiImpl.h>
|
2023-01-17 00:17:49 -05:00
|
|
|
#include <libultraship/bridge.h>
|
2022-09-03 00:00:04 -04:00
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
#include <libultraship/libultra/types.h>
|
2022-09-21 00:17:04 -04:00
|
|
|
#include "soh/Enhancements/cosmetics/CosmeticsEditor.h"
|
2022-09-03 00:00:04 -04:00
|
|
|
|
|
|
|
namespace UIWidgets {
|
|
|
|
|
|
|
|
// MARK: - Layout Helper
|
|
|
|
|
|
|
|
// Automatically adds newlines to break up text longer than a specified number of characters
|
|
|
|
// Manually included newlines will still be respected and reset the line length
|
|
|
|
// If line is midword when it hits the limit, text should break at the last encountered space
|
|
|
|
char* WrappedText(const char* text, unsigned int charactersPerLine) {
|
|
|
|
std::string newText(text);
|
|
|
|
const size_t tipLength = newText.length();
|
|
|
|
int lastSpace = -1;
|
2022-09-03 05:16:43 -04:00
|
|
|
int currentLineLength = 0;
|
2022-09-03 00:00:04 -04:00
|
|
|
for (unsigned int currentCharacter = 0; currentCharacter < tipLength; currentCharacter++) {
|
|
|
|
if (newText[currentCharacter] == '\n') {
|
|
|
|
currentLineLength = 0;
|
|
|
|
lastSpace = -1;
|
|
|
|
continue;
|
|
|
|
} else if (newText[currentCharacter] == ' ') {
|
|
|
|
lastSpace = currentCharacter;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((currentLineLength >= charactersPerLine) && (lastSpace >= 0)) {
|
|
|
|
newText[lastSpace] = '\n';
|
|
|
|
currentLineLength = currentCharacter - lastSpace - 1;
|
|
|
|
lastSpace = -1;
|
|
|
|
}
|
|
|
|
currentLineLength++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return strdup(newText.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
char* WrappedText(const std::string& text, unsigned int charactersPerLine) {
|
|
|
|
return WrappedText(text.c_str(), charactersPerLine);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha)
|
|
|
|
{
|
|
|
|
Color_RGBA8 defaultColors;
|
|
|
|
defaultColors.r = default_colors.x;
|
|
|
|
defaultColors.g = default_colors.y;
|
|
|
|
defaultColors.b = default_colors.z;
|
|
|
|
defaultColors.a = default_colors.w;
|
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
Color_RGBA8 cvarColor = CVarGetColor(cvarname, defaultColors);
|
2022-09-03 00:00:04 -04:00
|
|
|
|
|
|
|
ColorArray.x = cvarColor.r / 255.0;
|
|
|
|
ColorArray.y = cvarColor.g / 255.0;
|
|
|
|
ColorArray.z = cvarColor.b / 255.0;
|
|
|
|
ColorArray.w = cvarColor.a / 255.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetLastItemHoverText(const std::string& text) {
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
ImGui::BeginTooltip();
|
|
|
|
ImGui::Text("%s", WrappedText(text, 60));
|
|
|
|
ImGui::EndTooltip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-07 00:28:35 -05:00
|
|
|
void SetLastItemHoverText(const char* text) {
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
ImGui::BeginTooltip();
|
|
|
|
ImGui::Text("%s", WrappedText(text, 60));
|
|
|
|
ImGui::EndTooltip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
// Adds a "?" next to the previous ImGui item with a custom tooltip
|
|
|
|
void InsertHelpHoverText(const std::string& text) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?");
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
ImGui::BeginTooltip();
|
|
|
|
ImGui::Text("%s", WrappedText(text, 60));
|
|
|
|
ImGui::EndTooltip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-07 00:28:35 -05:00
|
|
|
void InsertHelpHoverText(const char* text) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?");
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
ImGui::BeginTooltip();
|
|
|
|
ImGui::Text("%s", WrappedText(text, 60));
|
|
|
|
ImGui::EndTooltip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
|
|
|
|
// MARK: - UI Elements
|
|
|
|
|
|
|
|
void Tooltip(const char* text) {
|
|
|
|
if (ImGui::IsItemHovered()) {
|
|
|
|
ImGui::SetTooltip("%s", WrappedText(text));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Spacer(float height) {
|
|
|
|
ImGui::Dummy(ImVec2(0.0f, height));
|
|
|
|
}
|
|
|
|
|
|
|
|
void PaddedSeparator(bool padTop, bool padBottom, float extraVerticalTopPadding, float extraVerticalBottomPadding) {
|
|
|
|
if (padTop)
|
|
|
|
Spacer(0);
|
|
|
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
if (padBottom)
|
|
|
|
Spacer(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) {
|
|
|
|
float thickness = ImMax(sz / 5.0f, 1.0f);
|
|
|
|
sz -= thickness * 0.5f;
|
|
|
|
pos += ImVec2(thickness * 0.25f, thickness * 0.25f);
|
|
|
|
|
|
|
|
draw_list->PathLineTo(ImVec2(pos.x, pos.y));
|
|
|
|
draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y + sz));
|
|
|
|
draw_list->PathStroke(col, 0, thickness);
|
|
|
|
|
|
|
|
draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y));
|
|
|
|
draw_list->PathLineTo(ImVec2(pos.x, pos.y + sz));
|
|
|
|
draw_list->PathStroke(col, 0, thickness);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic) {
|
|
|
|
ImGuiWindow* window = ImGui::GetCurrentWindow();
|
|
|
|
if (window->SkipItems)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
const ImGuiStyle& style = g.Style;
|
|
|
|
const ImGuiID id = window->GetID(label);
|
|
|
|
const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true);
|
|
|
|
|
|
|
|
const float square_sz = ImGui::GetFrameHeight();
|
|
|
|
const ImVec2 pos = window->DC.CursorPos;
|
|
|
|
const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f));
|
|
|
|
ImGui::ItemSize(total_bb, style.FramePadding.y);
|
|
|
|
if (!ImGui::ItemAdd(total_bb, id)) {
|
|
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool hovered, held;
|
|
|
|
bool pressed = ImGui::ButtonBehavior(total_bb, id, &hovered, &held);
|
|
|
|
if (pressed) {
|
|
|
|
*v = !(*v);
|
|
|
|
ImGui::MarkItemEdited(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz));
|
|
|
|
ImGui::RenderNavHighlight(total_bb, id);
|
|
|
|
ImGui::RenderFrame(check_bb.Min, check_bb.Max, ImGui::GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding);
|
|
|
|
ImU32 check_col = ImGui::GetColorU32(ImGuiCol_CheckMark);
|
|
|
|
ImU32 cross_col = ImGui::GetColorU32(ImVec4(0.50f, 0.50f, 0.50f, 1.00f));
|
|
|
|
bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0;
|
|
|
|
if (mixed_value) {
|
|
|
|
// Undocumented tristate/mixed/indeterminate checkbox (#2644)
|
|
|
|
// This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox)
|
|
|
|
ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)));
|
|
|
|
window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding);
|
|
|
|
} else if ((!disabled && *v) || (disabled && disabledGraphic == CheckboxGraphics::Checkmark)) {
|
|
|
|
const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f));
|
|
|
|
ImGui::RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f);
|
|
|
|
} else if (disabled && disabledGraphic == CheckboxGraphics::Cross) {
|
|
|
|
const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f));
|
|
|
|
RenderCross(window->DrawList, check_bb.Min + ImVec2(pad, pad), cross_col, square_sz - pad * 2.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y);
|
|
|
|
if (g.LogEnabled)
|
|
|
|
ImGui::LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]");
|
|
|
|
if (label_size.x > 0.0f)
|
|
|
|
ImGui::RenderText(label_pos, label);
|
|
|
|
|
|
|
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0));
|
|
|
|
return pressed;
|
|
|
|
}
|
|
|
|
|
2022-12-10 15:36:17 -05:00
|
|
|
bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) {
|
2022-10-17 11:26:14 -04:00
|
|
|
bool changed = false;
|
2022-09-03 00:00:04 -04:00
|
|
|
if (disabled) {
|
|
|
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
|
|
|
|
}
|
2023-01-17 00:17:49 -05:00
|
|
|
bool val = (bool)CVarGetInteger(cvarName, defaultValue);
|
2022-09-03 00:00:04 -04:00
|
|
|
if (CustomCheckbox(text, &val, disabled, disabledGraphic)) {
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-10-17 11:26:14 -04:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
ImGui::PopStyleVar(1);
|
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) {
|
|
|
|
ImGui::SetTooltip("%s", disabledTooltipText);
|
|
|
|
}
|
|
|
|
ImGui::PopItemFlag();
|
|
|
|
}
|
2022-10-17 11:26:14 -04:00
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
2022-12-10 15:36:17 -05:00
|
|
|
bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) {
|
2022-10-17 11:26:14 -04:00
|
|
|
bool changed = false;
|
2022-09-03 00:00:04 -04:00
|
|
|
if (padTop) Spacer(0);
|
|
|
|
|
2022-12-10 15:36:17 -05:00
|
|
|
if (EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic, defaultValue)) {
|
2022-10-17 11:26:14 -04:00
|
|
|
changed = true;
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
|
|
|
|
if (padBottom) Spacer(0);
|
2022-10-17 11:26:14 -04:00
|
|
|
|
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void EnhancementCombo(const std::string& name, const char* cvarName, const std::vector<std::string>& items, int defaultValue) {
|
2023-01-17 00:17:49 -05:00
|
|
|
if (ImGui::BeginCombo(name.c_str(), items[static_cast<int>(CVarGetInteger(cvarName, defaultValue))].c_str())) {
|
2022-09-03 00:00:04 -04:00
|
|
|
for (int settingIndex = 0; settingIndex < (int) items.size(); settingIndex++) {
|
|
|
|
if (ImGui::Selectable(items[settingIndex].c_str())) {
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, settingIndex);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-06 16:07:58 -05:00
|
|
|
bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue) {
|
|
|
|
bool changed = false;
|
2022-09-03 00:00:04 -04:00
|
|
|
if (FirstTimeValue <= 0) {
|
|
|
|
FirstTimeValue = 0;
|
|
|
|
}
|
2023-01-17 00:17:49 -05:00
|
|
|
uint8_t selected = CVarGetInteger(name, FirstTimeValue);
|
2022-09-03 00:00:04 -04:00
|
|
|
uint8_t DefaultValue = selected;
|
|
|
|
std::string comboName = std::string("##") + std::string(name);
|
|
|
|
if (ImGui::BeginCombo(comboName.c_str(), ComboArray[DefaultValue])) {
|
|
|
|
for (uint8_t i = 0; i < arraySize; i++) {
|
|
|
|
if (strlen(ComboArray[i]) > 1) {
|
|
|
|
if (ImGui::Selectable(ComboArray[i], i == selected)) {
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(name, i);
|
2022-09-03 00:00:04 -04:00
|
|
|
selected = i;
|
2022-11-06 16:07:58 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::EndCombo();
|
|
|
|
}
|
2022-11-06 16:07:58 -05:00
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void PaddedText(const char* text, bool padTop, bool padBottom) {
|
|
|
|
if (padTop)
|
|
|
|
Spacer(0);
|
|
|
|
|
|
|
|
ImGui::Text("%s", text);
|
|
|
|
|
|
|
|
if (padBottom)
|
|
|
|
Spacer(0);
|
|
|
|
}
|
|
|
|
|
2022-11-18 18:55:22 -05:00
|
|
|
void DisableComponentSwitch(const char* disabledTooltipText, const float alpha) {
|
|
|
|
// End of disable region of previous component
|
|
|
|
ImGui::PopStyleVar(1);
|
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) {
|
|
|
|
ImGui::SetTooltip("%s", disabledTooltipText);
|
|
|
|
}
|
|
|
|
ImGui::PopItemFlag();
|
|
|
|
|
|
|
|
// Start of disable region of next component
|
|
|
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
|
|
|
}
|
|
|
|
|
2022-12-08 23:24:39 -05:00
|
|
|
bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) {
|
|
|
|
bool changed = false;
|
2023-01-17 00:17:49 -05:00
|
|
|
int val = CVarGetInteger(cvarName, defaultValue);
|
2022-11-18 18:55:22 -05:00
|
|
|
|
|
|
|
float alpha;
|
|
|
|
if (disabled) {
|
|
|
|
alpha = ImGui::GetStyle().Alpha * 0.5f;
|
|
|
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha);
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
ImGui::Text(text, val);
|
2022-11-23 16:14:11 -05:00
|
|
|
Spacer(0);
|
2022-11-18 18:55:22 -05:00
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
DisableComponentSwitch(disabledTooltipText, alpha);
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
if(PlusMinusButton) {
|
|
|
|
std::string MinusBTNName = " - ##";
|
|
|
|
MinusBTNName += cvarName;
|
|
|
|
if (ImGui::Button(MinusBTNName.c_str())) {
|
|
|
|
val--;
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
2022-11-18 18:55:22 -05:00
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
DisableComponentSwitch(disabledTooltipText, alpha);
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
2022-11-23 16:14:11 -05:00
|
|
|
if (PlusMinusButton) {
|
|
|
|
#ifdef __SWITCH__
|
|
|
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 110.0f);
|
|
|
|
#elif defined(__WIIU__)
|
|
|
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
|
|
|
#else
|
|
|
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
|
|
|
#endif
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
if (ImGui::SliderInt(id, &val, min, max, format))
|
|
|
|
{
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
2022-11-23 16:14:11 -05:00
|
|
|
if (PlusMinusButton) {
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
if(PlusMinusButton) {
|
2022-11-18 18:55:22 -05:00
|
|
|
if (disabled) {
|
|
|
|
DisableComponentSwitch(disabledTooltipText, alpha);
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
std::string PlusBTNName = " + ##";
|
|
|
|
PlusBTNName += cvarName;
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
|
|
|
if (ImGui::Button(PlusBTNName.c_str())) {
|
|
|
|
val++;
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 18:55:22 -05:00
|
|
|
if (disabled) {
|
|
|
|
ImGui::PopStyleVar(1);
|
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) {
|
|
|
|
ImGui::SetTooltip("%s", disabledTooltipText);
|
|
|
|
}
|
|
|
|
ImGui::PopItemFlag();
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
if (val < min)
|
|
|
|
{
|
|
|
|
val = min;
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (val > max)
|
|
|
|
{
|
|
|
|
val = max;
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
2022-12-08 23:24:39 -05:00
|
|
|
|
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
2022-12-08 23:24:39 -05:00
|
|
|
bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) {
|
|
|
|
bool changed = false;
|
2023-01-17 00:17:49 -05:00
|
|
|
float val = CVarGetFloat(cvarName, defaultValue);
|
2022-09-03 00:00:04 -04:00
|
|
|
|
2022-11-18 18:55:22 -05:00
|
|
|
if (disabled) {
|
|
|
|
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
|
|
|
|
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
|
|
|
|
}
|
|
|
|
|
2022-09-27 19:30:50 -04:00
|
|
|
if (!isPercentage) {
|
2022-09-03 00:00:04 -04:00
|
|
|
ImGui::Text(text, val);
|
2022-09-27 19:30:50 -04:00
|
|
|
} else {
|
2022-09-03 00:00:04 -04:00
|
|
|
ImGui::Text(text, static_cast<int>(100 * val));
|
2022-09-27 19:30:50 -04:00
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
Spacer(0);
|
|
|
|
if(PlusMinusButton) {
|
|
|
|
std::string MinusBTNName = " - ##";
|
|
|
|
MinusBTNName += cvarName;
|
|
|
|
if (ImGui::Button(MinusBTNName.c_str())) {
|
2022-09-27 19:30:50 -04:00
|
|
|
if (!isPercentage) {
|
2022-09-03 00:00:04 -04:00
|
|
|
val -= 0.1f;
|
2022-09-27 19:30:50 -04:00
|
|
|
} else {
|
2022-09-03 00:00:04 -04:00
|
|
|
val -= 0.01f;
|
2022-09-27 19:30:50 -04:00
|
|
|
}
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetFloat(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
|
|
|
}
|
|
|
|
if (PlusMinusButton) {
|
2022-09-15 16:48:51 -04:00
|
|
|
#ifdef __SWITCH__
|
2022-09-13 20:47:00 -04:00
|
|
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 110.0f);
|
2022-09-27 19:29:55 -04:00
|
|
|
#elif defined(__WIIU__)
|
2022-09-15 16:48:51 -04:00
|
|
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f * 2);
|
2022-09-13 20:47:00 -04:00
|
|
|
#else
|
2022-09-03 00:00:04 -04:00
|
|
|
ImGui::PushItemWidth(ImGui::GetWindowSize().x - 79.0f);
|
2022-09-13 20:47:00 -04:00
|
|
|
#endif
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
2022-09-27 19:30:50 -04:00
|
|
|
if (ImGui::SliderFloat(id, &val, min, max, format)) {
|
|
|
|
if (isPercentage) {
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetFloat(cvarName, roundf(val * 100) / 100);
|
2022-09-27 19:30:50 -04:00
|
|
|
} else {
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetFloat(cvarName, val);
|
2022-09-27 19:30:50 -04:00
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
if (PlusMinusButton) {
|
|
|
|
ImGui::PopItemWidth();
|
|
|
|
}
|
|
|
|
if(PlusMinusButton) {
|
|
|
|
std::string PlusBTNName = " + ##";
|
|
|
|
PlusBTNName += cvarName;
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f);
|
|
|
|
if (ImGui::Button(PlusBTNName.c_str())) {
|
2022-09-27 19:30:50 -04:00
|
|
|
if (!isPercentage) {
|
2022-09-03 00:00:04 -04:00
|
|
|
val += 0.1f;
|
2022-09-27 19:30:50 -04:00
|
|
|
} else {
|
2022-09-03 00:00:04 -04:00
|
|
|
val += 0.01f;
|
2022-09-27 19:30:50 -04:00
|
|
|
}
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetFloat(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-18 18:55:22 -05:00
|
|
|
if (disabled) {
|
|
|
|
ImGui::PopStyleVar(1);
|
|
|
|
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) {
|
|
|
|
ImGui::SetTooltip("%s", disabledTooltipText);
|
|
|
|
}
|
|
|
|
ImGui::PopItemFlag();
|
|
|
|
}
|
|
|
|
|
2022-09-27 19:30:50 -04:00
|
|
|
if (val < min) {
|
2022-09-03 00:00:04 -04:00
|
|
|
val = min;
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetFloat(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
2022-09-27 19:30:50 -04:00
|
|
|
if (val > max) {
|
2022-09-03 00:00:04 -04:00
|
|
|
val = max;
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetFloat(cvarName, val);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-12-08 23:24:39 -05:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
2022-12-08 23:24:39 -05:00
|
|
|
|
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
2022-11-18 18:55:22 -05:00
|
|
|
void PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) {
|
2022-09-03 00:00:04 -04:00
|
|
|
if (padTop)
|
|
|
|
Spacer(0);
|
|
|
|
|
2022-11-18 18:55:22 -05:00
|
|
|
EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton, disabled, disabledTooltipText);
|
2022-09-03 00:00:04 -04:00
|
|
|
|
|
|
|
if (padBottom)
|
|
|
|
Spacer(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EnhancementRadioButton(const char* text, const char* cvarName, int id) {
|
|
|
|
/*Usage :
|
|
|
|
EnhancementRadioButton("My Visible Name","gMyCVarName", MyID);
|
|
|
|
First arg is the visible name of the Radio button
|
|
|
|
Second is the cvar name where MyID will be saved.
|
|
|
|
Note: the CVar name should be the same to each Buddies.
|
|
|
|
Example :
|
2022-12-06 00:36:53 -05:00
|
|
|
EnhancementRadioButton("English", "gLanguages", LANGUAGE_ENG);
|
|
|
|
EnhancementRadioButton("German", "gLanguages", LANGUAGE_GER);
|
|
|
|
EnhancementRadioButton("French", "gLanguages", LANGUAGE_FRA);
|
2022-09-03 00:00:04 -04:00
|
|
|
*/
|
|
|
|
std::string make_invisible = "##";
|
|
|
|
make_invisible += text;
|
|
|
|
make_invisible += cvarName;
|
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
int val = CVarGetInteger(cvarName, 0);
|
2022-09-03 00:00:04 -04:00
|
|
|
if (ImGui::RadioButton(make_invisible.c_str(), id == val)) {
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetInteger(cvarName, id);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
|
|
|
}
|
|
|
|
ImGui::SameLine();
|
|
|
|
ImGui::Text("%s", text);
|
|
|
|
}
|
|
|
|
|
2022-10-17 11:26:14 -04:00
|
|
|
bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha) {
|
|
|
|
bool changed = false;
|
2022-09-03 00:00:04 -04:00
|
|
|
std::string Cvar_RBM = cvarName;
|
|
|
|
Cvar_RBM += "RBM";
|
|
|
|
std::string MakeInvisible = "Reset";
|
|
|
|
MakeInvisible += "##";
|
|
|
|
MakeInvisible += cvarName;
|
|
|
|
MakeInvisible += "Reset";
|
|
|
|
if (ImGui::Button(MakeInvisible.c_str())) {
|
|
|
|
colors->x = defaultcolors.x;
|
|
|
|
colors->y = defaultcolors.y;
|
|
|
|
colors->z = defaultcolors.z;
|
2022-12-12 23:40:27 -05:00
|
|
|
colors->w = has_alpha ? defaultcolors.w : 255.0f;
|
2022-09-03 00:00:04 -04:00
|
|
|
|
|
|
|
Color_RGBA8 colorsRGBA;
|
|
|
|
colorsRGBA.r = defaultcolors.x;
|
|
|
|
colorsRGBA.g = defaultcolors.y;
|
|
|
|
colorsRGBA.b = defaultcolors.z;
|
2022-12-12 23:40:27 -05:00
|
|
|
colorsRGBA.a = has_alpha ? defaultcolors.w : 255.0f;
|
2022-09-03 00:00:04 -04:00
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetColor(cvarName, colorsRGBA);
|
|
|
|
CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode.
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-10-17 11:26:14 -04:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color");
|
2022-10-17 11:26:14 -04:00
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
2022-10-17 11:26:14 -04:00
|
|
|
bool DrawRandomizeColorButton(const char* cvarName, ImVec4* colors) {
|
|
|
|
bool changed = false;
|
2022-09-03 00:00:04 -04:00
|
|
|
Color_RGBA8 NewColors = {0,0,0,255};
|
|
|
|
std::string Cvar_RBM = cvarName;
|
|
|
|
Cvar_RBM += "RBM";
|
|
|
|
std::string MakeInvisible = "##";
|
|
|
|
MakeInvisible += cvarName;
|
|
|
|
MakeInvisible += "Random";
|
|
|
|
std::string FullName = "Random";
|
|
|
|
FullName += MakeInvisible;
|
|
|
|
if (ImGui::Button(FullName.c_str())) {
|
2022-09-27 19:29:55 -04:00
|
|
|
#if defined(__SWITCH__) || defined(__WIIU__)
|
2022-09-21 00:17:04 -04:00
|
|
|
srand(time(NULL));
|
2022-09-27 19:29:55 -04:00
|
|
|
#endif
|
2022-09-21 00:17:04 -04:00
|
|
|
ImVec4 color = GetRandomValue(255);
|
|
|
|
colors->x = color.x;
|
|
|
|
colors->y = color.y;
|
|
|
|
colors->z = color.z;
|
|
|
|
NewColors.r = fmin(fmax(colors->x * 255, 0), 255);
|
|
|
|
NewColors.g = fmin(fmax(colors->y * 255, 0), 255);
|
|
|
|
NewColors.b = fmin(fmax(colors->z * 255, 0), 255);
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetColor(cvarName, NewColors);
|
|
|
|
CVarSetInteger(Cvar_RBM.c_str(), 0); // On click disable rainbow mode.
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-10-17 11:26:14 -04:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
Tooltip("Chooses a random color\nOverwrites previously chosen color");
|
2022-10-17 11:26:14 -04:00
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
|
2022-10-21 00:05:08 -04:00
|
|
|
void DrawLockColorCheckbox(const char* cvarName) {
|
|
|
|
std::string Cvar_Lock = cvarName;
|
|
|
|
Cvar_Lock += "Lock";
|
2023-01-17 00:17:49 -05:00
|
|
|
s32 lock = CVarGetInteger(Cvar_Lock.c_str(), 0);
|
2022-10-21 00:05:08 -04:00
|
|
|
std::string FullName = "Lock##" + Cvar_Lock;
|
|
|
|
EnhancementCheckbox(FullName.c_str(), Cvar_Lock.c_str());
|
|
|
|
Tooltip("Prevents this color from being changed upon selecting \"Randomize all\"");
|
|
|
|
}
|
|
|
|
|
2022-09-03 00:00:04 -04:00
|
|
|
void RainbowColor(const char* cvarName, ImVec4* colors) {
|
|
|
|
std::string Cvar_RBM = cvarName;
|
|
|
|
Cvar_RBM += "RBM";
|
|
|
|
std::string MakeInvisible = "Rainbow";
|
|
|
|
MakeInvisible += "##";
|
|
|
|
MakeInvisible += cvarName;
|
|
|
|
MakeInvisible += "Rainbow";
|
|
|
|
|
|
|
|
EnhancementCheckbox(MakeInvisible.c_str(), Cvar_RBM.c_str());
|
|
|
|
Tooltip("Cycles through colors on a timer\nOverwrites previously chosen color");
|
|
|
|
}
|
|
|
|
|
2022-10-17 11:26:14 -04:00
|
|
|
bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow, bool has_alpha, bool TitleSameLine) {
|
|
|
|
bool changed = false;
|
2022-09-03 00:00:04 -04:00
|
|
|
LoadPickersColors(ColorRGBA, cvarName, default_colors, has_alpha);
|
|
|
|
|
|
|
|
ImGuiColorEditFlags flags = ImGuiColorEditFlags_None;
|
|
|
|
|
|
|
|
if (!TitleSameLine) {
|
|
|
|
ImGui::Text("%s", text);
|
|
|
|
flags = ImGuiColorEditFlags_NoLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::PushID(cvarName);
|
|
|
|
|
|
|
|
if (!has_alpha) {
|
|
|
|
if (ImGui::ColorEdit3(text, (float*)&ColorRGBA, flags))
|
|
|
|
{
|
|
|
|
Color_RGBA8 colors;
|
|
|
|
colors.r = ColorRGBA.x * 255.0;
|
|
|
|
colors.g = ColorRGBA.y * 255.0;
|
|
|
|
colors.b = ColorRGBA.z * 255.0;
|
2022-12-12 23:40:27 -05:00
|
|
|
colors.a = 255.0;
|
2022-09-03 00:00:04 -04:00
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetColor(cvarName, colors);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-10-17 11:26:14 -04:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Randomizer Auto Location tracker (#1942)
* Initial Auto-Location Tracking
* Updates styling for checked items in Check Tracker
* Fixes crashing issues with Check Tracker rendering
* Auto scroll Check Tracker windows to current area
* Checks Tracker only shows checked locations once in game
* Fixes issue where Check Tracker would auto-scroll to wrong location when entering a grotto
* Fixes gerudo fortress checks showing in tracker when settings have them removed
* InfTable Check Location Fixes: Lost Dog Richard, Rolling Gorons, HBA 1000, Thawed Zora
* Fixes most Event Chk Inf Checks on Check Tracker, and Frogs
* Check Tracker - Song from Malon now works
* Check Tracker
- Fixes Claim Check check not tracking
- Fixes spoiler for Claim Check check when getting Biggoron's Sword
- Fixes LACS being spoiled and not tracking
* Check Tracker - Fixes #2 for Skull Mask and Mask of Truth checks
* Check Tracker
- Adds support for merchants
- Fixes #7 for Bomchu Salesman
- Fixes #12 for Medigoron
* Check Tracker - Fixes #8 for Song from Saria
* Check Tracker - Fixes #9 for Adult Shooting Gallery
* Check Tracker - Fixes #10 for Composer Grave
* Check Tracker - Fixes #14 for Song from Ocarina of Time
* Check Tracker - Fixes #16 for Shooting the Sun
* Check Tracker - Fixes #19 for Darunia's Joy
* Save Editor - Adds missing label for Treasure Chest Game
* Check Tracker - Fixes Great Faries checks
* Check Tracker - Fixes Sheik at Temple
* Check Tracker - Fixes Great Fairy auto-scroll to wrong location
* Check Tracker - Updates blue warp checks
- Fixes Bongo Bongo and Twinrova checks
* Check Tracker - Fixes Dampe's Gravedigging Tour
* Check Tracker - Fixes Prescription to King Zora
* Check Tracker - Fixes Bazaar showing under wrong area on tracker between adult/child
* Check Tracker - Fixes scroll for Hyrule Market and Bazaar
* Check Tracker - Fixes giving Adult Trade Items shown on tracker: Broken Sword, Saw, Cojiro, Eyeball Froge, and Eyedrops
* Cleans up item_location
* Check Tracker - Item List
- Fixes item list not updating when changing seeds/options
- Separates item exclusion list from item check list
- Clean up comments
* Check Tracker - Adds Skip functionality to buttons
* Check Tracker - Refactors adult trade items to RandomizerInf
* Check Tracker - Fixes an issue where any time an item is removed the tracker would cause an application crash
* Check Tracker - Item names are now dependent on file language
* Check Tracker - Fixes Gerudo Card check not showing in Fast setting
* Reorders headers to (hopefully) avoid CI build conflicts on linux/consoles
* Explicitly defines vector header in randomizer.h to fix compile errors
* Complete Refactor of Check Tracker ImGui
* Adds missing check tracker files to CMakeLists
* Reverts the Item_location whitespace cleanup from ad10807c
* Check Tracker - Loading Fixes
- Fixes a bug where loading a save file a second time would add all the checks again
- Fixes a bug where the check tracker would not render at all until in a save file
* Check Tracker - Fixes a bug where checks would sometimes fail to load
* Check Tracker - Fixes duplicated checks when using Only on Pause or Only on Combo
* Check Tracker - Works around issue where single characters don't show in EnhancementCombobox, and fixes a label for combo buttons held option
* Check Tracker - Applies all Check Tracker changes to Item Location
* Check Tracker - Updated Check List
- Adds Link's pocket, either in KF or HM depending on starting age
- Supports Scrubs and Merchants
- Uses enums instead of magic numbers
- Updates DC Scrub Short Names for MQ
* Check Tracker - Adds a performance mode option
* Check Tracker - List Fixes (requires new rando generation)
- Fixes Frogs Rupees always visible
- Fixes Kokiri Sword Chest not showing
- Fixes Weird Egg not showing
* Check Tracker - MQ List basic support
* Check Tracker - MQ/Vanilla anti-spoilers
* Check Tracker - Collecting a compass now spoils the area
* Check Tracker - Basic Vanilla Support and fixes
- Vanilla items show in check tracker, even if many won't auto check
- Fixes an issue with Gerudo Fortress Keys
- Refactors IsVisibleInCheckTracker to randomizer_check_tracjer
* Check Tracker - Fixes merge conflict from 08a487f35e1d760ab9e69b932edbe4da6bcd9edb
* Check Tracker - Fixes tracker loading as Floating when default value is set to Windowed
* Randomizer Location Exclusion List
- Adds Scrubs, Merchants, Shops. Adult Trade items, MQ Dungeons, and Bean Salesman
- Fixes Kokiri Sword Chest, Weird Egg, and Frog Song Rupees from misbehaving
- Updates Gerudo Fortress logic to be dependent on Open/Fast/Normal Fortress
- Removes Invalid Check
- Adds RO Enum for MQ settings
- Updates magic values to RO enum
* Location Exclusion List - Scrubs that are always randomized now always show on the list
* For now, removes some extra code only needed for a Check Tracker.
* Randomizer Location Exclusion List - Fixes Eyeball Frog from showing up when Adult Trade Items was off
* Location Tracker - Updates Eyedrops to use RandomizerInf instead of Chest
* Check Tracker - Fixes a bug where Link's Pocket item wasn't acting as checked for area item count
* Check Tracker - Fixes a bug where Locations would incorrectly say Vanilla due to the first check in the area being a non-MQ check
* Check Tracker - Fixes a crash when Check Tracker is docked but not visible
* Check Tracker - Fixes areas being spoiled when loading different save files
* Check Tracker - Only reset variables if they are initialized
* Check Tracker - Cleans up old comments, unused variables, methods, and macros, adds language TODOs,
* Check Tracker - Readds rainbow UI elements after Cosmetics Editor refactor
* Check Tracker - Removal of flag lookup that was refactored, no longer needed header, and some trivial whitespace fixes.
* Check Tracker - Refactors Index to Bitmask code to a macro
* Check Tracker - Changes ordering from alphabetical to RandomizerCheck ordering
* Check Tracker - Wraps everything in a namespace to avoid global variable usage
* Check Tracker - Explicitly defines for-loop scope
* Check Tracker - refactors dungeon lookup from static array to function
* Fixes a bug when using EnhancementColor with alpha
* Check Tracker - Refactors all colour to use direct conversions
* Check Tracker - refactors settings loading and check visibility for readability
* Check Tracker - Fixes a bug where the wrong label showed on the Check Tracker BG Color
* UIWidgets - Adds Alpha bar to EnhancementColor when using alpha parameter
2022-12-10 22:39:23 -05:00
|
|
|
flags |= ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_AlphaPreview;
|
2022-09-03 00:00:04 -04:00
|
|
|
if (ImGui::ColorEdit4(text, (float*)&ColorRGBA, flags))
|
|
|
|
{
|
|
|
|
Color_RGBA8 colors;
|
Randomizer Auto Location tracker (#1942)
* Initial Auto-Location Tracking
* Updates styling for checked items in Check Tracker
* Fixes crashing issues with Check Tracker rendering
* Auto scroll Check Tracker windows to current area
* Checks Tracker only shows checked locations once in game
* Fixes issue where Check Tracker would auto-scroll to wrong location when entering a grotto
* Fixes gerudo fortress checks showing in tracker when settings have them removed
* InfTable Check Location Fixes: Lost Dog Richard, Rolling Gorons, HBA 1000, Thawed Zora
* Fixes most Event Chk Inf Checks on Check Tracker, and Frogs
* Check Tracker - Song from Malon now works
* Check Tracker
- Fixes Claim Check check not tracking
- Fixes spoiler for Claim Check check when getting Biggoron's Sword
- Fixes LACS being spoiled and not tracking
* Check Tracker - Fixes #2 for Skull Mask and Mask of Truth checks
* Check Tracker
- Adds support for merchants
- Fixes #7 for Bomchu Salesman
- Fixes #12 for Medigoron
* Check Tracker - Fixes #8 for Song from Saria
* Check Tracker - Fixes #9 for Adult Shooting Gallery
* Check Tracker - Fixes #10 for Composer Grave
* Check Tracker - Fixes #14 for Song from Ocarina of Time
* Check Tracker - Fixes #16 for Shooting the Sun
* Check Tracker - Fixes #19 for Darunia's Joy
* Save Editor - Adds missing label for Treasure Chest Game
* Check Tracker - Fixes Great Faries checks
* Check Tracker - Fixes Sheik at Temple
* Check Tracker - Fixes Great Fairy auto-scroll to wrong location
* Check Tracker - Updates blue warp checks
- Fixes Bongo Bongo and Twinrova checks
* Check Tracker - Fixes Dampe's Gravedigging Tour
* Check Tracker - Fixes Prescription to King Zora
* Check Tracker - Fixes Bazaar showing under wrong area on tracker between adult/child
* Check Tracker - Fixes scroll for Hyrule Market and Bazaar
* Check Tracker - Fixes giving Adult Trade Items shown on tracker: Broken Sword, Saw, Cojiro, Eyeball Froge, and Eyedrops
* Cleans up item_location
* Check Tracker - Item List
- Fixes item list not updating when changing seeds/options
- Separates item exclusion list from item check list
- Clean up comments
* Check Tracker - Adds Skip functionality to buttons
* Check Tracker - Refactors adult trade items to RandomizerInf
* Check Tracker - Fixes an issue where any time an item is removed the tracker would cause an application crash
* Check Tracker - Item names are now dependent on file language
* Check Tracker - Fixes Gerudo Card check not showing in Fast setting
* Reorders headers to (hopefully) avoid CI build conflicts on linux/consoles
* Explicitly defines vector header in randomizer.h to fix compile errors
* Complete Refactor of Check Tracker ImGui
* Adds missing check tracker files to CMakeLists
* Reverts the Item_location whitespace cleanup from ad10807c
* Check Tracker - Loading Fixes
- Fixes a bug where loading a save file a second time would add all the checks again
- Fixes a bug where the check tracker would not render at all until in a save file
* Check Tracker - Fixes a bug where checks would sometimes fail to load
* Check Tracker - Fixes duplicated checks when using Only on Pause or Only on Combo
* Check Tracker - Works around issue where single characters don't show in EnhancementCombobox, and fixes a label for combo buttons held option
* Check Tracker - Applies all Check Tracker changes to Item Location
* Check Tracker - Updated Check List
- Adds Link's pocket, either in KF or HM depending on starting age
- Supports Scrubs and Merchants
- Uses enums instead of magic numbers
- Updates DC Scrub Short Names for MQ
* Check Tracker - Adds a performance mode option
* Check Tracker - List Fixes (requires new rando generation)
- Fixes Frogs Rupees always visible
- Fixes Kokiri Sword Chest not showing
- Fixes Weird Egg not showing
* Check Tracker - MQ List basic support
* Check Tracker - MQ/Vanilla anti-spoilers
* Check Tracker - Collecting a compass now spoils the area
* Check Tracker - Basic Vanilla Support and fixes
- Vanilla items show in check tracker, even if many won't auto check
- Fixes an issue with Gerudo Fortress Keys
- Refactors IsVisibleInCheckTracker to randomizer_check_tracjer
* Check Tracker - Fixes merge conflict from 08a487f35e1d760ab9e69b932edbe4da6bcd9edb
* Check Tracker - Fixes tracker loading as Floating when default value is set to Windowed
* Randomizer Location Exclusion List
- Adds Scrubs, Merchants, Shops. Adult Trade items, MQ Dungeons, and Bean Salesman
- Fixes Kokiri Sword Chest, Weird Egg, and Frog Song Rupees from misbehaving
- Updates Gerudo Fortress logic to be dependent on Open/Fast/Normal Fortress
- Removes Invalid Check
- Adds RO Enum for MQ settings
- Updates magic values to RO enum
* Location Exclusion List - Scrubs that are always randomized now always show on the list
* For now, removes some extra code only needed for a Check Tracker.
* Randomizer Location Exclusion List - Fixes Eyeball Frog from showing up when Adult Trade Items was off
* Location Tracker - Updates Eyedrops to use RandomizerInf instead of Chest
* Check Tracker - Fixes a bug where Link's Pocket item wasn't acting as checked for area item count
* Check Tracker - Fixes a bug where Locations would incorrectly say Vanilla due to the first check in the area being a non-MQ check
* Check Tracker - Fixes a crash when Check Tracker is docked but not visible
* Check Tracker - Fixes areas being spoiled when loading different save files
* Check Tracker - Only reset variables if they are initialized
* Check Tracker - Cleans up old comments, unused variables, methods, and macros, adds language TODOs,
* Check Tracker - Readds rainbow UI elements after Cosmetics Editor refactor
* Check Tracker - Removal of flag lookup that was refactored, no longer needed header, and some trivial whitespace fixes.
* Check Tracker - Refactors Index to Bitmask code to a macro
* Check Tracker - Changes ordering from alphabetical to RandomizerCheck ordering
* Check Tracker - Wraps everything in a namespace to avoid global variable usage
* Check Tracker - Explicitly defines for-loop scope
* Check Tracker - refactors dungeon lookup from static array to function
* Fixes a bug when using EnhancementColor with alpha
* Check Tracker - Refactors all colour to use direct conversions
* Check Tracker - refactors settings loading and check visibility for readability
* Check Tracker - Fixes a bug where the wrong label showed on the Check Tracker BG Color
* UIWidgets - Adds Alpha bar to EnhancementColor when using alpha parameter
2022-12-10 22:39:23 -05:00
|
|
|
colors.r = ColorRGBA.x * 255.0;
|
|
|
|
colors.g = ColorRGBA.y * 255.0;
|
|
|
|
colors.b = ColorRGBA.z * 255.0;
|
|
|
|
colors.a = ColorRGBA.w * 255.0;
|
2022-09-03 00:00:04 -04:00
|
|
|
|
2023-01-17 00:17:49 -05:00
|
|
|
CVarSetColor(cvarName, colors);
|
2022-09-03 00:00:04 -04:00
|
|
|
SohImGui::RequestCvarSaveOnNextTick();
|
2022-10-17 11:26:14 -04:00
|
|
|
changed = true;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::PopID();
|
|
|
|
|
|
|
|
//ImGui::SameLine(); // Removing that one to gain some width spacing on the HUD editor
|
|
|
|
ImGui::PushItemWidth(-FLT_MIN);
|
2022-10-17 11:26:14 -04:00
|
|
|
if (DrawResetColorButton(cvarName, &ColorRGBA, default_colors, has_alpha)) {
|
|
|
|
changed = true;
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
ImGui::SameLine();
|
2022-10-17 11:26:14 -04:00
|
|
|
if (DrawRandomizeColorButton(cvarName, &ColorRGBA)) {
|
|
|
|
changed = true;
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
if (allow_rainbow) {
|
|
|
|
if (ImGui::GetContentRegionAvail().x > 185) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
}
|
|
|
|
RainbowColor(cvarName, &ColorRGBA);
|
|
|
|
}
|
2022-10-21 00:05:08 -04:00
|
|
|
DrawLockColorCheckbox(cvarName);
|
2022-09-03 00:00:04 -04:00
|
|
|
ImGui::NewLine();
|
|
|
|
ImGui::PopItemWidth();
|
2022-10-17 11:26:14 -04:00
|
|
|
|
|
|
|
return changed;
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|
2023-01-23 16:39:05 -05:00
|
|
|
|
|
|
|
void DrawFlagArray32(const std::string& name, uint32_t& flags) {
|
|
|
|
ImGui::PushID(name.c_str());
|
|
|
|
for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) {
|
|
|
|
if ((flagIndex % 8) != 0) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
}
|
|
|
|
ImGui::PushID(flagIndex);
|
|
|
|
uint32_t bitMask = 1 << flagIndex;
|
|
|
|
bool flag = (flags & bitMask) != 0;
|
|
|
|
if (ImGui::Checkbox("##check", &flag)) {
|
|
|
|
if (flag) {
|
|
|
|
flags |= bitMask;
|
|
|
|
} else {
|
|
|
|
flags &= ~bitMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawFlagArray16(const std::string& name, uint16_t& flags) {
|
|
|
|
ImGui::PushID(name.c_str());
|
|
|
|
for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) {
|
|
|
|
if ((flagIndex % 8) != 0) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
}
|
|
|
|
ImGui::PushID(flagIndex);
|
|
|
|
uint16_t bitMask = 1 << flagIndex;
|
|
|
|
bool flag = (flags & bitMask) != 0;
|
|
|
|
if (ImGui::Checkbox("##check", &flag)) {
|
|
|
|
if (flag) {
|
|
|
|
flags |= bitMask;
|
|
|
|
} else {
|
|
|
|
flags &= ~bitMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawFlagArray8(const std::string& name, uint8_t& flags) {
|
|
|
|
ImGui::PushID(name.c_str());
|
|
|
|
for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) {
|
|
|
|
if ((flagIndex % 8) != 0) {
|
|
|
|
ImGui::SameLine();
|
|
|
|
}
|
|
|
|
ImGui::PushID(flagIndex);
|
|
|
|
uint8_t bitMask = 1 << flagIndex;
|
|
|
|
bool flag = (flags & bitMask) != 0;
|
|
|
|
if (ImGui::Checkbox("##check", &flag)) {
|
|
|
|
if (flag) {
|
|
|
|
flags |= bitMask;
|
|
|
|
} else {
|
|
|
|
flags &= ~bitMask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
|
|
|
ImGui::PopID();
|
|
|
|
}
|
2022-09-03 00:00:04 -04:00
|
|
|
}
|