From 69f9b7bfe26a4979e329bdf49a3bde676c128978 Mon Sep 17 00:00:00 2001 From: maxellnormalbias <0087yugbocaj@gmail.com> Date: Sun, 26 Apr 2015 22:36:32 -0700 Subject: [PATCH] [ShiftOS Launcher] Fixed directory problem and moved .dat files to %localappdata% --- .../ShiftOS Launcher/FirstBootSetup.vb | 35 +++++----- .../ShiftOS Launcher/Main_Launcher.vb | 67 ++++++------------- 2 files changed, 36 insertions(+), 66 deletions(-) diff --git a/ShiftOS Launcher/ShiftOS Launcher/FirstBootSetup.vb b/ShiftOS Launcher/ShiftOS Launcher/FirstBootSetup.vb index dfac9e6..f08179f 100644 --- a/ShiftOS Launcher/ShiftOS Launcher/FirstBootSetup.vb +++ b/ShiftOS Launcher/ShiftOS Launcher/FirstBootSetup.vb @@ -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 \ No newline at end of file diff --git a/ShiftOS Launcher/ShiftOS Launcher/Main_Launcher.vb b/ShiftOS Launcher/ShiftOS Launcher/Main_Launcher.vb index 44feaa5..7b21a21 100644 --- a/ShiftOS Launcher/ShiftOS Launcher/Main_Launcher.vb +++ b/ShiftOS Launcher/ShiftOS Launcher/Main_Launcher.vb @@ -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 + Else 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()