Merge pull request #29 from maxellnormalbias/master

[ShiftOS Launcher] Fixed directory problem and moved .dat files to %localappdata%
This commit is contained in:
pfgithub 2015-04-27 16:46:11 -07:00
commit c6532553b5
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 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 If TextBox2.Text = "Type in a nickname here" Then TextBox2.Text = Nothing
End Sub 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 Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim folDialog As New FolderBrowserDialog Dim folDialog As New FolderBrowserDialog
If folDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then If folDialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
TextBox1.Text = folDialog.SelectedPath TextBox1.Text = folDialog.SelectedPath
End If End If
End Sub 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 End Class

View file

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