Skip to content

Commit

Permalink
New Version: 1.0.4.7
Browse files Browse the repository at this point in the history
- Added a function to unpack ".pack.xz" Archives with the command line tool
- The McMetrolauncher now automatically downloads missing Forge libraries and unpacks them. It also supports other libraries.
- Implemented the Forge JSON API and updated the Forge Installer
- File and Folder Variables were changed from String to Fileinfo
- Added Awesomium into the Installer
- Setup Updated
  • Loading branch information
JBou committed Mar 28, 2014
1 parent 47d5ccd commit a3c6bf5
Show file tree
Hide file tree
Showing 19 changed files with 683 additions and 813 deletions.
2 changes: 1 addition & 1 deletion MinecraftLauncher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
</TabControl.Resources>
<TabItem Header="Neuigkeiten" >
<Grid>
<awe:WebControl x:Name="Webcontrol_news" Margin="10" Source="http://mcupdate.tumblr.com/"/>
<awe:WebControl x:Name="Webcontrol_news" Margin="10" Source="http://mcupdate.tumblr.com/" IsTransparent="True" />
<Grid HorizontalAlignment="Center" VerticalAlignment="Center" Height="100">
<Label x:Name="lbl_news_loading" Content="Neuigkeiten werden geladen..." FontSize="60" VerticalAlignment="Top" />
<Controls:MetroProgressBar x:Name="pb_news_loading" IsIndeterminate="True" VerticalAlignment="Bottom" Height="10" />
Expand Down
412 changes: 160 additions & 252 deletions MinecraftLauncher/MainWindow.xaml.vb

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions MinecraftLauncher/McMetroLauncher.vbproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@
<Reference Include="Awesomium.Core, Version=1.7.3.0, Culture=neutral, PublicKeyToken=e1a0d7c8071a5214, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Awesomium Technologies LLC\Awesomium SDK\1.7.3.0\wrappers\Awesomium.NET\Assemblies\Awesomium.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Awesomium.Windows.Controls, Version=1.7.2.2, Culture=neutral, PublicKeyToken=7a34e179b8b61c39, processorArchitecture=x86">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\..\Program Files (x86)\Awesomium Technologies LLC\Awesomium SDK\1.7.2.2\wrappers\Awesomium.NET\Assemblies\Awesomium.Windows.Controls.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="BouncyCastle.Crypto">
<HintPath>..\libraries\BouncyCastle.Crypto.dll</HintPath>
Expand Down Expand Up @@ -190,7 +192,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Models\Converters.vb" />
<Compile Include="Models\Forge.vb" />
<Compile Include="Models\MainViewModel.vb" />
<Compile Include="Models\Unpack.vb" />
<Compile Include="Windows\Forge_installer.xaml.vb">
<DependentUpon>Forge_installer.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -377,6 +382,9 @@
<Resource Include="images\dark\appbar.page.copy.png" />
</ItemGroup>
<ItemGroup>
<Content Include="tools\Pack_xz_Extractor.jar">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Resource Include="minecraft_block.png" />
<Resource Include="images\web-ftb-logo_0.png" />
<Resource Include="images\light\appbar.control.play.png" />
Expand Down
152 changes: 152 additions & 0 deletions MinecraftLauncher/Models/Converters.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
Imports System.IO
Imports Craft.Net

#Region "Converters"
Public Structure ImageConvert
''' <summary>
''' Konvertiert ein Bild in einen Base64-String
''' </summary>
''' <param name="image">
''' Zu konvertierendes Bild
''' </param>
''' <returns>
''' Base64 Repräsentation des Bildes
''' </returns>
Public Shared Function GetStringFromImage(image As System.Drawing.Image) As String
If image IsNot Nothing Then
Dim ic As New ImageConverter()
Dim buffer As Byte() = DirectCast(ic.ConvertTo(image, GetType(Byte())), Byte())
Return Convert.ToBase64String(buffer, Base64FormattingOptions.InsertLineBreaks)
Else
Return Nothing
End If
End Function
'---------------------------------------------------------------------
''' <summary>
''' Konvertiert einen Base64-String zu einem Bild
''' </summary>
''' <param name="base64String">
''' Zu konvertierender String
''' </param>
''' <returns>
''' Bild das aus dem String erzeugt wird
''' </returns>
Public Shared Function GetImageFromString(base64String As String) As System.Drawing.Image
Dim buffer As Byte() = Convert.FromBase64String(base64String)

If buffer IsNot Nothing Then
Dim ic As New ImageConverter()
Return TryCast(ic.ConvertFrom(buffer), System.Drawing.Image)
Else
Return Nothing
End If
End Function

Public Shared Function GetImageStream(Image As System.Drawing.Image) As BitmapSource
Dim ms As New MemoryStream()
Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png)
ms.Position = 0
Dim bi As New BitmapImage()
bi.BeginInit()
bi.StreamSource = ms
bi.EndInit()

Return bi
End Function

End Structure

Public Class Base64ImageConverter
Implements System.Windows.Data.IValueConverter

Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim s As String = TryCast(value, String)

If s Is Nothing Then Return Nothing

Dim bi As New BitmapImage()

bi.BeginInit()
bi.StreamSource = New MemoryStream(System.Convert.FromBase64String(s))
bi.EndInit()

Return bi
End Function

Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function

End Class
Public Class FormattingcodesDocumentConverter
Implements System.Windows.Data.IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim s As String = TryCast(value, String)
If s Is Nothing Then Return Nothing
Return FormattingCodes.MinecraftText2Document(s)
End Function

Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function

End Class

''' <summary>
''' Convertiert eine IList(Of ServerStatus.Playerlist.Player) zu einem String, getrennt durch neue Zeilen
''' </summary>
''' <remarks></remarks>
Public Class Playerlist_Namesstring_Converter
Implements System.Windows.Data.IValueConverter

Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim s As IList(Of ServerStatus.PlayerList.Player) = TryCast(value, IList(Of ServerStatus.PlayerList.Player))
If s Is Nothing Then Return Nothing
Dim playernames As IList(Of String) = s.Select(Function(p) p.Name).ToList
Dim returnstring As String = "Players:" & Environment.NewLine & String.Join(Environment.NewLine, playernames)
Return returnstring
End Function

Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function

End Class
Public Class MODS_installed_imageConverter
Implements System.Windows.Data.IValueConverter

Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim s As IList(Of Modifications.Mod.Version) = TryCast(value, IList(Of Modifications.Mod.Version))
If s Is Nothing Then Return Nothing
Dim r As BitmapSource
If s.Where(Function(p) p.version = SelectedModVersion).First.installed = True Then
r = ImageConvert.GetImageStream(My.Resources.check_green)
Else
r = Nothing
End If
Return r
End Function

Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function

End Class

Public Class Modified_Date_Converter
Implements System.Windows.Data.IValueConverter

Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements System.Windows.Data.IValueConverter.Convert
Dim unixTime As Long = CLng(value)
If unixTime = Nothing Then Return Nothing
Dim epoch As New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)
Return epoch.AddSeconds(unixTime).ToString("G")
End Function

Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Throw New NotImplementedException()
End Function

End Class

#End Region
76 changes: 76 additions & 0 deletions MinecraftLauncher/Models/Forge.vb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Imports System.IO

Public Structure Forge
Public Shared BuildList As IList(Of ForgeBuild) = New List(Of ForgeBuild)
Public Shared LegacyBuildList As IList(Of ForgeBuild) = New List(Of ForgeBuild)
Public Shared ReadOnly Property ForgeList As IList(Of ForgeBuild)
Get
Dim ls As IList(Of ForgeBuild) = LegacyBuildList
For Each item As ForgeBuild In BuildList
If ls.Select(Function(p) p.build).Contains(item.build) = False Then
ls.Add(item)
End If
Next
Return ls
End Get
End Property
Private Shared Async Function LoadBuilds() As Task
BuildList.Clear()
Dim jo As JObject = JObject.Parse(File.ReadAllText(Forgefile.FullName))
For Each item As JProperty In jo("number")
Dim build As ForgeBuild = Await JsonConvert.DeserializeObjectAsync(Of ForgeBuild)(item.Value.ToString)
For Each file As JArray In item.Value.Value(Of JArray)("files")
Dim forgefile As New ForgeBuild.ForgeFileitem
forgefile.extension = file.Value(Of String)(0)
forgefile.type = file.Value(Of String)(1)
forgefile.hash = file.Value(Of String)(2)
build.files.Add(forgefile)
Next
BuildList.Add(build)
Next
End Function
Private Shared Async Function LoadLegacyBuilds() As Task
LegacyBuildList.Clear()
Dim jo As JObject = JObject.Parse(File.ReadAllText(Legacyforgefile.FullName))
For Each item As JProperty In jo("number")
Dim build As ForgeBuild = Await JsonConvert.DeserializeObjectAsync(Of ForgeBuild)(item.Value.ToString)
For Each file As JObject In item.Value.Value(Of JArray)("files")
Dim forgefile As New ForgeBuild.ForgeFileitem
forgefile.extension = file.Value(Of String)("ext")
forgefile.type = file.Value(Of String)("type")
forgefile.hash = Nothing
build.files.Add(forgefile)
Next
LegacyBuildList.Add(build)
Next
End Function

Public Shared Async Function Load() As Task
Await LoadBuilds()
Await LoadLegacyBuilds()
End Function

Public Class ForgeBuild
Public Property branch As Object
Public Property build As Integer
<JsonIgnore>
Public Property files As IList(Of ForgeFileitem)
Public Property mcversion As String
Public Property modified As Single
Public Property version As String
Public Sub New()
files = New List(Of ForgeFileitem)
End Sub
Public Class ForgeFileitem
Public Property extension As String
Public Property type As String
Public Property hash As String
Public Sub New()

End Sub
End Class
End Class

End Structure
Loading

0 comments on commit a3c6bf5

Please sign in to comment.