[ShiftOS Launcher] Fixed directory problem and moved .dat files to %localappdata%

This commit is contained in:
maxellnormalbias 2015-04-26 22:36:32 -07:00
parent 813d7c555e
commit 69f9b7bfe2
2 changed files with 36 additions and 66 deletions

View file

@ -16,28 +16,27 @@
Private Sub TextBox2_MouseDown(sender As Object, e As MouseEventArgs) Handles TextBox2.MouseDown
If TextBox2.Text = "Type in a nickname here" Then TextBox2.Text = Nothing
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then My.Computer.FileSystem.WriteAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\BuildOption.dat", "Stable", False)
If RadioButton2.Checked = True Then My.Computer.FileSystem.WriteAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\BuildOption.dat", "Unstable", False)
If TextBox1.Text = Nothing Then My.Computer.FileSystem.WriteAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\ExecFolder.dat", "C:\ShiftOS\SoftwareData\Launcher\ShiftOSEXE", False)
If Not TextBox1.Text = Nothing Then My.Computer.FileSystem.WriteAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\ExecFolder.dat", TextBox1.Text, False)
If TextBox2.Text = Nothing Then My.Computer.FileSystem.WriteAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\Nickname.dat", "ShiftOS User", False)
If Not TextBox2.Text = Nothing Then My.Computer.FileSystem.WriteAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\Nickname.dat", TextBox2.Text, False)
MsgBox("Completed!")
FinishedFirstBoot = True
Me.Close()
Main_Launcher.UpdateOptions()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim folDialog As New FolderBrowserDialog
If folDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox1.Text = folDialog.SelectedPath
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If RadioButton1.Checked = True Then My.Computer.FileSystem.WriteAllText(Main_Launcher.appData + "\BuildOption.dat", "Stable", False)
If RadioButton2.Checked = True Then My.Computer.FileSystem.WriteAllText(Main_Launcher.appData + "\BuildOption.dat", "Unstable", False)
If TextBox1.Text = Nothing Then My.Computer.FileSystem.WriteAllText(Main_Launcher.appData + "\ExecFolder.dat", "C:\ShiftOS\", False)
If Not TextBox1.Text = Nothing Then My.Computer.FileSystem.WriteAllText(Main_Launcher.appData + "\ExecFolder.dat", TextBox1.Text, False)
If TextBox2.Text = Nothing Then My.Computer.FileSystem.WriteAllText(Main_Launcher.appData + "\Nickname.dat", "ShiftOS User", False)
If Not TextBox2.Text = Nothing Then My.Computer.FileSystem.WriteAllText(Main_Launcher.appData + "\Nickname.dat", TextBox2.Text, False)
MsgBox("Completed!")
FinishedFirstBoot = True
Application.Restart()
End Sub
End Class

View file

@ -3,6 +3,8 @@
Public Class Main_Launcher
Public shiftDir As String = "C:\ShiftOS"
Public appData As String = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\ShiftOSLauncher"
Public FirstBoot As Boolean = False
Public Stable As Boolean = True
Dim loaddata(100) As String
@ -11,64 +13,33 @@ Public Class Main_Launcher
Dim doneversionsetup As Boolean = False
Dim currentlydownloading As Boolean = False
Dim currentversion As String = "0.0.8 RC2"
Dim exepath As String = "C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\ShiftOS 0.0.8 RC2"
Dim exepath As String = shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\ShiftOS 0.0.8 RC2"
Private Sub Main_Launcher_Load(sender As Object, e As EventArgs) Handles MyBase.Load
If Directory.Exists("C:\ShiftOS\SoftwareData\Launcher") Then Else Directory.CreateDirectory("C:\ShiftOS\SoftwareData\Launcher")
'If Not Directory.Exists(appData) Then Directory.CreateDirectory(appData)
If File.Exists("C:\ShiftOS\SoftwareData\Launcher\Log.txt") Then File.Delete("C:\ShiftOS\SoftwareData\Launcher\Log.txt")
File.Create("C:\ShiftOS\SoftwareData\Launcher\Log.txt")
If Directory.Exists("C:\ShiftOS\SoftwareData\Launcher\UserPreferences") Then Else FirstBoot = True
If FirstBoot = True Then Directory.CreateDirectory("C:\ShiftOS\SoftwareData\Launcher\UserPreferences")
'If File.Exists(shiftDir + "\SoftwareData\Launcher\Log.txt") Then File.Delete(shiftDir + "\SoftwareData\Launcher\Log.txt")
'File.Create(shiftDir + "\SoftwareData\Launcher\Log.txt")
If Not Directory.Exists(appData) Then FirstBoot = True
If FirstBoot = True Then
Directory.CreateDirectory(appData)
FirstBootSetup.Show()
Me.Text = "ShiftOS Launcher [Setting Up]"
Else
UpdateOptions()
End If
End Sub
Public Sub UpdateOptions()
If Me.Text = "ShiftOS Launcher [Setting Up]" Then Me.Text = "ShiftOS Launcher [Downloading]"
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\Nickname.dat")
Label1.Text = ("Greetings, " + fileContents)
Dim fileContents1 As String
fileContents1 = My.Computer.FileSystem.ReadAllText("C:\ShiftOS\SoftwareData\Launcher\UserPreferences\BuildOption.dat")
If currentlydownloading = True Then
If fileContents1 = "Stable" Then
Me.Text = "ShiftOS Launcher [Downloading: Stable]"
Label2.Text = "Status: Downloading [Stable]"
shiftDir = My.Computer.FileSystem.ReadAllText(appData + "\ExecFolder.dat")
Label1.Text = "Greetings, " + My.Computer.FileSystem.ReadAllText(appData + "\Nickname.dat")
If My.Computer.FileSystem.ReadAllText(appData + "\BuildOption.dat") = "Stable" Then
Stable = True
End If
If fileContents1 = "Unstable" Then
Me.Text = "ShiftOS Launcher [Downloading: Unstable]"
Label2.Text = "Status: Downloading [Unstable]"
Stable = False
End If
Else
If fileContents1 = "Stable" Then
Me.Text = "ShiftOS Launcher"
Label2.Text = "Status: Ready to play ShiftOS " & currentversion
Stable = True
End If
If fileContents1 = "Unstable" Then
Me.Text = "ShiftOS Launcher"
Label2.Text = "Status: Ready to play ShiftOS " & currentversion
Stable = False
End If
End If
End Sub
Private Sub readversiondata()
Dim sr As New StreamReader("C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat", True)
If File.Exists("C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat") Then
Dim sr As New StreamReader(shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat", True)
If File.Exists(shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat") Then
For i As Integer = 0 To 4 Step 1
loaddata(i) = sr.ReadLine
If i = 4 Then
@ -86,17 +57,17 @@ Public Class Main_Launcher
Private Sub DownloadLatestVersion(ByVal BuildOption As Boolean)
If My.Computer.Network.IsAvailable Then
If File.Exists("C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat") Then File.Delete("C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat")
My.Computer.Network.DownloadFile("http://shiftos.bitbucket.org/downloads/versiondata.dat", "C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat")
If File.Exists(shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat") Then File.Delete(shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat")
My.Computer.Network.DownloadFile("http://shiftos.bitbucket.org/downloads/versiondata.dat", shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\versiondata.dat")
readversiondata()
If doneversionsetup = True Then
If BuildOption = True Then
My.Computer.Network.DownloadFile("http://shiftos.bitbucket.org/downloads/ShiftOS" & lateststable & ".exe", "C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\ShiftOS" & lateststable & ".exe")
exepath = "C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\ShiftOS" & lateststable & ".exe"
My.Computer.Network.DownloadFile("http://shiftos.bitbucket.org/downloads/ShiftOS" & lateststable & ".exe", shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\ShiftOS" & lateststable & ".exe")
exepath = shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\ShiftOS" & lateststable & ".exe"
launchshiftos()
' Detect when finished, do fancy progress bar stuff and run
Else
My.Computer.Network.DownloadFile("http://shiftos.bitbucket.org/downloads/ShiftOS" & latestunstable & ".exe", "C:\ShiftOS\SoftwareData\Launcher\ShiftOSVersion\ShiftOS" & latestunstable & ".exe")
My.Computer.Network.DownloadFile("http://shiftos.bitbucket.org/downloads/ShiftOS" & latestunstable & ".exe", shiftDir + "\SoftwareData\Launcher\ShiftOSVersion\ShiftOS" & latestunstable & ".exe")
End If
End If
Else 'Offlinemode()