Skip to content

Commit

Permalink
Improve Fuzzy Matching to not use the DOS short names #96
Browse files Browse the repository at this point in the history
  • Loading branch information
JockeJarre committed Nov 6, 2024
1 parent 987cb07 commit 0fc5728
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 145 deletions.
2 changes: 0 additions & 2 deletions b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Imports System
Imports System.Windows.Forms
Imports System.Drawing
Imports Microsoft.Win32
Imports System.IO
Imports System.Reflection
Imports System.Text.RegularExpressions
Expand Down
24 changes: 9 additions & 15 deletions b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Public Class B2SSettings
Fantasy = 2
End Enum

Private Const filename As String = "B2STableSettings.xml"
Private Const settingsFilename As String = "B2STableSettings.xml"
Public Shared Property B2SScreenResFileName As String = SafeReadRegistry("Software\B2S", "B2SScreenResFileNameOverride", "ScreenRes.txt")
Public Shared Property B2STableSettingsExtendedPath() As Boolean = SafeReadRegistry("Software\B2S", "B2STableSettingsExtendedPath", "0") = "1"
Public Shared Property B2SWindowPunchActive() As Boolean = SafeReadRegistry("Software\B2S", "B2SWindowPunchActive", "0") = "1"
Expand Down Expand Up @@ -254,19 +254,14 @@ Public Class B2SSettings
End Function

Public Shared Function GetSettingFilename() As String
If IO.File.Exists(filename) Then
Return filename
#If B2S = "DLLBefore" Then
ElseIf StartAsEXE And B2STableSettingsExtendedPath And IO.File.Exists(IO.Path.Combine(Application.StartupPath(), filename)) Then
Return IO.Path.Combine(Application.StartupPath(), filename)
#Else
ElseIf B2STableSettingsExtendedPath And IO.File.Exists(IO.Path.Combine(Application.StartupPath(), filename)) Then
Return IO.Path.Combine(Application.StartupPath(), filename)
#End If
ElseIf B2STableSettingsExtendedPath And IO.File.Exists(IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filename)) Then
Return IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), filename)
If IO.File.Exists(settingsFilename) Then
Return settingsFilename
ElseIf B2STableSettingsExtendedPath And IO.File.Exists(IO.Path.Combine(Application.StartupPath(), settingsFilename)) Then
Return IO.Path.Combine(Application.StartupPath(), settingsFilename)
ElseIf B2STableSettingsExtendedPath And IO.File.Exists(IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), settingsFilename)) Then
Return IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), settingsFilename)
End If
Return filename
Return settingsFilename
End Function

Public Shared Sub LoadGlobalAndTableSettings(xmlNode As Xml.XmlNode)
Expand All @@ -287,6 +282,7 @@ Public Class B2SSettings
If xmlNode.SelectSingleNode("GlowIndex") IsNot Nothing Then GlowIndex = CInt(xmlNode.SelectSingleNode("GlowIndex").InnerText)
If xmlNode.SelectSingleNode("StartAsEXE") IsNot Nothing Then StartAsEXE = (xmlNode.SelectSingleNode("StartAsEXE").InnerText = "1")
If xmlNode.SelectSingleNode("StartBackground") IsNot Nothing Then StartBackground = (xmlNode.SelectSingleNode("StartBackground").InnerText = "1")
If xmlNode.SelectSingleNode("DisableFuzzyMatching") IsNot Nothing Then DisableFuzzyMatching = (xmlNode.SelectSingleNode("DisableFuzzyMatching").InnerText = "1")

If Not PureEXE Then
If xmlNode.SelectSingleNode("FormToFront") IsNot Nothing Then FormToFront = (xmlNode.SelectSingleNode("FormToFront").InnerText = "1")
Expand Down Expand Up @@ -330,8 +326,6 @@ Public Class B2SSettings
If DefaultStartMode <> eDefaultStartMode.Standard Then DefaultStartMode = eDefaultStartMode.EXE
If DefaultStartMode = eDefaultStartMode.Standard Then StartAsEXE = False

'If nodeHeader.SelectSingleNode("DisableFuzzyMatching") IsNot Nothing Then DisableFuzzyMatching = (nodeHeader.SelectSingleNode("DisableFuzzyMatching").InnerText = "1")

' get overall settings
If nodeHeader.SelectSingleNode("CPUAffinityMask") IsNot Nothing Then CPUAffinityMask = CInt(nodeHeader.SelectSingleNode("CPUAffinityMask").InnerText)
If nodeHeader.SelectSingleNode("LogPath") IsNot Nothing Then LogPath = nodeHeader.SelectSingleNode("LogPath").InnerText
Expand Down
5 changes: 5 additions & 0 deletions b2sbackglassserver/b2sbackglassserver/Classes/Processes.vb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ Public Class Processes
For Each proc As ProcInfo In windowlist
If Not String.IsNullOrEmpty(proc.Name) Then
If proc.Name.StartsWith("Visual Pinball - ", StringComparison.CurrentCultureIgnoreCase) Then
'Visual Pinball - [Tom and Jerry (Original 2019) v 1.33]
If String.IsNullOrEmpty(_tablename) Then
_tablename = proc.Name.Substring(17)
'[Tom and Jerry (Original 2019) v 1.33]___
If _tablename.StartsWith("[") AndAlso Not _tablename.EndsWith("]") Then
Dim i As Integer = _tablename.Length - 1
Dim found As Boolean = False
Expand All @@ -48,10 +50,13 @@ Public Class Processes
Loop
If found Then
_tablename = _tablename.Substring(0, i + 1)
'[Tom and Jerry (Original 2019) v 1.33]
End If
End If
If _tablename.StartsWith("[") Then _tablename = _tablename.Substring(1)
'Tom and Jerry (Original 2019) v 1.33]
If _tablename.EndsWith("]") Then _tablename = _tablename.Substring(0, _tablename.Length - 1)
'Tom and Jerry (Original 2019) v 1.33
If _tablename.EndsWith("*") Then _tablename = _tablename.Substring(0, _tablename.Length - 1)
If _tablename.EndsWith(".vpt") Then _tablename = _tablename.Substring(0, _tablename.Length - 4)
If _tablename.EndsWith("*") Then _tablename = _tablename.Substring(0, _tablename.Length - 1)
Expand Down
Loading

0 comments on commit 0fc5728

Please sign in to comment.