Skip to content

Commit

Permalink
Add support for whitelist favourites list
Browse files Browse the repository at this point in the history
  • Loading branch information
M1kerochip committed Jul 1, 2020
1 parent a4b7a5e commit 7e064b0
Show file tree
Hide file tree
Showing 9 changed files with 777 additions and 159 deletions.
18 changes: 18 additions & 0 deletions App.config
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@
<setting name="HiddenDriverList" serializeAs="String">
<value />
</setting>
<setting name="IncludeCreateFakeZip" serializeAs="String">
<value>False</value>
</setting>
<setting name="IncludeMoveFakeClones" serializeAs="String">
<value>False</value>
</setting>
<setting name="CreateFakeZipDir" serializeAs="String">
<value />
</setting>
<setting name="MoveFakeClonesDir" serializeAs="String">
<value />
</setting>
<setting name="UpdateSettings" serializeAs="String">
<value>True</value>
</setting>
<setting name="DontHideFavList" serializeAs="String">
<value>False</value>
</setting>
</CreateGameListFromMameXML.My.MySettings>
</userSettings>
</configuration>
89 changes: 69 additions & 20 deletions CreateGameList_XML.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,17 @@
Public Property RatingScale As Integer = 100
Public Property FavouritePath As String = ""
Public Property GenrePath As String = ""
Public Property IsSoftwareList As Boolean = False

Public Property CreateEmptyZip As String = ""
Public Property MoveEmptyZipClonesDir As String = ""

Public Property HiddenDriverList As String = ""

Public Property ResultString As String = ""

Public Property SearchRomSubDirs As Boolean = False

''' <summary>
''' If ratings are enabled, and there's a rating list, set this to true to check to see if a game has a score lower than this. If so, set hidden to true.
''' </summary>
Expand All @@ -36,6 +42,7 @@

Public Property HideBios As Boolean = True
Public Property HiddenListPath As String
Public Property DontHideFavGame As Boolean = False

''' <summary>
''' Include Mame xml emulation status and driver status as first line of description
Expand Down Expand Up @@ -176,6 +183,7 @@
End If

xd.Load(MAME_XML_Path) 'Load mame xml into xml document
Application.DoEvents()

Dim History As New ReadDATFile
If HistoryDAT_Path <> "" Then
Expand Down Expand Up @@ -256,12 +264,20 @@
W.WriteComment(“This file generated by the CreateGameList_XML class.”)
W.WriteStartElement(“gameList”) 'Write first Element, GameList

xn = xd.GetElementsByTagName("machine") 'Find the "Machine" elements in the MAME XML
If IsSoftwareList = False Then
xn = xd.GetElementsByTagName("machine") 'Find the "Machine" elements in the MAME XML
Else
xn = xd.GetElementsByTagName("software") 'Find the "software" elements in the Software List XML
End If
For i = 0 To xn.Count - 1
Try
Romfile = xn(i).Attributes.GetNamedItem("name").InnerText.Trim 'Read MAME Name (rom file/folder)
DriverName = xn(i).Attributes.GetNamedItem("sourcefile").InnerText.Trim 'Read MAME source file name.

If Not xn(i).Attributes("sourcefile") Is Nothing Then
DriverName = xn(i).Attributes.GetNamedItem("sourcefile").InnerText.Trim 'Read MAME source file name.
End If

ResultString = "ROM: " + Romfile + vbCrLf + "Name: " + DriverName
If ShowProgress Then
prgFrm.pbMain.Minimum = 0
prgFrm.pbMain.Maximum = xn.Count
Expand All @@ -271,7 +287,7 @@

Dim canwrite As Boolean = True

If ROMPath <> "" Then 'If the Rompath is not blank,
If ROMPath <> "" Then 'If the Rompath is not blank, we need to check if a file exists in the rom dir.
If Not IO.File.Exists(ROMPath + "\" + Romfile + GameExt) Then 'Check to see if the rom exists in the rom dir
canwrite = False 'If it doesn't then don't include this rom in the gamename.xml
End If
Expand All @@ -280,13 +296,23 @@
If canwrite = True Then 'Include this game?
W.WriteStartElement(“game”) 'Write Game Element

Dim romd As String = “./” + Romfile + GameExt

If MoveEmptyZipClonesDir <> "" Then
If Not xn(i).Attributes.GetNamedItem("cloneof") Is Nothing Then
romd = “./” + MoveEmptyZipClonesDir + "/" + Romfile + GameExt
End If
End If

W.WriteStartElement(“path”) 'Write Rom Path
W.WriteString(“./” + Romfile + GameExt)
W.WriteString(romd)
W.WriteEndElement() 'Close Rom Path

st1 = xn(i).Item("description").InnerText.Trim 'Read MAME Game Name (Long Name/Description)
Dim RomDescName As String = ""

RomDescName = xn(i).Item("description").InnerText.Trim 'Read MAME Game Name (Long Name/Description)
W.WriteStartElement(“name”) 'Write Game Name
W.WriteString(st1)
W.WriteString(RomDescName)
W.WriteEndElement() 'Close Game Name

st1 = ""
Expand All @@ -307,15 +333,18 @@
End If
End If

Dim HistDesc As String = ""
If HistoryDAT_Path <> "" Then 'If History.dat is not blank, include it in the <description>
st1 += History.GetData(Romfile) 'Include History in <description>
HistDesc += History.GetData(Romfile) 'Include History in <description>
End If

Dim InfoDesc As String = ""
If MameInfoDAT_Path <> "" Then 'If MameInfo.dat is not blank, include it in the <description>
st1 += Info.GetData(Romfile) 'Include MameInfo in <description>
InfoDesc += Info.GetData(Romfile) 'Include MameInfo in <description>
End If

W.WriteStartElement(“desc”) 'Write Description
W.WriteString(st1)
W.WriteString(st1 + HistDesc + InfoDesc)
W.WriteEndElement() 'Close Description

st1 = ImagePath + "/" + ImagePrepend + Romfile + ImageAppend + ImageExtension
Expand All @@ -330,7 +359,7 @@
W.WriteEndElement() 'Close video
End If

If MarqueePath <> "" Then
If MarqueePath <> "" Then 'If Marquee Path is not blank, include it in the .xml
st1 = MarqueePath + "/" + Romfile + ImageExtension
W.WriteStartElement(“marquee”) 'Write marquee
W.WriteString(st1)
Expand Down Expand Up @@ -417,6 +446,21 @@
Next
End If

'Final Hidden game override: Even if any of the above cause the game to be hidden, check to see if it's in the fav list. If so, whitelist it.
Dim FavReq As Boolean = False
Dim f As Boolean = False

If FavouritePath <> "" Then 'If we have a list of favourite.ini games
f = Fav.GetDataB(Romfile) 'Check to see if current game is in the fav list
If f = True Then
FavReq = True 'If so, need to mark it as fav in gamelist
End If
End If

If FavReq = True Then 'If this game is a favourite,
writeHiddensection = False 'Do not write hidden section for this game
End If

If writeHiddensection = True Then 'If any of the above causes the rom to be hidden:
W.WriteStartElement(“hidden”) 'Write hidden
W.WriteString("true")
Expand Down Expand Up @@ -454,16 +498,6 @@
W.WriteEndElement() 'Close players
End If

Dim FavReq As Boolean = False
Dim f As Boolean = False

If FavouritePath <> "" Then
f = Fav.GetDataB(Romfile)
If f = True Then
FavReq = True
End If
End If

If RatingPath <> "" Then
If FavRatedGamesWithScore = True Then
If CDbl(Ra) >= CDbl(FavScore) / RatingScale Then 'Check score is equal to or below level
Expand All @@ -487,8 +521,23 @@
prgFrm.pbMain.PerformStep()
prgFrm.Refresh()
End If

If CreateEmptyZip <> "" Then
Dim fn As String = ""
If MoveEmptyZipClonesDir <> "" Then
If Not xn(i).Attributes.GetNamedItem("cloneof") Is Nothing Then
fn = CreateEmptyZip + "\" + MoveEmptyZipClonesDir + "\" + Romfile + GameExt
Else
fn = CreateEmptyZip + "\" + Romfile + GameExt
End If
Else
fn = CreateEmptyZip + "\" + Romfile + GameExt
End If
IO.File.Create(fn).Dispose()
End If
Catch e As Exception
End Try
Application.DoEvents()
Next
If ShowProgress Then
prgFrm.lblMain.Text = "Writing gamename.xml"
Expand Down
4 changes: 3 additions & 1 deletion CreateListInfoXMLfromMAME.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Private p_MAME_EXE_Path As String
Private p_MAME_XML_Path As String

Public Property CMDArguments As String = "-listxml"

Public Property MAME_EXE_Path As String
Get
Expand Down Expand Up @@ -34,8 +35,9 @@
Dim SR As IO.StreamReader

CMD.StartInfo.FileName = MAME_EXE_Path
CMD.StartInfo.Arguments = "-listxml"
CMD.StartInfo.Arguments = CMDArguments
CMD.StartInfo.UseShellExecute = False
CMD.StartInfo.WorkingDirectory = IO.Path.GetDirectoryName(MAME_EXE_Path)
CMD.StartInfo.RedirectStandardInput = True
CMD.StartInfo.RedirectStandardOutput = True
CMD.StartInfo.CreateNoWindow = True
Expand Down
4 changes: 2 additions & 2 deletions My Project/AssemblyInfo.vb
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>

<Assembly: AssemblyVersion("1.5.2.0")>
<Assembly: AssemblyFileVersion("1.5.2.0")>
<Assembly: AssemblyVersion("1.5.3.0")>
<Assembly: AssemblyFileVersion("1.5.3.0")>
72 changes: 72 additions & 0 deletions My Project/Settings.Designer.vb

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

18 changes: 18 additions & 0 deletions My Project/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,23 @@
<Setting Name="HiddenDriverList" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="IncludeCreateFakeZip" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="IncludeMoveFakeClones" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="CreateFakeZipDir" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="MoveFakeClonesDir" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="UpdateSettings" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="DontHideFavList" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit 7e064b0

Please sign in to comment.