Skip to content

Commit

Permalink
アニメーションとスプラッシュスクリーンを追加
Browse files Browse the repository at this point in the history
  • Loading branch information
siketyan committed Nov 25, 2016
1 parent 88b1614 commit 1a73ffc
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ obj/
# Files
*.dll
*.otf
__*.cs
__*.cs
*.user
12 changes: 10 additions & 2 deletions osu! Player/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" Style="{DynamicResource DefaultWindowStyle}" MinWidth="160"
Title="osu! Player" MinHeight="131" Height="494" Width="330" Loaded="Init"
Closing="ClearBass" Icon="Resources/icon.ico" StateChanged="ChangeMargin">
Title="osu! Player" MinHeight="131" Height="494" Width="330" ShowInTaskbar="False"
AllowsTransparency="True" Opacity="0" Loaded="Init" Closing="OnClosing" WindowStyle="None"
Icon="Resources/icon.ico" StateChanged="ChangeMargin" WindowStartupLocation="CenterScreen">
<Window.Resources>
<DataTemplate x:Key="SongsListTemplate">
<DockPanel HorizontalAlignment="Stretch" Width="Auto" LastChildFill="True"
Expand All @@ -30,6 +31,13 @@
</StackPanel>
</DockPanel>
</DataTemplate>

<Storyboard x:Key="StartAnimation" Storyboard.TargetProperty="(Window.Opacity)">
<DoubleAnimation From="0" To="1" Duration="0:0:1"/>
</Storyboard>
<Storyboard x:Key="CloseAnimation" Storyboard.TargetProperty="(Window.Opacity)">
<DoubleAnimation From="1" To="0" Duration="0:0:1"/>
</Storyboard>
</Window.Resources>

<Grid x:Name="LayoutRoot">
Expand Down
44 changes: 40 additions & 4 deletions osu! Player/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
using Un4seen.Bass.AddOn.Fx;
using System.Reflection;
using System.Runtime.ExceptionServices;
using System.Windows.Media.Animation;
using System.Threading;

namespace osu_Player
{
Expand Down Expand Up @@ -127,7 +129,28 @@ private async void Init(object sender, RoutedEventArgs e)
}
}
}
await RefreshList();

if (settings.UseSplashScreen)
{
var splash = new SplashWindow();
splash.Show();
await Task.Run(() => Thread.Sleep(1000));
await RefreshList();
splash.Close();

Storyboard sb = FindResource("StartAnimation") as Storyboard;
Storyboard.SetTarget(sb, this);
sb.Completed += (s, a) =>
{
ShowInTaskbar = true;
};
sb.Begin();
}
else
{
Opacity = 1f;
await RefreshList();
}
}

private void PlaySong(string tag)
Expand Down Expand Up @@ -350,15 +373,28 @@ private void TimerTick(object sender, EventArgs e)
}
}

private void ClearBass(object sender, CancelEventArgs e)
private void OnClosing(object sender, CancelEventArgs e)
{
StopSong();

var isAnimationCompleted = false;
if (!isAnimationCompleted)
{
e.Cancel = true;
Storyboard sb = FindResource("CloseAnimation") as Storyboard;
Storyboard.SetTarget(sb, this);
sb.Completed += (s, a) =>
{
isAnimationCompleted = true;
Environment.Exit(0);
};
sb.Begin();
}
}

private void CloseWindow(object sender, RoutedEventArgs e)
{
StopSong();
Environment.Exit(0);
Close();
}

private void MinimizeWindow(object sender, RoutedEventArgs e)
Expand Down
Binary file added osu! Player/Resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion osu! Player/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ namespace osu_Player
[Serializable]
public class Settings
{
// 設定項目を追加する場合は、bool型→string型→数値型→リスト→それ以外で、配列は使用しない。
public bool UseSplashScreen { get; set; } = true;
public string OsuPath { get; set; }
public int AudioDevice { get; set; }
public int AudioDevice { get; set; } = 0;
public List<string> DisabledSongs { get; set; }
}

Expand Down
29 changes: 29 additions & 0 deletions osu! Player/SplashWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Window x:Class="osu_Player.SplashWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:osu_Player"
mc:Ignorable="d" AllowsTransparency="True" Background="Transparent"
Title="Loading - osu! Player" Height="256" Width="256" WindowStyle="None"
ShowInTaskbar="False" WindowStartupLocation="CenterScreen"
Closing="OnClosing" Topmost="True" Opacity="0">
<Window.Triggers>
<EventTrigger RoutedEvent="Window.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Duration="0:0:1" To="1"
Storyboard.TargetProperty="Opacity" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Window.Triggers>
<Window.Resources>
<Storyboard x:Key="CloseAnimation" Completed="OnAnimationCompleted">
<DoubleAnimation Duration="0:0:0.5" To="0"
Storyboard.TargetProperty="Opacity" />
</Storyboard>
</Window.Resources>

<Image Source="Resources/logo.png" />
</Window>
37 changes: 37 additions & 0 deletions osu! Player/SplashWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media.Animation;

namespace osu_Player
{
/// <summary>
/// SplashWindow.xaml の相互作用ロジック
/// </summary>
public partial class SplashWindow : Window
{
private bool _isAnimationCompleted;

public SplashWindow()
{
InitializeComponent();
}

public void OnClosing(object sender, CancelEventArgs e)
{
if (!_isAnimationCompleted)
{
e.Cancel = true;
Storyboard sb = FindResource("CloseAnimation") as Storyboard;
Storyboard.SetTarget(sb, this);
sb.Begin();
}
}

public void OnAnimationCompleted(object sender, EventArgs e)
{
_isAnimationCompleted = true;
Close();
}
}
}
8 changes: 8 additions & 0 deletions osu! Player/osu! Player.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
<DependentUpon>SettingsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Song.cs" />
<Compile Include="SplashWindow.xaml.cs">
<DependentUpon>SplashWindow.xaml</DependentUpon>
</Compile>
<Compile Include="WindowManager.cs" />
<Compile Include="__Private.cs" />
<Page Include="DisabledSongsWIndow.xaml">
Expand All @@ -105,6 +108,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SplashWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
Expand Down Expand Up @@ -148,6 +155,7 @@
<Content Include="bass_fx.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\logo.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down

0 comments on commit 1a73ffc

Please sign in to comment.