Skip to content

Commit

Permalink
Added process\parameter to ludusavi import
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMaximus committed Jun 3, 2022
1 parent 6d5d851 commit 3911cf9
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 11 deletions.
6 changes: 3 additions & 3 deletions GBM/Classes/YAML Serialize Classes/Ludusavi.vb
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,15 @@ Public Class LudusaviPath
End Class

Public Class LudusaviLaunch
Private oWhen As List(Of LudusaviWhen)
Private oWhen As LudusaviWhen()
Private sArguments As String
Private sWorkingDir As String

Property [when] As List(Of LudusaviWhen)
Property [when] As LudusaviWhen()
Get
Return oWhen
End Get
Set(value As List(Of LudusaviWhen))
Set(value As LudusaviWhen())
oWhen = value
End Set
End Property
Expand Down
21 changes: 15 additions & 6 deletions GBM/Forms/frmAdvancedImport.vb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ Public Class frmAdvancedImport
Private Sub LoadData(Optional ByVal sFilter As String = "", Optional ByVal bSelectedOnly As Boolean = False)
Dim oApp As clsGame
Dim oListViewItem As ListViewItem
Dim sProcess As String
Dim sTags As String
Dim bAddItem As Boolean

Expand All @@ -174,10 +175,16 @@ Public Class frmAdvancedImport
Next
sTags = sTags.TrimEnd(New Char() {",", " "})

If oApp.Parameter <> String.Empty Then
sProcess = oApp.ProcessName & " (" & oApp.Parameter & ")"
Else
sProcess = oApp.ProcessName
End If

If bClassicMode Then
oListViewItem = New ListViewItem(New String() {oApp.Name, oApp.ProcessName, oApp.Path, oApp.FileType, sTags})
oListViewItem = New ListViewItem(New String() {oApp.Name, sProcess, oApp.Path, oApp.FileType, sTags})
Else
oListViewItem = New ListViewItem(New String() {oApp.Name, oApp.Path, oApp.FileType, oApp.OS.ToString, sTags})
oListViewItem = New ListViewItem(New String() {oApp.Name, sProcess, oApp.Path, oApp.FileType, oApp.OS.ToString, sTags})
End If

oListViewItem.Tag = oApp.ID
Expand Down Expand Up @@ -241,11 +248,12 @@ Public Class frmAdvancedImport
lstGames.Columns(3).Width = Math.Round(lstGames.Size.Width * 0.13)
lstGames.Columns(4).Width = Math.Round(lstGames.Size.Width * 0.09)
Else
lstGames.Columns(0).Width = Math.Round(lstGames.Size.Width * 0.36)
lstGames.Columns(1).Width = Math.Round(lstGames.Size.Width * 0.29)
lstGames.Columns(2).Width = Math.Round(lstGames.Size.Width * 0.13)
lstGames.Columns(3).Width = Math.Round(lstGames.Size.Width * 0.09)
lstGames.Columns(0).Width = Math.Round(lstGames.Size.Width * 0.3)
lstGames.Columns(1).Width = Math.Round(lstGames.Size.Width * 0.15)
lstGames.Columns(2).Width = Math.Round(lstGames.Size.Width * 0.2)
lstGames.Columns(3).Width = Math.Round(lstGames.Size.Width * 0.13)
lstGames.Columns(4).Width = Math.Round(lstGames.Size.Width * 0.09)
lstGames.Columns(5).Width = Math.Round(lstGames.Size.Width * 0.09)
End If
lstGames.EndUpdate()
End If
Expand Down Expand Up @@ -287,6 +295,7 @@ Public Class frmAdvancedImport
lstGames.Columns.Add(frmAdvancedImport_ColumnTags)
Else
lstGames.Columns.Add(frmAdvancedImport_ColumnName)
lstGames.Columns.Add(frmAdvancedImport_ColumnProcess)
lstGames.Columns.Add(frmAdvancedImport_ColumnPath)
lstGames.Columns.Add(frmAdvancedImport_ColumnInclude)
lstGames.Columns.Add(frmAdvancedImport_ColumnOs)
Expand Down
64 changes: 62 additions & 2 deletions GBM/Managers/mgrLudusavi.vb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,26 @@ Public Class mgrLudusavi
Return True
End Function

Private Shared Function IsValidProcess(ByVal sProcess As String) As Boolean
Dim sExt As String() = {".bat", ".sh"}
Dim sName As String() = {"launch", "start_protected_game", "dowser"}
Dim s As String

For Each s In sExt
If sProcess.ToLower.EndsWith(s) Then
Return False
End If
Next

For Each s In sName
If sProcess.ToLower.Contains(s) Then
Return False
End If
Next

Return True
End Function

Private Shared Function HasStorePath(ByVal sPath As String) As Boolean
Return sPath.Contains("<root>")
End Function
Expand Down Expand Up @@ -184,6 +204,39 @@ Public Class mgrLudusavi
oGame.ImportTags.Add(New Tag("Ludusavi"))
End Sub

Private Shared Sub HandleLaunch(ByRef oGame As clsGame, ByRef oLudusaviLaunchData As Dictionary(Of String, List(Of LudusaviLaunch)), ByVal sOS As String)
Dim oLudusaviLaunchPair As KeyValuePair(Of String, List(Of LudusaviLaunch))
Dim oLudusaviLaunch As LudusaviLaunch
Dim sProcess As String = String.Empty
Dim sArguments As String = String.Empty

If Not oLudusaviLaunchData Is Nothing Then
For Each oLudusaviLaunchPair In oLudusaviLaunchData
For Each oLudusaviLaunch In oLudusaviLaunchPair.Value
If (oLudusaviLaunch.when(0).os Is Nothing Or oLudusaviLaunch.when(0).os = sOS) And (oLudusaviLaunch.when(0).bit = 0 Or oLudusaviLaunch.when(0).bit = 64) Then
sProcess = mgrPath.ValidatePath(oLudusaviLaunchPair.Key.Replace("<base>/", String.Empty))
If IsValidProcess(sProcess) Then
If sProcess.ToLower.EndsWith(".exe") Then
sProcess = Path.GetFileNameWithoutExtension(sProcess)
Else
sProcess = Path.GetFileName(sProcess)
End If
If Not oLudusaviLaunch.arguments Is Nothing Then
If oLudusaviLaunch.when(0).os = sOS Or oLudusaviLaunch.when(0).os Is Nothing Then
sArguments = oLudusaviLaunch.arguments
End If
End If
Exit For
End If
End If
Next
Next
End If

oGame.ProcessName = sProcess
oGame.Parameter = sArguments
End Sub

Private Shared Function DetectSupportedStorePaths() As List(Of String)
Dim oStores As New List(Of String)

Expand Down Expand Up @@ -300,8 +353,12 @@ Public Class mgrLudusavi
End If

HandleTags(oLudusaviPath.tags, w.store, oGame)
If Not (t = TagTypes.config.ToString And oLudusaviPath.tags.Length = 1) Then
HandleLaunch(oGame, oLudusaviGame.launch, w.os)
End If

oConfigurations.Add(oGame)
End If
End If
Next
End If
End If
Expand All @@ -326,6 +383,9 @@ Public Class mgrLudusavi
oGame.OS = clsGame.eOS.Windows

HandleTags(oLudusaviPath.tags, Nothing, oGame)
If Not (t = TagTypes.config.ToString And oLudusaviPath.tags.Length = 1) Then
HandleLaunch(oGame, oLudusaviGame.launch, OsTypes.windows.ToString)
End If
oConfigurations.Add(oGame)
End If
Next
Expand Down Expand Up @@ -387,7 +447,7 @@ Public Class mgrLudusavi

Return True
Catch ex As Exception
mgrCommon.ShowMessage(mgrLudusavi_ErrorReading, ex.InnerException.Message, MsgBoxStyle.Critical)
mgrCommon.ShowMessage(mgrLudusavi_ErrorReading, ex.Message, MsgBoxStyle.Critical)
Return False
Finally
Cursor.Current = Cursors.Default
Expand Down

0 comments on commit 3911cf9

Please sign in to comment.