Skip to content

Commit

Permalink
Merge pull request #1 from Siketyan/develop
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
Siketyan authored Nov 25, 2016
2 parents 61fcc22 + ab880f3 commit 1671291
Show file tree
Hide file tree
Showing 11 changed files with 229 additions and 29 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
62 changes: 46 additions & 16 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 All @@ -51,8 +59,20 @@
</Grid.ColumnDefinitions>

<StackPanel Grid.Column="0" Orientation="Horizontal">
<Button x:Name="DoubleTime" WindowChrome.IsHitTestVisibleInChrome="True" Foreground="#222"
Margin="6,0,0,0" Cursor="Hand" Click="ToDoubleTime" Content=""
ToolTip="Mod DoubleTimeを再現します。">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Label FontFamily="Resources/#FontAwesome"
FontSize="16" Content="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="Nightcore" WindowChrome.IsHitTestVisibleInChrome="True" Foreground="#222"
Margin="5,0,0,0" Cursor="Hand" Click="ToNightcore" Content="">
Margin="-6,0,0,0" Cursor="Hand" Click="ToNightcore" Content=""
ToolTip="Mod Nightcoreを再現します。">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Label FontFamily="Resources/#FontAwesome"
Expand All @@ -65,15 +85,16 @@

<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button WindowChrome.IsHitTestVisibleInChrome="True" Cursor="Hand"
Margin="0,0,5,0" Click="OpenSettings">
Margin="0,0,5,0" Click="OpenSettings" ToolTip="設定ウィンドウを表示します。">
<Button.Template>
<ControlTemplate>
<Label FontFamily="Resources/#FontAwesome" Foreground="#FFF"></Label>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="Pin" WindowChrome.IsHitTestVisibleInChrome="True"
Margin="0,0,3,0" Cursor="Hand" Click="ChangePin">
Margin="0,0,3,0" Cursor="Hand" Click="ChangePin"
ToolTip="ウィンドウを最前面に表示します。">
<Button.Template>
<ControlTemplate>
<Label FontFamily="Resources/#FontAwesome" Foreground="#FFF" RenderTransformOrigin="0.5,0.5">
Expand All @@ -86,26 +107,30 @@
</Button.Template>
</Button>
<Button x:Name="UnPin" WindowChrome.IsHitTestVisibleInChrome="True"
Margin="0,0,3,0" Cursor="Hand" Click="ChangePin" Visibility="Collapsed">
Margin="0,0,3,0" Cursor="Hand" Click="ChangePin" Visibility="Collapsed"
ToolTip="ウィンドウの最前面表示を解除します。">
<Button.Template>
<ControlTemplate>
<Label FontFamily="Resources/#FontAwesome" Foreground="#FFF"></Label>
</ControlTemplate>
</Button.Template>
</Button>
<Button x:Name="WindowMode" WindowChrome.IsHitTestVisibleInChrome="True"
Margin="0,0,3,0" Cursor="Hand" Click="ChangeWindowMode" Content="">
Margin="0,0,3,0" Cursor="Hand" Click="ChangeWindowMode" Content=""
ToolTip="ミニマルインターフェースモードに切り替えます。">
<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<Label FontFamily="Resources/#FontAwesome" Foreground="#FFF"
FontSize="17" Padding="3,2" Content="{TemplateBinding Content}" />
</ControlTemplate>
</Button.Template>
</Button>
<Button Template="{StaticResource WindowControlButtonTemplate}" Click="MinimizeWindow"
WindowChrome.IsHitTestVisibleInChrome="True" Cursor="Hand">0</Button>
<Button Template="{StaticResource WindowControlButtonTemplate}" Click="CloseWindow"
WindowChrome.IsHitTestVisibleInChrome="True" Cursor="Hand">r</Button>
<Button Template="{StaticResource WindowControlButtonTemplate}"
WindowChrome.IsHitTestVisibleInChrome="True" Cursor="Hand"
Click="MinimizeWindow" ToolTip="ウィンドウを最小化します。">0</Button>
<Button Template="{StaticResource WindowControlButtonTemplate}"
WindowChrome.IsHitTestVisibleInChrome="True" Cursor="Hand"
Click="CloseWindow" ToolTip="osu! Playerを終了します。">r</Button>
</StackPanel>
</Grid>
<Grid Margin="10,0,10,5">
Expand All @@ -127,20 +152,25 @@
<StackPanel x:Name="ControlButtons" Grid.Column="2" Margin="0,3,0,0">
<StackPanel Orientation="Horizontal" Margin="0,0,0,0">
<Label Style="{StaticResource ActionLabelStyle}" FontSize="14" Foreground="#FFF"
Padding="0,0,0,2" Margin="0,0,5,0" MouseLeftButtonDown="ShuffleSongs"></Label>
Padding="0,0,0,2" Margin="0,0,5,0" MouseLeftButtonDown="ShuffleSongs"
ToolTip="曲リストをシャッフルします。現在曲を再生している場合は停止されます。"></Label>
<Label x:Name="NoRepeat" Style="{StaticResource ActionLabelStyle}" FontSize="13"
Padding="0,0,0,1" Tag="N" MouseLeftButtonDown="ChangeRepeatMode"></Label>
Padding="0,0,0,1" Tag="N" MouseLeftButtonDown="ChangeRepeatMode"
ToolTip="再生モードをリピートなしに変更します。"></Label>
<Label x:Name="RepeatSong" Style="{StaticResource ActionLabelStyle}"
Tag="S" MouseLeftButtonDown="ChangeRepeatMode"></Label>
Tag="S" MouseLeftButtonDown="ChangeRepeatMode"
ToolTip="再生モードを1曲リピートに変更します。"></Label>
<Label x:Name="RepeatAll" Style="{StaticResource ActionLabelStyle}" Margin="0,0,0,1.5"
Foreground="#FFF" Tag="A" MouseLeftButtonDown="ChangeRepeatMode"></Label>
Foreground="#FFF" Tag="A" MouseLeftButtonDown="ChangeRepeatMode"
ToolTip="再生モードを全曲リピートに変更します。"></Label>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Style="{StaticResource ActionLabelStyle}"
Margin="0,0,2,0" Foreground="#FFF"></Label>
<Slider x:Name="Volume" Style="{StaticResource HorizontalSlider}" Foreground="#FFF"
ValueChanged="ChangeVolume" Value="50" Maximum="100" Width="48"
WindowChrome.IsHitTestVisibleInChrome="True" />
WindowChrome.IsHitTestVisibleInChrome="True"
ToolTip="ドラッグして音量を調整します。"/>
</StackPanel>
</StackPanel>
</Grid>
Expand Down
88 changes: 81 additions & 7 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 All @@ -31,6 +33,8 @@ private bool IsPausing
set
{
PlayingStatus.Content = value ? "" : "";
PlayingStatus.ToolTip = value ? "曲の再生を再開します。"
: "曲の再生を一時停止します。";
_isPausing = value;
}
}
Expand All @@ -42,12 +46,14 @@ private bool IsSearching
{
PlayingStatus.IsEnabled
= ControlButtons.IsEnabled
= SongsList.IsEnabled
= false;
}
else
{
PlayingStatus.IsEnabled
= ControlButtons.IsEnabled
= SongsList.IsEnabled
= true;
}
}
Expand All @@ -65,6 +71,7 @@ private bool IsSearching

private bool _isPausing;
private bool _isSizing;
private bool _isDoubleTime;
private bool _isNightcore;
private int _windowHeight;
private int _channel;
Expand Down Expand Up @@ -122,7 +129,35 @@ 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();
}

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

if (!settings.UseSplashScreen) await RefreshList();
}

private void PlaySong(string tag)
Expand All @@ -139,16 +174,19 @@ private void PlaySong(string tag)

Bass.BASS_SetDevice(settings.AudioDevice);
Bass.BASS_Init(settings.AudioDevice, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
_channel = Bass.BASS_StreamCreateFile(data[2], 0L, 0L, BASSFlag.BASS_DEFAULT);
_channel = Bass.BASS_StreamCreateFile(data[2], 0L, 0L, BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_STREAM_DECODE);
_channel = BassFx.BASS_FX_TempoCreate(_channel, BASSFlag.BASS_DEFAULT);
_playing = tag;
_timer.Start();
ChangeVolume(null, null);

if (_channel == 0) return;
if (_isDoubleTime) ToDoubleTime(null, null);
if (_isNightcore) ToNightcore(null, null);
Bass.BASS_ChannelPlay(_channel, false);

PlayingStatus.IsEnabled = true;
PlayingStatus.ToolTip = "曲の再生を一時停止します。";
PlayingStatus.Content = "";
PlayingTitle.Text = data[0];
PlayingArtist.Text = data[1];
Expand Down Expand Up @@ -194,6 +232,7 @@ private void StopSong()
_channel = 0;

PlayingStatus.IsEnabled = false;
PlayingStatus.ToolTip = null;
PlayingStatus.Content = "";
PlayingTitle.Text = "曲を選択してください";
PlayingArtist.Text = "クリックして再生します...";
Expand Down Expand Up @@ -243,8 +282,27 @@ private void ChangeVolume(object sender, RoutedEventArgs e)
);
}

private void ToDoubleTime(object sender, RoutedEventArgs e)
{
if (_isNightcore) ToNightcore(this, null);
if (_isDoubleTime && sender != null)
{
_isDoubleTime = false;
DoubleTime.Foreground = new SolidColorBrush(Color.FromRgb(0x22, 0x22, 0x22));
Bass.BASS_ChannelSetAttribute(_channel, BASSAttribute.BASS_ATTRIB_TEMPO, 0f);
return;
}

_isDoubleTime = true;
DoubleTime.Foreground = Brushes.White;
if (_channel == 0) return;

Bass.BASS_ChannelSetAttribute(_channel, BASSAttribute.BASS_ATTRIB_TEMPO, 50f);
}

private void ToNightcore(object sender, RoutedEventArgs e)
{
if (_isDoubleTime) ToDoubleTime(this, null);
if (_isNightcore && sender != null)
{
_isNightcore = false;
Expand All @@ -259,9 +317,8 @@ private void ToNightcore(object sender, RoutedEventArgs e)

Bass.BASS_ChannelGetAttribute(_channel, BASSAttribute.BASS_ATTRIB_FREQ, ref _pitch);
Bass.BASS_ChannelSetAttribute(_channel, BASSAttribute.BASS_ATTRIB_FREQ, _pitch * 1.5f);
Bass.BASS_ChannelSetAttribute(_channel, BASSAttribute.BASS_ATTRIB_TEMPO, 150);
}

private void TimerTick(object sender, EventArgs e)
{
if (_channel != 0 && Bass.BASS_ChannelIsActive(_channel) == BASSActive.BASS_ACTIVE_PLAYING)
Expand All @@ -284,6 +341,7 @@ private void TimerTick(object sender, EventArgs e)
break;
}

PlayingStatus.ToolTip = null;
PlayingStatus.Content = "";
PlayingTitle.Text = "曲を選択してください";
PlayingArtist.Text = "クリックして再生します...";
Expand Down Expand Up @@ -322,15 +380,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 && settings.UseAnimation)
{
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 Expand Up @@ -379,6 +450,7 @@ public async Task<int> RefreshList(bool doShuffle = false)
return 0;
}

PlayingStatus.ToolTip = null;
PlayingStatus.Content = "";
PlayingTitle.Text = "曲を検索しています";
PlayingArtist.Text = "しばらくお待ちください...";
Expand Down Expand Up @@ -458,6 +530,7 @@ private void ChangeWindowMode(object sender, RoutedEventArgs e)
Height = _windowHeight;
ResizeMode = ResizeMode.CanResize;
WindowMode.Content = "";
WindowMode.ToolTip = "ミニマルインターフェースモードに切り替えます。";
}
else // on Normal Mode
{
Expand All @@ -466,6 +539,7 @@ private void ChangeWindowMode(object sender, RoutedEventArgs e)
Height = 72;
ResizeMode = ResizeMode.NoResize;
WindowMode.Content = "";
WindowMode.ToolTip = "通常モードに切り替えます。";
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu! Player/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.2.9")]
[assembly: AssemblyFileVersion("1.1.2.9")]
[assembly: AssemblyVersion("1.2.0.10")]
[assembly: AssemblyFileVersion("1.2.0.10")]
[assembly: Guid("05EA8BF5-DA65-4EF0-BE35-B5CE28169F5E")]

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.
5 changes: 4 additions & 1 deletion osu! Player/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ namespace osu_Player
[Serializable]
public class Settings
{
// 設定項目を追加する場合は、bool型→string型→数値型→リスト→それ以外で、配列は使用しない。
public bool UseSplashScreen { get; set; } = true;
public bool UseAnimation { 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
Loading

0 comments on commit 1671291

Please sign in to comment.