Skip to content

Commit 8c4d24c

Browse files
authored
Merge pull request #529 from sp00ktober/master
Bugfix, Tooltips and minimap indicator
2 parents 09ba1cf + a061382 commit 8c4d24c

23 files changed

+568
-55
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
## Changelog
22

3+
0.8.3:
4+
5+
- @kremnev8: improved ingame chat
6+
- @starfish: added compatibility with BulletTime which enables fluent loading times on Planet and System arrival
7+
- @starfish: bugfix regarding too large dyson sphere data
8+
- @starfish: bugfix regarding reloading of dyson sphere
9+
- @starfish: improved loading of solar systems, this now runs on its own thread
10+
- @starfish: developer commands can now be executed from the ingame chat (using /xconsole [command] )
11+
- @sp00ktober: added tooltips to the Nebula settings
12+
- @sp00ktober: added setting to prevent `System.ObjectDisposedException` errors resulting in random client disconnect
13+
- @sp00ktober: added code to handle IndexOutOfBounds errors when importing PlanetFactory data (very rare issue)
14+
- @sp00ktober: fixed wrong array size for storage and slots in ILS
15+
- @sp00ktober: added minimap indicator for other players positions (on the same planet)
16+
- @sp00ktober: added chat command to list planets in a system
17+
- @sp00ktober: added chat command to navigate to star, planet or player by name or id
18+
319
0.8.2:
420

521
- @kremnev8: fix issue with EmojiDataManager when a save was loaded multiple times in a row.

NebulaModel/MultiplayerOptions.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ public class MultiplayerOptions : ICloneable
2828
public string LastIP { get; set; } = string.Empty;
2929

3030
[DisplayName("Sync Ups")]
31+
[Description("If enabled the UPS of each player is synced. This ensures a similar amount of GameTick() calls.")]
3132
public bool SyncUps { get; set; } = true;
32-
33+
34+
[DisplayName("Sync Soil")]
35+
[Description("If enabled the soil count of each players is added together and used as one big pool for everyone. Note that this is a server side setting applied to all clients.")]
36+
public bool SyncSoil { get; set; } = false;
37+
3338
[DisplayName("Streamer mode")]
39+
[Description("If enabled specific personal information like your IP address is hidden from the ingame chat.")]
3440
public bool StreamerMode { get; set; } = false;
3541

3642
[DisplayName("Default chat position")]
@@ -39,8 +45,9 @@ public class MultiplayerOptions : ICloneable
3945
[DisplayName("Default chat size")]
4046
public ChatSize DefaultChatSize { get; set; } = ChatSize.Medium;
4147

42-
[DisplayName("Sync Soil")]
43-
public bool SyncSoil { get; set; } = false;
48+
[DisplayName("Cleanup inactive sessions")]
49+
[Description("If disabled the underlying networking library will not cleanup inactive connections. This might solve issues with clients randomly disconnecting and hosts having a 'System.ObjectDisposedException'.")]
50+
public bool CleanupInactiveSessions { get; set; } = true;
4451

4552
public string MechaColors { get; set; } = "209 151 76 255;184 90 72 255;94 92 92 255;123 234 255 255;229 155 94 255;255 243 235 255;255 248 245 255;255 255 255 255;";
4653

NebulaModel/Packets/Logistics/ILSArriveStarPlanetResponse.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class ILSArriveStarPlanetResponse
1010

1111
public int[] StationMaxShips { get; set; }
1212
public int[] StorageLength { get; set; }
13+
public int[] SlotLength { get; set; }
1314
public int[] StorageIdx { get; set; }
1415
public int[] ItemId { get; set; }
1516
public int[] Count { get; set; }
@@ -20,6 +21,7 @@ public ILSArriveStarPlanetResponse(int[] stationGId,
2021
int[] stationMaxShips,
2122
int[] storageLength,
2223
int[] storageIdx,
24+
int[] slotLength,
2325
int[] itemId,
2426
int[] count,
2527
int[] inc)
@@ -29,6 +31,7 @@ public ILSArriveStarPlanetResponse(int[] stationGId,
2931
StationMaxShips = stationMaxShips;
3032
StorageLength = storageLength;
3133
StorageIdx = storageIdx;
34+
SlotLength = slotLength;
3235
ItemId = itemId;
3336
Count = count;
3437
Inc = inc;

NebulaNetwork/PacketProcessors/Logistics/ILSArriveStarPlanetRequestProcessor.cs

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,24 @@ public override void ProcessPacket(ILSArriveStarPlanetRequest packet, NebulaConn
3636
if (player != null)
3737
{
3838
List<int> stationGId = new List<int>();
39+
List<int> stationPId = new List<int>();
3940
List<int> stationMaxShips = new List<int>();
4041
List<int> storageLength = new List<int>();
41-
int arraySize = 0;
42-
int offset = 0;
42+
List<int> slotLength = new List<int>();
43+
int arraySizeStorage = 0;
44+
int arraySizeSlot = 0;
45+
int offsetStorage = 0;
46+
int offsetSlot = 0;
4347

4448
foreach (StationComponent stationComponent in GameMain.data.galacticTransport.stationPool)
4549
{
4650
if (stationComponent != null && GameMain.galaxy.PlanetById(stationComponent.planetId)?.star.id == packet.StarId)
4751
{
4852
stationGId.Add(stationComponent.gid);
53+
stationPId.Add(stationComponent.planetId);
4954
stationMaxShips.Add(stationComponent.workShipDatas.Length);
5055
storageLength.Add(stationComponent.storage.Length);
56+
slotLength.Add(stationComponent.slots.Length);
5157
}
5258
}
5359

@@ -57,36 +63,45 @@ public override void ProcessPacket(ILSArriveStarPlanetRequest packet, NebulaConn
5763

5864
for (int i = 0; i < storageLength.Count; i++)
5965
{
60-
arraySize += storageLength[i];
66+
arraySizeStorage += storageLength[i];
67+
}
68+
for(int i = 0; i < slotLength.Count; i++)
69+
{
70+
arraySizeSlot += slotLength[i];
6171
}
6272

63-
int[] planetId = new int[arraySize];
64-
int[] storageIdx = new int[arraySize];
65-
int[] itemId = new int[arraySize];
66-
int[] count = new int[arraySize];
67-
int[] inc = new int[arraySize];
73+
int[] storageIdx = new int[arraySizeSlot];
74+
75+
int[] itemId = new int[arraySizeStorage];
76+
int[] count = new int[arraySizeStorage];
77+
int[] inc = new int[arraySizeStorage];
6878

6979
for (int i = 0; i < stationGId.Count; i++)
7080
{
71-
for (int j = 0; j < storageLength[i]; j++)
81+
for(int j = 0; j < slotLength[i]; j++)
7282
{
73-
planetId[offset + j] = gStationPool[stationGId[i]].planetId;
7483
if (gStationPool[stationGId[i]].slots.Length > 0) // collectors dont have a slot for belts
7584
{
76-
storageIdx[offset + j] = gStationPool[stationGId[i]].slots[j].storageIdx;
85+
storageIdx[offsetSlot + j] = gStationPool[stationGId[i]].slots[j].storageIdx;
7786
}
78-
itemId[offset + j] = gStationPool[stationGId[i]].storage[j].itemId;
79-
count[offset + j] = gStationPool[stationGId[i]].storage[j].count;
80-
inc[offset + j] = gStationPool[stationGId[i]].storage[j].inc;
8187
}
82-
offset += storageLength[i];
88+
offsetSlot += slotLength[i];
89+
90+
for (int j = 0; j < storageLength[i]; j++)
91+
{
92+
itemId[offsetStorage + j] = gStationPool[stationGId[i]].storage[j].itemId;
93+
count[offsetStorage + j] = gStationPool[stationGId[i]].storage[j].count;
94+
inc[offsetStorage + j] = gStationPool[stationGId[i]].storage[j].inc;
95+
}
96+
offsetStorage += storageLength[i];
8397
}
8498

8599
player.SendPacket(new ILSArriveStarPlanetResponse(stationGId.ToArray(),
86-
planetId,
100+
stationPId.ToArray(),
87101
stationMaxShips.ToArray(),
88102
storageLength.ToArray(),
89103
storageIdx,
104+
slotLength.ToArray(),
90105
itemId,
91106
count,
92107
inc));

NebulaNetwork/PacketProcessors/Logistics/ILSArriveStarPlanetResponseProcessor.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ public override void ProcessPacket(ILSArriveStarPlanetResponse packet, NebulaCon
1818

1919
StationComponent[] gStationPool = GameMain.data.galacticTransport.stationPool;
2020

21-
int offset = 0;
21+
int offsetStorage = 0;
22+
int offsetSlot = 0;
2223
for (int i = 0; i < packet.StationGId.Length; i++)
2324
{
2425
if (packet.StationGId[i] >= gStationPool.Length || gStationPool[packet.StationGId[i]] == null)
@@ -29,25 +30,31 @@ public override void ProcessPacket(ILSArriveStarPlanetResponse packet, NebulaCon
2930
StationComponent stationComponent = gStationPool[packet.StationGId[i]];
3031
if (stationComponent.slots == null && !stationComponent.isCollector)
3132
{
32-
stationComponent.slots = new SlotData[packet.StorageLength[i]];
33+
stationComponent.slots = new SlotData[packet.SlotLength[i]];
3334
}
3435
if (stationComponent.storage == null)
3536
{
3637
stationComponent.storage = new StationStore[packet.StorageLength[i]];
3738
}
38-
for (int j = 0; j < packet.StorageLength[i]; j++)
39+
for (int j = 0; j < packet.SlotLength[i]; j++)
3940
{
40-
int index = offset + j;
41+
int index = offsetSlot + j;
4142

4243
if (!stationComponent.isCollector)
4344
{
4445
stationComponent.slots[j].storageIdx = packet.StorageIdx[index];
4546
}
47+
}
48+
offsetSlot += packet.SlotLength[i];
49+
for(int j = 0; j < packet.StorageLength[i]; j++)
50+
{
51+
int index = offsetStorage + j;
52+
4653
stationComponent.storage[j].itemId = packet.ItemId[index];
4754
stationComponent.storage[j].count = packet.Count[index];
4855
stationComponent.storage[j].inc = packet.Inc[index];
4956
}
50-
offset += packet.StorageLength[i];
57+
offsetStorage += packet.StorageLength[i];
5158
}
5259
}
5360
}

NebulaNetwork/Server.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public override void Start()
7373
socket.AddWebSocketService<WebSocketService>("/socket", wse => new WebSocketService());
7474
try
7575
{
76+
socket.KeepClean = Config.Options.CleanupInactiveSessions;
7677
socket.Start();
7778
}catch(System.InvalidOperationException e)
7879
{

NebulaPatcher/Patches/Dynamic/UIOptionWindow_Patch.cs

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,42 @@
99
using System.Linq;
1010
using System.Reflection;
1111
using UnityEngine;
12+
using UnityEngine.EventSystems;
1213
using UnityEngine.UI;
1314

1415
namespace NebulaPatcher.Patches.Dynamic
1516
{
1617
[HarmonyPatch(typeof(UIOptionWindow))]
1718
internal class UIOptionWindow_Patch
1819
{
20+
public class Tooltip : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
21+
{
22+
public string Title = null;
23+
public string Text = null;
24+
UIButtonTip tip = null;
25+
26+
public void OnPointerEnter(PointerEventData eventData)
27+
{
28+
tip = UIButtonTip.Create(true, Title, Text, 2, new Vector2(0, 0), 508, this.gameObject.transform, "", "");
29+
}
30+
31+
public void OnPointerExit(PointerEventData eventData)
32+
{
33+
if(tip != null)
34+
{
35+
Destroy(tip.gameObject);
36+
}
37+
}
38+
39+
public void OnDisable()
40+
{
41+
if (tip != null)
42+
{
43+
Destroy(tip.gameObject);
44+
}
45+
}
46+
}
47+
1948
private static RectTransform multiplayerTab;
2049

2150
// Templates
@@ -159,23 +188,24 @@ private static void AddMultiplayerOptionsProperties(RectTransform container)
159188
foreach (PropertyInfo prop in properties)
160189
{
161190
DisplayNameAttribute displayAttr = prop.GetCustomAttribute<DisplayNameAttribute>();
191+
DescriptionAttribute descriptionAttr = prop.GetCustomAttribute<DescriptionAttribute>();
162192
if (displayAttr != null)
163193
{
164194
if (prop.PropertyType == typeof(bool))
165195
{
166-
CreateBooleanControl(displayAttr, prop, anchorPosition, container);
196+
CreateBooleanControl(displayAttr, descriptionAttr, prop, anchorPosition, container);
167197
}
168198
else if (prop.PropertyType == typeof(int) || prop.PropertyType == typeof(float) || prop.PropertyType == typeof(ushort))
169199
{
170-
CreateNumberControl(displayAttr, prop, anchorPosition, container);
200+
CreateNumberControl(displayAttr, descriptionAttr, prop, anchorPosition, container);
171201
}
172202
else if (prop.PropertyType == typeof(string))
173203
{
174-
CreateStringControl(displayAttr, prop, anchorPosition, container);
204+
CreateStringControl(displayAttr, descriptionAttr, prop, anchorPosition, container);
175205
}
176206
else if (prop.PropertyType.IsEnum)
177207
{
178-
CreateEnumControl(displayAttr, prop, anchorPosition, container);
208+
CreateEnumControl(displayAttr, descriptionAttr, prop, anchorPosition, container);
179209
}
180210
else
181211
{
@@ -190,10 +220,10 @@ private static void AddMultiplayerOptionsProperties(RectTransform container)
190220
container.sizeDelta = new Vector2(container.sizeDelta.x, -anchorPosition.y + 40);
191221
}
192222

193-
private static void CreateBooleanControl(DisplayNameAttribute control, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
223+
private static void CreateBooleanControl(DisplayNameAttribute control, DescriptionAttribute descriptionAttr, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
194224
{
195225
RectTransform element = Object.Instantiate(checkboxTemplate, container, false);
196-
SetupUIElement(element, control, prop, anchorPosition);
226+
SetupUIElement(element, control, descriptionAttr, prop, anchorPosition);
197227
UIToggle toggle = element.GetComponentInChildren<UIToggle>();
198228
toggle.toggle.onValueChanged.RemoveAllListeners();
199229
toggle.toggle.onValueChanged.AddListener((value) => {
@@ -219,13 +249,13 @@ private static void CreateBooleanControl(DisplayNameAttribute control, PropertyI
219249
};
220250
}
221251

222-
private static void CreateNumberControl(DisplayNameAttribute control, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
252+
private static void CreateNumberControl(DisplayNameAttribute control, DescriptionAttribute descriptionAttr, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
223253
{
224254
UIRangeAttribute rangeAttr = prop.GetCustomAttribute<UIRangeAttribute>();
225255
bool sliderControl = rangeAttr != null && rangeAttr.Slider;
226256

227257
RectTransform element = Object.Instantiate(sliderControl ? sliderTemplate : inputTemplate, container, false);
228-
SetupUIElement(element, control, prop, anchorPosition);
258+
SetupUIElement(element, control, descriptionAttr, prop, anchorPosition);
229259

230260
bool isFloatingPoint = prop.PropertyType == typeof(float) || prop.PropertyType == typeof(double);
231261

@@ -294,10 +324,10 @@ private static void CreateNumberControl(DisplayNameAttribute control, PropertyIn
294324
}
295325
}
296326

297-
private static void CreateStringControl(DisplayNameAttribute control, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
327+
private static void CreateStringControl(DisplayNameAttribute control, DescriptionAttribute descriptionAttr, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
298328
{
299329
RectTransform element = Object.Instantiate(inputTemplate, container, false);
300-
SetupUIElement(element, control, prop, anchorPosition);
330+
SetupUIElement(element, control, descriptionAttr, prop, anchorPosition);
301331

302332
InputField input = element.GetComponentInChildren<InputField>();
303333
input.onValueChanged.RemoveAllListeners();
@@ -309,10 +339,10 @@ private static void CreateStringControl(DisplayNameAttribute control, PropertyIn
309339
};
310340
}
311341

312-
private static void CreateEnumControl(DisplayNameAttribute control, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
342+
private static void CreateEnumControl(DisplayNameAttribute control, DescriptionAttribute descriptionAttr, PropertyInfo prop, Vector2 anchorPosition, RectTransform container)
313343
{
314344
RectTransform element = Object.Instantiate(comboBoxTemplate, container, false);
315-
SetupUIElement(element, control, prop, anchorPosition);
345+
SetupUIElement(element, control, descriptionAttr, prop, anchorPosition);
316346
UIComboBox combo = element.GetComponentInChildren<UIComboBox>();
317347
combo.Items = System.Enum.GetNames(prop.PropertyType).ToList();
318348
combo.ItemsData = System.Enum.GetValues(prop.PropertyType).OfType<int>().ToList();
@@ -325,11 +355,17 @@ private static void CreateEnumControl(DisplayNameAttribute control, PropertyInfo
325355
};
326356
}
327357

328-
private static void SetupUIElement(RectTransform element, DisplayNameAttribute display, PropertyInfo prop, Vector2 anchorPosition)
358+
private static void SetupUIElement(RectTransform element, DisplayNameAttribute display, DescriptionAttribute descriptionAttr, PropertyInfo prop, Vector2 anchorPosition)
329359
{
330360
element.gameObject.SetActive(true);
331361
element.name = prop.Name;
332362
element.anchoredPosition = anchorPosition;
363+
if(descriptionAttr != null)
364+
{
365+
element.gameObject.AddComponent<Tooltip>();
366+
element.gameObject.GetComponent<Tooltip>().Title = display.DisplayName;
367+
element.gameObject.GetComponent<Tooltip>().Text = descriptionAttr.Description;
368+
}
333369
element.GetComponent<Localizer>().enabled = false;
334370
element.GetComponent<Text>().text = display.DisplayName;
335371
}

0 commit comments

Comments
 (0)