Skip to content

Commit

Permalink
Fonts are installed in the Fonts Folder
Browse files Browse the repository at this point in the history
Added some Resources files for Localization #49
Moved some Classes and Modules to separate Files
  • Loading branch information
JBou committed Apr 5, 2014
1 parent 8caeba1 commit d65e3fc
Show file tree
Hide file tree
Showing 9 changed files with 585 additions and 331 deletions.
327 changes: 7 additions & 320 deletions MinecraftLauncher/MainWindow.xaml.vb
Original file line number Diff line number Diff line change
Expand Up @@ -30,322 +30,9 @@ Imports System.Windows.Markup
Imports McMetroLauncher.Models
Imports System.Runtime.ExceptionServices
Imports System.Text
Imports System.Resources

#End Region
Public Module GlobalInfos
#Region "Functions/Subs"
Public Function Check_Updates() As Boolean
If New Version(onlineversion) > New Version(AssemblyVersion) Then
Return True
Else
Return False
End If
End Function
Public Async Function Versions_Load() As Task
Dim o As String = File.ReadAllText(outputjsonversions.FullName)
GlobalInfos.Versions = Await JsonConvert.DeserializeObjectAsync(Of Versionslist)(o)
If versionsfolder.Exists = True Then
Dim list_versionsdirectories As IEnumerable(Of String) = versionsfolder.GetDirectories.Select(Function(p) p.FullName)
Dim list_versions As IList(Of String) = New List(Of String)
For Each version As String In list_versionsdirectories
Dim versionname As String = IO.Path.GetFileName(version)
If GlobalInfos.Versions.versions.Select(Function(p) p.id).Contains(versionname) = False Then
list_versions.Add(versionname)
End If
Next
For Each Version As String In list_versions
If File.Exists(Path.Combine(versionsfolder.FullName, Version, Version & ".jar")) And File.Exists(Path.Combine(versionsfolder.FullName, Version, Version & ".json")) = True Then
Dim jo As JObject = JObject.Parse(File.ReadAllText(Path.Combine(versionsfolder.FullName, Version, Version & ".json")))
If jo("id").ToString = Version Then
Dim versionitem As New Versionslist.Version() With {
.id = jo("id").ToString,
.type = jo("type").ToString,
.time = jo("time").ToString,
.releaseTime = jo("releaseTime").ToString}
GlobalInfos.Versions.versions.Add(versionitem)
Else
'Falsche id wurde gefunden
End If
End If
Next
End If
End Function
Public Function GetJavaPath() As String
Dim environmentPath As String = Environment.GetEnvironmentVariable("JAVA_HOME")
If environmentPath IsNot Nothing Then
Return environmentPath
End If
Dim javaKey As String = "SOFTWARE\JavaSoft\Java Runtime Environment"
Dim javakeyWow6432Node As String = "SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment"
Using baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(javaKey)
If baseKey IsNot Nothing Then
Dim currentVersion As String = baseKey.GetValue("CurrentVersion").ToString()
Using homeKey = baseKey.OpenSubKey(currentVersion)
If homeKey IsNot Nothing Then
Return homeKey.GetValue("JavaHome").ToString()
End If
End Using
End If
End Using
Using baseKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64).OpenSubKey(javakeyWow6432Node)
If baseKey IsNot Nothing Then
Dim currentVersion As String = baseKey.GetValue("CurrentVersion").ToString()
Using homeKey = baseKey.OpenSubKey(currentVersion)
If homeKey IsNot Nothing Then
Return homeKey.GetValue("JavaHome").ToString()
End If
End Using
End If
End Using
Return Nothing
End Function
#End Region
Public Class Startinfos
Public Class Server
Private Shared m_serveradress As String
Private Shared m_serverport As String
Private Shared m_juststarted As Boolean
Public Shared Property JustStarted As Boolean
Get
Return m_juststarted
End Get
Set(value As Boolean)
m_juststarted = value
End Set
End Property
Public Shared Property ServerAdress As String
Get
Return m_serveradress
End Get
Set(value As String)
m_serveradress = value
End Set
End Property
Public Shared Property ServerPort As String
Get
Return m_serverport
End Get
Set(value As String)
m_serverport = value
End Set
End Property
End Class
Public Shared Property Profile As Profiles.Profile
Get
Return m_profile
End Get
Set(value As Profiles.Profile)
m_profile = value
End Set
End Property

Private Shared m_profile As Profiles.Profile
Public Shared Property Version As Versionslist.Version
Get
Return m_version
End Get
Set(value As Versionslist.Version)
m_version = value
End Set
End Property
Private Shared m_version As Versionslist.Version
Public Shared Property Versionsinfo As VersionsInfo
Get
Return m_versionsinfo
End Get
Set(value As VersionsInfo)
m_versionsinfo = value
End Set
End Property
Private Shared m_versionsinfo As VersionsInfo
Public Shared Property IsStarting As Boolean
Get
Return m_isstarting
End Get
Set(value As Boolean)
m_isstarting = value
End Set
End Property
Private Shared m_isstarting As Boolean

End Class

'--------supportedLauncherVersion---------
Public Const supportedLauncherVersion As Integer = 13
Public Const AwesomiumVersion As String = "1.7.3"
Public AppThemes As List(Of AppThemeMenuData)
Public AccentColors As List(Of AccentColorMenuData)
Public ViewModel As New MainViewModel
Public ReadOnly Property AssemblyVersion As String
Get
Return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
End Get
End Property
Public SelectedModVersion As String
Public Versions As Versionslist = New Versionslist
Public LastLogin As LastLogin
Public Session As Session
Public Website As String = "http://patzleiner.net/"
Public Appdata As New DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData))
Public mcpfad As New DirectoryInfo(Path.Combine(Appdata.FullName, ".minecraft"))
Public Applicationdata As New DirectoryInfo(Path.Combine(Appdata.FullName, "McMetroLauncher"))
Public Applicationcache As New DirectoryInfo(IO.Path.Combine(Applicationdata.FullName, "cache"))
Public cachefolder As New DirectoryInfo(Path.Combine(mcpfad.FullName, "cache"))
Public versionsfolder As New DirectoryInfo(Path.Combine(mcpfad.FullName, "versions"))
Public modsfolder As New DirectoryInfo(Path.Combine(mcpfad.FullName, "mods"))
Public modsfile As New FileInfo(Path.Combine(Applicationcache.FullName, "modlist.json"))
Public Forgefile As New FileInfo(Path.Combine(Applicationcache.FullName, "forge.json"))
Public Legacyforgefile As New FileInfo(Path.Combine(Applicationcache.FullName, "legacyforge.json"))
Public librariesfolder As New DirectoryInfo(Path.Combine(mcpfad.FullName, "libraries"))
Public assetspath As New DirectoryInfo(Path.Combine(mcpfad.FullName, "assets"))
Public launcher_profiles_json As New FileInfo(Path.Combine(mcpfad.FullName, "launcher_profiles.json"))
Public servers_dat As New FileInfo(Path.Combine(mcpfad.FullName, "servers.dat"))
Public Newprofile As Boolean
Public outputjsonversions As New FileInfo(Path.Combine(Applicationcache.FullName, "versions.json"))
Public ReadOnly Property versionsJSON(Version As Versionslist.Version) As String
Get
Dim versionid As String = Versions.versions.Where(Function(p) p.id = Version.id).First.id
Return Path.Combine(versionsfolder.FullName, versionid, versionid & ".json")
End Get
End Property
Public Versionsjar As String
Public UnpackDirectory As String
Public Arguments As String
Public Delegate Sub WriteA(ByVal Text As String, rtb As RichTextBox)
Public Delegate Sub WriteColored(ByVal Text As String, rtb As RichTextBox, Color As Brush)
Public downloadfilepath As String
Public servers As ServerList = New ServerList
Public onlineversion As String = Nothing
Public changelog As String = Nothing
Public resources_dir As New DirectoryInfo(Path.Combine(mcpfad.FullName, "resources"))
Public librariesurl As String = "https://libraries.minecraft.net/"
Public selectedprofile As String
Public ReadOnly Property indexesurl(index_name As String) As String
Get
Return "http://s3.amazonaws.com/Minecraft.Download/indexes/" & index_name & ".json"
End Get
End Property
Public ReadOnly Property cacheindexesfile(index_name As String) As FileInfo
Get
Return New FileInfo(Path.Combine(cachefolder.FullName, "indexes/" & index_name & ".json"))
End Get
End Property
Public ReadOnly Property indexesfile(index_name As String) As FileInfo
Get
Return New FileInfo(Path.Combine(assetspath.FullName, "indexes/" & index_name & ".json"))
End Get
End Property
Public ReadOnly Property resourcefile(hash As String) As FileInfo
Get
Return New FileInfo(Path.Combine(assetspath.FullName, "objects/" & hash.Substring(0, 2) & "/" & hash))
End Get
End Property
Public ReadOnly Property resourceurl(hash As String) As String
Get
Return "http://resources.download.minecraft.net/" & hash.Substring(0, 2) & "/" & hash
End Get
End Property
Public ReadOnly YoutubeVideoRegex As Regex = New Regex("youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase)
Public Versionsurl As String = "http://s3.amazonaws.com/Minecraft.Download/versions/versions.json"
Public modfileurl As String = Website & "download/modlist.json"
Public versionurl As String = Website & "mcmetrolauncher/version.txt"
Public changelogurl As String = Website & "mcmetrolauncher/changelog.txt"
Public Forgeurl As String = "http://files.minecraftforge.net/maven/net/minecraftforge/forge/json"
Public Legacyforgeurl As String = "http://files.minecraftforge.net/minecraftforge/json2"
Public startedversions As IList(Of String) = New List(Of String)
'http://www.joomlavision.com/customize-browser-scrollbars-css3/

'http://ospa.arvat.org/gmail-style-scrollbar-using-webkit-and-css/
Public Scrollbarcss As String = <![CDATA[
::-webkit-scrollbar{
width:10px;
height:10px;
background-color:#fff;
box-shadow: inset 1px 1px 0 rgba(0,0,0,.1),inset -1px -1px 0 rgba(0,0,0,.07);
}
::-webkit-scrollbar:hover{
background-color:#eee;
}
::-webkit-resizer{
-webkit-border-radius:4px;
background-color:#666;
}
::-webkit-scrollbar-thumb{
min-height:0.8em;
min-width:0.8em;
background-color: rgba(0, 0, 0, .2);
box-shadow: inset 1px 1px 0 rgba(0,0,0,.1),inset -1px -1px 0 rgba(0,0,0,.07);
}
::-webkit-scrollbar-thumb:hover{
background-color: #bbb;
}
::-webkit-scrollbar-thumb:active{
background-color:#888;
}
]]>.Value
End Module

Public Class AccentColorMenuData
Public Property Name() As String
Get
Return m_Name
End Get
Set(value As String)
m_Name = value
End Set
End Property
Private m_Name As String
Public Property BorderColorBrush() As Brush
Get
Return m_BorderColorBrush
End Get
Set(value As Brush)
m_BorderColorBrush = value
End Set
End Property
Private m_BorderColorBrush As Brush
Public Property ColorBrush() As Brush
Get
Return m_ColorBrush
End Get
Set(value As Brush)
m_ColorBrush = value
End Set
End Property
Private m_ColorBrush As Brush

Private m_changeAccentCommand As ICommand

Public ReadOnly Property ChangeAccentCommand() As ICommand
Get
Dim r = If(Me.m_changeAccentCommand, (InlineAssignHelper(m_changeAccentCommand, New SimpleCommand() With { _
.CanExecuteDelegate = Function(x) True, _
.ExecuteDelegate = Sub() DoChangeTheme() _
})))
Return r
End Get
End Property

Protected Overridable Sub DoChangeTheme()
Dim theme = ThemeManager.DetectAppStyle(Application.Current)
Dim accent = ThemeManager.GetAccent(Me.Name)
ThemeManager.ChangeAppStyle(Application.Current, accent, theme.Item1)
End Sub
Private Shared Function InlineAssignHelper(Of T)(ByRef target As T, value As T) As T
target = value
Return value
End Function
End Class

Public Class AppThemeMenuData
Inherits AccentColorMenuData
Protected Overrides Sub DoChangeTheme()
Dim theme = ThemeManager.DetectAppStyle(Application.Current)
Dim appTheme = ThemeManager.GetAppTheme(Me.Name)
ThemeManager.ChangeAppStyle(Application.Current, theme.Item2, appTheme)
End Sub
End Class


Public Class MainWindow
#Region "Variables"
Expand Down Expand Up @@ -851,14 +538,14 @@ Public Class MainWindow
If IO.Directory.Exists(Directoryname) = False Then
IO.Directory.CreateDirectory(Directoryname)
End If
If IO.File.Exists(Outputfile) Then
IO.File.Delete(Outputfile)
End If
ElseIf todownload = False And File.Exists(Outputfile) = False Then
Write("Minecraft " & versionid & " existiert nicht und konnte nicht heruntergeladen werden", LogLevel.ERROR)
downloaderror = True
End If
If downloaderror = False And File.Exists(CacheOutputfile) = True Then
If IO.File.Exists(Outputfile) Then
IO.File.Delete(Outputfile)
End If
IO.File.Move(CacheOutputfile, Outputfile)
ElseIf downloaderror = True Then
Startinfos.IsStarting = False
Expand Down Expand Up @@ -898,14 +585,14 @@ Public Class MainWindow
If IO.Directory.Exists(Directoryname) = False Then
IO.Directory.CreateDirectory(Directoryname)
End If
If IO.File.Exists(OutputfileJSON) Then
IO.File.Delete(OutputfileJSON)
End If
ElseIf jsontodownload = False And File.Exists(OutputfileJSON) = False Then
Write("Minecraft " & versionid & " existiert nicht und konnte nicht heruntergeladen werden", LogLevel.ERROR)
jsondownloaderror = True
End If
If jsondownloaderror = False And File.Exists(CacheOutputfileJSON) = True Then
If IO.File.Exists(OutputfileJSON) Then
IO.File.Delete(OutputfileJSON)
End If
IO.File.Move(CacheOutputfileJSON, OutputfileJSON)
ElseIf jsondownloaderror = True Then
Startinfos.IsStarting = False
Expand Down
Loading

0 comments on commit d65e3fc

Please sign in to comment.