Skip to content

Commit

Permalink
final push now the app is at its final stage im now just gonna fix bu…
Browse files Browse the repository at this point in the history
…gs and maybe add some minor functionalities
  • Loading branch information
Luciano Godoy committed Apr 12, 2020
1 parent 33fb998 commit 9ee8efd
Show file tree
Hide file tree
Showing 8 changed files with 294 additions and 24 deletions.
16 changes: 15 additions & 1 deletion ClassLibrary/ClassLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,29 @@
<Compile Include="Configurations.cs" />
<Compile Include="Extractor.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LIBRARIES\osu-database-reader-master\osu-database-reader-master\osu-database-reader\osu-database-reader.csproj">
<Project>{41df5448-1519-4ad9-8d26-cf8ec1a6469c}</Project>
<Project>{842b69ae-2344-4acd-a19a-85a5d8bb616b}</Project>
<Name>osu-database-reader</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\Defaultsongthumbnail.jpg" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
2 changes: 1 addition & 1 deletion ClassLibrary/Configurations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void updatePublicProperties()

//Private management
private string CfgPath { get; set; }
private string AppPath { get; set; }
public string AppPath { get; set; }

//Actual properties
public Dictionary<string, string> Cfg { get; set; }
Expand Down
85 changes: 75 additions & 10 deletions ClassLibrary/Extractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
using System.IO;
using osu_database_reader.BinaryFiles;
using osu_database_reader.Components.Beatmaps;
using osu_database_reader.TextFiles;
using System.Drawing;
using System.Drawing.Imaging;

namespace ClassLibrary
{
Expand All @@ -21,11 +24,6 @@ public Extractor(ProgressBar progressBar, Button buttonExtract, Button buttonOpt
ViewButtonCancel = buttonCancel;
ViewPrBar = progressBar;

Pic = new TagLib.Picture();
Pic.Type = TagLib.PictureType.FrontCover;
Pic.Description = "Cover";
Pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;

BackgroundWorker1 = new BackgroundWorker();
BackgroundWorker1.DoWork += BackgroundWorker1_DoWork;
BackgroundWorker1.ProgressChanged += BackgroundWorker1_ProgressChanged;
Expand All @@ -46,7 +44,17 @@ public void extract(string mode, Configurations configs, OsuDb odb, CollectionD
if (Odb.Beatmaps.Count != 0)
{
Log = new List<string>();


if (!System.IO.File.Exists(ImagePath))
{
try
{
Properties.Resources.Defaultsongthumbnail.Save(ImagePath);
PicDefault.Data = TagLib.ByteVector.FromPath(ImagePath);
}
catch (Exception) { ; }
}

try
{
Directory.CreateDirectory(Path.Combine(Configs.OutPath, ValidMode));
Expand Down Expand Up @@ -220,9 +228,64 @@ private void copyAudioFile(string input, string output, string entryName, Beatma

if (Configs.IncludeThumbnails)
{
; //ADD THUMBNAIL SUPPORT
TagLib.Picture Pic = new TagLib.Picture();
Pic.MimeType = System.Net.Mime.MediaTypeNames.Image.Jpeg;
Pic.Description = "Cover";

BeatmapFile beatmapFile = BeatmapFile.Read(Path.Combine(Configs.SongsPath, bmp.FolderName, bmp.BeatmapFileName), true);
string imagePath;

if (beatmapFile.BackgroundImageFile != null && System.IO.File.Exists(imagePath = Path.Combine(Configs.SongsPath, bmp.FolderName, beatmapFile.BackgroundImageFile)))
{
foreach (PictureType pType in Enum.GetValues(typeof(PictureType)))
{
Pic.Type = pType;
Pic.Data = null;
}

try
{
Pic.Type = TagLib.PictureType.FrontCover;

using (MemoryStream ms = new MemoryStream())
{
string name = Path.GetFileNameWithoutExtension(imagePath);
//string path = Path.GetDirectoryName(imagePath);

Image png = Image.FromFile(imagePath);

string dou = File.MimeType;
string dea = File.Properties.Description;
string xd = File.Properties.Codecs.ToString();

png.Save(ms, ImageFormat.Jpeg);
ms.Position = 0;
png.Dispose();

Pic.Data = TagLib.ByteVector.FromStream(ms);
}
}
catch (Exception)
{
try
{
Pic.Data = PicDefault.Data;
}
catch (Exception) { ; }
}
}
else
{
try
{
Pic.Data = PicDefault.Data;
}
catch (Exception) {; }
}

File.Tag.Pictures = new TagLib.IPicture[] { Pic };
}

File.Save();

if (useAuxFile())
Expand Down Expand Up @@ -279,7 +342,7 @@ private bool useAuxFile()
{
return ((Configs.OverwriteAlbum && !Configs.ForceAlbum) || (Configs.OverwriteArtist && !Configs.ForceArtist) || (Configs.OverwriteTitle && !Configs.ForceTitle));
}

private void updateArtist(string artist)
{
File.Tag.AlbumArtists = null;
Expand Down Expand Up @@ -318,6 +381,7 @@ private string validChars(string str)
private OsuDb Odb { get; set; }
private CollectionDb Cdb { get; set; }

private string ImagePath { get; set; }
private Collection SelectedCollection { get; set; }
private int PrBarMax { get; set; }
private bool Cancel { get; set; }
Expand All @@ -326,7 +390,8 @@ private string validChars(string str)
private string OutputSubFolder { get; set; }
private Configurations Configs { get; set; }
private TagLib.File File { get; set; }
private TagLib.Picture Pic { get; set; }
//private TagLib.Picture Pic { get; set; }
private TagLib.Picture PicDefault { get; set; }
private BackgroundWorker BackgroundWorker1 { get; set; }

public List<string> Log { get; set; }
Expand Down
73 changes: 73 additions & 0 deletions ClassLibrary/Properties/Resources.Designer.cs

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

124 changes: 124 additions & 0 deletions ClassLibrary/Properties/Resources.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Defaultsongthumbnail" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Defaultsongthumbnail.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added ClassLibrary/Resources/Defaultsongthumbnail.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion View/View.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\LIBRARIES\osu-database-reader-master\osu-database-reader-master\osu-database-reader\osu-database-reader.csproj">
<Project>{41df5448-1519-4ad9-8d26-cf8ec1a6469c}</Project>
<Project>{842b69ae-2344-4acd-a19a-85a5d8bb616b}</Project>
<Name>osu-database-reader</Name>
</ProjectReference>
<ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj">
Expand Down
Loading

0 comments on commit 9ee8efd

Please sign in to comment.