diff --git a/SLAM/App.config b/SLAM/App.config index ff91538..48d65f2 100644 --- a/SLAM/App.config +++ b/SLAM/App.config @@ -37,6 +37,15 @@ False + + False + + + C:\Program Files (x86)\Steam\steamapps\ + + + C:\Program Files (x86)\Steam\userdata\ + \ No newline at end of file diff --git a/SLAM/Form1.Designer.vb b/SLAM/Form1.Designer.vb index b8b7642..b333127 100644 --- a/SLAM/Form1.Designer.vb +++ b/SLAM/Form1.Designer.vb @@ -49,6 +49,7 @@ Partial Class Form1 Me.ContextHotKey = New System.Windows.Forms.ToolStripMenuItem() Me.SetVolumeToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.TrimToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() + Me.LoadToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.PlayKeyButton = New System.Windows.Forms.Button() Me.StatusLabel = New System.Windows.Forms.Label() Me.TrackContextMenu.SuspendLayout() @@ -142,8 +143,8 @@ Partial Class Form1 'ImportDialog ' Me.ImportDialog.FileName = "ImportDialog" - Me.ImportDialog.Filter = "Media files|*.mp3;*.wav;*.aac;*.wma;*.m4a;*.mp4;*.wmv;*.avi;*.m4v;*.mov;|Audio fi" & _ - "les|*.mp3;*.wav;*.aac;*.wma;*.m4a;|Video files|*.mp4;*.wmv;*.avi;*.m4v;*.mov;|Al" & _ + Me.ImportDialog.Filter = "Media files|*.mp3;*.wav;*.aac;*.wma;*.m4a;*.mp4;*.wmv;*.avi;*.m4v;*.mov;|Audio fi" & + "les|*.mp3;*.wav;*.aac;*.wma;*.m4a;|Video files|*.mp4;*.wmv;*.avi;*.m4v;*.mov;|Al" & "l files|*.*" Me.ImportDialog.Multiselect = True ' @@ -178,9 +179,10 @@ Partial Class Form1 ' 'TrackContextMenu ' - Me.TrackContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContextDelete, Me.GoToToolStripMenuItem, Me.ContextRefresh, Me.RemoveHotkeyToolStripMenuItem, Me.RenameToolStripMenuItem, Me.ContextHotKey, Me.SetVolumeToolStripMenuItem, Me.TrimToolStripMenuItem}) + Me.TrackContextMenu.ImageScalingSize = New System.Drawing.Size(24, 24) + Me.TrackContextMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ContextDelete, Me.GoToToolStripMenuItem, Me.ContextRefresh, Me.RemoveHotkeyToolStripMenuItem, Me.RenameToolStripMenuItem, Me.ContextHotKey, Me.SetVolumeToolStripMenuItem, Me.TrimToolStripMenuItem, Me.LoadToolStripMenuItem}) Me.TrackContextMenu.Name = "TrackContextMenu" - Me.TrackContextMenu.Size = New System.Drawing.Size(145, 180) + Me.TrackContextMenu.Size = New System.Drawing.Size(145, 202) ' 'ContextDelete ' @@ -230,6 +232,12 @@ Partial Class Form1 Me.TrimToolStripMenuItem.Size = New System.Drawing.Size(144, 22) Me.TrimToolStripMenuItem.Text = "Trim" ' + 'LoadToolStripMenuItem + ' + Me.LoadToolStripMenuItem.Name = "LoadToolStripMenuItem" + Me.LoadToolStripMenuItem.Size = New System.Drawing.Size(144, 22) + Me.LoadToolStripMenuItem.Text = "Load" + ' 'PlayKeyButton ' Me.PlayKeyButton.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) @@ -301,4 +309,5 @@ Partial Class Form1 Friend WithEvents Trimmed As System.Windows.Forms.ColumnHeader Friend WithEvents StatusLabel As System.Windows.Forms.Label Friend WithEvents RenameToolStripMenuItem As System.Windows.Forms.ToolStripMenuItem + Friend WithEvents LoadToolStripMenuItem As ToolStripMenuItem End Class diff --git a/SLAM/Form1.vb b/SLAM/Form1.vb index de4bff9..593dea1 100644 --- a/SLAM/Form1.vb +++ b/SLAM/Form1.vb @@ -13,9 +13,20 @@ Public Class Form1 Dim Games As New List(Of SourceGame) Dim running As Boolean = False Dim ClosePending As Boolean = False + Dim SteamAppsPath As String + Dim status As Integer = IDLE + + Const IDLE = -1 + Const SEARCHING = -2 + Const WORKING = -3 + Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load RefreshPlayKey() + If My.Settings.PlayKey = My.Settings.RelayKey Then + My.Settings.RelayKey = "=" + My.Settings.Save() + End If If My.Settings.UpdateCheck Then CheckForUpdate() @@ -45,6 +56,7 @@ Public Class Form1 tf2.directory = "common\Team Fortress 2\" tf2.ToCfg = "tf\cfg\" tf2.libraryname = "tf2\" + tf2.samplerate = 22050 Games.Add(tf2) Dim gmod As New SourceGame @@ -214,7 +226,7 @@ Public Class Form1 End Function Private Sub ReloadTracks(Game As SourceGame) - If System.IO.Directory.Exists(Game.libraryname) Then + If IO.Directory.Exists(Game.libraryname) Then Game.tracks.Clear() For Each File In System.IO.Directory.GetFiles(Game.libraryname) @@ -295,6 +307,10 @@ Public Class Form1 Dim GameDir As String = Path.Combine(SteamappsPath, Game.directory) Dim GameCfgFolder As String = Path.Combine(GameDir, Game.ToCfg) + If Not IO.Directory.Exists(GameCfgFolder) Then + Throw New System.Exception("Steamapps folder is incorrect. Disable ""override folder detection"", or select a correct folder.") + End If + 'slam.cfg Using slam_cfg As StreamWriter = New StreamWriter(GameCfgFolder & "slam.cfg") slam_cfg.WriteLine("alias slam_listtracks ""exec slam_tracklist.cfg""") @@ -357,11 +373,11 @@ Public Class Form1 End Sub - Private Function LoadTrack(ByVal Game As SourceGame, ByVal index As Integer, ByVal SteamappsPath As String) As Boolean + Private Function LoadTrack(ByVal Game As SourceGame, ByVal index As Integer) As Boolean Dim Track As track If Game.tracks.Count > index Then Track = Game.tracks(index) - Dim voicefile As String = Path.Combine(SteamappsPath, Game.directory) & "voice_input.wav" + Dim voicefile As String = Path.Combine(SteamAppsPath, Game.directory) & "voice_input.wav" Try If File.Exists(voicefile) Then File.Delete(voicefile) @@ -400,7 +416,7 @@ Public Class Form1 End If - Dim GameCfgFolder As String = Path.Combine(SteamappsPath, Game.directory, Game.ToCfg) + Dim GameCfgFolder As String = Path.Combine(SteamAppsPath, Game.directory, Game.ToCfg) Using slam_curtrack As StreamWriter = New StreamWriter(GameCfgFolder & "slam_curtrack.cfg") slam_curtrack.WriteLine("echo ""[SLAM] Track name: {0}""", Track.name) End Using @@ -432,41 +448,52 @@ Public Class Form1 End Function Private Sub PollRelayWorker_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles PollRelayWorker.DoWork - PollRelayWorker.ReportProgress(-1) 'Report that SLAM is searching. + PollRelayWorker.ReportProgress(SEARCHING) 'Report that SLAM is searching. Dim Game As SourceGame = e.Argument Dim GameDir As String = Game.directory & Game.exename & ".exe" - Dim SteamAppsPath As String = vbNullString + SteamAppsPath = vbNullString Dim UserDataPath As String = vbNullString Try - Do While Not PollRelayWorker.CancellationPending + If Not My.Settings.OverrideFolders Then - Dim GameProcess As String = GetFilepath(Game.exename) - If Not String.IsNullOrEmpty(GameProcess) AndAlso GameProcess.EndsWith(GameDir) Then - SteamAppsPath = GameProcess.Remove(GameProcess.Length - GameDir.Length) - End If + Do While Not PollRelayWorker.CancellationPending - Dim SteamProcess As String = GetFilepath("Steam") - If Not String.IsNullOrEmpty(SteamProcess) Then - UserDataPath = SteamProcess.Remove(SteamProcess.Length - "Steam.exe".Length) & "userdata\" - End If + Dim GameProcess As String = GetFilepath(Game.exename) + If Not String.IsNullOrEmpty(GameProcess) AndAlso GameProcess.EndsWith(GameDir) Then + SteamAppsPath = GameProcess.Remove(GameProcess.Length - GameDir.Length) + End If + + Dim SteamProcess As String = GetFilepath("Steam") + If Not String.IsNullOrEmpty(SteamProcess) Then + UserDataPath = SteamProcess.Remove(SteamProcess.Length - "Steam.exe".Length) & "userdata\" + End If - If System.IO.Directory.Exists(SteamAppsPath) Then - If Not Game.id = 0 Then + If IO.Directory.Exists(SteamAppsPath) Then + If Not Game.id = 0 Then - If System.IO.Directory.Exists(UserDataPath) Then + If IO.Directory.Exists(UserDataPath) Then + Exit Do + End If + + Else Exit Do End If - - Else - Exit Do End If - End If - Thread.Sleep(Game.PollInterval) - Loop + Thread.Sleep(Game.PollInterval) + Loop + + Else + SteamAppsPath = My.Settings.steamapps + If IO.Directory.Exists(My.Settings.userdata) Then + UserDataPath = My.Settings.userdata + Else + Throw New System.Exception("Userdata folder does not exist. Disable ""override folder detection"", or select a correct folder.") + End If + End If If Not String.IsNullOrEmpty(SteamAppsPath) Then CreateCfgFiles(Game, SteamAppsPath) @@ -479,7 +506,7 @@ Public Class Form1 End Try - PollRelayWorker.ReportProgress(-2) 'Report that SLAM is working. + PollRelayWorker.ReportProgress(WORKING) 'Report that SLAM is working. Do While Not PollRelayWorker.CancellationPending Try @@ -500,7 +527,7 @@ Public Class Form1 If Not String.IsNullOrEmpty(command) Then 'load audiofile If IsNumeric(command) Then - If LoadTrack(Game, Convert.ToInt32(command) - 1, SteamAppsPath) Then + If LoadTrack(Game, Convert.ToInt32(command) - 1) Then PollRelayWorker.ReportProgress(Convert.ToInt32(command) - 1) End If End If @@ -526,7 +553,7 @@ Public Class Form1 End Sub Public Function UserDataCFG(Game As SourceGame, UserdataPath As String) As String - If System.IO.Directory.Exists(UserdataPath) Then + If IO.Directory.Exists(UserdataPath) Then For Each userdir As String In System.IO.Directory.GetDirectories(UserdataPath) Dim CFGPath As String = Path.Combine(userdir, Game.id.ToString) & "\local\cfg\slam_relay.cfg" If File.Exists(CFGPath) Then @@ -545,7 +572,7 @@ Public Class Form1 Using results = searcher.Get() Dim Process As ManagementObject = results.Cast(Of ManagementObject)().FirstOrDefault() - If Process IsNot Nothing Then + If Process IsNot Nothing AndAlso Not String.IsNullOrEmpty(Process("ExecutablePath").ToString) Then Return Process("ExecutablePath").ToString End If @@ -557,9 +584,11 @@ Public Class Form1 Private Sub PollRelayWorker_ProgressChanged(sender As Object, e As System.ComponentModel.ProgressChangedEventArgs) Handles PollRelayWorker.ProgressChanged Select Case e.ProgressPercentage - Case -1 + Case SEARCHING + status = SEARCHING StatusLabel.Text = "Status: Searching..." - Case -2 + Case WORKING + status = WORKING StatusLabel.Text = "Status: Working." Case Else DisplayLoaded(e.ProgressPercentage) @@ -572,6 +601,7 @@ Public Class Form1 StopPoll() End If + status = IDLE StatusLabel.Text = "Status: Idle." If Not IsNothing(e.Result) Then 'Result is always an exception @@ -698,10 +728,14 @@ Public Class Form1 Else If running Then TrimToolStripMenuItem.Visible = True 'visible when only one selected AND is running + If status = WORKING Then + LoadToolStripMenuItem.Visible = True + End If Else For Each Control In TrackContextMenu.Items 'visible when only one selected AND is not running (all) Control.visible = True Next + LoadToolStripMenuItem.Visible = False End If End If @@ -896,9 +930,13 @@ Public Class Form1 Private Sub PlayKeyButton_Click(sender As Object, e As EventArgs) Handles PlayKeyButton.Click Dim SelectKeyDialog As New SelectKey If SelectKeyDialog.ShowDialog = Windows.Forms.DialogResult.OK Then - My.Settings.PlayKey = SelectKeyDialog.ChosenKey - My.Settings.Save() - RefreshPlayKey() + If Not SelectKeyDialog.ChosenKey = My.Settings.RelayKey Then + My.Settings.PlayKey = SelectKeyDialog.ChosenKey + My.Settings.Save() + RefreshPlayKey() + Else + MessageBox.Show("Play key and relay key can not be the same!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + End If End If End Sub @@ -909,7 +947,7 @@ Public Class Form1 Private Sub LogError(ByVal ex As Exception) If My.Settings.LogError Then Using log As StreamWriter = New StreamWriter("errorlog.txt", True) - log.WriteLine("--------------------{0}--------------------", DateTime.Now) + log.WriteLine("--------------------{0} UTC--------------------", DateTime.Now.ToUniversalTime) log.WriteLine(ex.ToString) End Using End If @@ -952,4 +990,9 @@ Public Class Form1 e.Cancel = True End If End Sub + + Private Sub LoadToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles LoadToolStripMenuItem.Click + LoadTrack(GetCurrentGame, TrackList.SelectedItems(0).Index) + DisplayLoaded(TrackList.SelectedItems(0).Index) + End Sub End Class \ No newline at end of file diff --git a/SLAM/My Project/Settings.Designer.vb b/SLAM/My Project/Settings.Designer.vb index 590e8c3..b65cbad 100644 --- a/SLAM/My Project/Settings.Designer.vb +++ b/SLAM/My Project/Settings.Designer.vb @@ -161,6 +161,42 @@ Namespace My Me("HoldToPlay") = value End Set End Property + + _ + Public Property OverrideFolders() As Boolean + Get + Return CType(Me("OverrideFolders"),Boolean) + End Get + Set + Me("OverrideFolders") = value + End Set + End Property + + _ + Public Property steamapps() As String + Get + Return CType(Me("steamapps"),String) + End Get + Set + Me("steamapps") = value + End Set + End Property + + _ + Public Property userdata() As String + Get + Return CType(Me("userdata"),String) + End Get + Set + Me("userdata") = value + End Set + End Property End Class End Namespace diff --git a/SLAM/My Project/Settings.settings b/SLAM/My Project/Settings.settings index 27f4ed4..52eb3e3 100644 --- a/SLAM/My Project/Settings.settings +++ b/SLAM/My Project/Settings.settings @@ -29,5 +29,14 @@ False + + False + + + C:\Program Files (x86)\Steam\steamapps\ + + + C:\Program Files (x86)\Steam\userdata\ + \ No newline at end of file diff --git a/SLAM/SettingsForm.Designer.vb b/SLAM/SettingsForm.Designer.vb index b5030af..14065d5 100644 --- a/SLAM/SettingsForm.Designer.vb +++ b/SLAM/SettingsForm.Designer.vb @@ -25,10 +25,20 @@ Partial Class SettingsForm Me.StatusStrip1 = New System.Windows.Forms.StatusStrip() Me.ToolStripStatusLabel1 = New System.Windows.Forms.ToolStripStatusLabel() Me.VersionLabel = New System.Windows.Forms.ToolStripStatusLabel() + Me.DonateLabel = New System.Windows.Forms.ToolStripStatusLabel() Me.TabPage2 = New System.Windows.Forms.TabPage() + Me.OverrideGroup = New System.Windows.Forms.GroupBox() + Me.Label2 = New System.Windows.Forms.Label() + Me.FinduserdataButton = New System.Windows.Forms.Button() + Me.userdatatext = New System.Windows.Forms.TextBox() + Me.Label1 = New System.Windows.Forms.Label() + Me.FindsteamappsButton = New System.Windows.Forms.Button() + Me.steamappstext = New System.Windows.Forms.TextBox() + Me.EnableOverrideBox = New System.Windows.Forms.CheckBox() Me.GroupBox3 = New System.Windows.Forms.GroupBox() Me.ChangeRelayButton = New System.Windows.Forms.Button() Me.GroupBox2 = New System.Windows.Forms.GroupBox() + Me.HoldToPlay = New System.Windows.Forms.CheckBox() Me.ConTagsCheckBox = New System.Windows.Forms.CheckBox() Me.StartEnabledCheckBox = New System.Windows.Forms.CheckBox() Me.LogCheckBox = New System.Windows.Forms.CheckBox() @@ -36,9 +46,9 @@ Partial Class SettingsForm Me.UpdateCheckBox = New System.Windows.Forms.CheckBox() Me.TabControl1 = New System.Windows.Forms.TabControl() Me.TabPage1 = New System.Windows.Forms.TabPage() - Me.HoldToPlay = New System.Windows.Forms.CheckBox() Me.StatusStrip1.SuspendLayout() Me.TabPage2.SuspendLayout() + Me.OverrideGroup.SuspendLayout() Me.GroupBox3.SuspendLayout() Me.GroupBox2.SuspendLayout() Me.TabControl1.SuspendLayout() @@ -47,7 +57,8 @@ Partial Class SettingsForm ' 'StatusStrip1 ' - Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1, Me.VersionLabel}) + Me.StatusStrip1.ImageScalingSize = New System.Drawing.Size(24, 24) + Me.StatusStrip1.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.ToolStripStatusLabel1, Me.VersionLabel, Me.DonateLabel}) Me.StatusStrip1.Location = New System.Drawing.Point(0, 309) Me.StatusStrip1.Name = "StatusStrip1" Me.StatusStrip1.Size = New System.Drawing.Size(284, 22) @@ -67,8 +78,16 @@ Partial Class SettingsForm Me.VersionLabel.Size = New System.Drawing.Size(31, 17) Me.VersionLabel.Text = "0.0.0" ' + 'DonateLabel + ' + Me.DonateLabel.IsLink = True + Me.DonateLabel.Name = "DonateLabel" + Me.DonateLabel.Size = New System.Drawing.Size(199, 17) + Me.DonateLabel.Text = "Want to support SLAM by donating?" + ' 'TabPage2 ' + Me.TabPage2.Controls.Add(Me.OverrideGroup) Me.TabPage2.Controls.Add(Me.GroupBox3) Me.TabPage2.Location = New System.Drawing.Point(4, 22) Me.TabPage2.Name = "TabPage2" @@ -78,6 +97,90 @@ Partial Class SettingsForm Me.TabPage2.Text = "Advanced" Me.TabPage2.UseVisualStyleBackColor = True ' + 'OverrideGroup + ' + Me.OverrideGroup.Controls.Add(Me.Label2) + Me.OverrideGroup.Controls.Add(Me.FinduserdataButton) + Me.OverrideGroup.Controls.Add(Me.userdatatext) + Me.OverrideGroup.Controls.Add(Me.Label1) + Me.OverrideGroup.Controls.Add(Me.FindsteamappsButton) + Me.OverrideGroup.Controls.Add(Me.steamappstext) + Me.OverrideGroup.Controls.Add(Me.EnableOverrideBox) + Me.OverrideGroup.Location = New System.Drawing.Point(8, 64) + Me.OverrideGroup.Name = "OverrideGroup" + Me.OverrideGroup.Size = New System.Drawing.Size(260, 96) + Me.OverrideGroup.TabIndex = 3 + Me.OverrideGroup.TabStop = False + Me.OverrideGroup.Text = "Override folder detection" + ' + 'Label2 + ' + Me.Label2.AutoSize = True + Me.Label2.Enabled = False + Me.Label2.Location = New System.Drawing.Point(6, 71) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(51, 13) + Me.Label2.TabIndex = 6 + Me.Label2.Text = "userdata:" + ' + 'FinduserdataButton + ' + Me.FinduserdataButton.Enabled = False + Me.FinduserdataButton.Location = New System.Drawing.Point(230, 66) + Me.FinduserdataButton.Name = "FinduserdataButton" + Me.FinduserdataButton.Size = New System.Drawing.Size(24, 23) + Me.FinduserdataButton.TabIndex = 5 + Me.FinduserdataButton.Text = "..." + Me.FinduserdataButton.UseVisualStyleBackColor = True + ' + 'userdatatext + ' + Me.userdatatext.Enabled = False + Me.userdatatext.Location = New System.Drawing.Point(73, 68) + Me.userdatatext.Name = "userdatatext" + Me.userdatatext.ReadOnly = True + Me.userdatatext.Size = New System.Drawing.Size(151, 20) + Me.userdatatext.TabIndex = 4 + ' + 'Label1 + ' + Me.Label1.AutoSize = True + Me.Label1.Enabled = False + Me.Label1.Location = New System.Drawing.Point(6, 45) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(61, 13) + Me.Label1.TabIndex = 3 + Me.Label1.Text = "steamapps:" + ' + 'FindsteamappsButton + ' + Me.FindsteamappsButton.Enabled = False + Me.FindsteamappsButton.Location = New System.Drawing.Point(230, 40) + Me.FindsteamappsButton.Name = "FindsteamappsButton" + Me.FindsteamappsButton.Size = New System.Drawing.Size(24, 23) + Me.FindsteamappsButton.TabIndex = 2 + Me.FindsteamappsButton.Text = "..." + Me.FindsteamappsButton.UseVisualStyleBackColor = True + ' + 'steamappstext + ' + Me.steamappstext.Enabled = False + Me.steamappstext.Location = New System.Drawing.Point(73, 42) + Me.steamappstext.Name = "steamappstext" + Me.steamappstext.ReadOnly = True + Me.steamappstext.Size = New System.Drawing.Size(151, 20) + Me.steamappstext.TabIndex = 1 + ' + 'EnableOverrideBox + ' + Me.EnableOverrideBox.AutoSize = True + Me.EnableOverrideBox.Location = New System.Drawing.Point(6, 19) + Me.EnableOverrideBox.Name = "EnableOverrideBox" + Me.EnableOverrideBox.Size = New System.Drawing.Size(59, 17) + Me.EnableOverrideBox.TabIndex = 0 + Me.EnableOverrideBox.Text = "Enable" + Me.EnableOverrideBox.UseVisualStyleBackColor = True + ' 'GroupBox3 ' Me.GroupBox3.Controls.Add(Me.ChangeRelayButton) @@ -112,6 +215,16 @@ Partial Class SettingsForm Me.GroupBox2.TabStop = False Me.GroupBox2.Text = "Other" ' + 'HoldToPlay + ' + Me.HoldToPlay.AutoSize = True + Me.HoldToPlay.Location = New System.Drawing.Point(6, 134) + Me.HoldToPlay.Name = "HoldToPlay" + Me.HoldToPlay.Size = New System.Drawing.Size(82, 17) + Me.HoldToPlay.TabIndex = 11 + Me.HoldToPlay.Text = "Hold to play" + Me.HoldToPlay.UseVisualStyleBackColor = True + ' 'ConTagsCheckBox ' Me.ConTagsCheckBox.AutoSize = True @@ -184,16 +297,6 @@ Partial Class SettingsForm Me.TabPage1.Text = "Misc." Me.TabPage1.UseVisualStyleBackColor = True ' - 'HoldToPlay - ' - Me.HoldToPlay.AutoSize = True - Me.HoldToPlay.Location = New System.Drawing.Point(6, 134) - Me.HoldToPlay.Name = "HoldToPlay" - Me.HoldToPlay.Size = New System.Drawing.Size(82, 17) - Me.HoldToPlay.TabIndex = 11 - Me.HoldToPlay.Text = "Hold to play" - Me.HoldToPlay.UseVisualStyleBackColor = True - ' 'SettingsForm ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -208,6 +311,8 @@ Partial Class SettingsForm Me.StatusStrip1.ResumeLayout(False) Me.StatusStrip1.PerformLayout() Me.TabPage2.ResumeLayout(False) + Me.OverrideGroup.ResumeLayout(False) + Me.OverrideGroup.PerformLayout() Me.GroupBox3.ResumeLayout(False) Me.GroupBox2.ResumeLayout(False) Me.GroupBox2.PerformLayout() @@ -232,4 +337,13 @@ Partial Class SettingsForm Friend WithEvents ChangeRelayButton As System.Windows.Forms.Button Friend WithEvents TabPage1 As System.Windows.Forms.TabPage Friend WithEvents HoldToPlay As System.Windows.Forms.CheckBox + Friend WithEvents OverrideGroup As GroupBox + Friend WithEvents FindsteamappsButton As Button + Friend WithEvents steamappstext As TextBox + Friend WithEvents EnableOverrideBox As CheckBox + Friend WithEvents Label1 As Label + Friend WithEvents DonateLabel As ToolStripStatusLabel + Friend WithEvents Label2 As Label + Friend WithEvents FinduserdataButton As Button + Friend WithEvents userdatatext As TextBox End Class diff --git a/SLAM/SettingsForm.vb b/SLAM/SettingsForm.vb index 14b4d19..4fd567c 100644 --- a/SLAM/SettingsForm.vb +++ b/SLAM/SettingsForm.vb @@ -9,6 +9,9 @@ ConTagsCheckBox.Checked = My.Settings.WriteTags ChangeRelayButton.Text = String.Format("Relay key: ""{0}"" (change)", My.Settings.RelayKey) HoldToPlay.Checked = My.Settings.HoldToPlay + userdatatext.Text = My.Settings.userdata + steamappstext.Text = My.Settings.steamapps + EnableOverrideBox.Checked = My.Settings.OverrideFolders End Sub Private Sub UpdateCheckBox_CheckedChanged(sender As Object, e As EventArgs) Handles UpdateCheckBox.CheckedChanged @@ -39,9 +42,13 @@ Private Sub ChangeRelayButton_Click(sender As Object, e As EventArgs) Handles ChangeRelayButton.Click Dim SelectKeyDialog As New SelectKey If SelectKeyDialog.ShowDialog = Windows.Forms.DialogResult.OK Then - My.Settings.RelayKey = SelectKeyDialog.ChosenKey - My.Settings.Save() - ChangeRelayButton.Text = String.Format("Relay key: ""{0}"" (change)", My.Settings.RelayKey) + If Not SelectKeyDialog.ChosenKey = My.Settings.PlayKey Then + My.Settings.RelayKey = SelectKeyDialog.ChosenKey + My.Settings.Save() + ChangeRelayButton.Text = String.Format("Relay key: ""{0}"" (change)", My.Settings.RelayKey) + Else + MessageBox.Show("Play key and relay key can not be the same!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) + End If End If End Sub @@ -49,4 +56,40 @@ My.Settings.HoldToPlay = HoldToPlay.Checked My.Settings.Save() End Sub + + Private Sub DonateLabel_Click(sender As Object, e As EventArgs) Handles DonateLabel.Click + Process.Start("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RVLLPGWJUG6CY") + End Sub + + Private Sub EnableOverrideBox_CheckedChanged(sender As Object, e As EventArgs) Handles EnableOverrideBox.CheckedChanged + My.Settings.OverrideFolders = EnableOverrideBox.Checked + My.Settings.Save() + + For Each control In OverrideGroup.Controls + control.enabled = EnableOverrideBox.Checked + Next + EnableOverrideBox.Enabled = True + End Sub + + Private Sub ShowFolderSelector(name As String, ByRef setting As String) + Dim ChangeDirDialog As New FolderBrowserDialog + ChangeDirDialog.Description = String.Format("Select your {0} folder:", name) + ChangeDirDialog.ShowNewFolderButton = False + + If ChangeDirDialog.ShowDialog = System.Windows.Forms.DialogResult.OK Then + setting = ChangeDirDialog.SelectedPath & "\" + My.Settings.Save() + End If + + End Sub + + Private Sub FindsteamappsButton_Click(sender As Object, e As EventArgs) Handles FindsteamappsButton.Click + ShowFolderSelector("steamapps", My.Settings.steamapps) + steamappstext.Text = My.Settings.steamapps + End Sub + + Private Sub FinduserdataButton_Click(sender As Object, e As EventArgs) Handles FinduserdataButton.Click + ShowFolderSelector("userdata", My.Settings.userdata) + userdatatext.Text = My.Settings.userdata + End Sub End Class \ No newline at end of file