Skip to content

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
Changes:

* Now supports .mp3, .wav, .aac, .wma, .m4a, .mp4, .wmv, .avi, .m4v, and
.mov file types.
* Better folder selection process.
* Better Error reporting for errors occurring while "started".
* Able to disable the use of the userdata folder (1.2.0/legacy mode).
* Fixed "Alias name is too long" error.
  • Loading branch information
SilentSys committed Jan 2, 2016
1 parent cf0f15b commit 4b63522
Show file tree
Hide file tree
Showing 9 changed files with 211 additions and 131 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SLAM is a new way to share sounds with your friends over the built in communicat
Current features:
- Simple in-game interface.
- Select tracks either by their track number, or tags.
- Import multiple .mp3 and .wav files at once with the click of a button.
- Import multiple media files at once with the click of a button (.mp3, .wav, .aac, .wma, .m4a, .mp4, .wmv, .avi, .m4v, and .mov file types).
- Support for multiple games, such as: Counter-Strike: Global Offensive (CS:GO), Counter-Strike: Source (CS:S), and Team Fortress 2 (TF2)
- Create binds to load specific songs.
- Change track volume on the go.
Expand Down
7 changes: 5 additions & 2 deletions SLAM/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<userSettings>
<SLAM.My.MySettings>
<setting name="SteamAppsFolder" serializeAs="String">
<value>C:\Program Files (x86)\Steam\steamapps\</value>
<value />
</setting>
<setting name="PlayKey" serializeAs="String">
<value>X</value>
Expand All @@ -38,7 +38,10 @@
<value>=</value>
</setting>
<setting name="UserdataPath" serializeAs="String">
<value>C:\Program Files (x86)\Steam\userdata\</value>
<value />
</setting>
<setting name="UserDataEnabled" serializeAs="String">
<value>True</value>
</setting>
</SLAM.My.MySettings>
</userSettings>
Expand Down
14 changes: 8 additions & 6 deletions SLAM/Form1.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

127 changes: 87 additions & 40 deletions SLAM/Form1.vb
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,7 @@ Public Class Form1
End Sub

Private Sub WaveCreator(File As String, outputFile As String, Game As SourceGame)
Dim reader As New Object

If Path.GetExtension(File) = ".mp3" Then
reader = New Mp3FileReader(File)
ElseIf Path.GetExtension(File) = ".wav" Then
reader = New WaveFileReader(File)
End If
Dim reader As New MediaFoundationReader(File)

Dim outFormat = New WaveFormat(Game.samplerate, Game.bits, Game.channels)

Expand Down Expand Up @@ -215,6 +209,28 @@ Public Class Form1
End Sub

Private Sub StartPoll()

Dim Game As SourceGame = GetCurrentGame()
If Not Game.id = 0 And My.Settings.UserDataEnabled Then 'The CFG's are located in the userdata folder
Dim CFGExists As Boolean = False
If Directory.Exists(My.Settings.UserdataPath) Then
For Each userdir As String In Directory.GetDirectories(My.Settings.UserdataPath)
Dim CFGPath As String = Path.Combine(userdir, Game.id.ToString) & "\local\cfg\"
If Directory.Exists(CFGPath) Then
CFGExists = True
Exit For
End If
Next
End If
If Not CFGExists Then
MessageBox.Show("The set ""UserData"" folder does not seem to be correct! Please choose the correct folder.", "Folder does not exist!", MessageBoxButtons.OK, MessageBoxIcon.Error)
If ShowUserDataSelector() Then
StartPoll()
End If
Return
End If
End If

running = True
StartButton.Text = "Stop"
CreateCfgFiles()
Expand Down Expand Up @@ -364,45 +380,51 @@ Public Class Form1
Dim GameDir As String = Path.Combine(SteamappsPath, Game.directory)
Dim GameCfg As String = Path.Combine(GameDir, Game.ToCfg) & "slam_relay.cfg"

Try
Do
If PollRelayWorker.CancellationPending Then
Exit Do
End If

Do
If PollRelayWorker.CancellationPending Then
Exit Do
End If
If Not Game.id = 0 And My.Settings.UserDataEnabled Then
GameCfg = UserDataCFG(Game)
End If

If Not String.IsNullOrEmpty(Game.id) Then
GameCfg = UserDataCFG(Game)
End If
If File.Exists(GameCfg) Then
Dim RelayCfg As String
Using reader As StreamReader = New StreamReader(GameCfg)
RelayCfg = reader.ReadToEnd
End Using

If File.Exists(GameCfg) Then
Dim RelayCfg As String
Using reader As StreamReader = New StreamReader(GameCfg)
RelayCfg = reader.ReadToEnd
End Using

Dim command As String = recog(RelayCfg, String.Format("bind ""{0}"" ""(.*?)""", My.Settings.RelayKey))
If Not String.IsNullOrEmpty(command) Then
'load audiofile
If IsNumeric(command) Then
If LoadTrack(Game, Convert.ToInt32(command) - 1) Then
PollRelayWorker.ReportProgress(Convert.ToInt32(command) - 1)
Dim command As String = recog(RelayCfg, String.Format("bind ""{0}"" ""(.*?)""", My.Settings.RelayKey))
If Not String.IsNullOrEmpty(command) Then
'load audiofile
If IsNumeric(command) Then
If LoadTrack(Game, Convert.ToInt32(command) - 1) Then
PollRelayWorker.ReportProgress(Convert.ToInt32(command) - 1)
End If
End If
File.Delete(GameCfg)
End If
File.Delete(GameCfg)
End If
End If

Thread.Sleep(Game.PollInterval)
Loop
Thread.Sleep(Game.PollInterval)
Loop
Catch ex As Exception
LogError(ex)
e.Result = ex
End Try
End Sub

Public Function UserDataCFG(Game As SourceGame) As String
For Each userdir As String In Directory.GetDirectories(My.Settings.UserdataPath)
Dim CFGPath As String = Path.Combine(userdir, Game.id.ToString) & "\local\cfg\slam_relay.cfg"
If File.Exists(CFGPath) Then
Return CFGPath
End If
Next
If Directory.Exists(My.Settings.UserdataPath) Then
For Each userdir As String In Directory.GetDirectories(My.Settings.UserdataPath)
Dim CFGPath As String = Path.Combine(userdir, Game.id.ToString) & "\local\cfg\slam_relay.cfg"
If File.Exists(CFGPath) Then
Return CFGPath
End If
Next
End If
Return vbNullString
End Function

Expand All @@ -414,6 +436,10 @@ Public Class Form1
If running Then
StopPoll()
End If

If Not IsNothing(e.Result) Then 'Result is always an exception
MessageBox.Show(e.Result.Message & " See errorlog.txt for more info.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub

Private Sub CreateTags(ByVal Game As SourceGame)
Expand All @@ -425,7 +451,7 @@ Public Class Form1

For Each Word In Words

If Not IsNumeric(Word) And Not Game.blacklist.Contains(Word.ToLower) Then
If Not IsNumeric(Word) And Not Game.blacklist.Contains(Word.ToLower) And Word.Length < 32 Then
If NameWords.ContainsKey(Word) Then
NameWords.Remove(Word)
Else
Expand Down Expand Up @@ -485,6 +511,12 @@ Public Class Form1
ReloadTracks(GetCurrentGame)
RefreshTrackList()

'This should set the UserData path drive to the same as the drive on the SteamApps path on first run
If String.IsNullOrEmpty(My.Settings.UserdataPath) Then
My.Settings.UserdataPath = SteamappsPath.Split("\")(0) & "\Program Files (x86)\Steam\userdata\"
End If


My.Settings.SteamAppsFolder = SteamappsPath
My.Settings.Save()

Expand All @@ -498,17 +530,19 @@ Public Class Form1

End Sub

Public Sub ShowFolderSelector()
Public Function ShowFolderSelector() As Boolean
Dim ChangeDirDialog As New FolderBrowserDialog
ChangeDirDialog.Description = "Select your steamapps folder:"
ChangeDirDialog.ShowNewFolderButton = False

If ChangeDirDialog.ShowDialog = System.Windows.Forms.DialogResult.OK Then
SteamappsPath = ChangeDirDialog.SelectedPath & "\"
LoadGames()
Return True
End If

End Sub
Return False
End Function

Private Sub LoadTrackKeys(ByVal Game As SourceGame)
Dim SettingsList As New List(Of SourceGame.track)
Expand Down Expand Up @@ -755,7 +789,7 @@ Public Class Form1

Private Sub LogError(ByVal ex As Exception)
If My.Settings.LogError Then
Using log As StreamWriter = New StreamWriter("log.txt", True)
Using log As StreamWriter = New StreamWriter("errorlog.txt", True)
log.WriteLine("--------------------{0}--------------------", DateTime.Now)
log.WriteLine(ex.ToString)
End Using
Expand Down Expand Up @@ -792,6 +826,19 @@ Public Class Form1

End Sub

Public Function ShowUserDataSelector() As Boolean
Dim ChangeDirDialog As New FolderBrowserDialog
ChangeDirDialog.Description = "Select your userdata folder:"
ChangeDirDialog.ShowNewFolderButton = False

If ChangeDirDialog.ShowDialog = System.Windows.Forms.DialogResult.OK Then
My.Settings.UserdataPath = ChangeDirDialog.SelectedPath & "\"
Return True
End If

Return False
End Function

Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If running Then
StopPoll()
Expand Down
6 changes: 3 additions & 3 deletions SLAM/My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("SLAM")>
<Assembly: AssemblyCopyright("Copyright © 2015")>
<Assembly: AssemblyCopyright("Copyright © 2016")>
<Assembly: AssemblyTrademark("")>

<Assembly: ComVisible(False)>
Expand All @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.2.1.0")>
<Assembly: AssemblyFileVersion("1.2.1.0")>
<Assembly: AssemblyVersion("1.2.2.0")>
<Assembly: AssemblyFileVersion("1.2.2.0")>
16 changes: 14 additions & 2 deletions SLAM/My Project/Settings.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions SLAM/My Project/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<Profiles />
<Settings>
<Setting Name="SteamAppsFolder" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\Program Files (x86)\Steam\steamapps\</Value>
<Value Profile="(Default)" />
</Setting>
<Setting Name="PlayKey" Type="System.String" Scope="User">
<Value Profile="(Default)">X</Value>
Expand All @@ -30,7 +30,10 @@
<Value Profile="(Default)">=</Value>
</Setting>
<Setting Name="UserdataPath" Type="System.String" Scope="User">
<Value Profile="(Default)">C:\Program Files (x86)\Steam\userdata\</Value>
<Value Profile="(Default)" />
</Setting>
<Setting Name="UserDataEnabled" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit 4b63522

Please sign in to comment.