diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb index 5986d6e..171717d 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb @@ -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 diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb index dfdd4d8..7124444 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb @@ -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" @@ -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) @@ -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") @@ -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 diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/Processes.vb b/b2sbackglassserver/b2sbackglassserver/Classes/Processes.vb index 7dd0638..3aee7f9 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/Processes.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/Processes.vb @@ -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 @@ -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) diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index 847736b..9afc76a 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -1,4 +1,5 @@ Imports System.Drawing +Imports System.Drawing.Imaging Imports System.IO Imports System.Windows.Forms Imports Microsoft.Win32 @@ -18,17 +19,17 @@ Public Class formBackglass Private formSettings As formSettings = Nothing Private formMode As formMode = Nothing -#If B2S = "DLL" Then Private startupTimer As Timer = Nothing - Private snifferTimer As Timer = Nothing +#If B2S = "DLL" Then + + Private snifferTimer As Timer = Nothing Private snifferLamps As B2SSnifferPanel = Nothing Private snifferSolenoids As B2SSnifferPanel = Nothing Private snifferGIStrings As B2SSnifferPanel = Nothing Private chkSniffer As CheckBox = Nothing Private Const snifferTimerInterval As Integer = 311 #Else - Private timer As Timer = Nothing Private tableTimer As Timer = Nothing Private B2STimer As Timer = Nothing Private tableHandle As Integer = 0 @@ -77,6 +78,13 @@ Public Class formBackglass If B2SData.TableFileName.EndsWith(".directb2s") Then B2SData.TableFileName = Path.GetFileNameWithoutExtension(B2SData.TableFileName) B2SSettings.PureEXE = True + B2SSettings.GameName = String.Empty + B2SSettings.B2SName = String.Empty + Else + Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S") + B2SSettings.GameName = regkey.GetValue("B2SGameName", String.Empty) + B2SSettings.B2SName = regkey.GetValue("B2SB2SName", String.Empty) + End Using End If If My.Application.CommandLineArgs.Count > 1 Then @@ -97,12 +105,6 @@ Public Class formBackglass 'B2SSettings.GameName = "smanve_101" 'B2SData.TableFileName = "Spider-Man(Stern 2007) alt full dmdON127" - - Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S") - B2SSettings.GameName = regkey.GetValue("B2SGameName", String.Empty) - B2SSettings.B2SName = regkey.GetValue("B2SB2SName", String.Empty) - End Using - ' Westworld 2016-18-11 - TableFileName is empty in some cases when launched via PinballX, we use GameName as alternativ If String.IsNullOrEmpty(B2SData.TableFileName) Then B2SData.TableFileName = B2SSettings.GameName @@ -141,18 +143,13 @@ Public Class formBackglass ' show snippits ShowStartupSnippits() -#If B2S = "DLL" Then ' create 'image on' timer and start it startupTimer = New Timer() startupTimer.Interval = 2000 AddHandler startupTimer.Tick, AddressOf StartupTimer_Tick startupTimer.Start() -#Else - ' create 'image on' timer and start it - timer = New Timer() - timer.Interval = 2000 - AddHandler timer.Tick, AddressOf Timer_Tick - timer.Start() + +#If B2S = "EXE" Then ' create 'table is still running' timer tableTimer = New Timer @@ -260,13 +257,13 @@ Public Class formBackglass On Error Resume Next If rotateTimer IsNot Nothing Then rotateTimer.Stop() + If startupTimer IsNot Nothing Then startupTimer.Stop() + #If B2S = "DLL" Then ' stop all timers as DLL - If startupTimer IsNot Nothing Then startupTimer.Stop() If snifferTimer IsNot Nothing Then snifferTimer.Stop() #Else ' stop all timers as EXE - If timer IsNot Nothing Then timer.Stop() If tableTimer IsNot Nothing Then tableTimer.Stop() If B2STimer IsNot Nothing Then B2STimer.Stop() #End If @@ -361,13 +358,12 @@ Public Class formBackglass On Error Resume Next If rotateTimer IsNot Nothing Then RemoveHandler rotateTimer.Tick, AddressOf RotateTimer_Tick + + If startupTimer IsNot Nothing Then RemoveHandler startupTimer.Tick, AddressOf StartupTimer_Tick #If B2S = "DLL" Then If snifferTimer IsNot Nothing Then RemoveHandler snifferTimer.Tick, AddressOf SnifferTimer_Tick - If startupTimer IsNot Nothing Then RemoveHandler startupTimer.Tick, AddressOf StartupTimer_Tick #Else - ' stop all timers as EXE - If timer IsNot Nothing Then RemoveHandler timer.Tick, AddressOf Timer_Tick - If tabletimer IsNot Nothing Then RemoveHandler tabletimer.Tick, AddressOf TableTimer_Tick + If tableTimer IsNot Nothing Then RemoveHandler tableTimer.Tick, AddressOf TableTimer_Tick If B2STimer IsNot Nothing Then RemoveHandler B2STimer.Tick, AddressOf B2STimer_Tick #End If @@ -503,23 +499,12 @@ Public Class formBackglass snifferGIStrings.Invalidate() End Sub - +#End If #End Region #Region "some timer events" - Private Sub StartupTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) - - startupTimer.Stop() - - ' maybe show some 'startup on' images - ShowStartupImages() - - ' start autostarted animations - B2SAnimation.AutoStart() - - End Sub - +#If B2S = "DLL" Then Private Sub SnifferTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) If B2SStatistics.LogStatistics Then @@ -527,28 +512,33 @@ Public Class formBackglass End If End Sub -#Else - - Private Sub Timer_Tick(ByVal sender As Object, ByVal e As EventArgs) +#End If + Private Sub StartupTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) - timer.Stop() + startupTimer.Stop() ' set focus to the VP player SetFocusToVPPlayer() + ' maybe show some 'startup on' images + ShowStartupImages() + ' start autostarted animations B2SAnimation.AutoStart() - ' start B2S data timer - B2STimer.Start() - ' set focus to the VP player SetFocusToVPPlayer() +#If B2S = "EXE" Then + ' start B2S data timer + B2STimer.Start() + ' start table check timer tableTimer.Start() - +#End If End Sub + +#If B2S = "EXE" Then Private Sub TableTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) If tableHandle <> 0 AndAlso Not IsWindow(tableHandle) Then @@ -564,9 +554,6 @@ Public Class formBackglass ' poll registry data PollingData() - ' show some 'startup on' images (one time) - ShowStartupImages() - End Sub #End If @@ -1704,8 +1691,8 @@ Public Class formBackglass Case B2SSettings.eImageFileType.GIF : imageformat = Imaging.ImageFormat.Gif : extension = ".gif" Case B2SSettings.eImageFileType.BMP : imageformat = Imaging.ImageFormat.Bmp : extension = ".bmp" End Select - Dim filename As String = IO.Path.Combine(B2SSettings.ScreenshotPath, IO.Path.GetFileNameWithoutExtension(B2SData.BackglassFileName) & extension) - B2SScreen.MakeScreenShot(filename, imageformat) + Dim screenshotFilename As String = IO.Path.Combine(B2SSettings.ScreenshotPath, IO.Path.GetFileNameWithoutExtension(B2SData.BackglassFileName) & extension) + B2SScreen.MakeScreenShot(screenshotFilename, imageformat) My.Computer.Audio.Play(My.Resources.camera1, AudioPlayMode.Background) End If #If B2S = "EXE" Then @@ -1869,12 +1856,12 @@ Public Class formBackglass Private Sub LoadB2SData() Dim filename As String = B2SData.TableFileName & ".directb2s" - Dim shortfilename As String = B2SData.ShortFileName(filename) - Dim hyperpinfilename As String = String.Empty - Dim shorthyperpinfilename As String = String.Empty + Dim shortFilename As String = B2SData.ShortFileName(filename) & ".directb2s" + Dim hyperpinFilename As String = String.Empty + Dim shorthyperpinFilename As String = String.Empty ' check whether the table name can be found - If Not String.IsNullOrEmpty(B2SSettings.GameName) And Not IO.File.Exists(filename) AndAlso Not IO.File.Exists(shortfilename) Then + If Not String.IsNullOrEmpty(B2SSettings.GameName) And Not IO.File.Exists(filename) AndAlso Not IO.File.Exists(shortFilename) Then 'Westworld, check for gamename If IO.File.Exists(B2SSettings.GameName & ".directb2s") Then filename = B2SSettings.GameName & ".directb2s" @@ -1882,44 +1869,49 @@ Public Class formBackglass End If If Not B2SSettings.DisableFuzzyMatching Then - If Not IO.File.Exists(filename) AndAlso Not IO.File.Exists(shortfilename) Then + B2SScreen.debugLog.WriteLogEntry("FuzzyMatching") + If Not IO.File.Exists(filename) AndAlso Not IO.File.Exists(shortFilename) Then If B2SSettings.LocateHyperpinXMLFile() Then - hyperpinfilename = B2SSettings.HyperpinName & ".directb2s" - shorthyperpinfilename = B2SData.ShortFileName(hyperpinfilename) + hyperpinFilename = B2SSettings.HyperpinName & ".directb2s" + shorthyperpinFilename = B2SData.ShortFileName(hyperpinFilename) & ".directb2s" End If ' check whether the hyperpin description can be found - If Not IO.File.Exists(hyperpinfilename) AndAlso Not IO.File.Exists(shorthyperpinfilename) Then + If Not IO.File.Exists(hyperpinFilename) AndAlso Not IO.File.Exists(shorthyperpinFilename) Then If filename.Length >= 8 Then ' look for short name - B2SSettings.MatchingFileNames = IO.Directory.GetFiles(IO.Directory.GetCurrentDirectory(), filename.Substring(0, 6) & "*.directb2s") - If B2SSettings.MatchingFileNames Is Nothing OrElse Not IsArray(B2SSettings.MatchingFileNames) OrElse B2SSettings.MatchingFileNames.Length <= 0 Then - B2SSettings.MatchingFileNames = IO.Directory.GetFiles(IO.Directory.GetCurrentDirectory(), filename.Substring(0, 6).Replace(" ", "") & "*.directb2s") - End If + B2SSettings.MatchingFileNames = IO.Directory.GetFiles(IO.Directory.GetCurrentDirectory(), shortFilename.Replace(".directb2s", "*.directb2s")) + If B2SSettings.MatchingFileNames IsNot Nothing Then For i As Integer = 0 To B2SSettings.MatchingFileNames.Length - 1 Dim fileinfo As IO.FileInfo = New IO.FileInfo(B2SSettings.MatchingFileNames(i)) B2SSettings.MatchingFileNames(i) = fileinfo.Name Next + B2SScreen.debugLog.WriteLogEntry("FuzzyMatching Matching FileNames:" & String.Join(", ", B2SSettings.MatchingFileNames)) End If - shortfilename = String.Empty - For Each file As String In B2SSettings.MatchingFileNames - If String.IsNullOrEmpty(shortfilename) Then - shortfilename = file + shortFilename = String.Empty + For Each matchedFileName As String In B2SSettings.MatchingFileNames + If String.IsNullOrEmpty(shortFilename) Then + shortFilename = matchedFileName End If - If Not String.IsNullOrEmpty(B2SSettings.MatchingFileName) AndAlso file.Equals(B2SSettings.MatchingFileName, StringComparison.CurrentCultureIgnoreCase) Then - shortfilename = file + If Not String.IsNullOrEmpty(B2SSettings.MatchingFileName) AndAlso File.Equals(B2SSettings.MatchingFileName, StringComparison.CurrentCultureIgnoreCase) Then + shortFilename = matchedFileName Exit For End If Next + B2SScreen.debugLog.WriteLogEntry("FuzzyMatching Selected FileName:" & shortFilename) + End If End If + B2SScreen.debugLog.WriteLogEntry("FuzzyMatching END") + Else + B2SScreen.debugLog.WriteLogEntry("FuzzyMatching END - Found matching filename") End If End If - If Not IO.File.Exists(filename) AndAlso Not IO.File.Exists(shortfilename) AndAlso Not IO.File.Exists(hyperpinfilename) AndAlso Not IO.File.Exists(shorthyperpinfilename) Then + If Not IO.File.Exists(filename) AndAlso Not IO.File.Exists(shortFilename) AndAlso Not IO.File.Exists(hyperpinFilename) AndAlso Not IO.File.Exists(shorthyperpinFilename) Then Dim text As String = "File '" & IO.Path.Combine(IO.Directory.GetCurrentDirectory(), filename) - If Not String.IsNullOrEmpty(hyperpinfilename) AndAlso Not filename.Equals(hyperpinfilename, StringComparison.CurrentCultureIgnoreCase) Then - text &= " and file '" & IO.Path.Combine(IO.Directory.GetCurrentDirectory(), hyperpinfilename) & "'" + If Not String.IsNullOrEmpty(hyperpinFilename) AndAlso Not filename.Equals(hyperpinFilename, StringComparison.CurrentCultureIgnoreCase) Then + text &= " and file '" & IO.Path.Combine(IO.Directory.GetCurrentDirectory(), hyperpinFilename) & "'" End If text &= " not found. Please rename or download the matching directb2s backglass file." Throw New Exception(text) @@ -1928,12 +1920,12 @@ Public Class formBackglass Dim XML As Xml.XmlDocument = New Xml.XmlDocument If IO.File.Exists(filename) Then B2SData.BackglassFileName = filename - ElseIf IO.File.Exists(shortfilename) Then - B2SData.BackglassFileName = shortfilename - ElseIf IO.File.Exists(hyperpinfilename) Then - B2SData.BackglassFileName = hyperpinfilename - ElseIf IO.File.Exists(shorthyperpinfilename) Then - B2SData.BackglassFileName = shorthyperpinfilename + ElseIf IO.File.Exists(shortFilename) Then + B2SData.BackglassFileName = shortFilename + ElseIf IO.File.Exists(hyperpinFilename) Then + B2SData.BackglassFileName = hyperpinFilename + ElseIf IO.File.Exists(shorthyperpinFilename) Then + B2SData.BackglassFileName = shorthyperpinFilename End If ' maybe load XML file If Not String.IsNullOrEmpty(B2SData.BackglassFileName) Then @@ -1947,7 +1939,7 @@ Public Class formBackglass ' try to get into the file and read some XML If XML Is Nothing OrElse XML.SelectSingleNode("DirectB2SData") Is Nothing Then - Throw New Exception("File '" & filename & "' is not a valid directb2s backglass file.") + Throw New Exception("File '" & B2SData.BackglassFileName & "' is not a valid directb2s backglass file.") Else diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb index 89ccde4..2161c17 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb @@ -167,7 +167,7 @@ Partial Class formSettings Me.btnEditScreenRes.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.btnEditScreenRes.Location = New System.Drawing.Point(91, 13) Me.btnEditScreenRes.Name = "btnEditScreenRes" - Me.btnEditScreenRes.Size = New System.Drawing.Size(99, 24) + Me.btnEditScreenRes.Size = New System.Drawing.Size(137, 24) Me.btnEditScreenRes.TabIndex = 39 Me.btnEditScreenRes.Text = "Edit ScreenRes..." Me.btnEditScreenRes.UseVisualStyleBackColor = True @@ -228,9 +228,9 @@ Partial Class formSettings Me.grpPlugins.Controls.Add(Me.chkShowStartupError) Me.grpPlugins.Controls.Add(Me.chkActivatePlugins) Me.grpPlugins.Controls.Add(Me.btnPluginSettings) - Me.grpPlugins.Location = New System.Drawing.Point(12, 535) + Me.grpPlugins.Location = New System.Drawing.Point(12, 550) Me.grpPlugins.Name = "grpPlugins" - Me.grpPlugins.Size = New System.Drawing.Size(515, 75) + Me.grpPlugins.Size = New System.Drawing.Size(515, 68) Me.grpPlugins.TabIndex = 37 Me.grpPlugins.TabStop = False Me.grpPlugins.Text = "Plugins" @@ -336,9 +336,9 @@ Partial Class formSettings ' 'btnHyperpin ' - Me.btnHyperpin.Location = New System.Drawing.Point(370, 18) + Me.btnHyperpin.Location = New System.Drawing.Point(407, 17) Me.btnHyperpin.Name = "btnHyperpin" - Me.btnHyperpin.Size = New System.Drawing.Size(98, 24) + Me.btnHyperpin.Size = New System.Drawing.Size(105, 24) Me.btnHyperpin.TabIndex = 2 Me.btnHyperpin.Text = "Locate VP.xml" Me.btnHyperpin.UseVisualStyleBackColor = True @@ -346,7 +346,7 @@ Partial Class formSettings 'lblFile ' Me.lblFile.AutoSize = True - Me.lblFile.Location = New System.Drawing.Point(162, 24) + Me.lblFile.Location = New System.Drawing.Point(131, 21) Me.lblFile.Name = "lblFile" Me.lblFile.Size = New System.Drawing.Size(26, 13) Me.lblFile.TabIndex = 15 @@ -360,7 +360,7 @@ Partial Class formSettings Me.cmbMode.Items.AddRange(New Object() {"Authentic", "Fantasy"}) Me.cmbMode.Location = New System.Drawing.Point(47, 20) Me.cmbMode.Name = "cmbMode" - Me.cmbMode.Size = New System.Drawing.Size(246, 21) + Me.cmbMode.Size = New System.Drawing.Size(73, 21) Me.cmbMode.TabIndex = 0 ' 'lblMode @@ -377,18 +377,17 @@ Partial Class formSettings ' Me.cmbMatchingFileNames.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cmbMatchingFileNames.FormattingEnabled = True - Me.cmbMatchingFileNames.Location = New System.Drawing.Point(207, 20) + Me.cmbMatchingFileNames.Location = New System.Drawing.Point(157, 18) Me.cmbMatchingFileNames.Name = "cmbMatchingFileNames" - Me.cmbMatchingFileNames.Size = New System.Drawing.Size(156, 21) + Me.cmbMatchingFileNames.Size = New System.Drawing.Size(244, 21) Me.cmbMatchingFileNames.Sorted = True Me.cmbMatchingFileNames.TabIndex = 1 - Me.cmbMatchingFileNames.Visible = False ' 'btnCheck ' - Me.btnCheck.Location = New System.Drawing.Point(370, 18) + Me.btnCheck.Location = New System.Drawing.Point(428, 18) Me.btnCheck.Name = "btnCheck" - Me.btnCheck.Size = New System.Drawing.Size(98, 24) + Me.btnCheck.Size = New System.Drawing.Size(83, 24) Me.btnCheck.TabIndex = 2 Me.btnCheck.Text = "Check monitors" Me.btnCheck.UseVisualStyleBackColor = True @@ -431,7 +430,7 @@ Partial Class formSettings Me.grpScreenshot.Controls.Add(Me.btnScreenshotPath) Me.grpScreenshot.Location = New System.Drawing.Point(12, 482) Me.grpScreenshot.Name = "grpScreenshot" - Me.grpScreenshot.Size = New System.Drawing.Size(515, 50) + Me.grpScreenshot.Size = New System.Drawing.Size(515, 62) Me.grpScreenshot.TabIndex = 6 Me.grpScreenshot.TabStop = False Me.grpScreenshot.Text = "Screenshot" @@ -439,7 +438,7 @@ Partial Class formSettings 'lblFileType ' Me.lblFileType.AutoSize = True - Me.lblFileType.Location = New System.Drawing.Point(268, 19) + Me.lblFileType.Location = New System.Drawing.Point(304, 28) Me.lblFileType.Name = "lblFileType" Me.lblFileType.Size = New System.Drawing.Size(78, 13) Me.lblFileType.TabIndex = 0 @@ -451,7 +450,7 @@ Partial Class formSettings Me.cmbScreenshotType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cmbScreenshotType.FormattingEnabled = True Me.cmbScreenshotType.Items.AddRange(New Object() {"PNG", "JPG", "GIF", "BMP"}) - Me.cmbScreenshotType.Location = New System.Drawing.Point(357, 16) + Me.cmbScreenshotType.Location = New System.Drawing.Point(393, 25) Me.cmbScreenshotType.Name = "cmbScreenshotType" Me.cmbScreenshotType.Size = New System.Drawing.Size(111, 21) Me.cmbScreenshotType.TabIndex = 19 @@ -460,7 +459,7 @@ Partial Class formSettings ' Me.btnScreenshotPath.Location = New System.Drawing.Point(8, 16) Me.btnScreenshotPath.Name = "btnScreenshotPath" - Me.btnScreenshotPath.Size = New System.Drawing.Size(226, 24) + Me.btnScreenshotPath.Size = New System.Drawing.Size(290, 40) Me.btnScreenshotPath.TabIndex = 18 Me.btnScreenshotPath.Text = "Screenshot path" Me.btnScreenshotPath.UseVisualStyleBackColor = True @@ -531,7 +530,7 @@ Partial Class formSettings 'lblFormFront ' Me.lblFormFront.AutoSize = True - Me.lblFormFront.Location = New System.Drawing.Point(281, 51) + Me.lblFormFront.Location = New System.Drawing.Point(278, 51) Me.lblFormFront.Name = "lblFormFront" Me.lblFormFront.Size = New System.Drawing.Size(62, 13) Me.lblFormFront.TabIndex = 41 @@ -631,7 +630,7 @@ Partial Class formSettings ' 'lblGlowing ' - Me.lblGlowing.Location = New System.Drawing.Point(303, 53) + Me.lblGlowing.Location = New System.Drawing.Point(325, 53) Me.lblGlowing.Name = "lblGlowing" Me.lblGlowing.Size = New System.Drawing.Size(48, 13) Me.lblGlowing.TabIndex = 25 @@ -655,7 +654,7 @@ Partial Class formSettings Me.cmbGlowing.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cmbGlowing.FormattingEnabled = True Me.cmbGlowing.Items.AddRange(New Object() {"Off", "Low", "Medium", "High", "Default"}) - Me.cmbGlowing.Location = New System.Drawing.Point(357, 50) + Me.cmbGlowing.Location = New System.Drawing.Point(379, 50) Me.cmbGlowing.Name = "cmbGlowing" Me.cmbGlowing.Size = New System.Drawing.Size(111, 21) Me.cmbGlowing.TabIndex = 15 @@ -665,7 +664,7 @@ Partial Class formSettings Me.radioDream7LED.Appearance = System.Windows.Forms.Appearance.Button Me.radioDream7LED.Location = New System.Drawing.Point(124, 20) Me.radioDream7LED.Name = "radioDream7LED" - Me.radioDream7LED.Size = New System.Drawing.Size(110, 24) + Me.radioDream7LED.Size = New System.Drawing.Size(132, 24) Me.radioDream7LED.TabIndex = 12 Me.radioDream7LED.TabStop = True Me.radioDream7LED.Text = "Use 'Dream7' LEDs" @@ -675,7 +674,7 @@ Partial Class formSettings 'chkWireframe ' Me.chkWireframe.Appearance = System.Windows.Forms.Appearance.Button - Me.chkWireframe.Location = New System.Drawing.Point(240, 20) + Me.chkWireframe.Location = New System.Drawing.Point(262, 20) Me.chkWireframe.Name = "chkWireframe" Me.chkWireframe.Size = New System.Drawing.Size(111, 24) Me.chkWireframe.TabIndex = 13 @@ -686,7 +685,7 @@ Partial Class formSettings 'chkBulbs ' Me.chkBulbs.Appearance = System.Windows.Forms.Appearance.Button - Me.chkBulbs.Location = New System.Drawing.Point(357, 20) + Me.chkBulbs.Location = New System.Drawing.Point(379, 20) Me.chkBulbs.Name = "chkBulbs" Me.chkBulbs.Size = New System.Drawing.Size(111, 24) Me.chkBulbs.TabIndex = 14 diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx index 3626916..5c3f545 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx @@ -124,7 +124,7 @@ iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL - DwAACw8BkvkDpQAAHIZJREFUeF7tWQdYlOeyPhuUsp26lO27wNJ7L9LLAtJ7EUVAY1eiETR2jb0TBRVR + DgAACw4BQL7hQQAAHIZJREFUeF7tWQdYlOeyPhuUsp26lO27wNJ7L9LLAtJ7EUVAY1eiETR2jb0TBRVR LBELCoKACLajGFs0ydHEaGLUJDaMJ4pImTvfuhBWjfHec03OPc+d53mfXfb//vln3plvZr6fv/3V0paR T0G8pwRF+fO/l7Sl5lEQam1peRoI5sPUXM5PyTmiH1NyzBCSe2m5hm3pefS2jLwBylveKG2Z6GxmPvXn tOHcc9FpDiciEn1ORiR5XUnIsnqQkaeL195KDxF8LgVt6oPy5/+ZtCXnvodQa0vJVUdootP0e8nDDc9H diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb index 54cc147..ada03af 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb @@ -118,8 +118,8 @@ Public Class formSettings ' maybe show matching file names combo box If B2SSettings.MatchingFileNames IsNot Nothing AndAlso B2SSettings.MatchingFileNames.Length >= 2 Then cmbMatchingFileNames.Items.Clear() - For Each filename As String In B2SSettings.MatchingFileNames - cmbMatchingFileNames.Items.Add(filename) + For Each matchedFilename As String In B2SSettings.MatchingFileNames + cmbMatchingFileNames.Items.Add(matchedFilename) Next If Not String.IsNullOrEmpty(B2SSettings.MatchingFileName) Then cmbMatchingFileNames.Text = B2SSettings.MatchingFileName @@ -530,6 +530,14 @@ Public Class formSettings End Sub Private Sub B2SLogo_Click(sender As Object, e As EventArgs) Handles B2SLogo.Click - B2SLogoToolTip.SetToolTip(B2SLogo, "Settings: " & B2SSettings.SettingFilePath & vbCrLf & "ScreenRes: " & B2SSettings.LoadedResFilePath & vbCrLf & "PluginPath: " & B2SSettings.PluginsFilePath) + Dim openForms As String = "" + For Each frm As Form In Application.OpenForms + openForms = openForms & " " & frm.Text & vbCrLf + Next + + Dim ToolTip As String = "Settings: " & B2SSettings.SettingFilePath & vbCrLf & vbCrLf & "ScreenRes: " & B2SSettings.LoadedResFilePath & vbCrLf & + vbCrLf & "PluginPath: " & B2SSettings.PluginsFilePath & vbCrLf & vbCrLf & "OpenForms: " & openForms + B2SLogoToolTip.SetToolTip(B2SLogo, ToolTip) End Sub + End Class \ No newline at end of file diff --git a/b2sbackglassserver/b2sbackglassserver/Server.vb b/b2sbackglassserver/b2sbackglassserver/Server.vb index be3336c..7a15852 100644 --- a/b2sbackglassserver/b2sbackglassserver/Server.vb +++ b/b2sbackglassserver/b2sbackglassserver/Server.vb @@ -1,12 +1,7 @@ -Imports System -Imports System.Text +Imports System.Text Imports System.Runtime.InteropServices Imports Microsoft.Win32 -Imports System.Linq.Expressions Imports System.Drawing -Imports System.Reflection -Imports System.Runtime.InteropServices.WindowsRuntime -Imports System.ComponentModel Imports System.Threading Imports System.Windows.Forms @@ -142,7 +137,6 @@ Public Class Server .IsLogOn = B2SSettings.B2SDebugLog } - errorlog.IsLogOn = B2SSettings.B2SDebugLog If B2SSettings.ArePluginsOn Then B2SSettings.PluginHost = New PluginHost(True) End If @@ -278,8 +272,7 @@ Public Class Server End If Catch ex As Exception - Dim st As New StackTrace(ex, True) - errorlog.WriteLogEntry(DateTime.Now & "Line: " & st.GetFrame(0).GetMethod().Name & " : " & st.GetFrame(0).GetFileLineNumber().ToString & " : " & ex.Message) + errorlog.WriteLogEntry(DateTime.Now & ex.Message & vbNewLine & ex.StackTrace) Throw ex End Try @@ -307,7 +300,7 @@ Public Class Server End Get End Property - Public ReadOnly Property B2SServerBuild() As Double + Public ReadOnly Property B2SBuildVersion() As Double Get Return CInt(B2SVersionInfo.B2S_VERSION_MAJOR) * 10000 + CInt(B2SVersionInfo.B2S_VERSION_MINOR) * 100 + @@ -426,6 +419,17 @@ Public Class Server End Get End Property + Public ReadOnly Property VPMBuildVersion() As String + Get + Try + Return VPinMAME.FullVersion + Catch ex As Exception + Return VPinMAME.Version + End Try + End Get + End Property + + Public Sub Run(Optional ByVal handle As Object = 0) 'Make sure this is run on threadContext thread If SynchronizationContext.Current IsNot threadContext Then @@ -666,77 +670,73 @@ Public Class Server Public ReadOnly Property ChangedLamps() As Object Get + isChangedLampsCalled = True + Dim chg As Object = VPinMAME.ChangedLamps() Try - isChangedLampsCalled = True - Dim chg As Object = VPinMAME.ChangedLamps() If B2SData.GetLampsData() Then CheckLamps(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then B2SSettings.PluginHost.DataReceive(Convert.ToChar("L"), chg) End If - Return chg Catch ex As Exception errorlog.WriteLogEntry(DateTime.Now & ": ChangedLamps ('" & ex.Message & "')") - Return Nothing End Try + Return chg End Get End Property Public ReadOnly Property ChangedSolenoids() As Object Get + isChangedSolenoidsCalled = True + Dim chg As Object = VPinMAME.ChangedSolenoids() Try - isChangedSolenoidsCalled = True - Dim chg As Object = VPinMAME.ChangedSolenoids() If B2SData.GetSolenoidsData() Then CheckSolenoids(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then B2SSettings.PluginHost.DataReceive(Convert.ToChar("S"), chg) End If - Return chg Catch ex As Exception errorlog.WriteLogEntry(DateTime.Now & ": ChangedSolenoids ('" & ex.Message & "')") - Return Nothing End Try + Return chg End Get End Property Public ReadOnly Property ChangedGIStrings() As Object Get + isChangedGIStringsCalled = True + Dim chg As Object = VPinMAME.ChangedGIStrings() Try - isChangedGIStringsCalled = True - Dim chg As Object = VPinMAME.ChangedGIStrings() If B2SData.GetGIStringsData() Then CheckGIStrings(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then B2SSettings.PluginHost.DataReceive(Convert.ToChar("G"), chg) End If - Return chg Catch ex As Exception errorlog.WriteLogEntry(DateTime.Now & ": ChangedGIStrings ('" & ex.Message & "')") - Return Nothing End Try + Return chg End Get End Property Public ReadOnly Property ChangedLEDs(ByVal mask2 As Object, ByVal mask1 As Object, Optional ByVal mask3 As Object = 0, Optional ByVal mask4 As Object = 0) As Object Get + isChangedLEDsCalled = True + Dim chg As Object = VPinMAME.ChangedLEDs(mask2, mask1, mask3, mask4) ' (&HFFFFFFFF, &HFFFFFFFF) Try - isChangedLEDsCalled = True - Dim chg As Object = VPinMAME.ChangedLEDs(mask2, mask1, mask3, mask4) ' (&HFFFFFFFF, &HFFFFFFFF) If B2SData.GetLEDsData() Then CheckLEDs(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then B2SSettings.PluginHost.DataReceive(Convert.ToChar("D"), chg) End If - Return chg Catch ex As Exception errorlog.WriteLogEntry(DateTime.Now & ": ChangedLEDs ('" & ex.Message & "')") - Return Nothing End Try + Return chg End Get End Property