This commit is contained in:
JacobTech 2024-04-01 10:12:49 -04:00
parent d685737e1e
commit 64a22b5358
33 changed files with 399 additions and 393 deletions

View File

@ -6,7 +6,7 @@ public class Settings
{
[JsonInclude]
[JsonPropertyName("scale")]
public double Scale { get; set; } = 1;
public double? Scale { get; set; } = null;
[JsonInclude]
[JsonPropertyName("perscrollpixels")]
public uint PerScrollPixels { get; set; } = 20;
@ -25,11 +25,25 @@ public class Settings
[JsonInclude]
[JsonPropertyName("default_display")]
public int Display { get; set; } = 0;
[JsonInclude]
[JsonPropertyName("log")]
public ConsoleLog Logs { get; set; } = ConsoleLog.DrawFrames | ConsoleLog.BigErrosForOpenGL |
ConsoleLog.MediumErrosForOpenGL | ConsoleLog.LowErrosForOpenGL;
[JsonInclude]
[JsonPropertyName("scale_fonts")]
public bool ScaleFonts { get; set; } = true;
[JsonInclude]
[JsonPropertyName("default_font_px")]
public uint DefaultFontPX { get; set; } = 20;
[JsonInclude]
[JsonPropertyName("top_time_font_px")]
public uint TopTimeFonttPX { get; set; } = 11;
[JsonInclude]
[JsonPropertyName("message_font_px")]
public uint MessageFontPX { get; set; } = 17;
[JsonInclude]
[JsonPropertyName("message_font_line_space_px")]
public uint MessageFontLineSpacePX { get; set; } = 5;
}

View File

@ -17,7 +17,7 @@ public class AccountButton : UserControl
:base(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
this.SM = SM;
base.Size = new((int)(297 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
base.Size = new(297.ScaleInt(), 40.ScaleInt());
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
l = new Label(Globals.DefaultFont)

View File

@ -10,14 +10,14 @@ public class AddServerIcon : UserControl
{
Button = new(Globals.ms.TextureManager.GetTextureResource("add.png"))
{
Location = new((int)(18 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale), 0),
Size = new((int)(32 * Globals.Settings.Scale)),
Location = new(18.ScaleInt(), 8.ScaleInt(), 0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.White,
IgnoreHover = true
};
Controls.Add(Button);
BackgroundColor = new(26, 26, 26, 255);
base.Size = new((int)(68 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
base.BackgroundColor = new(26, 26, 26, 255);
base.Size = new(68.ScaleInt(), 48.ScaleInt());
}
}

View File

@ -34,7 +34,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
Form = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
Size = new((int)(350 * Globals.Settings.Scale), (int)(347 * Globals.Settings.Scale)),
Size = new(350.ScaleInt(), 347.ScaleInt()),
BackgroundColor = new(32,32,32,255),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
TextureDisplay = TextureDisplay.Center
@ -50,18 +50,18 @@ public class AddServerOverlay : UserControl, IServerOverlay
Color = Color4.DarkGray,
IgnoreHover = true
};
Vector2i s =new((int)(ll.Size.X * 1.6f),(int)(27 * Globals.Settings.Scale));
Vector2i s =new((int)(ll.Size.X * 1.6f),27.ScaleInt());
ll = null;
Rectangle line = new Rectangle()
{
Size = new Vector2i((int)Globals.Settings.Scale),
Size = new Vector2i(1.ScaleInt()),
BackgroundColor = Globals.DodgerBlue
};
tb = new()
{
Location = new((int)(10*Globals.Settings.Scale),(int)(50 * Globals.Settings.Scale), 0),
Location = new(10.ScaleInt(),50.ScaleInt(), 0),
Size = s,
WatermarkText = "Server Address",
TextLocation = TextLocation.PostiveTureCenterLeft,
@ -195,8 +195,8 @@ public class AddServerOverlay : UserControl, IServerOverlay
btn.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
page!.Controls.Add(UserName = new()
{
Location = new(0, (int)(10* Globals.Settings.Scale), 0),
Size = new(page.Size.X, (int)(30* Globals.Settings.Scale)),
Location = new(0, 10.ScaleInt(), 0),
Size = new(page.Size.X, 30.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
AllowMultiLine = false
@ -283,7 +283,7 @@ public class AddServerOverlay : UserControl, IServerOverlay
page.Controls.Add(rec = new(Globals.ms.TextureManager.GetAlphaCircle())
{
Size = new((int)(50 * Globals.Settings.Scale)),
Size = new(50.ScaleInt()),
BackgroundColor = Color4.Red,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
IgnoreHover = false
@ -355,8 +355,8 @@ public class AddServerOverlay : UserControl, IServerOverlay
btn!.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
page!.Controls.Add(UserName = new()
{
Location = new(0, (int)(22* Globals.Settings.Scale), 0),
Size = new(page.Size.X, (int)(31* Globals.Settings.Scale)),
Location = new(0, 22.ScaleInt(), 0),
Size = new(page.Size.X, 31.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
AllowMultiLine = false

View File

@ -11,9 +11,9 @@ public class LuskiContextMenu : BetterContextMenu
public LuskiContextMenu()
:base(Globals.ms.TextureManager.GetTextureResource("Context.png"))
{
Margins = new((int)(5 * Globals.Settings.Scale));
Margins = new(5.ScaleInt());
TextureDisplay = TextureDisplay.Center;
SpaceBetweenObjects = (int)(8 * Globals.Settings.Scale);
SpaceBetweenObjects = 8.ScaleInt();
}
public Label AddLabel(string text, Color4 color)
@ -47,6 +47,6 @@ public class LuskiContextMenu : BetterContextMenu
public new void AddLine()
{
AddLine(Color4.White, (int)Globals.Settings.Scale);
AddLine(Color4.White, 1.ScaleInt());
}
}

View File

@ -0,0 +1,34 @@
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class RoleView : FlowLayout
{
private string n = "";
private int i = 0;
private Label l;
private Role r;
public RoleView(Role r)
{
n = r.Name;
this.r = r;
Console.WriteLine(r.Name);
l = new(Globals.DefaultFont)
{
Text = " " + n + " — " + i.ToString(),
};
base.Size = new(0, 30.ScaleInt());
base.BackgroundColor = new(43, 45, 49, 255);
Controls.Add(l);
}
public async Task AddUser(SocketUser user)
{
var f = await UserView.Make(user, r);
Controls.Add(f);
Size = new(Size.X, Size.Y + f.Size.Y);
i++;
l.Text = " " + n + " — " + i.ToString();
}
}

View File

@ -1,3 +1,4 @@
using System.Timers;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
@ -6,6 +7,7 @@ using OpenTK.Mathematics;
using OpenTK.Windowing.Common;
using OpenTK.Windowing.Common.Input;
using OpenTK.Windowing.GraphicsLibraryFramework;
using Timer = System.Timers.Timer;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
@ -13,10 +15,16 @@ public class TextBox : UserControl
{
private Label _watermark, _label;
private bool use;
private Rectangle Pointer;
private Timer t;
public int CursorLocation { get; set; } = 0;
public TextBox()
:base(Globals.ms.TextureManager.GetTextureResource("Textbox.png"))
{
t = new(500);
t.Elapsed += TOnElapsed;
TextureDisplay = TextureDisplay.Center;
_label = new Label(Globals.DefaultFont)
{
@ -30,18 +38,36 @@ public class TextBox : UserControl
HoverMouse = MouseCursor.IBeam,
IgnoreHover = true
};
Pointer = new()
{
Size = new(1.ScaleInt(), (int)(Globals.DefaultFont.PixelHeight * ((float)Globals.DefaultFont.CurrentFonts[0].Face.Height/Globals.DefaultFont.CurrentFonts[0].Face.UnitsPerEM)) ),
Location = _watermark.Location,
BackgroundColor = Color4.White,
Visible = false
};
Controls.Add(Pointer);
Controls.Add(_label);
Controls.Add(_watermark);
}
private void TOnElapsed(object? sender, ElapsedEventArgs e)
{
Globals.ms.Invoke(new Action(() =>
{
Pointer.Visible = !Pointer.Visible;
}));
}
public event Func<KeyboardKeyEventArgs, Task>? KeyPress;
public override void UnFocus()
{
use = false;
Pointer.Visible = false;
if (Window is not null && Window.focused == this)
Window.focused = null;
}
public override void Focus()
{
@ -51,6 +77,7 @@ public class TextBox : UserControl
{
Window.focused.UnFocus();
}
t.Start();
Window.focused = this;
use = true;
@ -65,12 +92,17 @@ public class TextBox : UserControl
window.TextInput += WindowOnTextInput;
if (!window.Context.IsCurrent) window.Context.MakeCurrent();
base.LoadToParent(parent, window);
Pointer.Location = _watermark.Location;
}
private void WindowOnTextInput(TextInputEventArgs obj)
{
if (!use) return;
Text += obj.AsString;
Text = Text.Insert((int)CursorLocation, obj.AsString);
CursorLocation += obj.AsString.Length;
var f = _label.GetCharLocation((int)CursorLocation);
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
Pointer.Visible = true;
}
@ -88,7 +120,7 @@ public class TextBox : UserControl
{
_label.Location = value switch
{
TextLocation.PostiveTureCenterLeft => new((int)(10 * Globals.Settings.Scale),
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(),
((Size.Y - _label.PostiveTrueHeight) / 2) - _label.Size.Y + _label.TrueHeight, Location.Z),
_ => _label.Location
};
@ -98,7 +130,7 @@ public class TextBox : UserControl
{
_watermark.Location = value switch
{
TextLocation.PostiveTureCenterLeft => new((int)(10 * Globals.Settings.Scale),
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(),
((Size.Y - _watermark.PostiveTrueHeight) / 2) - _watermark.Size.Y + _watermark.TrueHeight, Location.Z),
_ => _watermark.Location
};
@ -160,7 +192,7 @@ public class TextBox : UserControl
_label.Visible = true;
_label.Location = TextLocation switch
{
TextLocation.PostiveTureCenterLeft => new((int)(10*Globals.Settings.Scale), ((Size.Y - _label.PostiveTrueHeight) / 2) - _label.Size.Y + _label.TrueHeight, Location.Z),
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(), ((Size.Y - _label.PostiveTrueHeight) / 2) - _label.Size.Y + _label.TrueHeight, Location.Z),
_ => _label.Location
};
/*
@ -188,7 +220,7 @@ public class TextBox : UserControl
_watermark.Visible = true;
_watermark.Location = TextLocation switch
{
TextLocation.PostiveTureCenterLeft => new((int)(10*Globals.Settings.Scale), ((Size.Y - _watermark.PostiveTrueHeight) / 2) - _watermark.Size.Y + _watermark.TrueHeight, Location.Z),
TextLocation.PostiveTureCenterLeft => new(10.ScaleInt(), ((Size.Y - _watermark.PostiveTrueHeight) / 2) - _watermark.Size.Y + _watermark.TrueHeight, Location.Z),
_ => _watermark.Location
};
/*
@ -222,17 +254,48 @@ public class TextBox : UserControl
private void Window_KeyDown(KeyboardKeyEventArgs obj)
{
if (!use) return;
if (obj.Key == Keys.Left)
{
CursorLocation--;
var f = _label.GetCharLocation((int)CursorLocation);
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
Pointer.Visible = true;
}
if (obj.Key == Keys.Right)
{
if (CursorLocation != Text.Length)
{
CursorLocation++;
var f = _label.GetCharLocation((int)CursorLocation);
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
Pointer.Visible = true;
}
}
if (obj.Key == Keys.CapsLock || obj.Key == Keys.Menu || obj.Key == Keys.LeftSuper || obj.Key == Keys.RightSuper || obj.Key == Keys.End || obj.Key == Keys.Home || obj.Key == Keys.PageDown || obj.Key == Keys.PageUp || obj.Key == Keys.Insert || obj.Key == Keys.Up || obj.Key == Keys.Down || obj.Key == Keys.Left || obj.Key == Keys.Right) return;
if (obj.Key == Keys.Backspace || obj.Key == Keys.Delete)
if (obj.Key == Keys.Backspace)
{
if (!(Text.Length > 0)) return;
if (Text[Text.Length - 1] == '\n')
if (Text[CursorLocation- 1] == '\n')
{
Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight);
if (OnRemoveLine is not null) OnRemoveLine.Invoke();
}
Text = Text.Remove(Text.Length - 1, 1);
Text = Text.Remove(CursorLocation - 1, 1);
CursorLocation--;
var f = _label.GetCharLocation(CursorLocation);
Pointer.Location = _label.Location + new Vector3i(f.X, f.Y, 0);
Pointer.Visible = true;
}
if (obj.Key == Keys.Delete)
{
if (CursorLocation == Text.Length) return;
if (Text[CursorLocation] == '\n')
{
Size = new(Size.X, Size.Y - (int)_label.Font.PixelHeight);
if (OnRemoveLine is not null) OnRemoveLine.Invoke();
}
Text = Text.Remove(CursorLocation, 1);
}
if (obj.Key == Keys.Enter)

View File

@ -0,0 +1,31 @@
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.net.Structures.Public;
namespace Luski.GUI.MainScreen.UI.LuskiControls;
public class UserView : UserControl
{
private UserView(IRenderObject user, SocketUser u, Role r)
{
base.Size = new(244.ScaleInt(), 44.ScaleInt());
base.BackgroundColor = new(43, 45, 49, 255);
user.Location = new(8.ScaleInt(), 6.ScaleInt(), 0);
user.ForceDistanceUpdate(this);
Label uname = new(Globals.DefaultFont)
{
Text = u.DisplayName,
Color = r.Color.ToColor4()
};
uname.Location = new(user.Location.X + user.Size.X + 8.ScaleInt(),
(user.Location.Y + (user.Size.Y / 2) - (uname.PostiveTrueHeight / 2) - uname.Size.Y + uname.TrueHeight), 0);
Controls.Add(uname);
Controls.Add(user);
}
public static async Task<UserView> Make(SocketUser u, Role r)
{
UserView m = new(await u.MakeRct(new(32.ScaleInt()), true), u, r);
return m;
}
}

View File

@ -23,8 +23,8 @@ public class AddChannel : UserControl
Anchor = ObjectAnchor.All;
FlowLayout fl = new()
{
SpaceBetweenObjects = (int)(5 * Globals.Settings.Scale),
Size = new((int)(350 * Globals.Settings.Scale), (int)(220 * Globals.Settings.Scale)),
SpaceBetweenObjects = 5.ScaleInt(),
Size = new(350.ScaleInt(), 220.ScaleInt()),
BackgroundColor = new(32,32,32,255),
//Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
//TextureDisplay = TextureDisplay.Center
@ -34,7 +34,7 @@ public class AddChannel : UserControl
fl.Controls.Add(cn =new TextBox()
{
WatermarkText = "Channel Name",
Size = new((int)(34 * Globals.Settings.Scale)),
Size = new(34.ScaleInt()),
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
TextLocation = TextLocation.PostiveTureCenterLeft
});
@ -42,14 +42,14 @@ public class AddChannel : UserControl
fl.Controls.Add(cd =new TextBox()
{
WatermarkText = "Channel Description",
Size = new((int)(34 * Globals.Settings.Scale)),
Size = cn.Size,
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
TextLocation = TextLocation.PostiveTureCenterLeft
});
fl.Controls.Add(new Label(Globals.DefaultFont) {Text = "\n "});
fl.Controls.Add(btn = new(Globals.ms.TextureManager.GetTextureResource("Textbox.png"))
{
Size = new((int)(40 * Globals.Settings.Scale)),
Size = new(40.ScaleInt()),
TextureDisplay = TextureDisplay.Center
});
Label sub = new(Globals.DefaultFont)

View File

@ -27,7 +27,7 @@ public class Category : UserControl, IChannelAdder
c.CurrentCategory = cat;
c.CS = cs;
c.Anchor = ObjectAnchor.All;
c.Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
c.Size = new(307.ScaleInt(), 40.ScaleInt());
c.tmp = new()
{
Size = c.Size,
@ -40,7 +40,7 @@ public class Category : UserControl, IChannelAdder
c.tmp.Controls.Add(c.ee = new(Globals.DefaultFont)
{
Text = ">",
Location = new((int)(5*Globals.Settings.Scale)),
Location = new(5.ScaleInt()),
Color = cat.Color.ToColor4(),
DIR = new(1,0),
IgnoreHover = true
@ -52,11 +52,11 @@ public class Category : UserControl, IChannelAdder
IgnoreHover = true
});
c.Clicked += c.AllOnClicked;
c.Name.Location = new((int)(26 * Globals.Settings.Scale), ((c.Size.Y/2) - (c.Name.TrueHeight/ 2) - (c.Name.Size.Y - c.Name.TrueHeight)), 0);
c.Name.Location = new(26.ScaleInt(), ((c.Size.Y/2) - (c.Name.TrueHeight/ 2) - (c.Name.Size.Y - c.Name.TrueHeight)), 0);
c.Members = new()
{
Anchor = ObjectAnchor.All,
Location = new((int)(20 * Globals.Settings.Scale), c.Size.Y, 0),
Location = new(20.ScaleInt(), c.Size.Y, 0),
IgnoreHover = true
};
c.ee.Location = new(c.ee.Location.X, c.Name.Location.Y, 0);

View File

@ -21,15 +21,15 @@ public class Channel : UserControl
{
CS = cs;
CurrentChannel = chan;
base.Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
base.Size = new(307.ScaleInt(), 34.ScaleInt());
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
int i = (int)(4 * Globals.Settings.Scale);
int i = 4.ScaleInt();
r = new Rectangle(Globals.ms.TextureManager.GetAlphaCircle())
{
Location = new(i,i,0),
Size = new ((int)(32 * Globals.Settings.Scale)),
Size = new (32.ScaleInt()),
IgnoreHover = true
};
Texture tex;
@ -48,7 +48,7 @@ public class Channel : UserControl
};
Controls.Add(ChannelName);
Clicked += AllOnClicked;
ChannelName.Location = new((int)(40 * Globals.Settings.Scale),
ChannelName.Location = new(40.ScaleInt(),
(base.Size.Y / 2) - ((int)ChannelName.Font.PixelHeight) + (ChannelName.PostiveTrueHeight / 2)
, 0);
base.HoverMouse = MouseCursor.Hand;
@ -59,11 +59,11 @@ public class Channel : UserControl
{
CS = cs;
CurrentChannel = chan;
base.Size = new((int)(307 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale));
base.Size = new(307.ScaleInt(), 34.ScaleInt());
TextureDisplay = TextureDisplay.HorizontalCenter;
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context];
int i = (int)(4 * Globals.Settings.Scale);
int i = 4.ScaleInt();
GC.Collect();
ChannelName = new Label(Globals.DefaultFont)
{

View File

@ -1,10 +1,7 @@
using System.Diagnostics;
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using GraphicsManager.Objects.Core;
using Luski.net.Interfaces;
using Luski.net.Structures.Main;
using Luski.net.Structures.Public;
@ -16,7 +13,6 @@ namespace Luski.GUI.MainScreen.UI.PublicServers;
public class ChatMessage : UserControl
{
//private static Font TimeFont;// = Font.MakeFontFromSystem(13);
private SocketMessage Msg { get; }
private SocketChannel ch { get; }
@ -25,8 +21,8 @@ public class ChatMessage : UserControl
private IRenderObject LastObject;
private Label FirstL;
private readonly double HorPadding = (12 * Globals.Settings.Scale),
VerticalPadding = (12 * Globals.Settings.Scale);
private readonly double HorPadding = 12.ScaleDouble(),
VerticalPadding = 0.ScaleDouble();
private static Dictionary<MainSocketRemoteUser, List<ChatMessage>> Messages = new();
@ -35,7 +31,7 @@ public class ChatMessage : UserControl
IUser auth = await message.GetAuthor(CancellationToken.None);
Color c = await auth.GetColor();
Color4 c4 = new(c.R, c.G, c.B, c.A);
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), auth, await auth.MakeRct(new((int)(38 * Globals.Settings.Scale)), message.IsProfile), c4);
return new ChatMessage(p, message, await message.GetParent(CancellationToken.None), auth, await auth.MakeRct(new(40.ScaleInt()), message.IsProfile), c4);
}
@ -43,70 +39,70 @@ public class ChatMessage : UserControl
{
pc = p;
Label label1;
Size = new((int)(723.5 * Globals.Settings.Scale), (int)(37 * Globals.Settings.Scale));
base.Size = new(723.5.ScaleInt(), 37.ScaleInt());
ch = chan;
BackgroundColor = new(40, 40, 40, 255);
base.BackgroundColor = new(40, 40, 40, 255);
Msg = message;
Anchor = ObjectAnchor.Left | ObjectAnchor.Right;
DateTime time = chan.Epoch.AddMilliseconds(Msg.ID >> 20).ToLocalTime();
string timestr;
string time_str;
if (time.Date == DateTime.Now.ToLocalTime().Date)
{
timestr = $"Today at {time.ToShortTimeString()}";
time_str = $"Today at {time.ToShortTimeString()}";
}
else if (time.Date == DateTime.Now.ToLocalTime().AddDays(-1).Date)
{
timestr = $"Yesterday at {time.ToShortTimeString()}";
time_str = $"Yesterday at {time.ToShortTimeString()}";
}
else
{
timestr = $"{time:M/dd/yyyy h:mm tt}";
time_str = $"{time:M/dd/yyyy h:mm tt}";
}
UserIcon.Location = new((int)(10 * Globals.Settings.Scale), (int)(2 * Globals.Settings.Scale), 0);
UserIcon.Location = new(10.ScaleInt(), 2.ScaleInt(), 0);
Controls.Add(UserIcon);
Controls.Add(label1 = new Label(Globals.DefaultFont) { Color = UserNameColor, Text = Author.DisplayName });
label1.Location = new(
(int)(54 * Globals.Settings.Scale),
(int)(UserIcon.Location.Y + (UserIcon.Size.Y / 2) - (label1.Font.CurrentFonts[0].Face.Size.Metrics.NominalHeight / 2) - label1.Size.Y + label1.Font.PixelHeight), 0);
54.ScaleInt(),
//(int)(UserIcon.Location.Y + (UserIcon.Size.Y / 2) - (label1.Font.CurrentFonts[0].Face.Size.Metrics.NominalHeight / 2) - label1.Size.Y + label1.Font.PixelHeight),
UserIcon.Location.Y,
0);
LastObject = label1;
FirstL = label1;
Controls.Add(new Label(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + (int)(8 * Globals.Settings.Scale), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight), 0), Text = timestr});
Controls.Add(new Label(Globals.TopTimeFont) { Location = new(label1.Location.X + label1.Size.X + 8.ScaleInt(), (int)(label1.Location.Y + label1.Font.PixelHeight - Globals.TopTimeFont.PixelHeight), 0), Text = time_str});
if (!string.IsNullOrWhiteSpace(Msg.Context))
{
Label l;
Controls.Add(l = new Label(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(LastObject.Location.Y + (LastObject as Label)!.Size.Y + VerticalPadding), 0), Text = message.Context});
Controls.Add(l = new Label(Globals.MessageFont) { Location = new(LastObject.Location.X, (int)(UserIcon.Location.Y + UserIcon.Size.Y - Globals.MessageFont.PixelHeight), 0), Text = message.Context});
LastObject = l;
}
if (Msg.Files.Count > 0)
{
int row = 1;
int filesonrow = 0;
int files_on_row = 0;
for (int i = 0; i < Msg.Files.Count; i++)
{
double lx = (HorPadding * filesonrow) + LastObject.Location.X + (333 * (filesonrow + 1));
if (lx > Size.X)
double lx = (HorPadding * files_on_row) + LastObject.Location.X + (333 * (files_on_row + 1));
if (lx > base.Size.X)
{
row++;
filesonrow = 0;
lx = (HorPadding * filesonrow) + LastObject.Location.X + (333 * (filesonrow + 1));
files_on_row = 0;
lx = (HorPadding * files_on_row) + LastObject.Location.X + (333 * (files_on_row + 1));
}
filesonrow++;
files_on_row++;
IRenderObject cem = ContentEmbed.GetEmbed(this, Msg.Files[i], Msg.ChannelID).Result;
cem.Location = new((int)(lx - 333), (int)(LastObject.Location.Y + 2 + LastObject.Size.Y + (HorPadding * row) + (66 * (row - 1))), 0);
LastObject = cem;
//lo = cem.Location;
// si = cem.Size;
Controls.Add(cem);
}
}
if (LastObject is Label ll) Size = new(Size.X, (int)(ll.Location.Y + ll.Size.Y + VerticalPadding));
else Size = new(Size.X ,(int)(LastObject.Location.Y + LastObject.Size.Y + VerticalPadding));
if (LastObject is Label ll) base.Size = new(base.Size.X, (int)(ll.Location.Y + ll.Size.Y + VerticalPadding));
else base.Size = new(base.Size.X ,(int)(LastObject.Location.Y + LastObject.Size.Y + VerticalPadding));
}
public async Task AddMessage(SocketMessage msg)
@ -216,7 +212,7 @@ public class ChatMessage : UserControl
Label m = new(Globals.DefaultFont)
{
Text = time.ToString("h:mm tt"),
Location = new((int)(7.5 * Globals.Settings.Scale), label.Location.Y - 13 + (int)label.Font.PixelHeight, 0),
Location = new(7.5.ScaleInt(), label.Location.Y - 13 + (int)label.Font.PixelHeight, 0),
};
Controls.Add(m);

View File

@ -25,7 +25,7 @@ public class ContentEmbed : UserControl
Texture t = Globals.ms.TextureManager.AddTexture(data);
data.Dispose();
Rectangle r;
double s = (Globals.Settings.Scale * 322);
double s = 322.ScaleDouble();
double scale = s / t.RawSize!.Value.X;
m.Controls.Add(r = new Rectangle(t)
{

View File

@ -1,6 +1,7 @@
using System.Reflection;
using GraphicsManager;
using GraphicsManager.Enums;
using GraphicsManager.Interfaces;
using GraphicsManager.Objects;
using Luski.GUI.MainScreen.UI.LuskiControls;
using Luski.net.Structures.Public;
@ -21,17 +22,18 @@ public class PublicChat : UserControl
UserControl titlecon;
private Rectangle? UserCon;
private SocketMessage? first;
private FlowLayout? memberflow = null;
public PublicChat()
{
base.Size = new((int)(980 * Globals.Settings.Scale), (int)(866 * Globals.Settings.Scale));
base.Size = new(980.ScaleInt(), 866.ScaleInt());
BackgroundColor = new(40,40,40,255);
Anchor = ObjectAnchor.All;
Controls.Add(MessageFlow = new()
{
Size = new(base.Size.X, (int)(761 * Globals.Settings.Scale)),
Location = new(0, (int)(52 * Globals.Settings.Scale), 0),
Size = new(base.Size.X, 761.ScaleInt()),
Location = new(0, 52.ScaleInt(), 0),
BackgroundColor = new(40,40,40,255),
Anchor = ObjectAnchor.All,
HScrollPixels = Globals.Settings.PerScrollPixels,
@ -41,7 +43,7 @@ public class PublicChat : UserControl
Controls.Add(titlecon = new UserControl()
{
Anchor = ObjectAnchor.Left | ObjectAnchor.Top | ObjectAnchor.Right,
Size = new((int)(980 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale)),
Size = new(980.ScaleInt(), 48.ScaleInt()),
BackgroundColor = new(50,50,50,255),
});
if (LuskiExperiments.ServerExperiments.MemberList.IsEnabled())
@ -49,12 +51,13 @@ public class PublicChat : UserControl
UserCon =
new(Globals.ms.TextureManager.GetTextureResource("person.png"))
{
Size = new((int)(24 * Globals.Settings.Scale)),
Location = new((int)(944 * Globals.Settings.Scale),(int)(12 * Globals.Settings.Scale),0),
Size = new(24.ScaleInt()),
Location = new(944.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Red
};
UserCon.Clicked += UserConOnClicked;
titlecon.Controls.Add(UserCon);
}
LuskiExperiments.ServerExperiments.MemberList.EventToggled += MemberListOnEventToggled;
@ -63,8 +66,6 @@ public class PublicChat : UserControl
titlecon.Controls.Add(title = new Label(Globals.DefaultFont)
{
//Location = new(
// (int)((26 - (Globals.DefaultFont.PixelHeight / 2)) * Globals.Settings.Scale),
// (int)((26 * Globals.Settings.Scale) - (Globals.DefaultFont.PixelHeight/2.0)))
});
titlecon.Controls.Add(desc = new Label(Globals.DefaultFont)
{
@ -76,8 +77,8 @@ public class PublicChat : UserControl
{
// InsideColor = new(28, 28, 28, 255),
//BorderColor = Color4.DarkCyan,
Location = new((int)(10 * Globals.Settings.Scale), (int)(824 * Globals.Settings.Scale), 0),
Size = new((int)(960 * Globals.Settings.Scale), (int)(34 * Globals.Settings.Scale)),
Location = new(10.ScaleInt(), 824.ScaleInt(), 0),
Size = new(960.ScaleInt(), 34.ScaleInt()),
Anchor = ObjectAnchor.Bottom | ObjectAnchor.Left | ObjectAnchor.Right,
HoverMouse = MouseCursor.IBeam,
//Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
@ -118,6 +119,7 @@ public class PublicChat : UserControl
{
await Channel!.SendMessage(tb.Text);
tb.Text = string.Empty;
tb.CursorLocation = 0;
}
}
@ -139,28 +141,74 @@ public class PublicChat : UserControl
return Task.CompletedTask;
}
private Task MemberListOnEventToggled(bool arg)
private async Task MemberListOnEventToggled(bool arg)
{
if (arg)
{
UserCon =
new(Globals.ms.TextureManager.GetTextureResource("person.png"))
{
Size = new((int)(24 * Globals.Settings.Scale)),
Location = new(base.Size.X - (int)(36 * Globals.Settings.Scale),(int)(12 * Globals.Settings.Scale),0),
Size = new(24.ScaleInt()),
Location = new(base.Size.X - 36.ScaleInt(), 12.ScaleInt(),0),
Anchor = ObjectAnchor.Right | ObjectAnchor.Top,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Red
};
UserCon.Clicked += UserConOnClicked;
titlecon.Controls.Add(UserCon);
}
else
{
if (um_open) await UserConOnClicked(UserCon!);
titlecon.Controls.Remove(UserCon!);
UserCon = null;
}
}
return Task.CompletedTask;
private bool um_open = false;
private async Task UserConOnClicked(IRenderObject arg)
{
um_open = !um_open;
if (um_open)
{
if (memberflow is null)
{
int x = 232.ScaleInt();
memberflow = new()
{
BackgroundColor = new(255, 0, 0, 255),
Size = new(x, Size.Y - titlecon.Size.Y),
Location = new(Size.X - x, titlecon.Size.Y, 0)
};
Controls.Add(memberflow);
Dictionary<long, RoleView> Roles = new();
foreach (var m in await Channel!.GetMembers())
{
Role top_role = (await m.GetRoles())[0];
if (!Roles.ContainsKey(top_role.ID))
{
Roles.Add(top_role.ID, new(top_role));
memberflow.Controls.Add(Roles[top_role.ID]);
}
Roles[top_role.ID].AddUser(m);
}
}
memberflow.Visible = true;
MessageFlow.Size = new(MessageFlow.Size.X - memberflow.Size.X, MessageFlow.Size.Y);
tb.Size = new(tb.Size.X - memberflow.Size.X, tb.Size.Y);
tb.ForceDistanceUpdate();
}
else
{
memberflow!.Visible = false;
MessageFlow.Size = new(MessageFlow.Size.X + memberflow.Size.X, MessageFlow.Size.Y);
tb.Size = new(tb.Size.X + memberflow.Size.X, tb.Size.Y);
tb.ForceDistanceUpdate();
}
}
private SocketMessage? lastm;
@ -177,15 +225,21 @@ public class PublicChat : UserControl
public async Task LoadChannel(SocketChannel channel)
{
Channel = channel;
if (memberflow is not null)
{
memberflow.Controls.Clear();
}
title.Text = channel.Name;
desc.Text = channel.Description;
desc.Location = new((int)(title.Location.X + title.Size.X + (5 * Globals.Settings.Scale)), desc.Location.Y, 0);
desc.Location = new((int)(title.Location.X + title.Size.X + 5.ScaleInt()), desc.Location.Y, 0);
if (Window is not null)
{
Window.Title = $"{channel.Name} | {channel.Server.Name} - Luski";
}
tb.WatermarkText = $"Message {channel.Name}";
tb.Text = "";
tb.CursorLocation = 0;
tb.Focus();
}
public void ClearChat()

View File

@ -45,23 +45,23 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
{
Rectangle r = new(Globals.ms.TextureManager.GetTextureResource("rc.png"))
{
Location = new((int)(18 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale), 0),
Size = new((int)(32 * Globals.Settings.Scale)),
Location = new(18.ScaleInt(), 8.ScaleInt(), 0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaTextureShader[Globals.ms.Context],
IgnoreHover = true
};
Rectangle rr = new(r.Textures[0])
{
Location = new((int)(17 * Globals.Settings.Scale), (int)(7 * Globals.Settings.Scale), 0),
Size = new((int)(34 * Globals.Settings.Scale)),
Location = new(17.ScaleInt(), 7.ScaleInt(), 0),
Size = new(34.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = new(26, 26, 26, 255),
IgnoreHover = true
};
SelectedRect = new(r.Textures[0])
{
Location = new((int)(14 * Globals.Settings.Scale), (int)(4 * Globals.Settings.Scale), 0),
Size = new((int)(40 * Globals.Settings.Scale)),
Location = new(14.ScaleInt(), 4.ScaleInt(), 0),
Size = new(40.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = new(26, 26, 26, 255),
IgnoreHover = true
@ -75,7 +75,7 @@ public class ServerIcon<TServer> : UserControl where TServer : Server
Controls.Add(r);
BackgroundColor = new(26, 26, 26, 255);
this.Clicked += OnClicked;
Size = new((int)(68 * Globals.Settings.Scale), (int)(48 * Globals.Settings.Scale));
Size = new(68.ScaleInt(), 48.ScaleInt());
}
private async Task OnClicked(IRenderObject arg)

View File

@ -34,7 +34,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Form = new(Globals.ms.TextureManager.GetTextureResource("RoundedRectangle.png"))
{
Size = new((int)(350 * Globals.Settings.Scale), (int)(347 * Globals.Settings.Scale)),
Size = new(350.ScaleInt(), 347.ScaleInt()),
BackgroundColor = new(32,32,32,255),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
TextureDisplay = TextureDisplay.Center
@ -50,18 +50,18 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
Color = Color4.DarkGray,
IgnoreHover = true
};
Vector2i s =new((int)(ll.Size.X * 1.6f),(int)(27 * Globals.Settings.Scale));
Vector2i s =new((int)(ll.Size.X * 1.6f),27.ScaleInt());
ll = null;
Rectangle line = new Rectangle()
{
Size = new Vector2i((int)Globals.Settings.Scale),
Size = new Vector2i(1.ScaleInt()),
BackgroundColor = Globals.DodgerBlue
};
tb = new()
{
Location = new((int)(10*Globals.Settings.Scale),(int)(50 * Globals.Settings.Scale), 0),
Location = new(10.ScaleInt(),50.ScaleInt(), 0),
Size = s,
Text = address,
WatermarkText = "Server Address",
@ -196,8 +196,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
btn.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
page!.Controls.Add(UserName = new()
{
Location = new(0, (int)(10* Globals.Settings.Scale), 0),
Size = new(page.Size.X, (int)(30* Globals.Settings.Scale)),
Location = new(0, 10.ScaleInt(), 0),
Size = new(page.Size.X, 30.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
AllowMultiLine = false
@ -284,7 +284,7 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
page.Controls.Add(rec = new(Globals.ms.TextureManager.GetAlphaCircle())
{
Size = new((int)(50 * Globals.Settings.Scale)),
Size = new(50.ScaleInt()),
BackgroundColor = Color4.Red,
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
IgnoreHover = false
@ -356,8 +356,8 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
btn!.Textures[0] = Globals.ms.TextureManager.GetTextureResource("BadTextbox.png");
page!.Controls.Add(UserName = new()
{
Location = new(0, (int)(22* Globals.Settings.Scale), 0),
Size = new(page.Size.X, (int)(31* Globals.Settings.Scale)),
Location = new(0, 22.ScaleInt(), 0),
Size = new(page.Size.X, 31.ScaleInt()),
WatermarkText = "Username",
TextLocation = TextLocation.PostiveTureCenterLeft,
AllowMultiLine = false
@ -466,8 +466,6 @@ public class ServerLoginOverlay : UserControl, IServerOverlay
BackgroundColor = Form.BackgroundColor
};
page.Size = new(Form.Size.X - tb.Location.X - tb.Location.X, Form.Size.Y - tb.Location.X - page.Location.Y - ca.Size.Y - tb.Location.X);
Console.Write(page.Size.Y - tb.Location.X - tb.Location.X - (50*2*3));
Console.WriteLine(page.Size);
Form.Controls.Add(page);
btn = new(Globals.ms.TextureManager.GetTextureResource("BadTextbox.png"))

View File

@ -33,7 +33,7 @@ public class SettingsMenu : UserControl
fl = new()
{
BackgroundColor = new(20, 20, 20, 255),
Size = new((int)(307 * Globals.Settings.Scale), base.Size.Y),
Size = new(307.ScaleInt(), base.Size.Y),
Anchor = ObjectAnchor.Top | ObjectAnchor.Left | ObjectAnchor.Bottom
};
f = Globals.DefaultFont.Clone();
@ -46,7 +46,7 @@ public class SettingsMenu : UserControl
AppSettings = new("APP SETTINGS");
Label Top = new(Globals.DefaultFont)
{
Location = new((int)(5 * Globals.Settings.Scale), (int)(5 * Globals.Settings.Scale), 0),
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
Text = LuskiThemes.Dark.Name
};
CategoryButton cb2 = new("Appearance", this)
@ -60,9 +60,9 @@ public class SettingsMenu : UserControl
ThemeDropButton LightDD;
ThemeDrop = new(CategoryButton.seltec!,new Rectangle()
{
Size = new(base.Size.X - 2, (int)Globals.Settings.Scale),
Size = new(base.Size.X - 2, 1.ScaleInt()),
BackgroundColor = Color4.Gray,
Location = new(1, base.Size.Y - (int)Globals.Settings.Scale, 0),
Location = new(1, base.Size.Y - 1.ScaleInt(), 0),
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Bottom
}, LightDD = new(LuskiThemes.Light)
{
@ -74,13 +74,13 @@ public class SettingsMenu : UserControl
Color = Color4.DarkGray,
IgnoreHover = true
};
ll.Location = new((int)(10 * Globals.Settings.Scale),
ll.Location = new(10.ScaleInt(),
(ThemeDrop!.Size.Y / 2) - ((int)ll.Font.PixelHeight) + (ll.PostiveTrueHeight / 2)
, 0);
ThemeDrop.Controls.Add(ll);
},
Size = new((int)(297 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale)),
}){DropDownParentOverride = Globals.ms,Size = new((int)(40 * Globals.Settings.Scale)),
Size = new(297.ScaleInt(), 40.ScaleInt()),
}){DropDownParentOverride = Globals.ms,Size = new(40.ScaleInt()),
Location = new(Top.Location.X, Top.Location.Y, 0),
BackgroundColor = new(40, 40, 40, 255),
Anchor = ObjectAnchor.Right | ObjectAnchor.Left,};
@ -98,12 +98,12 @@ public class SettingsMenu : UserControl
Color = Color4.DarkGray,
IgnoreHover = true
};
ll.Location = new((int)(10 * Globals.Settings.Scale),
ll.Location = new(10.ScaleInt(),
(ThemeDrop!.Size.Y / 2) - ((int)ll.Font.PixelHeight) + (ll.PostiveTrueHeight / 2)
, 0);
ThemeDrop.Controls.Add(ll);
},
Size = new((int)(297 * Globals.Settings.Scale), (int)(40* Globals.Settings.Scale)),
Size = new(297.ScaleInt(), 40.ScaleInt()),
});
if (themeStart.Name == Globals.Settings.Theme) ThemeDrop.SetSelected(tdb);
}
@ -113,9 +113,9 @@ public class SettingsMenu : UserControl
ThemeDrop.DropDownContainer.BackgroundColor = ThemeDrop.BackgroundColor;
Rectangle line = new()
{
Size = new(base.Size.X - 2, (int)Globals.Settings.Scale),
Size = new(base.Size.X - 2, 1.ScaleInt()),
BackgroundColor = Color4.Gray,
Location = new(1, base.Size.Y - (int)Globals.Settings.Scale, 0),
Location = new(1, base.Size.Y - 1.ScaleInt(), 0),
Anchor = ObjectAnchor.Left | ObjectAnchor.Right | ObjectAnchor.Bottom
};
ThemeDrop.OpenStatusChanged += b =>
@ -192,7 +192,7 @@ public class SettingsMenu : UserControl
Text = Globals.UpdaterSettings.Updater!,
WatermarkText = "Updater File",
TextureDisplay = TextureDisplay.Center,
Size = new(page.Size.X, (int)(34 * Globals.Settings.Scale)),
Size = new(page.Size.X, 34.ScaleInt()),
TextLocation = TextLocation.PostiveTureCenterLeft,
AllowMultiLine = false
});
@ -210,8 +210,8 @@ public class SettingsMenu : UserControl
page = new()
{
BackgroundColor = this.BackgroundColor,
Location = new(fl.Size.X + (int)(40 * Globals.Settings.Scale), 0, 0),
Size = new(Globals.ms.Size.X - fl.Size.X - ((int)(80 * Globals.Settings.Scale)), Globals.ms.Size.Y),
Location = new(fl.Size.X + 40.ScaleInt(), 0, 0),
Size = new(Globals.ms.Size.X - fl.Size.X - 80.ScaleInt(), Globals.ms.Size.Y),
AllowHoverFromBehind = true,
Anchor = ObjectAnchor.All,
HScrollPixels = Globals.Settings.PerScrollPixels
@ -222,8 +222,8 @@ public class SettingsMenu : UserControl
Rectangle closebtn = new(Globals.ms.TextureManager.GetTextureResource("close.png"))
{
Location = new(Globals.ms.Size.X - (int)(40 * Globals.Settings.Scale), (int)(8 * Globals.Settings.Scale),0),
Size = new((int)(32 * Globals.Settings.Scale)),
Location = new(Globals.ms.Size.X - 40.ScaleInt(), 8.ScaleInt(),0),
Size = new(32.ScaleInt()),
Shader = Rectangle.DefaultAlphaShader[Globals.ms.Context],
BackgroundColor = Color4.Gray,
Anchor = ObjectAnchor.Top | ObjectAnchor.Right

View File

@ -24,17 +24,17 @@ public class Category : UserControl
}
Top = new(fi)
{
Location = new((int)(5 * Globals.Settings.Scale), (int)(5 * Globals.Settings.Scale), 0),
Location = new(5.ScaleInt(), 5.ScaleInt(), 0),
Text = Name
};
BackgroundColor = new(255, 255, 255, 0);
base.Size = new((int)(307 * Globals.Settings.Scale), (int)(20 * Globals.Settings.Scale) + Top.Size.Y);
base.Size = new(307.ScaleInt(), 20.ScaleInt() + Top.Size.Y);
Top.Location = new((base.Size.X - Top.Size.X) / 2, Top.Location.Y, 0);
line = new()
{
Size = new(base.Size.X, (int)Globals.Settings.Scale),
Size = new(base.Size.X, 1.ScaleInt()),
BackgroundColor = Color4.Gray,
Location = new(0, base.Size.Y - (int)Globals.Settings.Scale, 0)
Location = new(0, base.Size.Y - 1.ScaleInt(), 0)
};
line.ForceDistanceUpdate(this);
Controls.Add(line);
@ -44,7 +44,7 @@ public class Category : UserControl
public void AddButton(CategoryButton cb)