UI/Window/PathWindow.razor
@using Sandbox
@using Sandbox.UI
@using System

@namespace HC3.UI
@inherits SingletonWindow<PathWindow>

<root>
	<row>
		<column class="categories window-container">
			<button class="@(PathBuilder.PathType == PathType.Path ? "selected" : "")" tooltip="Path" onclick=@(() => SelectMode(PathType.Path))>
				<img class="icon" src="textures/path/path.png" />
			</button>

			<button class="@(PathBuilder.PathType == PathType.Queue ? "selected" : "")" tooltip="Queue" onclick=@(() => SelectMode(PathType.Queue))>
				<img class="icon" src="textures/path/queue.png" />
			</button>
		</column>

		<separator style="height: 100%;"/>

		<column>
			<column class="gap group">
				<row class="center gap">
					<button tooltip="Turn Left" class="@(BridgeActive ? "enabled" : "disabled")" onclick=@(() => PathBuilder.RotateCursor(-1))>
						<img class="icon small" src="textures/path/left.png" />
					</button>
					<button tooltip="Forward" class="@(BridgeActive ? "enabled" : "disabled")" onclick=@(() => PathBuilder.BuildCursor())>
						<img class="icon" src="textures/path/forward.png" />
					</button>
					<button tooltip="Turn Right" class="@(BridgeActive ? "enabled" : "disabled")" onclick=@(() => PathBuilder.RotateCursor(1))>
						<img class="icon small" src="textures/path/right.png" />
					</button>
				</row>
				<row class="gap">
					<button tooltip="Stairs Down" class="@(BridgeActive ? "enabled" : "disabled")" onclick=@(() => PathBuilder.Elevation = PathElevation.StairDown)>
						<img class="icon" src="textures/path/down.png" />
					</button>
					<button tooltip="Level" class="@(BridgeActive ? "enabled" : "disabled")" onclick=@(() => PathBuilder.Elevation = PathElevation.Flat)>
						<img class="icon" src="textures/path/flat.png" />
					</button>
					<button tooltip="Stairs Up" class="@(BridgeActive ? "enabled" : "disabled")" onclick=@(() => PathBuilder.Elevation = PathElevation.StairUp)>
						<img class="icon" src="textures/path/up.png" />
					</button>
				</row>
			</column>
		</column>
	</row>
</root>

@code
{
	public override string Title => "Paths";
	public override string Icon => "book";

	PathBuilder PathBuilder => PathBuilder.Instance;

	public bool BridgeActive => PathBuilder.CursorPosition != null;

	void SelectMode( PathType type )
	{
		if ( PathBuilder.PathType == type )
		{
			PlaySound("sounds/ui/click5.sound");
			return;
		}

		PlaySound("sounds/ui/click3.sound");
		PathBuilder.PathType = type;
		PathBuilder.UpdateGhostPath();
	}

	public override void OnActivated()
	{
		PathBuilder.Enabled = true;
	}

	public override void OnDeactivated()
	{
		PathBuilder.Enabled = false;
	}

	public override void Tick()
	{
		base.Tick();

		// can't use mouse enter/exit events because we've got buttons inside and they steal it
		PathBuilder.CursorMode = Box.Rect.IsInside( Mouse.Position );
	}

	protected override int BuildHash() => System.HashCode.Combine( base.BuildHash(), PathBuilder.PathType, BridgeActive );
}