forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8ad8335
commit cddc6be
Showing
9 changed files
with
189 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Control xmlns="https://spacestation14.io" | ||
MouseFilter="Stop" | ||
MinSize="100 100"> | ||
|
||
<Label | ||
Name="NoImageLabel" Text="{Loc 'image-viewer-no-image'}" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
MouseFilter="Ignore"/> | ||
|
||
<TextureRect | ||
Name="Picture" | ||
Stretch="KeepCentered" | ||
MouseFilter="Ignore"/> | ||
</Control> |
106 changes: 106 additions & 0 deletions
106
Content.Client/SS220/PictureViewer/PictureViewer.xaml.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,106 @@ | ||
using System.Numerics; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Input; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.SS220.PictureViewer; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class PictureViewer : Control | ||
{ | ||
private ResPath _viewedPicture; | ||
|
||
private const float ScrollSensitivity = 0.1f; | ||
private const float MaxZoom = 10f; | ||
|
||
private float _zoom = 1f; | ||
private bool _draggin = false; | ||
private Vector2 _offset = Vector2.Zero; | ||
|
||
public ResPath ViewedPicture | ||
{ | ||
get => _viewedPicture; | ||
set | ||
{ | ||
_viewedPicture = value; | ||
Picture.TexturePath = value.ToString(); | ||
} | ||
} | ||
|
||
private void UpdateZoom() | ||
{ | ||
var invZoom = 1 / _zoom; | ||
Picture.TextureScale = new Vector2(invZoom, invZoom); | ||
} | ||
|
||
private void UpdateOffset() | ||
{ | ||
//Picture.Margin = new Thickness(_offset.X, _offset.Y); | ||
var position = _offset; | ||
var rect = UIBox2.FromDimensions(position, this.Size); | ||
Picture.Arrange(rect); | ||
} | ||
|
||
protected override void MouseWheel(GUIMouseWheelEventArgs args) | ||
{ | ||
base.MouseWheel(args); | ||
_zoom -= args.Delta.Y * ScrollSensitivity; | ||
_zoom = float.Clamp(_zoom, 1, MaxZoom); | ||
Logger.DebugS("ZOOM: ", _zoom.ToString()); | ||
UpdateZoom(); | ||
UpdateOffset(); | ||
|
||
args.Handle(); | ||
} | ||
|
||
protected override void KeyBindDown(GUIBoundKeyEventArgs args) | ||
{ | ||
base.KeyBindDown(args); | ||
|
||
if (args.Function == EngineKeyFunctions.Use) | ||
{ | ||
_draggin = true; | ||
} | ||
} | ||
|
||
protected override void KeyBindUp(GUIBoundKeyEventArgs args) | ||
{ | ||
base.KeyBindUp(args); | ||
|
||
if (args.Function == EngineKeyFunctions.Use) | ||
{ | ||
_draggin = false; | ||
} | ||
} | ||
|
||
protected override void MouseMove(GUIMouseMoveEventArgs args) | ||
{ | ||
base.MouseMove(args); | ||
|
||
if (!_draggin) | ||
return; | ||
|
||
//_recentering = false; | ||
_offset += new Vector2(args.Relative.X, args.Relative.Y); | ||
Logger.DebugS("OFFSET: ", _offset.ToString()); | ||
UpdateOffset(); | ||
|
||
/* | ||
if (_offset != Vector2.Zero) | ||
{ | ||
_recenter.Disabled = false; | ||
} | ||
else | ||
{ | ||
_recenter.Disabled = true; | ||
} | ||
*/ | ||
} | ||
|
||
public PictureViewer() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
Content.Client/SS220/ViewableStationMap/UI/ViewableStationMapWindow.xaml
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,7 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
xmlns:pv="clr-namespace:Content.Client.SS220.PictureViewer" | ||
Title="{Loc 'viewable-station-map-ui-window-title'}" | ||
MinSize="300 300" | ||
SetSize="725 725"> | ||
<pv:PictureViewer Name="Viewer"/> | ||
</DefaultWindow> |
21 changes: 21 additions & 0 deletions
21
Content.Client/SS220/ViewableStationMap/UI/ViewableStationMapWindow.xaml.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,21 @@ | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.SS220.ViewableStationMap.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class ViewableStationMapWindow : DefaultWindow | ||
{ | ||
public ResPath ViewedMap | ||
{ | ||
get => Viewer.ViewedPicture; | ||
set => Viewer.ViewedPicture = value; | ||
} | ||
|
||
public ViewableStationMapWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
} | ||
} |
32 changes: 30 additions & 2 deletions
32
Content.Client/SS220/ViewableStationMap/ViewableStationMapBoundUi.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 |
---|---|---|
@@ -1,12 +1,40 @@ | ||
using Robust.Client.GameObjects; | ||
using Robust.Shared.Serialization.TypeSerializers.Implementations; | ||
using Content.Client.SS220.ViewableStationMap.UI; | ||
using Content.Shared.SS220.ViewableStationMap; | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Client.SS220.ViewableStationMap; | ||
|
||
public sealed class ViewableStationMapBoundUserInterface : BoundUserInterface | ||
[UsedImplicitly] | ||
public sealed class StationViewableMapBoundUserInterface : BoundUserInterface | ||
{ | ||
public ViewableStationMapBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
[Dependency] private readonly IEntityManager _entMan = default!; | ||
|
||
private ViewableStationMapWindow? _window; | ||
|
||
public StationViewableMapBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new ViewableStationMapWindow(); | ||
_window.OpenCentered(); | ||
|
||
_window.OnClose += Close; | ||
|
||
if (_entMan.TryGetComponent(Owner, out ViewableStationMapComponent? comp)) | ||
_window.ViewedMap = SpriteSpecifierSerializer.TextureRoot/comp.MapTexture; | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (disposing) | ||
_window?.Dispose(); | ||
} | ||
} |
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 @@ | ||
image-viewer-no-image = К сожалению карты для этой станции пока еще нет. Увы! |
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 @@ | ||
viewable-station-map-ui-window-title = карта станции |
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