Skip to content

Commit

Permalink
Sundry cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
algernon-A committed Sep 21, 2023
1 parent 9c093f0 commit 7d5c721
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Code/AutoReplace/AutoReplaceXML.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public enum Replacements : int
MOM,

/// <summary>
/// Number of replacment types.
/// Number of replacement types.
/// </summary>
NumReplacements,
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Mod : PatcherMod<OptionsPanel, PatcherBase>, IUserMod
public override string BaseName => "RON - the network replacer";

/// <summary>
/// Gets the mod's unique Harmony identfier.
/// Gets the mod's unique Harmony identifier.
/// </summary>
public override string HarmonyID => "com.github.algernon-A.csl.ron";

Expand Down
8 changes: 4 additions & 4 deletions Code/Patches/Escape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public static class Escape
/// <summary>
/// Harmony prefix patch to cancel the RON tool when it's active and the escape key is pressed.
/// </summary>
/// <returns>True (continue on to game method) if the zoning tool isn't already active, false (pre-empt game method) otherwise.</returns>
/// <returns>True (continue on to game method) if the zoning tool isn't already active, false (preempt game method) otherwise.</returns>
public static bool Prefix()
{
// Is the RON tool active?
if (RONTool.IsActiveTool)
{
// Yes; toggle tool status and return false (pre-empt original method).
// Yes; toggle tool status and return false (preempt original method).
RONTool.ToggleTool();
return false;
}
Expand All @@ -32,7 +32,7 @@ public static bool Prefix()
// Is the station panel open?
if (StandalonePanelManager<StationPanel>.Panel is StationPanel stationPanel)
{
// Yes; close panel and return false (pre-empt original method).
// Yes; close panel and return false (preempt original method).
stationPanel.Close();
return false;
}
Expand All @@ -41,7 +41,7 @@ public static bool Prefix()
// Is the built station panel open?
if (StandalonePanelManager<BuiltStationPanel>.Panel is BuiltStationPanel builtStationPanel)
{
// Yes; close panel and return false (pre-empt original method).
// Yes; close panel and return false (preempt original method).
builtStationPanel.Close();
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Patches/ToolBasePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace RON
[HarmonyPatch(typeof(ToolBase))]
public static class ToolBasePatch
{
// Setment to highlight (0 for none).
// Segment to highlight (0 for none).
private static ushort s_selectedSegment = 0;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Code/Replacer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal static void ReplaceNets(NetInfo target, NetInfo replacement, List<ushor
// Check that this is an active network before we do actual replacement.
if (segment.m_flags != NetSegment.Flags.None)
{
// Get segment name and prority.
// Get segment name and priority.
bool priority = netManager.IsPriorityRoad(segmentID, out bool _);
ushort nameSeed = segment.m_nameSeed;
bool customNameFlag = (segment.m_flags & NetSegment.Flags.CustomName) != 0;
Expand Down
10 changes: 5 additions & 5 deletions Code/Settings/ModSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ModSettings : SettingsXMLBase
private static bool s_replaceMOM = true;

/// <summary>
/// Gets or sets a value indicating whether North Americal Rail tracks should be auto-replaced on load (true).
/// Gets or sets a value indicating whether North American Rail tracks should be auto-replaced on load (true).
/// </summary>
[XmlIgnore]
private static bool s_replaceNAR = true;
Expand Down Expand Up @@ -97,7 +97,7 @@ public bool XMLShowRailwayReplacer
}

/// <summary>
/// Gets or sets a value indicating whether Network Extensons 2 roads should be auto-replaced on load (true).
/// Gets or sets a value indicating whether Network Extensions 2 roads should be auto-replaced on load (true).
/// </summary>
[XmlElement("ReplaceNExt2")]
public bool XMLReplaceNext
Expand All @@ -117,7 +117,7 @@ public bool XMLReplaceMOM
}

/// <summary>
/// Gets or sets a value indicating whether North Americal Rail tracks should be auto-replaced on load (true).
/// Gets or sets a value indicating whether North American Rail tracks should be auto-replaced on load (true).
/// </summary>
[XmlElement("ReplaceNAR")]
public bool XMLReplaceNAR
Expand Down Expand Up @@ -149,7 +149,7 @@ public AutoReplaceXML.Replacements XMLReplaceNARmode
internal static bool EnableAdvanced { get => s_enableAdvanced; set => s_enableAdvanced = value; }

/// <summary>
/// Gets or sets a value indicating whether Network Extensons 2 roads should be auto-replaced on load (true).
/// Gets or sets a value indicating whether Network Extensions 2 roads should be auto-replaced on load (true).
/// </summary>
[XmlIgnore]
internal static bool ReplaceNExt2 { get => s_replaceNExt2; set => s_replaceNExt2 = value; }
Expand All @@ -161,7 +161,7 @@ public AutoReplaceXML.Replacements XMLReplaceNARmode
internal static bool ReplaceMOM { get => s_replaceMOM; set => s_replaceMOM = value; }

/// <summary>
/// Gets or sets a value indicating whether North Americal Rail tracks should be auto-replaced on load (true).
/// Gets or sets a value indicating whether North American Rail tracks should be auto-replaced on load (true).
/// </summary>
[XmlIgnore]
internal static bool ReplaceNAR { get => s_replaceNAR; set => s_replaceNAR = value; }
Expand Down
2 changes: 1 addition & 1 deletion Code/UI/BuiltStationPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public override void Awake()
}

/// <summary>
/// Called by Unity every tick. Used here to track state of any in-progress replacments.
/// Called by Unity every tick. Used here to track state of any in-progress replacements.
/// </summary>
public override void Update()
{
Expand Down
4 changes: 2 additions & 2 deletions Code/UI/RONTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override NetSegment.Flags GetSegmentIgnoreFlags(out bool nameOnly)
}

/// <summary>
/// Sets vehicle ingore flags to ignore all vehicles.
/// Sets vehicle ignore flags to ignore all vehicles.
/// </summary>
/// <returns>Vehicle flags ignoring all vehicles.</returns>
public override Vehicle.Flags GetVehicleIgnoreFlags() =>
Expand Down Expand Up @@ -259,7 +259,7 @@ protected override void OnEnable()
// Make sure that game is loaded before activating tool.
if (!OnLevelLoadedPatch.Loaded)
{
// Loading not complete - deactivate tool by seting default tool.
// Loading not complete - deactivate tool by setting default tool.
ToolsModifierControl.SetTool<DefaultTool>();
return;
}
Expand Down
42 changes: 21 additions & 21 deletions Code/UI/ReplacerPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ internal class ReplacerPanel : StandalonePanel
private const float ReplaceWidth = 150f;
private const float FilterX = (CalculatedPanelWidth - Margin) - 360f;
private const float FilterWidth = 220;
private const float FilterMenuxX = FilterX + FilterWidth + Margin;
private const float FilterMenuWidth = CalculatedPanelWidth - FilterMenuxX - Margin;
private const float FilterMenuX = FilterX + FilterWidth + Margin;
private const float FilterMenuWidth = CalculatedPanelWidth - FilterMenuX - Margin;
private const float ButtonWidth = 220f;
private const float PrevX = Margin;
private const float NextX = LeftWidth + Margin - ButtonWidth;
Expand Down Expand Up @@ -214,13 +214,13 @@ internal class ReplacerPanel : StandalonePanel
};

// Segment info record.
private Dictionary<NetInfo, List<ushort>> _segmentDict = new Dictionary<NetInfo, List<ushort>>();
private readonly Dictionary<NetInfo, List<ushort>> _segmentDict = new Dictionary<NetInfo, List<ushort>>();

// Parent-child network relation dictionaries.
private Dictionary<NetInfo, NetInfo> _slopeParents = new Dictionary<NetInfo, NetInfo>();
private Dictionary<NetInfo, NetInfo> _elevatedParents = new Dictionary<NetInfo, NetInfo>();
private Dictionary<NetInfo, NetInfo> _bridgeParents = new Dictionary<NetInfo, NetInfo>();
private Dictionary<NetInfo, NetInfo> _tunnelParents = new Dictionary<NetInfo, NetInfo>();
private readonly Dictionary<NetInfo, NetInfo> _slopeParents = new Dictionary<NetInfo, NetInfo>();
private readonly Dictionary<NetInfo, NetInfo> _elevatedParents = new Dictionary<NetInfo, NetInfo>();
private readonly Dictionary<NetInfo, NetInfo> _bridgeParents = new Dictionary<NetInfo, NetInfo>();
private readonly Dictionary<NetInfo, NetInfo> _tunnelParents = new Dictionary<NetInfo, NetInfo>();

// Panel components.
private UIList _targetList;
Expand Down Expand Up @@ -447,7 +447,7 @@ public override void Awake()
nameFilter.eventTextSubmitted += (c, text) => LoadedList();

// Search by name/author dropdown.
_searchTypeMenu = UIDropDowns.AddDropDown(this, FilterMenuxX, ToolRow1Y, FilterMenuWidth);
_searchTypeMenu = UIDropDowns.AddDropDown(this, FilterMenuX, ToolRow1Y, FilterMenuWidth);
_searchTypeMenu.items = new string[(int)SearchTypes.NumTypes] { Translations.Translate("RON_PNL_NET"), Translations.Translate("RON_PNL_CRE") };
_searchTypeMenu.selectedIndex = (int)SearchTypes.SearchNetwork;
_searchTypeMenu.eventSelectedIndexChanged += (c, isChecked) => LoadedList();
Expand Down Expand Up @@ -587,7 +587,7 @@ internal void SetTarget(ushort segmentID)
// Set target list position.
_targetList.FindItem<NetRowItem>(x => x.Prefab == selectedNet);

// Set selected network segement.
// Set selected network segment.
_currentSegment = segmentID;

// Set selected segments.
Expand Down Expand Up @@ -651,7 +651,7 @@ private void SetSelectedSegments()
// Get district of selected segment.
ushort districtID = districtManager.GetDistrict(segmentBuffer[_currentSegment].m_middlePosition);

// Iterate through each segment of this type in our dictionary, adding to our list of selected segments if both start and end nodes are in the same district as the initial segement.
// Iterate through each segment of this type in our dictionary, adding to our list of selected segments if both start and end nodes are in the same district as the initial segment.
foreach (ushort districtSegment in _segmentDict[SelectedPrefab])
{
if (districtManager.GetDistrict(nodeBuffer[segmentBuffer[districtSegment].m_startNode].m_position) == districtID && districtManager.GetDistrict(nodeBuffer[segmentBuffer[districtSegment].m_endNode].m_position) == districtID)
Expand Down Expand Up @@ -764,7 +764,7 @@ private void Delete(UIComponent c, UIMouseEventParameter p)
YesNoNotification warningNotification = NotificationBase.ShowNotification<YesNoNotification>();
warningNotification.YesButton.eventClicked += (button, clickEvent) => DeleteNets();

// Singlular or plural?
// Singular or plural?
warningNotification.AddParas(
Translations.Translate(_selectedSegments.Count > 1 ? "RON_WAR_DEL" : "RON_WAR_DES"),
Translations.Translate("RON_WAR_UND"));
Expand Down Expand Up @@ -815,7 +815,7 @@ private void NextSegment(UIComponent c, UIMouseEventParameter p)
// Is the selected segment ahead of this?
if (segmentID > _currentSegment)
{
// 'Fresh' segment - update target to this and finish looping, since we've found our taget.
// 'Fresh' segment - update target to this and finish looping, since we've found our target.
targetSegment = segmentID;
break;
}
Expand All @@ -825,7 +825,7 @@ private void NextSegment(UIComponent c, UIMouseEventParameter p)
// Did we find a valid target?
if (targetSegment != 0)
{
ViewSegement(targetSegment);
ViewSegment(targetSegment);
}
}

Expand Down Expand Up @@ -855,7 +855,7 @@ private void PreviousSegment(UIComponent c, UIMouseEventParameter p)
// Is the previously-shown segment counter ahead of this?
if (segmentID < _currentSegment)
{
// 'Fresh' segment - update target to this and finish looping, since we've found our taget.
// 'Fresh' segment - update target to this and finish looping, since we've found our target.
targetSegment = segmentID;
break;
}
Expand All @@ -865,7 +865,7 @@ private void PreviousSegment(UIComponent c, UIMouseEventParameter p)
// Did we find a valid target?
if (targetSegment != 0)
{
ViewSegement(targetSegment);
ViewSegment(targetSegment);
}
}

Expand Down Expand Up @@ -971,7 +971,7 @@ private void SortTargets(UIComponent c, UIMouseEventParameter p)
/// Moves the camera to view the given segment.
/// </summary>
/// <param name="segmentID">Segment ID of target segment.</param>
private void ViewSegement(ushort segmentID)
private void ViewSegment(ushort segmentID)
{
// Yes - set camera position.
Vector3 cameraPosition = NetManager.instance.m_segments.m_buffer[segmentID].m_middlePosition;
Expand Down Expand Up @@ -1048,7 +1048,7 @@ private void TargetList()
NetSegment[] segments = netManager.m_segments.m_buffer;
for (ushort i = 0; i < segments.Length; ++i)
{
// Skip any inleigible flags.
// Skip any ineligible flags.
if ((segments[i].m_flags & NetSegment.Flags.Created) == 0)
{
continue;
Expand Down Expand Up @@ -1089,7 +1089,7 @@ private void TargetList()
}
}

// Create new object list for fastlist, ordering as approprite.
// Create new object list for fastlist, ordering as appropriate.
object[] objectArray;
switch (_targetSearchStatus)
{
Expand Down Expand Up @@ -1186,7 +1186,7 @@ private void LoadedList()
}
}

// Create new object list for fastlist, ordering as approprite.
// Create new object list for fastlist, ordering as appropriate.
object[] objectArray;
switch (_loadedSearchStatus)
{
Expand Down Expand Up @@ -1276,7 +1276,7 @@ private void DisplayNetwork(NetInfo network, UISprite previewSprite)
}

/// <summary>
/// Retuns the type icon filename for the given network.
/// Returns the type icon filename for the given network.
/// </summary>
/// <param name="network">Network to get icon for.</param>
/// <returns>Type icon filename, or null if no type icon is available.</returns>
Expand Down Expand Up @@ -1436,7 +1436,7 @@ private UISprite AddArrowSprite(UIComponent parent, float xPos, string spriteNam
/// Adds an arrow button.
/// </summary>
/// <param name="parent">Parent component.</param>
/// <param name="posX">Relative X postion.</param>
/// <param name="posX">Relative X position.</param>
/// <param name="posY">Relative Y position.</param>
/// <param name="width">Button width (default 32).</param>
/// <param name="height">Button height (default 20).</param>
Expand Down
2 changes: 1 addition & 1 deletion Code/UI/UIList/NetRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected override void OnSizeChanged()
_stationLabel.relativePosition = new Vector2(StationX, (RowHeight - LabelHeight) / 2f);
_categoryLabel.relativePosition = new Vector2(CategoryX, (RowHeight - LabelHeight) / 2f);

// Set icon sprice position.
// Set icon sprite position.
_typeIconSprite.relativePosition = new Vector2(TypeX, (RowHeight - SpriteSize) / 2f);
}
}
Expand Down
10 changes: 5 additions & 5 deletions Code/UI/UIList/NetRowItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ namespace RON
public class NetRowItem
{
// Private fields.
private NetInfo _prefab;
private readonly NetInfo _prefab;
private readonly string _creator;
private readonly bool _isStation = false;
private string _displayName;
private string _creator;
private bool _isStation = false;

// Network indicator flags - if this is a vanilla/NExt2/mod asset.
private bool _isVanilla = false;
Expand Down Expand Up @@ -92,7 +92,7 @@ private void GetDisplayName()
// If no period, assume it's either vanilla or Mod.
if (period < 0)
{
// Check for NEext prefabs. NExt prefabs aren't as consistent as would be ideal....
// Check for NExt prefabs. NExt prefabs aren't as consistent as would be ideal....
_isNExt2 =
_prefab.m_class.name.StartsWith("NExt") ||
_prefab.m_class.name.StartsWith("NEXT") ||
Expand All @@ -102,7 +102,7 @@ private void GetDisplayName()
_prefab.name.StartsWith("Highway2L2W") ||
_prefab.name.StartsWith("AsymHighwayL1R2");

// Check for Extra Train Station Tracks, OneWayTrainTrack, and MOM prefabs; this overrides the NExt2 check due to some OneWayTrainTrack prefabs haveing 'NExtSingleStaitonTrack' ItemClass (and hence being picked up above as NExt2 items).
// Check for Extra Train Station Tracks, OneWayTrainTrack, and MOM prefabs; this overrides the NExt2 check due to some OneWayTrainTrack prefabs having 'NExtSingleStationTrack' ItemClass (and hence being picked up above as NExt2 items).
_isMod = _prefab.name.StartsWith("Station") ||
_prefab.name.StartsWith("Train Station Track (") ||
_prefab.name.StartsWith("Rail1L") ||
Expand Down
7 changes: 3 additions & 4 deletions Code/Utils/PrefabUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace RON
{
using System;
using System.Collections.Generic;
using ColossalFramework;
using ColossalFramework.Packaging;
Expand Down Expand Up @@ -308,8 +307,8 @@ internal static string GetCreator(NetInfo network)
/// </summary>
/// <param name="slopeParents">Slope parent dictionary.</param>
/// <param name="elevatedParents">Elevated parent dictionary.</param>
/// <param name="bridgeParents">Brige parent dictionary.</param>
/// <param name="tunnelParents">Tunnel arent dictionary.</param>
/// <param name="bridgeParents">Bridge parent dictionary.</param>
/// <param name="tunnelParents">Tunnel parent dictionary.</param>
internal static void GetParents(Dictionary<NetInfo, NetInfo> slopeParents, Dictionary<NetInfo, NetInfo> elevatedParents, Dictionary<NetInfo, NetInfo> bridgeParents, Dictionary<NetInfo, NetInfo> tunnelParents)
{
// Iterate through all loaded net prefabs.
Expand Down Expand Up @@ -404,7 +403,7 @@ internal static string GetDisplayName(PrefabInfo prefab)
/// <param name="parent">Parent prefab.</param>
private static void RecordParent(Dictionary<NetInfo, NetInfo> dictionary, NetInfo child, NetInfo parent)
{
// Null checks - child is routine, but the othes shouldn't be.
// Null checks - child is routine, but the others shouldn't be.
if (child == null || parent == null || dictionary == null)
{
return;
Expand Down

0 comments on commit 7d5c721

Please sign in to comment.