Skip to content

Commit

Permalink
Merge pull request #716 from starfi5h/pr-update
Browse files Browse the repository at this point in the history
Nebula DSP 0.10.31.24646 Update
  • Loading branch information
starfi5h authored Dec 3, 2024
2 parents a8a1f99 + 31f2d5f commit 98a8fd4
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static void UpdateEntry(UIControlPanelObjectEntry objectEntry, LCPObject
text = packet.Name;
entry.stationNameText.color = entry.masterWindow.renamedColor;
}
Utils.UITextTruncateShow(entry.stationNameText, text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings);
Utils.UITextTruncateShow(entry.stationNameText, ref text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings);
}
else if (objectEntry is UIControlPanelAdvancedMinerEntry)
{
Expand All @@ -89,7 +89,7 @@ private static void UpdateEntry(UIControlPanelObjectEntry objectEntry, LCPObject
text = packet.Name;
entry.stationNameText.color = entry.masterWindow.renamedColor;
}
Utils.UITextTruncateShow(entry.stationNameText, text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings);
Utils.UITextTruncateShow(entry.stationNameText, ref text, entry.stationNameTextWidthLimit, ref entry.stationNameTextSettings);
}
else if (objectEntry is UIControlPanelDispenserEntry)
{
Expand Down
23 changes: 23 additions & 0 deletions NebulaPatcher/Patches/Dynamic/SectorModel_Patch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#region

using HarmonyLib;

#endregion

namespace NebulaPatcher.Patches.Dynamic;

[HarmonyPatch(typeof(SectorModel))]
internal class SectorModel_Patch
{
[HarmonyPrefix]
[HarmonyPatch(nameof(SectorModel.OnCameraPostRender))]
public static bool OnCameraPostRender_Prefix()
{
if (!GameMain.isPaused && !GameMain.inOtherScene)
{
// Skip if GameMain.mainPlayer is null to prevent NRE when player joining the game
return GameMain.mainPlayer != null;
}
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,68 +60,4 @@ public static bool IsLocal_Prefix(UIControlPanelAdvancedMinerEntry __instance, r
}
return true;
}

[HarmonyPrefix]
[HarmonyPatch(nameof(UIControlPanelAdvancedMinerEntry.OnFillNecessaryButtonClick))]
public static bool OnFillNecessaryButtonClick_Prefix(UIControlPanelAdvancedMinerEntry __instance)
{
if (!Multiplayer.IsActive) return true;
if (__instance.factory == null || __instance.station == null)
{
UIRealtimeTip.Popup("Unavailable".Translate());
return false;
}

var packet = new StationUI()
{
PlanetId = __instance.factory.planetId,
StationId = __instance.station.id,
StationGId = __instance.station.gid
};
var text = "";
if (__instance.station.isStellar)
{
int shortAge, previousCount;

previousCount = __instance.station.idleDroneCount;
shortAge = __instance.station.workDroneDatas.Length - (__instance.station.idleDroneCount + __instance.station.workDroneCount);
UIControlPanelObjectEntry.ReplenishItems(5001, shortAge, ref __instance.station.idleDroneCount, ref text);
packet.SettingIndex = StationUI.EUISettings.SetDroneCount;
packet.SettingValue = (__instance.station.idleDroneCount + __instance.station.workDroneCount);
Multiplayer.Session.Network.SendPacket(packet);
if (Multiplayer.Session.IsClient) __instance.station.idleDroneCount = previousCount; // Wait for server to authorize

previousCount = __instance.station.idleShipCount;
shortAge = __instance.station.workShipDatas.Length - (__instance.station.idleShipCount + __instance.station.workShipCount);
UIControlPanelObjectEntry.ReplenishItems(5002, shortAge, ref __instance.station.idleShipCount, ref text);
packet.SettingIndex = StationUI.EUISettings.SetShipCount;
packet.SettingValue = (__instance.station.idleShipCount + __instance.station.workShipCount);
Multiplayer.Session.Network.SendPacket(packet);
if (Multiplayer.Session.IsClient) __instance.station.idleShipCount = previousCount; // Wait for server to authorize

previousCount = __instance.station.warperCount;
shortAge = __instance.station.warperMaxCount - __instance.station.warperCount;
UIControlPanelObjectEntry.ReplenishItems(1210, shortAge, ref __instance.station.warperCount, ref text);
packet.SettingIndex = StationUI.EUISettings.SetWarperCount;
packet.SettingValue = __instance.station.warperCount;
Multiplayer.Session.Network.SendPacket(packet);
if (Multiplayer.Session.IsClient) __instance.station.warperCount = previousCount; // Wait for server to authorize
}
else
{
var previousCount = __instance.station.idleDroneCount;
var shortAge = __instance.station.workDroneDatas.Length - (__instance.station.idleDroneCount + __instance.station.workDroneCount);
UIControlPanelObjectEntry.ReplenishItems(5001, shortAge, ref __instance.station.idleDroneCount, ref text);
packet.SettingIndex = StationUI.EUISettings.SetDroneCount;
packet.SettingValue = (__instance.station.idleDroneCount + __instance.station.workDroneCount);
Multiplayer.Session.Network.SendPacket(packet);
if (Multiplayer.Session.IsClient) __instance.station.idleDroneCount = previousCount; // Wait for server to authorize
}
if (!string.IsNullOrEmpty(text))
{
UIRealtimeTip.Popup(text, false, 0);
VFAudio.Create("equip-1", GameMain.mainPlayer.transform, Vector3.zero, true, 4, -1, -1L);
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static bool UpdateBanner_Prefix(UIControlPanelPlanetEntry __instance)
}
__instance.planetTypeText.text = __instance.planet.typeString;
var displayName = __instance.planet.displayName;
Utils.UITextTruncateShow(__instance.planetNameText, displayName, __instance.planetNameTextWidthLimit, ref __instance.planetNameTextSettings);
Utils.UITextTruncateShow(__instance.planetNameText, ref displayName, __instance.planetNameTextWidthLimit, ref __instance.planetNameTextSettings);

return false;
}
Expand Down
4 changes: 2 additions & 2 deletions NebulaPatcher/Patches/Dynamic/UIGalaxySelect_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public static void _OnOpen_Postfix(UIGalaxySelect __instance)
}

[HarmonyPrefix]
[HarmonyPatch(nameof(UIGalaxySelect.EnterGame))]
public static bool EnterGame_Prefix(UIGalaxySelect __instance)
[HarmonyPatch(nameof(UIGalaxySelect.ApplySetting))]
public static bool ApplySetting_Prefix(UIGalaxySelect __instance)
{
if (!Multiplayer.IsInMultiplayerMenu || __instance.uiCombat.active)
{
Expand Down
4 changes: 2 additions & 2 deletions NebulaPatcher/Patches/Dynamic/UIStatisticsWindow_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public static void _OnClose_Postfix()
}

[HarmonyPrefix]
[HarmonyPatch(nameof(UIStatisticsWindow.AddFactoryStatGroup))]
[HarmonyPatch(nameof(UIStatisticsWindow.AddProductStatGroup))]
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Original Function Name")]
public static bool AddFactoryStatGroup_Prefix(int _factoryIndex, ProductionStatistics ___productionStat)
public static bool AddProductStatGroup_Prefix(int _factoryIndex, ProductionStatistics ___productionStat)
{
//Skip when StatisticsDataPacket hasn't arrived yet
return _factoryIndex >= 0 && ___productionStat.factoryStatPool[_factoryIndex] != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ private static IEnumerable<CodeInstruction> RefreshAstroBox_Transpiler(IEnumerab
}

[HarmonyTranspiler]
[HarmonyPatch(nameof(UIStatisticsWindow.ComputeDisplayProductEntries))]
private static IEnumerable<CodeInstruction> ComputeDisplayEntries_Transpiler(IEnumerable<CodeInstruction> instructions)
[HarmonyPatch(nameof(UIStatisticsWindow.DetermineProductEntryList))]
private static IEnumerable<CodeInstruction> DetermineProductEntryList_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//Change: this.gameData.factoryCount
//To: GetFactoryCount()
Expand Down

0 comments on commit 98a8fd4

Please sign in to comment.