Skip to content

Commit

Permalink
Changed how button is positioned (now doesn't affect ELT or SP)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quboid committed Jun 20, 2023
1 parent 4cd3d38 commit 09308d1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
36 changes: 24 additions & 12 deletions NetworkAnarchy/NA_GUI.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ColossalFramework.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;

Expand Down Expand Up @@ -230,32 +231,43 @@ private void CreateToolOptionsButton()

try
{
UIPanel optionBar = UIView.Find<UIPanel>("OptionsBar");
String[] ignoreComponents = { "WaterPanel", "BrushPanel", "UndoTerrainPanel", "LevelHeightPanel" };
UIPanel optionsBar = UIView.Find<UIPanel>("OptionsBar");

if (optionBar == null)
if (optionsBar == null)
{
Log.Warning("OptionBar not found!", "[NA31.1]");
Log.Warning("OptionsBar not found!", "[NA31.1]");
return;
}

optionBar.autoLayout = true;
optionBar.autoLayoutDirection = LayoutDirection.Horizontal;
//optionsBar.autoLayout = true;
optionsBar.autoLayoutDirection = LayoutDirection.Horizontal;

// Save existing optionsBar components, clear list
IList<UIComponent> components = new List<UIComponent>();
foreach (UIComponent comp in optionBar.components)
foreach (UIComponent comp in optionsBar.components)
{
components.Add(comp);
if (!ignoreComponents.Contains(comp.name))
{
components.Add(comp);
}
}
foreach (UIComponent comp in components)
{
optionsBar.components.Remove(comp);
}
optionBar.components.Clear();

// Add NA button to empty list
m_toolOptionButton = optionBar.AddUIComponent(typeof(UIToolOptionsButton)) as UIToolOptionsButton;
m_toolOptionButton = optionsBar.AddUIComponent(typeof(UIToolOptionsButton)) as UIToolOptionsButton;

// Re-add components after NA button
foreach (UIComponent comp in components)
{
optionBar.components.Add(comp);
optionsBar.components.Add(comp);
if (comp.name == "RoadsOptionPanel")
{
comp.relativePosition += new Vector3(36, 0, 0);
}
}

if (m_toolOptionButton == null)
Expand All @@ -267,11 +279,11 @@ private void CreateToolOptionsButton()
// Configure NA button
m_toolOptionButton.autoSize = false;
m_toolOptionButton.size = new Vector2(36, 36);
m_toolOptionButton.position = Vector2.zero;
m_toolOptionButton.relativePosition = new Vector2(-47, 0);
m_toolOptionButton.isVisible = false;

// Iterate networks' option panels
RoadsOptionPanel[] panels = optionBar.GetComponentsInChildren<RoadsOptionPanel>();
RoadsOptionPanel[] panels = optionsBar.GetComponentsInChildren<RoadsOptionPanel>();
foreach (RoadsOptionPanel panel in panels)
{
// Remove vanilla elevation button
Expand Down
6 changes: 3 additions & 3 deletions NetworkAnarchy/NetworkAnarchy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net35</TargetFramework>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<Version>3.2.2</Version>
<Version>3.2.3</Version>
<ManagedDLLPath>$(MSBuildProgramFiles32)/Steam/steamapps/common/Cities_Skylines/Cities_Data/Managed/</ManagedDLLPath>
<AssemblySearchPaths>
$(AssemblySearchPaths);
Expand All @@ -11,8 +11,8 @@
</AssemblySearchPaths>
<PlatformTarget>AnyCPU</PlatformTarget>
<Deterministic>False</Deterministic>
<AssemblyVersion>3.2.2.*</AssemblyVersion>
<FileVersion>3.2.2.0</FileVersion>
<AssemblyVersion>3.2.3.*</AssemblyVersion>
<FileVersion>3.2.3.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CitiesHarmony.API" Version="2.1.0" />
Expand Down

0 comments on commit 09308d1

Please sign in to comment.