Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions NetworkSkins/Props/PropCustomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class PropCustomizer : LoadingExtensionBase
{
public static PropCustomizer Instance;

private readonly List<TreeInfo> _availableTrees = new List<TreeInfo>();
private readonly List<PropInfo> _availableStreetLights = new List<PropInfo>();
private List<TreeInfo> _availableTrees = new List<TreeInfo>();
private List<PropInfo> _availableStreetLights = new List<PropInfo>();

public int[] StreetLightPrefabDataIndices;

Expand All @@ -39,9 +39,6 @@ public void OnUpdateData(SimulationManager.UpdateMode mode)
&& mode != SimulationManager.UpdateMode.LoadGame && mode != SimulationManager.UpdateMode.NewGameFromMap
&& mode != SimulationManager.UpdateMode.NewGameFromScenario) return;

// no trees
_availableTrees.Add(null);

for (uint i = 0; i < PrefabCollection<TreeInfo>.LoadedCount(); i++)
{
var prefab = PrefabCollection<TreeInfo>.GetLoaded(i);
Expand All @@ -51,8 +48,8 @@ public void OnUpdateData(SimulationManager.UpdateMode mode)
_availableTrees.Add(prefab);
}

// no street lights
_availableStreetLights.Add(null);
_availableTrees = _availableTrees.OrderBy(prefab => UITreeOption.GenerateBeautifiedPrefabName(prefab).ToLowerInvariant().Replace("the ", "")).ToList();
_availableTrees.Insert(0, null);

for (uint i = 0; i < PrefabCollection<PropInfo>.LoadedCount(); i++)
{
Expand All @@ -76,6 +73,9 @@ public void OnUpdateData(SimulationManager.UpdateMode mode)
}
}

_availableStreetLights = _availableStreetLights.OrderBy(prefab => prefab?.GetUncheckedLocalizedTitle().Trim().ToLowerInvariant().Replace("the ", "")).ToList();
_availableStreetLights.Insert(0, null);

// compile list of data indices for fast check if a prefab is a street light:
StreetLightPrefabDataIndices = _availableStreetLights.Where(prop => prop != null).Select(prop => prop.m_prefabDataIndex).ToArray();
}
Expand Down
9 changes: 5 additions & 4 deletions NetworkSkins/Props/UITreeOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ protected override bool PopulateDropDown()

foreach (var tree in _availableTrees)
{
var itemName = UIUtil.GenerateBeautifiedPrefabName(tree);
itemName = BeautifyNameEvenMore(itemName);
var itemName = GenerateBeautifiedPrefabName(tree);
if (tree == defaultTree) itemName += " (Default)";
DropDown.AddItem(itemName);

Expand All @@ -62,9 +61,11 @@ protected override bool PopulateDropDown()
return false;
}

private string BeautifyNameEvenMore(string itemName)
public static string GenerateBeautifiedPrefabName(TreeInfo tree)
{
switch(itemName)
var itemName = UIUtil.GenerateBeautifiedPrefabName(tree);

switch (itemName)
{
case "Cherry Tree01": return "Cherry Tree";
case "Tree with Leaves": return "Small Oak";
Expand Down