Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Difficulties shown on main grid!
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholastay committed Jun 1, 2016
1 parent 7f13866 commit 12d31d9
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 7 deletions.
32 changes: 32 additions & 0 deletions WpfNexDirect/Bloodcat.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
using NAudio.Wave;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web;
using System.Windows;
using System.Windows.Media.Imaging;

namespace NexDirect
{
Expand All @@ -25,6 +28,7 @@ public class BeatmapSet
public string Title { get; set; }
public string Mapper { get; set; }
public string RankingStatus { get; set; }
public IEnumerable<Difficulty> Difficulties { get; set; }
public bool AlreadyHave { get; set; }
public Uri PreviewImage { get; set; }
public JObject BloodcatData { get; set; }
Expand All @@ -38,8 +42,36 @@ public BeatmapSet(MainWindow _this, JObject rawData)
RankingStatus = Tools.resolveRankingStatus(rawData["status"].ToString());
PreviewImage = new Uri(string.Format("http://b.ppy.sh/thumb/{0}l.jpg", Id));
AlreadyHave = _this.alreadyDownloaded.Any(b => b.Contains(Id + " "));
Difficulties = ((JArray)rawData["beatmaps"]).Select(b => new Difficulty(b["name"].ToString(), b["mode"].ToString()));
BloodcatData = rawData;
}

public class Difficulty
{
public string Name { get; set; }
public string Mode { get; set; }
public Uri ModeImage { get; set; }

public Difficulty(string name, string mode)
{
Name = name;
Mode = mode;

string _image;
switch (mode)
{
case "1":
_image = "pack://application:,,,/Resources/mode-taiko-small.png"; break;
case "2":
_image = "pack://application:,,,/Resources/mode-fruits-small.png"; break;
case "3":
_image = "pack://application:,,,/Resources/mode-mania-small.png"; break;
default:
_image = "pack://application:,,,/Resources/mode-osu-small.png"; break;
}
ModeImage = new Uri(_image);
}
}
}

// i dont even 100% know how this notifypropertychanged works
Expand Down
32 changes: 25 additions & 7 deletions WpfNexDirect/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:NexDirect"
mc:Ignorable="d"
Title="NexDirect" Height="600.5" Width="1128" Icon="Resources/logo.ico" Loaded="MainWindow_Loaded" Background="White">
Title="NexDirect" Height="600.5" Width="1316" Icon="Resources/logo.ico" Loaded="MainWindow_Loaded" Background="White">
<Grid Margin="0,0,2,0">
<DataGrid x:Name="dataGrid" Margin="10,101,200,26" ItemsSource="{Binding}" AutoGenerateColumns="False" IsReadOnly="True" MouseDoubleClick="dataGrid_DoubleClick" HeadersVisibility="Column" RowHeight="35" MouseLeftButtonUp="dataGrid_MouseDown" BorderBrush="#FF688CAF" GridLinesVisibility="Horizontal" HorizontalGridLinesBrush="#BF6A6A6A">
<DataGrid.Columns>
Expand All @@ -22,6 +22,24 @@
<DataGridTextColumn Binding="{Binding Artist}" Width="150" Header="Artist"/>
<DataGridTextColumn Binding="{Binding Title}" Width="300" Header="Title"/>
<DataGridTextColumn Binding="{Binding Mapper}" Width="150" Header="Mapper"/>
<DataGridTemplateColumn Width="200">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding Difficulties}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding ModeImage}" Width="24" Height="24" Margin="2,0,0,0" ToolTip="{Binding Name}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
</DataGrid>
<TextBox x:Name="searchBox" Height="44" Margin="10,23,377,0" TextWrapping="Wrap" VerticalAlignment="Top" BorderThickness="3" BorderBrush="#FFCD8721" Background="#FFE0DDDD" FontSize="26.667" TextChanged="searchBox_TextChanged"/>
Expand All @@ -36,13 +54,13 @@
<ProgressBar x:Name="searchingLoading" Margin="328,278,530,0" IsIndeterminate="True" ToolTip="Loading..." Height="22" VerticalAlignment="Top" Visibility="Hidden"/>
<Label x:Name="overlayModeNotice" Content="Overlay mode is active. Use CTRL+SHIFT+HOME to toggle the interface." HorizontalAlignment="Left" Margin="10,0,0,0" Width="393" Height="32" VerticalAlignment="Bottom" Visibility="Hidden"/>
<Label x:Name="overlayModeExit" Content="X" Height="23" VerticalAlignment="Top" HorizontalAlignment="Right" Width="19" MouseUp="overlayModeExit_MouseUp" Cursor="Hand" Margin="0,1,0,0" Visibility="Hidden"/>
<ComboBox x:Name="rankedStatusBox" Height="23" Margin="0,75,889,0" VerticalAlignment="Top" SelectedIndex="0" HorizontalAlignment="Right" Width="161"/>
<ComboBox x:Name="modeSelectBox" Height="23" Margin="0,73,629,0" VerticalAlignment="Top" SelectedIndex="0" HorizontalAlignment="Right" Width="161"/>
<Label x:Name="label" Content="Show:" Height="23" Margin="0,73,1050,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="46"/>
<Label x:Name="label1" Content="Mode:" Height="27" Margin="0,71,795,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="45"/>
<ComboBox x:Name="rankedStatusBox" Height="23" Margin="68,75,0,0" VerticalAlignment="Top" SelectedIndex="0" HorizontalAlignment="Left" Width="161"/>
<ComboBox x:Name="modeSelectBox" Height="23" Margin="328,73,0,0" VerticalAlignment="Top" SelectedIndex="0" HorizontalAlignment="Left" Width="161"/>
<Label x:Name="label" Content="Show:" Height="23" Margin="22,73,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="46"/>
<Label x:Name="label1" Content="Mode:" Height="27" Margin="278,71,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="45"/>
<Button x:Name="popularLoadButton" Content="Load Popular Maps" Height="25" Margin="0,71,206,0" VerticalAlignment="Top" Click="popularLoadButton_Click" HorizontalAlignment="Right" Width="159"/>
<Label x:Name="searchViaLabel" Content="Search via: " Height="27" Margin="0,71,530,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="68" Visibility="Hidden"/>
<ComboBox x:Name="searchViaSelectBox" HorizontalAlignment="Left" Height="22" Margin="593,73,0,0" VerticalAlignment="Top" Width="135" SelectedIndex="1" Visibility="Hidden"/>
<Label x:Name="searchViaLabel" Content="Search via: " Height="27" Margin="0,72,530,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="68" Visibility="Hidden"/>
<ComboBox x:Name="searchViaSelectBox" Height="22" Margin="0,74,395,0" VerticalAlignment="Top" SelectedIndex="1" HorizontalAlignment="Right" Width="135" Visibility="Hidden"/>
</Grid>


Expand Down
40 changes: 40 additions & 0 deletions WpfNexDirect/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions WpfNexDirect/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1205,4 +1205,16 @@
1sYaaqjhUEDwR/8fUwkfUqRZ5KAAAAAASUVORK5CYII=
</value>
</data>
<data name="modeCtb" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mode-fruits-small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="modeMania" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mode-mania-small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="modeOsu" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mode-osu-small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="modeTaiko" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\mode-taiko-small.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added WpfNexDirect/Resources/mode-fruits-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added WpfNexDirect/Resources/mode-mania-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added WpfNexDirect/Resources/mode-osu-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added WpfNexDirect/Resources/mode-taiko-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions WpfNexDirect/WpfNexDirect.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@
<ItemGroup>
<None Include="Resources\match-start.wav" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\mode-mania-small.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\mode-osu-small.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\mode-taiko-small.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\mode-fruits-small.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.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down

0 comments on commit 12d31d9

Please sign in to comment.