-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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
Showing
19 changed files
with
683 additions
and
813 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.