1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 06:53:31 +08:00

Starmap filter: Hide top overlaping windows while the filter UI is shown

This commit is contained in:
2025-05-02 21:03:46 +08:00
parent fb3a74c7e7
commit 47cfb4d79a
4 changed files with 41 additions and 11 deletions

View File

@@ -6,6 +6,7 @@
* 1.3.3
+ `Re-initialize planet`: Fix a crash.
+ `Auto navigation on sailings`: Do not auto-use Warper if required Tech is not researched.
+ Starmap filter: Hide top overlaping windows while the filter UI is shown.
* 1.3.2
+ New feature: `Disable battle-related techs in Peace mode`
+ New button: `Unlock all techs with metadata`

View File

@@ -22,7 +22,7 @@ public static class UIFunctions
private static bool _starmapFilterInitialized;
private static ulong[] _starmapStarFilterValues;
private static bool _starFilterEnabled;
private static UI.MyCheckButton _starmapFilterToggler;
public static UI.MyCheckButton StarmapFilterToggler;
public static bool[] ShowStarName;
public static void Init()
@@ -224,7 +224,7 @@ public static class UIFunctions
{
Functions.UIFunctions.CornerComboBoxIndex = index;
};
_starmapFilterToggler = UI.MyCheckButton.CreateCheckButton(0, 0, rtrans, false, ">>").WithSize(24, 24);
StarmapFilterToggler = UI.MyCheckButton.CreateCheckButton(0, 0, rtrans, false, ">>").WithSize(24, 24);
MyCheckButton[] buttons = [
UI.MyCheckButton.CreateCheckButton(24, 0, rtrans, false).WithIcon().WithSize(24, 24).WithIconWidth(24), // Kimberlite
UI.MyCheckButton.CreateCheckButton(48, 0, rtrans, false).WithIcon().WithSize(24, 24).WithIconWidth(24), // Fractal Silicon
@@ -264,7 +264,7 @@ public static class UIFunctions
};
var allOresText = MyWindow.AddText(20, 190, rtrans, "All 6 Basic Ores".Translate(), 12);
allOresText.gameObject.SetActive(false);
_starmapFilterToggler.OnChecked += UpdateButtons;
StarmapFilterToggler.OnChecked += UpdateButtons;
foreach (var button in buttons)
{
button.OnChecked += () =>
@@ -374,8 +374,8 @@ public static class UIFunctions
break;
}
}
_starmapFilterToggler.gameObject.SetActive(false);
_starmapFilterToggler.Checked = false;
StarmapFilterToggler.gameObject.SetActive(false);
StarmapFilterToggler.Checked = false;
UpdateButtons();
SetStarFilterEnabled(false);
foreach (var star in galaxy.stars)
@@ -446,7 +446,7 @@ public static class UIFunctions
}
void UpdateButtons()
{
var chk = _starmapFilterToggler.Checked;
var chk = StarmapFilterToggler.Checked;
foreach (var button in buttons)
{
if (chk)
@@ -459,17 +459,18 @@ public static class UIFunctions
}
unionCheckBox.gameObject.SetActive(chk);
allOresText.gameObject.SetActive(chk);
_starmapFilterToggler.SetLabelText(chk ? "X" : ">>");
StarmapFilterToggler.SetLabelText(chk ? "X" : ">>");
if (!chk)
{
UpdateStarmapStarFilters();
}
UIRoot.instance.uiGame.dfMonitor.transform.parent.gameObject.SetActive(!chk);
}
void UpdateStarmapStarFilters()
{
var filterValue = 0UL;
var union = unionCheckBox.Checked;
if (_starmapFilterToggler.Checked)
if (StarmapFilterToggler.Checked)
{
for (int i = 0; i < 12; i++)
{
@@ -513,9 +514,9 @@ public static class UIFunctions
public static void OnPlanetScanEnded()
{
if (!_starmapFilterInitialized || _starmapFilterToggler == null || _starmapFilterToggler.gameObject.activeSelf) return;
if (!_starmapFilterInitialized || StarmapFilterToggler == null || StarmapFilterToggler.gameObject.activeSelf) return;
StarmapUpdateFilterValues();
_starmapFilterToggler.gameObject.SetActive(true);
StarmapFilterToggler.gameObject.SetActive(true);
}
private static void StarmapUpdateFilterValues()

View File

@@ -41,4 +41,33 @@ public class UIPatch: PatchImpl<UIPatch>
{
return Functions.UIFunctions.CornerComboBoxIndex == 0;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIMechaLab), nameof(UIMechaLab.DetermineVisible))]
private static bool UIMechaLab_DetermineVisible_Prefix(UIMechaLab __instance, ref bool __result)
{
if (!UIRoot.instance.uiGame.starmap.active || !Functions.UIFunctions.StarmapFilterToggler.Checked)
{
return true;
}
__instance._Close();
__result = false;
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIGoalPanel), nameof(UIGoalPanel.DetermineVisiable))]
private static bool UIGoalPanel_DetermineVisiable_Prefix(UIGoalPanel __instance)
{
if (!UIRoot.instance.uiGame.starmap.active || !Functions.UIFunctions.StarmapFilterToggler.Checked)
{
return true;
}
__instance.isUseOverwrittenState = true;
if (__instance.stateOverwritten == EUIGoalPanelState.None)
{
__instance.stateOverwritten = EUIGoalPanelState.Collapse;
}
return false;
}
}

View File

@@ -1,4 +1,3 @@
#### TODO
* Starmap filter: top windows overlap fix
* Set battlefield analysis base power charging
* Auto-navigation: avoid darkfogs