Skip to content

Commit

Permalink
Removed legacy modules; Fixed overlay icon sizes; Fixed button toggli…
Browse files Browse the repository at this point in the history
…ng in SpeedLimits
  • Loading branch information
kvakvs committed Nov 15, 2020
1 parent ffb6576 commit 14711de
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 2,403 deletions.
6 changes: 6 additions & 0 deletions TLM/TLM/Constants.cs
Expand Up @@ -30,5 +30,11 @@ public static class Constants {
}

public static IManagerFactory ManagerFactory => Manager.Impl.ManagerFactory.Instance;

/// <summary>Size for clickable signs used in overlays. Larger than readonly signs.</summary>
public const float OVERLAY_INTERACTIVE_SIGN_SIZE = 6.0f;

/// <summary>Size for readonly signs used in overlays.</summary>
public const float OVERLAY_READONLY_SIGN_SIZE = 3.8f;
}
}
2 changes: 0 additions & 2 deletions TLM/TLM/TLM.csproj
Expand Up @@ -312,15 +312,13 @@
<Compile Include="UI\Helpers\TrafficRulesOverlay.cs" />
<Compile Include="UI\SubTools\PrioritySigns\PrioritySignsTool.cs" />
<Compile Include="UI\SubTools\SpeedLimits\MphToggleButton.cs" />
<Compile Include="UI\SubTools\SpeedLimits\LegacySpeedLimitsTool.cs" />
<Compile Include="UI\SubTools\SpeedLimits\Overlay\OverlayLaneSpeedlimitHandle.cs" />
<Compile Include="UI\SubTools\SpeedLimits\Overlay\OverlaySegmentSpeedlimitHandle.cs" />
<Compile Include="UI\SubTools\SpeedLimits\Overlay\SpeedLimitsOverlay.cs" />
<Compile Include="UI\SubTools\SpeedLimits\Overlay\SpeedLimitsOverlaySign.cs" />
<Compile Include="UI\SubTools\SpeedLimits\PaletteGenerator.cs" />
<Compile Include="UI\SubTools\SpeedLimits\SpeedLimitPaletteButton.cs" />
<Compile Include="UI\SubTools\SpeedLimits\SpeedLimitSignTheme.cs" />
<Compile Include="UI\SubTools\SpeedLimits\SpeedLimitsTool_Legacy.cs" />
<Compile Include="UI\SubTools\SpeedLimits\SpeedLimitsTool.cs" />
<Compile Include="UI\SubTools\SpeedLimits\SpeedLimitsWindow.cs" />
<Compile Include="UI\SubTools\SpeedLimits\SpeedUnit.cs" />
Expand Down
18 changes: 13 additions & 5 deletions TLM/TLM/U/Button/UButton.cs
@@ -1,5 +1,6 @@
namespace TrafficManager.U {
using System;
using ColossalFramework.UI;

/// <summary>
/// Basic button, cannot be activated, clickable, no tooltip.
Expand Down Expand Up @@ -29,15 +30,22 @@ public class UButton : BaseUButton {
}

protected override bool IsActive() {
if (this.uIsActive != null) {
return this.uIsActive(this);
}

return false;
// use uIsActive if its defined, otherwise false. Override this in your buttons.
return this.uIsActive != null && this.uIsActive(this);
}

protected override string U_OverrideTooltipText() => this.uTooltip; // to override in subclass

protected override bool IsVisible() => this.isVisible;

/// <summary>
/// Sets up a clickable button which can be active (to toggle textures on the button).
/// </summary>
public void SetupToggleButton(MouseEventHandler onClickFun,
Func<UIComponent, bool> isActiveFun) {
this.uOnClick = onClickFun;
this.uIsActive = isActiveFun;
this.uCanActivate = _ => true;
}
}
}

0 comments on commit 14711de

Please sign in to comment.