diff --git a/Nebula.Launcher/ViewModels/ServerEntryModelView.cs b/Nebula.Launcher/ViewModels/ServerEntryModelView.cs index 86977fe..7f2eb64 100644 --- a/Nebula.Launcher/ViewModels/ServerEntryModelView.cs +++ b/Nebula.Launcher/ViewModels/ServerEntryModelView.cs @@ -93,7 +93,7 @@ public partial class ServerEntryModelView : ViewModelBase { Description = "Server of meow girls! Nya~ \nNyaMeow\nOOOINK!!"; ServerHubInfo = new ServerHubInfo("ss14://localhost", - new ServerStatus("Ameba", "Locala", ["rp:hrp", "18+"], "Antag", 15, 5, 1, false, DateTime.Now, 100), ["meow:rp"]); + new ServerStatus("Ameba", "Locala meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow meow ", ["rp:hrp", "18+"], "Antag", 15, 5, 1, false, DateTime.Now, 100), ["meow:rp"]); } protected override void Initialise() diff --git a/Nebula.Launcher/Views/ServerEntryView.axaml b/Nebula.Launcher/Views/ServerEntryView.axaml index 559f50c..30e0691 100644 --- a/Nebula.Launcher/Views/ServerEntryView.axaml +++ b/Nebula.Launcher/Views/ServerEntryView.axaml @@ -6,18 +6,21 @@ x:DataType="viewModels:ServerEntryModelView" xmlns="https://github.com/avaloniaui" xmlns:asyncImageLoader="clr-namespace:AsyncImageLoader;assembly=AsyncImageLoader.Avalonia" + xmlns:converters="clr-namespace:Nebula.Launcher.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:system="clr-namespace:System;assembly=System.Runtime" xmlns:viewModels="clr-namespace:Nebula.Launcher.ViewModels" - xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:converters="clr-namespace:Nebula.Launcher.Converters"> + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - - + + + + HorizontalScrollBarVisibility="Hidden" + Margin="10,0,0,0" + VerticalScrollBarVisibility="Disabled" + x:Name="AutoScrollViewer"> @@ -57,6 +64,7 @@ + - + - + - @@ -99,7 +96,7 @@ IsVisible="{Binding ExpandInfo}" Margin="5"> + + + diff --git a/Nebula.Launcher/Views/ServerEntryView.axaml.cs b/Nebula.Launcher/Views/ServerEntryView.axaml.cs index f1bf5ca..683464a 100644 --- a/Nebula.Launcher/Views/ServerEntryView.axaml.cs +++ b/Nebula.Launcher/Views/ServerEntryView.axaml.cs @@ -1,19 +1,69 @@ +using System; using Avalonia; using Avalonia.Controls; using Avalonia.Markup.Xaml; +using Avalonia.Threading; using Nebula.Launcher.ViewModels; namespace Nebula.Launcher.Views; public partial class ServerEntryView : UserControl { + private DispatcherTimer _scrollTimer; + private bool _scrollingDown = true; + public ServerEntryView() { InitializeComponent(); + StartAutoScrolling(); } public ServerEntryView(ServerEntryModelView modelView) : this() { DataContext = modelView; } + + private void StartAutoScrolling() + { + _scrollTimer = new DispatcherTimer + { + Interval = TimeSpan.FromMilliseconds(50) // Adjust the interval for scroll speed + }; + _scrollTimer.Tick += AutoScroll; + _scrollTimer.Start(); + } + + private void AutoScroll(object? sender, EventArgs e) + { + // Get the current offset and extent + var currentOffset = AutoScrollViewer.Offset.X; + var maxOffset = AutoScrollViewer.Extent.Width - AutoScrollViewer.Viewport.Width; + + if (_scrollingDown) + { + // Scroll down + if (currentOffset < maxOffset) + { + AutoScrollViewer.Offset = new Avalonia.Vector(currentOffset + 2, AutoScrollViewer.Offset.Y); // Adjust speed + } + else + { + // Reverse direction when reaching the bottom + _scrollingDown = false; + } + } + else + { + // Scroll up + if (currentOffset > 0) + { + AutoScrollViewer.Offset = new Avalonia.Vector(currentOffset - 2, AutoScrollViewer.Offset.Y); // Adjust speed + } + else + { + // Reverse direction when reaching the top + _scrollingDown = true; + } + } + } } \ No newline at end of file