-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge https://github.com/ekrixi-14/ekrixi into morelowpop
- Loading branch information
Showing
43 changed files
with
1,110 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:ftlPoints="clr-namespace:Content.Client._FTL.FtlPoints" | ||
Resizable="False" | ||
Name="StarmapComputer" | ||
SetSize="1000 725" | ||
MinSize="1000 725"> | ||
<GridContainer Columns="2" Margin="5 0 5 0"> | ||
<BoxContainer Margin="0 0 5 0" Orientation="Vertical" HorizontalAlignment="Left"> | ||
<ftlPoints:StarmapControl Name="Stars" | ||
HorizontalExpand="True" | ||
VerticalExpand="True" | ||
MinSize="700 700" | ||
MaxSize="700 700" | ||
Margin="5 0 0 0"> | ||
</ftlPoints:StarmapControl> | ||
</BoxContainer> | ||
<BoxContainer Orientation="Vertical" | ||
HorizontalAlignment="Right" | ||
MinWidth="256" | ||
MaxWidth="256"> | ||
<controls:StripeBack> | ||
<Label Name="GeneralDetailsLabel" Text="{Loc 'starmap-details-display-label'}" HorizontalAlignment="Center"/> | ||
</controls:StripeBack> | ||
<BoxContainer Name="GDReadonlyDisplay"> | ||
<GridContainer Columns="2" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Top"> | ||
<Label Text="{Loc 'starmap-star-details-current-star'}"/> | ||
<Label Name="CurrentStarName" | ||
Text="0.0" | ||
HorizontalAlignment="Right"/> | ||
<Label Text="{Loc 'starmap-star-details-spin-range'}"/> | ||
<Label Name="MaxSpinRange" | ||
Text="0.0" | ||
HorizontalAlignment="Right"/> | ||
<Label Text="{Loc 'starmap-star-details-crystal-integrity'}"/> | ||
<Label Name="CrystalIntegrity" | ||
Text="0.0" | ||
HorizontalAlignment="Right"/> | ||
</GridContainer> | ||
</BoxContainer> | ||
|
||
<controls:StripeBack> | ||
<Label Name="StarDetailsLabel" Text="{Loc 'starmap-star-details-display-label'}" HorizontalAlignment="Center"/> | ||
</controls:StripeBack> | ||
<BoxContainer Name="SDReadonlyDisplay"> | ||
<GridContainer Columns="2" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Top"> | ||
<Label Text="{Loc 'starmap-star-details-name'}"/> | ||
<Label Name="StarName" | ||
Text="0.0" | ||
HorizontalAlignment="Right"/> | ||
<Label Text="{Loc 'starmap-star-details-coordinates'}"/> | ||
<Label Name="StarCoordinates" | ||
Text="0.0" | ||
HorizontalAlignment="Right"/> | ||
<Button Name="StarWarpButton" Text="{Loc 'starmap-star-details-button-warp'}" Disabled="True"/> | ||
</GridContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</GridContainer> | ||
</controls:FancyWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Numerics; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared._FTL.FtlPoints; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client._FTL.FtlPoints; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class StarmapConsole : FancyWindow | ||
{ | ||
private readonly StarmapConsoleBoundUserInterface _owner; | ||
private Star? _hoveredStar = null; | ||
|
||
public StarmapConsole(StarmapConsoleBoundUserInterface owner, IPrototypeManager protoManager) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
_owner = owner; | ||
|
||
Title = Loc.GetString("starmap-computer-title"); | ||
Stars.OnStarSelect += StarsOnOnStarSelect; | ||
StarWarpButton.OnPressed += args => | ||
{ | ||
if (_hoveredStar.HasValue) | ||
{ | ||
_owner.StarWarpButtonOnOnPressed(_hoveredStar.Value); | ||
} | ||
}; | ||
} | ||
|
||
private void StarsOnOnStarSelect(Star obj) | ||
{ | ||
StarName.Text = obj.Name; | ||
StarCoordinates.Text = Loc.GetString("starmap-star-details-position", ("x", MathF.Round(obj.GlobalPosition.X, 1)), ("y", MathF.Round(obj.GlobalPosition.Y, 1))); | ||
StarWarpButton.Disabled = false; | ||
_hoveredStar = obj; | ||
} | ||
|
||
public void UpdateState(StarmapConsoleBoundUserInterfaceState state) | ||
{ | ||
UpdateStars(state.Stars); | ||
Stars.Range = state.Range; | ||
var currentStar = state.Stars.Find(star => star.Position == Vector2.Zero); | ||
CurrentStarName.Text = currentStar.Name; | ||
} | ||
|
||
private void UpdateStars(List<Star> stars) | ||
{ | ||
Stars.SetStars(stars); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
Content.Client/_FTL/FtlPoints/StarmapConsoleBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Content.Shared._FTL.FtlPoints; | ||
using Robust.Shared.Prototypes; | ||
using JetBrains.Annotations; | ||
using Robust.Client.UserInterface.Controls; | ||
|
||
namespace Content.Client._FTL.FtlPoints; | ||
|
||
[UsedImplicitly] | ||
public sealed class StarmapConsoleBoundUserInterface : BoundUserInterface | ||
{ | ||
private StarmapConsole? _window; | ||
|
||
public StarmapConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) {} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
var collection = IoCManager.Instance; | ||
|
||
if (collection == null) | ||
return; | ||
|
||
_window = new StarmapConsole(this, IoCManager.Resolve<IPrototypeManager>()); | ||
_window.OnClose += Close; | ||
|
||
_window.OpenCentered(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (disposing) | ||
{ | ||
_window?.Dispose(); | ||
} | ||
} | ||
|
||
public void StarWarpButtonOnOnPressed(Star star) | ||
{ | ||
var message = new WarpToStarMessage(star); | ||
SendMessage(message); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
var castState = (StarmapConsoleBoundUserInterfaceState) state; | ||
_window?.UpdateState(castState); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
using System.Numerics; | ||
using Content.Shared._FTL.FtlPoints; | ||
using Content.Shared.Input; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Input; | ||
using Robust.Client.ResourceManagement; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.Input; | ||
using YamlDotNet.Core.Tokens; | ||
|
||
namespace Content.Client._FTL.FtlPoints; | ||
|
||
public sealed class StarmapControl : Control | ||
{ | ||
[Dependency] private readonly IInputManager _inputManager = default!; | ||
|
||
public float Range = 1f; | ||
|
||
private List<Star> _stars = new List<Star>(); | ||
private const float Ppd = 15f; | ||
|
||
private readonly Font _font; | ||
private bool _mouseDown = false; | ||
|
||
public event Action<Star>? OnStarSelect; | ||
|
||
public StarmapControl() | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
|
||
var cache = IoCManager.Resolve<IResourceCache>(); | ||
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/IBMPlexMono/IBMPlexMono-Regular.ttf"), 8); | ||
} | ||
|
||
public void SetStars(List<Star> stars) | ||
{ | ||
_stars = stars; | ||
} | ||
|
||
private Vector2 CalculateOffset() | ||
{ | ||
return Size / 2; | ||
} | ||
|
||
private Vector2 GetMouseCoordinates() | ||
{ | ||
return _inputManager.MouseScreenPosition.Position; | ||
} | ||
|
||
private Vector2 GetPositionOfStar(Vector2 position) | ||
{ | ||
return CalculateOffset() + (position * Ppd); | ||
} | ||
|
||
protected override void Draw(DrawingHandleScreen handle) | ||
{ | ||
base.Draw(handle); | ||
handle.DrawRect(new UIBox2(Vector2.Zero, Size), Color.Black); | ||
|
||
// Draw lines in a grid | ||
var lines = 10; | ||
|
||
for (var i = 0; i < lines; i++) | ||
{ | ||
var xStep = Size.X / lines; | ||
var yStep = Size.X / lines; | ||
handle.DrawLine(new Vector2(i * xStep, 0), new Vector2(i * xStep, Size.Y), Color.DarkSlateGray); | ||
handle.DrawLine(new Vector2(0, i * yStep), new Vector2(Size.X, i * yStep), Color.DarkSlateGray); | ||
} | ||
|
||
// Draw warp range | ||
handle.DrawCircle(GetPositionOfStar(Vector2.Zero), Range * Ppd, Color.White, false); | ||
handle.DrawCircle(GetPositionOfStar(Vector2.Zero), Range * Ppd, new Color(47, 79, 79, 127)); | ||
|
||
// Draw sensor range | ||
handle.DrawCircle(GetPositionOfStar(Vector2.Zero), (int) (Range * 1.5) * Ppd, Color.Blue, false); | ||
|
||
foreach (var star in _stars) | ||
{ | ||
var uiPosition = GetPositionOfStar(star.Position); | ||
var globalPosition = GlobalPosition + uiPosition; | ||
var radius = 5f; | ||
|
||
// check if distance is smaller than radius of circle then BOOm | ||
var hovered = Vector2.Distance(GetMouseCoordinates(), globalPosition) <= radius * 1.5; | ||
|
||
var color = Color.White; | ||
var name = star.Name; | ||
|
||
// out of warp range | ||
if (Vector2.Distance(Vector2.Zero, star.Position) >= Range) | ||
color = Color.Red; | ||
|
||
// out of scanning range | ||
if (Vector2.Distance(Vector2.Zero, star.Position) >= Range * 1.5) | ||
{ | ||
color = Color.DarkRed; | ||
name = Loc.GetString("ship-ftl-tag-oor"); | ||
} | ||
|
||
if (star.Position == Vector2.Zero) | ||
color = Color.Blue; | ||
|
||
// before circle rendering so that we can change whats rendered | ||
if (hovered) | ||
{ | ||
radius = 10f; | ||
} | ||
handle.DrawCircle(uiPosition, radius, color); | ||
|
||
// after circle rendering incase we wish to show text/etc | ||
if (hovered) | ||
{ | ||
handle.DrawString(_font, uiPosition + new Vector2(10, 0), name); | ||
} | ||
|
||
// on click | ||
if (!hovered || !_inputManager.IsKeyDown(Keyboard.Key.MouseLeft)) | ||
continue; | ||
|
||
if (Vector2.Distance(Vector2.Zero, star.Position) >= Range) | ||
continue; // out of warp range | ||
|
||
OnStarSelect?.Invoke(star); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.