feat(gui): optimized refresh rate
This commit is contained in:
1 parent
679b041b09
commit
9f6988e2ff
4 files changed
+95
-25
No files matched your search
@@ -150,6 +150,9 @@
|
|||||||
<Border.Effect>
|
<Border.Effect>
|
||||||
<BlurEffect Radius="18"/>
|
<BlurEffect Radius="18"/>
|
||||||
</Border.Effect>
|
</Border.Effect>
|
||||||
|
<Border.CacheMode>
|
||||||
|
<BitmapCache/>
|
||||||
|
</Border.CacheMode>
|
||||||
</Border>
|
</Border>
|
||||||
<Border x:Name="B" Background="{TemplateBinding Background}" CornerRadius="12" Padding="{TemplateBinding Padding}">
|
<Border x:Name="B" Background="{TemplateBinding Background}" CornerRadius="12" Padding="{TemplateBinding Padding}">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
@@ -1,8 +1,38 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
using System.Windows.Media.Animation;
|
||||||
|
|
||||||
namespace CapyLauncher
|
namespace CapyLauncher
|
||||||
{
|
{
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
struct DisplayMode
|
||||||
|
{
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string DeviceName;
|
||||||
|
public short SpecVersion, DriverVersion, Size, DriverExtra;
|
||||||
|
public int Fields, PositionX, PositionY, Orientation, FixedOutput;
|
||||||
|
public short Color, Duplex, YResolution, TTOption, Collate;
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)] public string FormName;
|
||||||
|
public short LogPixels;
|
||||||
|
public int BitsPerPel, PelsWidth, PelsHeight, DisplayFlags, DisplayFrequency;
|
||||||
|
public int IcmMethod, IcmIntent, MediaType, DitherType, Reserved1, Reserved2, PanningWidth, PanningHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
|
||||||
|
static extern bool EnumDisplaySettings(string device, int mode, ref DisplayMode devMode);
|
||||||
|
|
||||||
|
static int RefreshRate()
|
||||||
|
{
|
||||||
|
var mode = new DisplayMode { Size = (short)Marshal.SizeOf(typeof(DisplayMode)) };
|
||||||
|
if (!EnumDisplaySettings(null, -1, ref mode) || mode.DisplayFrequency <= 1)
|
||||||
|
return 60;
|
||||||
|
return mode.DisplayFrequency;
|
||||||
|
}
|
||||||
|
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline), new FrameworkPropertyMetadata { DefaultValue = RefreshRate() });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+34
-19
@@ -14,23 +14,23 @@
|
|||||||
<Window.Triggers>
|
<Window.Triggers>
|
||||||
<EventTrigger RoutedEvent="Window.Loaded">
|
<EventTrigger RoutedEvent="Window.Loaded">
|
||||||
<BeginStoryboard>
|
<BeginStoryboard>
|
||||||
<Storyboard>
|
<Storyboard Timeline.DesiredFrameRate="30">
|
||||||
<DoubleAnimation Storyboard.TargetName="BlobPink" Storyboard.TargetProperty="(Canvas.Left)" From="-160" To="140" Duration="0:0:23" AutoReverse="True" RepeatBehavior="Forever">
|
<DoubleAnimation Storyboard.TargetName="BlobPink" Storyboard.TargetProperty="RenderTransform.X" From="0" To="300" Duration="0:0:23" AutoReverse="True" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
<DoubleAnimation Storyboard.TargetName="BlobPink" Storyboard.TargetProperty="(Canvas.Top)" From="-180" To="60" Duration="0:0:17" AutoReverse="True" RepeatBehavior="Forever">
|
<DoubleAnimation Storyboard.TargetName="BlobPink" Storyboard.TargetProperty="RenderTransform.Y" From="0" To="240" Duration="0:0:17" AutoReverse="True" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
<DoubleAnimation Storyboard.TargetName="BlobPurple" Storyboard.TargetProperty="(Canvas.Left)" From="520" To="860" Duration="0:0:29" AutoReverse="True" RepeatBehavior="Forever">
|
<DoubleAnimation Storyboard.TargetName="BlobPurple" Storyboard.TargetProperty="RenderTransform.X" From="0" To="340" Duration="0:0:29" AutoReverse="True" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
<DoubleAnimation Storyboard.TargetName="BlobPurple" Storyboard.TargetProperty="(Canvas.Top)" From="380" To="140" Duration="0:0:21" AutoReverse="True" RepeatBehavior="Forever">
|
<DoubleAnimation Storyboard.TargetName="BlobPurple" Storyboard.TargetProperty="RenderTransform.Y" From="0" To="-240" Duration="0:0:21" AutoReverse="True" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
<DoubleAnimation Storyboard.TargetName="BlobBlue" Storyboard.TargetProperty="(Canvas.Left)" From="980" To="620" Duration="0:0:26" AutoReverse="True" RepeatBehavior="Forever">
|
<DoubleAnimation Storyboard.TargetName="BlobBlue" Storyboard.TargetProperty="RenderTransform.X" From="0" To="-360" Duration="0:0:26" AutoReverse="True" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
<DoubleAnimation Storyboard.TargetName="BlobBlue" Storyboard.TargetProperty="(Canvas.Top)" From="-220" To="20" Duration="0:0:19" AutoReverse="True" RepeatBehavior="Forever">
|
<DoubleAnimation Storyboard.TargetName="BlobBlue" Storyboard.TargetProperty="RenderTransform.Y" From="0" To="240" Duration="0:0:19" AutoReverse="True" RepeatBehavior="Forever">
|
||||||
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
<DoubleAnimation.EasingFunction><SineEase EasingMode="EaseInOut"/></DoubleAnimation.EasingFunction>
|
||||||
</DoubleAnimation>
|
</DoubleAnimation>
|
||||||
</Storyboard>
|
</Storyboard>
|
||||||
@@ -40,24 +40,39 @@
|
|||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Canvas ClipToBounds="True" IsHitTestVisible="False">
|
<Canvas ClipToBounds="True" IsHitTestVisible="False">
|
||||||
<Canvas.CacheMode>
|
<Ellipse x:Name="BlobPink" Width="900" Height="900" Canvas.Left="-330" Canvas.Top="-350">
|
||||||
<BitmapCache RenderAtScale="0.5"/>
|
<Ellipse.Fill>
|
||||||
</Canvas.CacheMode>
|
<RadialGradientBrush>
|
||||||
<Ellipse x:Name="BlobPink" Width="560" Height="560" Fill="#FF9AA2" Opacity="0.13">
|
<GradientStop Color="#2EFF9AA2" Offset="0"/>
|
||||||
<Ellipse.Effect><BlurEffect Radius="160" KernelType="Gaussian"/></Ellipse.Effect>
|
<GradientStop Color="#14FF9AA2" Offset="0.45"/>
|
||||||
|
<GradientStop Color="#00FF9AA2" Offset="1"/>
|
||||||
|
</RadialGradientBrush>
|
||||||
|
</Ellipse.Fill>
|
||||||
|
<Ellipse.RenderTransform><TranslateTransform/></Ellipse.RenderTransform>
|
||||||
</Ellipse>
|
</Ellipse>
|
||||||
<Ellipse x:Name="BlobPurple" Width="620" Height="620" Fill="#D689FF" Opacity="0.11">
|
<Ellipse x:Name="BlobPurple" Width="980" Height="980" Canvas.Left="350" Canvas.Top="210">
|
||||||
<Ellipse.Effect><BlurEffect Radius="170" KernelType="Gaussian"/></Ellipse.Effect>
|
<Ellipse.Fill>
|
||||||
|
<RadialGradientBrush>
|
||||||
|
<GradientStop Color="#26D689FF" Offset="0"/>
|
||||||
|
<GradientStop Color="#11D689FF" Offset="0.45"/>
|
||||||
|
<GradientStop Color="#00D689FF" Offset="1"/>
|
||||||
|
</RadialGradientBrush>
|
||||||
|
</Ellipse.Fill>
|
||||||
|
<Ellipse.RenderTransform><TranslateTransform/></Ellipse.RenderTransform>
|
||||||
</Ellipse>
|
</Ellipse>
|
||||||
<Ellipse x:Name="BlobBlue" Width="520" Height="520" Fill="#7DC8FF" Opacity="0.09">
|
<Ellipse x:Name="BlobBlue" Width="860" Height="860" Canvas.Left="810" Canvas.Top="-390">
|
||||||
<Ellipse.Effect><BlurEffect Radius="160" KernelType="Gaussian"/></Ellipse.Effect>
|
<Ellipse.Fill>
|
||||||
|
<RadialGradientBrush>
|
||||||
|
<GradientStop Color="#227DC8FF" Offset="0"/>
|
||||||
|
<GradientStop Color="#0F7DC8FF" Offset="0.45"/>
|
||||||
|
<GradientStop Color="#007DC8FF" Offset="1"/>
|
||||||
|
</RadialGradientBrush>
|
||||||
|
</Ellipse.Fill>
|
||||||
|
<Ellipse.RenderTransform><TranslateTransform/></Ellipse.RenderTransform>
|
||||||
</Ellipse>
|
</Ellipse>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
|
|
||||||
<Grid x:Name="Shell">
|
<Grid x:Name="Shell">
|
||||||
<Grid.Effect>
|
|
||||||
<BlurEffect x:Name="ShellBlur" Radius="0"/>
|
|
||||||
</Grid.Effect>
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="52"/>
|
<RowDefinition Height="52"/>
|
||||||
<RowDefinition Height="*"/>
|
<RowDefinition Height="*"/>
|
||||||
|
|||||||
+28
-6
@@ -66,7 +66,6 @@ namespace CapyLauncher
|
|||||||
string dispatch, gamePort, lastError;
|
string dispatch, gamePort, lastError;
|
||||||
bool closing;
|
bool closing;
|
||||||
int frame;
|
int frame;
|
||||||
double bob;
|
|
||||||
|
|
||||||
public MainWindow()
|
public MainWindow()
|
||||||
{
|
{
|
||||||
@@ -403,6 +402,24 @@ namespace CapyLauncher
|
|||||||
EmptyCapy.Source = swim[0];
|
EmptyCapy.Source = swim[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bob(bool on)
|
||||||
|
{
|
||||||
|
var move = (TranslateTransform)Capy.RenderTransform;
|
||||||
|
if (!on)
|
||||||
|
{
|
||||||
|
move.BeginAnimation(TranslateTransform.YProperty, new DoubleAnimation(0, TimeSpan.FromMilliseconds(300)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (move.HasAnimatedProperties && move.Y != 0)
|
||||||
|
return;
|
||||||
|
move.BeginAnimation(TranslateTransform.YProperty, new DoubleAnimation(-1.6, 1.6, TimeSpan.FromMilliseconds(900))
|
||||||
|
{
|
||||||
|
AutoReverse = true,
|
||||||
|
RepeatBehavior = RepeatBehavior.Forever,
|
||||||
|
EasingFunction = new SineEase { EasingMode = EasingMode.EaseInOut },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Swim()
|
void Swim()
|
||||||
{
|
{
|
||||||
bool awake = state == State.Online || state == State.Starting;
|
bool awake = state == State.Online || state == State.Starting;
|
||||||
@@ -411,8 +428,6 @@ namespace CapyLauncher
|
|||||||
if (awake)
|
if (awake)
|
||||||
{
|
{
|
||||||
Capy.Source = swim[frame];
|
Capy.Source = swim[frame];
|
||||||
bob += 0.35;
|
|
||||||
((TranslateTransform)Capy.RenderTransform).Y = Math.Sin(bob) * 1.5;
|
|
||||||
}
|
}
|
||||||
if (EmptyState.Visibility == Visibility.Visible)
|
if (EmptyState.Visibility == Visibility.Visible)
|
||||||
EmptyCapy.Source = swim[frame];
|
EmptyCapy.Source = swim[frame];
|
||||||
@@ -463,10 +478,10 @@ namespace CapyLauncher
|
|||||||
Animate(Capy, OpacityProperty, awake, 400);
|
Animate(Capy, OpacityProperty, awake, 400);
|
||||||
Animate(Water, OpacityProperty, up ? 0.55 : 0.2, 600);
|
Animate(Water, OpacityProperty, up ? 0.55 : 0.2, 600);
|
||||||
}
|
}
|
||||||
|
Bob(up);
|
||||||
if (!up)
|
if (!up)
|
||||||
{
|
{
|
||||||
Capy.Source = swim[0];
|
Capy.Source = swim[0];
|
||||||
((TranslateTransform)Capy.RenderTransform).Y = 0;
|
|
||||||
UptimeText.Text = "—";
|
UptimeText.Text = "—";
|
||||||
PlayerText.Text = "—";
|
PlayerText.Text = "—";
|
||||||
PlayerText.Foreground = (Brush)FindResource("Text");
|
PlayerText.Foreground = (Brush)FindResource("Text");
|
||||||
@@ -910,7 +925,9 @@ namespace CapyLauncher
|
|||||||
Animate(Overlay, OpacityProperty, 1, 200);
|
Animate(Overlay, OpacityProperty, 1, 200);
|
||||||
Animate(scale, ScaleTransform.ScaleXProperty, 1, 260, 0, 0.94);
|
Animate(scale, ScaleTransform.ScaleXProperty, 1, 260, 0, 0.94);
|
||||||
Animate(scale, ScaleTransform.ScaleYProperty, 1, 260, 0, 0.94);
|
Animate(scale, ScaleTransform.ScaleYProperty, 1, 260, 0, 0.94);
|
||||||
Animate(ShellBlur, BlurEffect.RadiusProperty, 10, 260);
|
var blur = new BlurEffect { Radius = 0 };
|
||||||
|
Shell.Effect = blur;
|
||||||
|
Animate(blur, BlurEffect.RadiusProperty, 10, 260);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HideDialog(bool result)
|
void HideDialog(bool result)
|
||||||
@@ -918,7 +935,12 @@ namespace CapyLauncher
|
|||||||
var fade = new DoubleAnimation(0, TimeSpan.FromMilliseconds(160));
|
var fade = new DoubleAnimation(0, TimeSpan.FromMilliseconds(160));
|
||||||
fade.Completed += (s, e) => Overlay.Visibility = Visibility.Collapsed;
|
fade.Completed += (s, e) => Overlay.Visibility = Visibility.Collapsed;
|
||||||
Overlay.BeginAnimation(OpacityProperty, fade);
|
Overlay.BeginAnimation(OpacityProperty, fade);
|
||||||
Animate(ShellBlur, BlurEffect.RadiusProperty, 0, 200);
|
if (Shell.Effect is BlurEffect blur)
|
||||||
|
{
|
||||||
|
var clear = new DoubleAnimation(0, TimeSpan.FromMilliseconds(200));
|
||||||
|
clear.Completed += (s, e) => { if (Overlay.Visibility != Visibility.Visible) Shell.Effect = null; };
|
||||||
|
blur.BeginAnimation(BlurEffect.RadiusProperty, clear);
|
||||||
|
}
|
||||||
answer?.TrySetResult(result);
|
answer?.TrySetResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user