Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions OpenDreamClient/Interface/BrowsePopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ internal sealed class BrowsePopup {
public BrowsePopup(
string name,
Vector2i size,
IClydeWindow ownerWindow) {
WindowDescriptor popupWindowDescriptor = new WindowDescriptor(name,
new() {
new ControlDescriptorBrowser {
Id = new DMFPropertyString("browser"),
Size = new DMFPropertySize(size),
Anchor1 = new DMFPropertyPos(0, 0),
Anchor2 = new DMFPropertyPos(100, 100)
}
}) {
Size = new DMFPropertySize(size)
};
IClydeWindow ownerWindow,
WindowDescriptor? descriptor = null) {

WindowDescriptor popupWindowDescriptor = descriptor ?? new WindowDescriptor(name) {
Size = new DMFPropertySize(size)
};

popupWindowDescriptor.ControlDescriptors.Add(new ControlDescriptorBrowser {
Id = new DMFPropertyString("browser"),
Size = new DMFPropertySize(size),
Anchor1 = new DMFPropertyPos(0, 0),
Anchor2 = new DMFPropertyPos(100, 100),
});

WindowElement = new ControlWindow(popupWindowDescriptor);
WindowElement.CreateChildControls();
Expand Down
24 changes: 13 additions & 11 deletions OpenDreamClient/Interface/Controls/ControlWindow.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using OpenDreamShared.Interface.Descriptors;
using OpenDreamShared.Interface.Descriptors;
using OpenDreamShared.Interface.DMF;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using System.Diagnostics.CodeAnalysis;

namespace OpenDreamClient.Interface.Controls;

Expand Down Expand Up @@ -50,7 +50,7 @@ protected override void UpdateElementDescriptor() {
_menuContainer.Visible = false;
}

if(!WindowDescriptor.IsPane.Value)
if (!WindowDescriptor.IsPane.Value)
UpdateWindowAttributes(_myWindow);

if (WindowDescriptor.IsDefault.Value) {
Expand All @@ -62,16 +62,16 @@ protected override void UpdateElementDescriptor() {
/// Closes the window if it is a child window. No effect if it is either a default window or a pane
/// </summary>
public void CloseChildWindow() {
if(_myWindow.osWindow is not null)
if (_myWindow.osWindow is not null)
_myWindow.osWindow.Close();
}

public OSWindow CreateWindow() {
if(_myWindow.osWindow is not null)
if (_myWindow.osWindow is not null)
return _myWindow.osWindow;

OSWindow window = new();
if(UIElement.Parent is not null)
if (UIElement.Parent is not null)
UIElement.Orphan();
window.Children.Add(UIElement);

Expand Down Expand Up @@ -103,7 +103,7 @@ public OSWindow CreateWindow() {

public void RegisterOnClydeWindow(IClydeWindow window) {
// todo: listen for closed.
if(_myWindow.osWindow is not null){
if (_myWindow.osWindow is not null) {
_myWindow.osWindow.Close();
UIElement.Orphan();
}
Expand Down Expand Up @@ -171,9 +171,9 @@ public void UpdateAnchorPosition(InterfaceControl control) {
// Also update the anchor position for anything with a size of 0
foreach (var child in ChildControls) {
if (child.UIElement.SetWidth == 0)
child.AnchorPosition = child.AnchorPosition with {X = _canvas.PixelWidth + child.Size.X};
child.AnchorPosition = child.AnchorPosition with { X = _canvas.PixelWidth + child.Size.X };
if (child.UIElement.SetHeight == 0)
child.AnchorPosition = child.AnchorPosition with {Y = _canvas.PixelHeight + child.Size.Y};
child.AnchorPosition = child.AnchorPosition with { Y = _canvas.PixelHeight + child.Size.Y };
}

UpdateAnchors();
Expand All @@ -184,7 +184,7 @@ private void UpdateWindowAttributes((OSWindow? osWindow, IClydeWindow? clydeWind
var (osWindow, clydeWindow) = windowRoot;

//if our window is null or closed, we need to create a new one. Otherwise we need to update the existing one.
if(osWindow == null && clydeWindow == null) {
if (osWindow == null && clydeWindow == null) {
CreateWindow();
return; //we return because CreateWindow() calls UpdateWindowAttributes() again.
}
Expand All @@ -206,8 +206,10 @@ private void UpdateWindowAttributes((OSWindow? osWindow, IClydeWindow? clydeWind

if (osWindow != null && osWindow.ClydeWindow != null) {
osWindow.ClydeWindow.IsVisible = WindowDescriptor.IsVisible.Value;
osWindow.ClydeWindow.IsTitleBarVisible = WindowDescriptor.TitleBar.Value;
} else if (clydeWindow != null) {
clydeWindow.IsVisible = WindowDescriptor.IsVisible.Value;
clydeWindow.IsTitleBarVisible = WindowDescriptor.TitleBar.Value;
}
}

Expand Down Expand Up @@ -341,7 +343,7 @@ public override bool TryGetProperty(string property, [NotNullWhen(true)] out IDM
public override void SetProperty(string property, string value, bool manualWinset = false) {
switch (property) {
case "size":
if (_myWindow.osWindow is {ClydeWindow: not null}) {
if (_myWindow.osWindow is { ClydeWindow: not null }) {
var size = new DMFPropertySize(value);
var uiScale = _myWindow.osWindow.UIScale;
size.X = (int)(size.X * uiScale); // TODO: RT should probably do this itself
Expand Down
8 changes: 4 additions & 4 deletions OpenDreamClient/Interface/Controls/InterfaceControl.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Diagnostics.CodeAnalysis;
using OpenDreamShared.Interface.Descriptors;
using OpenDreamShared.Interface.Descriptors;
using OpenDreamShared.Interface.DMF;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using System.Diagnostics.CodeAnalysis;

namespace OpenDreamClient.Interface.Controls;

Expand All @@ -22,7 +22,7 @@ public abstract class InterfaceControl : InterfaceElement {
/// </summary>
public Vector2i AnchorPosition = Vector2i.Zero;

protected ControlDescriptor ControlDescriptor => (ControlDescriptor) ElementDescriptor;
protected ControlDescriptor ControlDescriptor => (ControlDescriptor)ElementDescriptor;
protected readonly ControlWindow? Window;

[SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")]
Expand All @@ -45,7 +45,7 @@ protected override void UpdateElementDescriptor() {

//transparent is default because it's white with 0 alpha, and DMF color can't have none-255 alpha
StyleBox? styleBox = (ControlDescriptor.BackgroundColor.Value != Color.Transparent)
? new StyleBoxFlat {BackgroundColor = ControlDescriptor.BackgroundColor.Value}
? new StyleBoxFlat { BackgroundColor = ControlDescriptor.BackgroundColor.Value }
: null;

switch (UIElement) {
Expand Down
Loading
Loading