Skip to content

Commit

Permalink
Merge pull request #17 from CitiesSkylinesMods/bugfix/v.0.8.0
Browse files Browse the repository at this point in the history
Version 0.8
  • Loading branch information
krzychu124 authored Mar 22, 2023
2 parents ab3508c + 07c381e commit 3f7019a
Show file tree
Hide file tree
Showing 21 changed files with 209 additions and 71 deletions.
30 changes: 30 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

[*]

# Microsoft .NET properties
csharp_indent_braces = false
csharp_new_line_before_catch = false
csharp_new_line_before_else = false
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_open_brace = accessors,events,indexers,properties
csharp_preferred_modifier_order = private, protected, public, virtual, volatile, abstract, internal, override, sealed, new, static, extern, unsafe, readonly, async:suggestion
csharp_preserve_single_line_blocks = true

# ReSharper properties
resharper_align_multiline_parameter = true
resharper_arguments_literal = positional
resharper_blank_lines_around_auto_property = 0
resharper_braces_for_for = required
resharper_csharp_align_multiline_binary_expressions_chain = true
resharper_csharp_blank_lines_around_invocable = 0
resharper_csharp_insert_final_newline = false
resharper_csharp_max_line_length = 286
resharper_csharp_wrap_parameters_style = chop_if_long
resharper_instance_members_qualify_declared_in =
resharper_keep_existing_embedded_block_arrangement = false
resharper_keep_existing_enum_arrangement = false
resharper_place_expr_property_on_single_line = true
resharper_remove_blank_lines_near_braces_in_declarations = false
resharper_space_within_single_line_array_initializer_braces = false
resharper_wrap_before_declaration_rpar = false
resharper_wrap_object_and_collection_initializer_style = wrap_if_long
7 changes: 5 additions & 2 deletions BrokenNodeDetector/BndResultHighlightManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class BndResultHighlightManager: SimulationManagerBase<BndResultHighlight
private Dictionary<HighlightType, IHighlightable> _highlightables = new Dictionary<HighlightType, IHighlightable>();
protected override void Awake() {
base.Awake();
name = "BND_ResultHighlightManager";
_mainCamera = Camera.main;
_highlightables = new Dictionary<HighlightType, IHighlightable> {
{HighlightType.Building, new BuildingHighlight()},
Expand Down Expand Up @@ -98,8 +99,10 @@ private bool RayCast(ToolBase.RaycastInput input, out ToolBase.RaycastOutput out
Vector3 hit;
bool found = false;
if (input.m_ignoreBuildingFlags != Building.Flags.All &&
Singleton<BuildingManager>.instance.RayCast(ray, input.m_buildingService.m_service, input.m_buildingService.m_subService, input.m_buildingService.m_itemLayers, input.m_ignoreBuildingFlags, out hit, out output.m_building))
{
Singleton<BuildingManager>.instance.RayCast(ray, input.m_buildingService.m_service, input.m_buildingService.m_subService, input.m_buildingService.m_itemLayers, input.m_ignoreBuildingFlags, out hit, out ushort buildingId)) {

ushort parentBuilding = Building.FindParentBuilding(buildingId);
output.m_building = parentBuilding != 0 ? parentBuilding : buildingId;
float distance = Vector3.Distance(hit, origin);
if (distance < (double) len)
{
Expand Down
7 changes: 5 additions & 2 deletions BrokenNodeDetector/BrokenNodeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@
using BrokenNodeDetector.UI;
using CitiesHarmony.API;
using ColossalFramework.UI;
using JetBrains.Annotations;
using UnityEngine;

namespace BrokenNodeDetector
{
public class BrokenNodeDetector : IUserMod {
public static readonly string Version = "0.7.1";
public static readonly string Version = "0.8.0";

public string Name => "Broken Node Detector " + Version;

public string Description => "Search for broken nodes when TM:PE vehicles despawn.";
public string Description => "Search for broken nodes when TM:PE vehicles despawn and more.";
#if TEST_UI
private MainUI _testUI;
#endif

[UsedImplicitly]
public void OnEnabled() {
Debug.Log($"[BND] Broken Node Detector enabled. Version {Version}");
HarmonyHelper.EnsureHarmonyInstalled();
Expand All @@ -34,6 +36,7 @@ public void OnEnabled() {
#endif
}

[UsedImplicitly]
public void OnDisabled() {
Debug.Log("[BND] Broken Node Detector disabled.");
if (LoadingExtension.MainUi) {
Expand Down
7 changes: 2 additions & 5 deletions BrokenNodeDetector/BrokenNodeDetector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="UI\Tools\BndColorAnimator.cs" />
<Compile Include="UI\Tools\StuckCimsTool\StuckCims.cs" />
<Compile Include="UI\Tools\UIHelpers.cs" />
<Compile Include="UI\Tools\Utils\EMLUtisl.cs" />
<Compile Include="UI\Tools\Utils\UnityExtensions.cs" />
</ItemGroup>
<ItemGroup>
Expand All @@ -87,10 +88,7 @@
<Reference Include="ColossalManaged, Version=0.3.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\Dependencies\ColossalManaged.dll</HintPath>
</Reference>
<Reference Include="EManagersLib.API">
<HintPath>..\Dependencies\EManagersLib.API.dll</HintPath>
</Reference>
<Reference Include="ICities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
<Reference Include="ICities, Version=1.16.0.0, Culture=neutral, PublicKeyToken=null">
<HintPath>..\Dependencies\ICities.dll</HintPath>
</Reference>
<Reference Include="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
Expand Down Expand Up @@ -120,7 +118,6 @@
del /Q "%25DEPLOYDIR%25*"
xcopy /y "$(TargetDir)BrokenNodeDetector.dll" "%25DEPLOYDIR%25"
xcopy /y "$(TargetDir)CitiesHarmony.API.dll" "%25DEPLOYDIR%25"
xcopy /y "$(TargetDir)EManagersLib.API.dll" "%25DEPLOYDIR%25"

set DEPLOYDIR=</PostBuildEvent>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions BrokenNodeDetector/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BrokenNodeDetector")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,4 +32,4 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.7.*")]
[assembly: AssemblyVersion("1.0.8.*")]
3 changes: 3 additions & 0 deletions BrokenNodeDetector/UI/MainPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class MainPanel : UIPanel {

public override void Awake() {
base.Awake();
name = "BND_MainPanel";
autoLayout = false;
width = PANEL_WIDTH;
height = PANEL_HEIGHT;
Expand Down Expand Up @@ -197,6 +198,8 @@ private void OnPrepareFinished(IDetector detector) {

private void OnResultsClose(bool updateHeight = false) {
_returnButton.Hide();
_preparePanel.CancelPrepare();
_preparePanel.Hide();
RunFadeInOutAnimations(_resultsPanel, _detectorsPanel);
if (BndResultHighlightManager.instance) {
BndResultHighlightManager.instance.enabled = false;
Expand Down
1 change: 1 addition & 0 deletions BrokenNodeDetector/UI/MainUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class MainUI : UIComponent {

public override void Awake() {
base.Awake();
name = "BND_MainUI";
var uiView = UIView.GetAView();
MainPanel = (MainPanel) uiView.AddUIComponent(typeof(MainPanel));
MainPanel.Initialize();
Expand Down
1 change: 1 addition & 0 deletions BrokenNodeDetector/UI/PreparePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public override void OnDestroy() {
public void CancelPrepare() {
if (_preparing && _prepareCoroutine != null) {
StopCoroutine(_prepareCoroutine);
_preparing = false;
}
}

Expand Down
17 changes: 15 additions & 2 deletions BrokenNodeDetector/UI/SettingsUI.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using System;
using ColossalFramework;
using ColossalFramework.UI;
#if BROKEN_PROPS_SCANNER
using BrokenNodeDetector.UI.Tools.Utils;
using EManagersLib.API;
#endif
using ICities;
using UnityEngine;

Expand All @@ -13,7 +16,10 @@ namespace BrokenNodeDetector.UI {
public class SettingsUI {
private const float ROW_WIDTH = 744f - 15f;
private const float ROW_HEIGHT = 34f;

#if BROKEN_PROPS_SCANNER
private bool? _emlInstalled;
#endif

private SavedInputKey _currentlyEditingBinding;

public void BuildUI(UIHelper helper) {
Expand All @@ -25,7 +31,14 @@ public void BuildUI(UIHelper helper) {
UIHelperBase group2 = helper.AddGroup("Other");
UIPanel panel2 = CreateRowPanel((UIPanel) ((UIHelper) group2).self);
CreateResetMenuPosition(panel2);
CreateLabel(panel2, $"EML integration active: {(PropAPI.m_isEMLInstalled ? "<color #00FF00>Yes</color>" : "No")}", 1f, true);

#if BROKEN_PROPS_SCANNER
if (!_emlInstalled.HasValue) {
_emlInstalled = EmlUtils.IsEmlInstalled();
}
CreateLabel(panel2, $"EML integration active: {(_emlInstalled.Value ? "<color #00FF00>Yes</color>" : "No")}", 1f, true);
#endif

panel2.autoLayoutDirection = LayoutDirection.Vertical;
panel2.autoLayoutPadding = new RectOffset(0, 0, 10, 10);
panel2.autoSize = true;
Expand Down
16 changes: 13 additions & 3 deletions BrokenNodeDetector/UI/Tools/BndColorAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace BrokenNodeDetector.UI.Tools {
public class BndColorAnimator : Singleton<BndColorAnimator> {
private readonly List<AnimationInfo> _animatorInfos = new List<AnimationInfo>();
private readonly NameMatcher _matcher = new NameMatcher();

public static void Animate(Action<Color> target, AnimatedColor color) {
instance.AnimateInternal(null, target, color, null);
Expand Down Expand Up @@ -34,16 +35,17 @@ public static bool IsAnimating(string name) {
}

private bool InternalIsAnimating(string animationName) {
AnimationInfo animationInfo =
this._animatorInfos.Find(info => info.AnimationName == animationName);
_matcher.name = animationName;
AnimationInfo animationInfo = this._animatorInfos.Find(_matcher.Match);
return animationInfo != null;
}

private void AnimateInternal(string animationName,
Action<Color> target,
AnimatedColor v,
Action completed) {
AnimationInfo animationInfo = _animatorInfos.Find(info => info.AnimationName == animationName);
_matcher.name = animationName;
AnimationInfo animationInfo = _animatorInfos.Find(_matcher.Match);
if (animationName != null && animationInfo != null) {
animationInfo.Value = v;
animationInfo.Completed = completed;
Expand Down Expand Up @@ -97,6 +99,7 @@ private void Update() {
}

private void OnDestroy() {
_animatorInfos.Clear();
GetType().GetField("sInstance", BindingFlags.NonPublic | BindingFlags.Static)
?.SetValue(null, null);
}
Expand All @@ -110,5 +113,12 @@ private class AnimationInfo {

public Action Completed;
}

private class NameMatcher {
public string name;
public bool Match(AnimationInfo info) {
return info.AnimationName == name;
}
}
}
}
1 change: 1 addition & 0 deletions BrokenNodeDetector/UI/Tools/BrokenNodesTool/BrokenNodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public override void InitResultsView(UIComponent component) {

private void BuildTemplate() {
_template = new GameObject("BrokenNodesTemplate").AddComponent<UIPanel>();
_template.transform.SetParent(_defaultGameObject.transform, true);
_template.width = 400;
_template.height = 50;
UILabel label = _template.AddUIComponent<UILabel>();
Expand Down
3 changes: 3 additions & 0 deletions BrokenNodeDetector/UI/Tools/BrokenPathTool/BrokenPaths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ private void AttachCallbacks(UIComponent templateInstance, ushort buildingId) {

private void BuildResultTemplate() {
_template = new GameObject("BrokenPathsTemplate").AddComponent<UIPanel>();
_template.transform.SetParent(_defaultGameObject.transform, true);
_template.width = 400;
_template.height = 50;
UILabel label = _template.AddUIComponent<UILabel>();
Expand Down Expand Up @@ -190,6 +191,7 @@ private void BuildResultTemplate() {

private void BuildPrepareTemplate() {
_templatePrepare = new GameObject("BrokenPathsPrepareTemplate").AddComponent<UIPanel>();
_templatePrepare.transform.SetParent(_defaultGameObject.transform, true);
_templatePrepare.width = 400;
_templatePrepare.height = 50;
UILabel label = _templatePrepare.AddUIComponent<UILabel>();
Expand All @@ -203,6 +205,7 @@ private void BuildPrepareTemplate() {

private void BuildRowTemplate() {
UIPanel resultRow = new GameObject("BrokenPathsRowTemplate").AddComponent<UIPanel>();
resultRow.gameObject.transform.SetParent(_defaultGameObject.transform, true);
resultRow.name = RESULT_ROW;
resultRow.width = 400;
resultRow.height = 40;
Expand Down
4 changes: 3 additions & 1 deletion BrokenNodeDetector/UI/Tools/BrokenPropsTool/BrokenProps.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if BROKEN_PROPS_SCANNER
using System.Collections;
using System.Collections.Generic;
using System.Threading;
Expand Down Expand Up @@ -145,4 +146,5 @@ private IEnumerator FixPropGrid() {
yield return null;
}
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if BROKEN_PROPS_SCANNER
using System;
using System.Collections;
using System.Collections.Generic;
Expand Down Expand Up @@ -169,4 +170,5 @@ private IEnumerator FixPropGrid() {
yield return null;
}
}
}
}
#endif
12 changes: 11 additions & 1 deletion BrokenNodeDetector/UI/Tools/DetectorFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
using System.Collections.ObjectModel;
using BrokenNodeDetector.UI.Tools.BrokenNodesTool;
using BrokenNodeDetector.UI.Tools.BrokenPathTool;
#if BROKEN_PROPS_SCANNER
using BrokenNodeDetector.UI.Tools.BrokenPropsTool;
#endif
using BrokenNodeDetector.UI.Tools.DisconnectedBuildingsTool;
using BrokenNodeDetector.UI.Tools.DisconnectedPublicTransportStopsTool;
using BrokenNodeDetector.UI.Tools.StuckCimsTool;
using BrokenNodeDetector.UI.Tools.GhostNodesTool;
using BrokenNodeDetector.UI.Tools.ShortSegmentsTool;
#if BROKEN_PROPS_SCANNER
using EManagersLib.API;
#endif
#if SEGMENT_UPDATER
using BrokenNodeDetector.UI.Tools.SegmentUpdateTool;
#endif
Expand All @@ -19,7 +23,10 @@ namespace BrokenNodeDetector.UI.Tools {
public class DetectorFactory : IDisposable {
private List<Detector> _detectors;

public DetectorFactory() {
public DetectorFactory() {
#if BROKEN_PROPS_SCANNER
PropAPI.Initialize();
#endif
_detectors = new List<Detector> {
new BrokenNodes(),
new GhostNodes(),
Expand All @@ -29,7 +36,9 @@ public DetectorFactory() {
#if SEGMENT_UPDATER
// new SegmentUpdateRequest(),
#endif
#if BROKEN_PROPS_SCANNER
(PropAPI.m_isEMLInstalled ? (Detector)new BrokenPropsEML() : new BrokenProps()),
#endif
new StuckCims(),
new BrokenPaths(),
};
Expand All @@ -46,6 +55,7 @@ public void Dispose() {
}
}
_detectors.Clear();
Detector.DisposeDefaultGameObject();
}
}
}
Loading

0 comments on commit 3f7019a

Please sign in to comment.