mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-26 15:50:25 +00:00
Fix Sidebar Search (#796)
* Ensures the sidebar search gets added if on at boot. Searches the sidebar entries to find an entry with a label that matches the searchSidebarEntry label to delete when disabling sidebar search, just in case something goes wrong and it's not actually where it's supposed to be (sidebarSearchIndex). * ... clang...
This commit is contained in:
parent
69edc89292
commit
da793a5bf2
@ -403,6 +403,12 @@ void FreeLookPitchMinMax() {
|
||||
CVarSetFloat("gEnhancements.Camera.FreeLook.MinPitch", std::min(maxY, minY));
|
||||
}
|
||||
|
||||
void InsertSidebarSearch() {
|
||||
menuEntries[0].sidebarEntries.insert(menuEntries[0].sidebarEntries.begin() + searchSidebarIndex,
|
||||
searchSidebarEntry);
|
||||
CVarSetInteger(menuEntries[0].sidebarCvar, CVarGetInteger(menuEntries[0].sidebarCvar, 0) + 1);
|
||||
}
|
||||
|
||||
void AddSettings() {
|
||||
// General Settings
|
||||
settingsSidebar.push_back(
|
||||
@ -447,12 +453,18 @@ void AddSettings() {
|
||||
{},
|
||||
[](widgetInfo& info) {
|
||||
if (CVarGetInteger("gSettings.SidebarSearch", 0)) {
|
||||
menuEntries[0].sidebarEntries.insert(menuEntries[0].sidebarEntries.begin() + searchSidebarIndex,
|
||||
searchSidebarEntry);
|
||||
CVarSetInteger(menuEntries[0].sidebarCvar, CVarGetInteger(menuEntries[0].sidebarCvar, 0) + 1);
|
||||
InsertSidebarSearch();
|
||||
} else {
|
||||
menuEntries[0].sidebarEntries.erase(menuEntries[0].sidebarEntries.begin() + searchSidebarIndex);
|
||||
CVarSetInteger(menuEntries[0].sidebarCvar, CVarGetInteger(menuEntries[0].sidebarCvar, 0) - 1);
|
||||
std::erase_if(menuEntries[0].sidebarEntries, [](SidebarEntry entry) {
|
||||
return strncmp(entry.label.c_str(), searchSidebarEntry.label.c_str(), 5) == 0;
|
||||
});
|
||||
int32_t sidebarVal = CVarGetInteger(menuEntries[0].sidebarCvar, 0);
|
||||
if (sidebarVal < menuEntries.size()) {
|
||||
sidebarVal -= 1;
|
||||
} else {
|
||||
sidebarVal = menuEntries.size() - 1;
|
||||
}
|
||||
CVarSetInteger(menuEntries[0].sidebarCvar, sidebarVal);
|
||||
}
|
||||
} },
|
||||
{ "Search Input Autofocus", "gSettings.SearchAutofocus",
|
||||
@ -679,6 +691,10 @@ void AddSettings() {
|
||||
"Enables the separate Input Editor window.",
|
||||
WIDGET_WINDOW_BUTTON,
|
||||
{ .size = UIWidgets::Sizes::Inline, .windowName = "2S2H Input Editor" } } } } });
|
||||
|
||||
if (CVarGetInteger("gSettings.SidebarSearch", 0)) {
|
||||
settingsSidebar.insert(settingsSidebar.begin() + searchSidebarIndex, searchSidebarEntry);
|
||||
}
|
||||
}
|
||||
int32_t motionBlurStrength;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user