From dfaf34dcf1cdf7a29b22c9f2401552ce3b836a9a Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Mon, 24 Jun 2024 19:38:23 -0700 Subject: [PATCH 1/9] Add Absolute version of Set Pos --- .../b2sbackglassserver/Server.vb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/b2sbackglassserver/b2sbackglassserver/Server.vb b/b2sbackglassserver/b2sbackglassserver/Server.vb index 3893c72..dae2b03 100644 --- a/b2sbackglassserver/b2sbackglassserver/Server.vb +++ b/b2sbackglassserver/b2sbackglassserver/Server.vb @@ -1709,6 +1709,14 @@ Public Class Server End If End Sub + + Public Sub B2SSetPosAbsolute(ByVal idORname As Object, ByVal xpos As Object, ByVal ypos As Object) + + If IsNumeric(idORname) And IsNumeric(xpos) And IsNumeric(ypos) Then + MyB2SSetPosAbsolute(CInt(idORname), CInt(xpos), CInt(ypos)) + End If + End Sub + ' method to set illumination Public Sub B2SSetIllumination(ByVal name As Object, ByVal value As Object) @@ -2158,6 +2166,35 @@ Public Class Server End Sub + Private Sub MyB2SSetPosAbsolute(ByVal id As Integer, ByVal xpos As Integer, ByVal ypos As Integer) + + If B2SData.IsBackglassRunning Then + + If B2SData.IsBackglassStartedAsEXE Then + + Else + If B2SData.UsedRomLampIDs.ContainsKey(id) Then + Dim rescaleBackglass As SizeF + Me.formBackglass.GetScaleFactor(rescaleBackglass) + + For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(id) + If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then + picbox.Left = xpos + picbox.Top = ypos + ' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes. + picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height) + 'Invalidating this object does not work, need to Invalidate the parent. + If picbox.Parent IsNot Nothing Then + picbox.Parent.Invalidate() + End If + End If + Next + End If + End If + End If + + End Sub + Private Sub MyB2SSetLED(ByVal digit As Integer, ByVal value As Object) If Not B2SData.IsBackglassRunning Then Return From 98332cec34648e002d478cdf60ca159872d77596 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Tue, 9 Jul 2024 15:14:19 -0700 Subject: [PATCH 2/9] Initial work for Seperate B2S UI Thread --- .../Classes/B2SAnimation.vb | 4 +- .../b2sbackglassserver/Controls/B2SLEDBox.vb | 6 +- .../Controls/B2SPictureBox.vb | 20 ++----- .../b2sbackglassserver/Controls/B2SReelBox.vb | 31 ++++++++-- .../b2sbackglassserver/Forms/formBackglass.vb | 8 ++- .../b2sbackglassserver/Forms/formSettings.vb | 12 +++- .../b2sbackglassserver/Plugin/PluginWindow.vb | 2 +- .../b2sbackglassserver/Server.vb | 60 ++++++++++++++++--- 8 files changed, 107 insertions(+), 36 deletions(-) diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SAnimation.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SAnimation.vb index 44205ae..cc1a5cb 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SAnimation.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SAnimation.vb @@ -404,10 +404,10 @@ Public Class B2SAnimation With DirectCast(currentForm, formBackglass) MainFormBackgroundImage = .BackgroundImage .BackgroundImage = .DarkImage - .Refresh() + .Invalidate() End With Else - currentForm.Refresh() + currentForm.Invalidate() End If End If End If diff --git a/b2sbackglassserver/b2sbackglassserver/Controls/B2SLEDBox.vb b/b2sbackglassserver/b2sbackglassserver/Controls/B2SLEDBox.vb index 2170d91..7d200db 100644 --- a/b2sbackglassserver/b2sbackglassserver/Controls/B2SLEDBox.vb +++ b/b2sbackglassserver/b2sbackglassserver/Controls/B2SLEDBox.vb @@ -106,7 +106,11 @@ Public Class B2SLEDBox Set(ByVal newvalue As Integer) If _Value <> newvalue OrElse refresh Then _Value = newvalue - Me.Refresh() + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If End If End Set End Property diff --git a/b2sbackglassserver/b2sbackglassserver/Controls/B2SPictureBox.vb b/b2sbackglassserver/b2sbackglassserver/Controls/B2SPictureBox.vb index 09efd9b..1b565b4 100644 --- a/b2sbackglassserver/b2sbackglassserver/Controls/B2SPictureBox.vb +++ b/b2sbackglassserver/b2sbackglassserver/Controls/B2SPictureBox.vb @@ -24,27 +24,17 @@ Public Class B2SPictureBox Protected Overrides Sub OnPaint(e As System.Windows.Forms.PaintEventArgs) - ' rectangle area for painting - Dim rect As Rectangle = New Rectangle(0, 0, Me.Width - 1, Me.Height - 1) - - ' draw dashed frame - Dim pen As Pen = New Pen(Brushes.LightGray) - pen.DashPattern = New Single() {3.0F, 3.0F} - e.Graphics.DrawRectangle(pen, rect) - pen.Dispose() - - ' draw text - 'If Not String.IsNullOrEmpty(Me.Text) Then - ' TextRenderer.DrawText(e.Graphics, Me.Text, Me.Font, rect, Color.White, TextFormatFlags.WordBreak Or TextFormatFlags.HorizontalCenter Or TextFormatFlags.VerticalCenter) - 'End If + + 'e.Graphics.DrawImage(BackgroundImage, e.ClipRectangle) End Sub Public Sub New() + ' set some drawing styles Me.SetStyle(ControlStyles.SupportsTransparentBackColor, True) 'Me.SetStyle(ControlStyles.ResizeRedraw Or ControlStyles.SupportsTransparentBackColor, True) - 'Me.DoubleBuffered = True - Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.DoubleBuffer, True) + Me.DoubleBuffered = True + Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer, True) ' backcolor needs to be transparent Me.BackColor = Color.Transparent diff --git a/b2sbackglassserver/b2sbackglassserver/Controls/B2SReelBox.vb b/b2sbackglassserver/b2sbackglassserver/Controls/B2SReelBox.vb index ad0bc2d..b580cc9 100644 --- a/b2sbackglassserver/b2sbackglassserver/Controls/B2SReelBox.vb +++ b/b2sbackglassserver/b2sbackglassserver/Controls/B2SReelBox.vb @@ -117,7 +117,11 @@ Public Class B2SReelBox If intermediates2go > 0 OrElse intermediates = -1 Then - Me.Refresh() + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If intermediates2go -= 1 Else @@ -143,8 +147,11 @@ Public Class B2SReelBox End If Catch End Try - Me.Refresh() - + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If intermediates2go -= 1 ElseIf intermediates2go = -1 Then intermediates2go -= 1 @@ -201,7 +208,11 @@ Public Class B2SReelBox If _Illuminated <> value Then _Illuminated = value intermediates2go = 0 - Me.Refresh() + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If End If End Set End Property @@ -215,7 +226,11 @@ Public Class B2SReelBox If _Value <> value OrElse refresh Then _Value = value reelindex = ConvertValue(_Value) - Me.Refresh() + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If End If End Set End Property @@ -236,7 +251,11 @@ Public Class B2SReelBox timer.Start() Else reelindex = ConvertText(_Text) - Me.Refresh() + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If End If End If End If diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index f96265e..eeb5376 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -1718,7 +1718,13 @@ Public Class formBackglass B2SSettings.Save(, True) #End If Me.BackgroundImage = DarkImage - Me.Refresh() + + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() Me.Invalidate()) + Else + Me.Invalidate() + End If + ShowStartupImages() B2SAnimation.RestartAnimations() If formMode IsNot Nothing Then diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb index 47d4d69..fe0b454 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb @@ -227,8 +227,16 @@ Public Class formSettings isSettingsScreenDirty = True B2SSettings.CurrentDualMode = cmbMode.SelectedIndex + 1 If formBackglass IsNot Nothing Then - formBackglass.BackgroundImage = formBackglass.DarkImage - formBackglass.Refresh() + If Me.InvokeRequired Then + Me.BeginInvoke(Sub() + formBackglass.BackgroundImage = formBackglass.DarkImage + formBackglass.Invalidate() + End Sub + ) + Else + formBackglass.BackgroundImage = formBackglass.DarkImage + formBackglass.Invalidate() + End If End If B2SAnimation.RestartAnimations() End Sub diff --git a/b2sbackglassserver/b2sbackglassserver/Plugin/PluginWindow.vb b/b2sbackglassserver/b2sbackglassserver/Plugin/PluginWindow.vb index 82d7c96..393a363 100644 --- a/b2sbackglassserver/b2sbackglassserver/Plugin/PluginWindow.vb +++ b/b2sbackglassserver/b2sbackglassserver/Plugin/PluginWindow.vb @@ -17,7 +17,7 @@ Public Class PluginWindow Private Set(ByVal value As PluginList) _Plugins = value Me.PluginDataGrid.DataSource = value - Me.PluginDataGrid.Refresh() + Me.PluginDataGrid.Invalidate() End Set End Property diff --git a/b2sbackglassserver/b2sbackglassserver/Server.vb b/b2sbackglassserver/b2sbackglassserver/Server.vb index 242b461..9946fa3 100644 --- a/b2sbackglassserver/b2sbackglassserver/Server.vb +++ b/b2sbackglassserver/b2sbackglassserver/Server.vb @@ -6,12 +6,19 @@ 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 Public Class Server Implements IDisposable + Private Shared thread As Thread + Private Shared threadContext As SynchronizationContext = Nothing + Public threadReady As Boolean = False + Private Declare Function IsWindow Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, Msg As UInteger, wParam As Integer, lParam As Integer) As Integer Public Const WM_SYSCOMMAND As Integer = &H112 @@ -94,7 +101,31 @@ Public Class Server #Region "constructor and end timer" Public Sub New() + ' Create new STA thread for this dll to run in, if the thread is already running then don't start another + ' However if the thread is running, we need to stop the application from running, and then restart it by running StartThread again + If thread IsNot Nothing Then + Try + thread.Abort() + Catch + End Try + End If + thread = New Thread(AddressOf StartThread) + thread.SetApartmentState(ApartmentState.STA) + thread.Name = "B2SThread" + thread.Start() + ' Dont return until the thread is ready, by checking the threadReady variable + Do While Not threadReady + Thread.Sleep(100) + Loop + End Sub + + + Private Sub StartThread() + ' Create a syncronization context for the thread + SynchronizationContext.SetSynchronizationContext(New WindowsFormsSynchronizationContext()) + ' Store the context for later use + threadContext = SynchronizationContext.Current ' maybe create the base registry key If Registry.CurrentUser.OpenSubKey("Software\B2S") Is Nothing Then Registry.CurrentUser.CreateSubKey("Software\B2S") If Registry.CurrentUser.OpenSubKey("Software\B2S\VPinMAME") Is Nothing Then Registry.CurrentUser.CreateSubKey("Software\B2S\VPinMAME") @@ -105,7 +136,6 @@ Public Class Server regkey.DeleteValue("B2SB2SName", False) End Using - ' maybe prepare plugins B2SSettings.Load(, True) ' prepare error log @@ -127,6 +157,10 @@ Public Class Server AddHandler timer.Tick, AddressOf Timer_Tick timer.Interval = 37 + ' set the thread ready flag + threadReady = True + + Application.Run() End Sub Private Sub Timer_Tick() @@ -394,6 +428,11 @@ Public Class Server 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 + threadContext.Send(New SendOrPostCallback(AddressOf Run), handle) + Return + End If ' startup tableHandle = CInt(handle) @@ -2167,13 +2206,18 @@ Public Class Server For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(id) If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then If picbox.Left <> xpos OrElse picbox.Top <> ypos Then - picbox.Left = xpos - picbox.Top = ypos - ' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes. - picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height) - 'Invalidating this object does not work, need to Invalidate the parent. - If picbox.Parent IsNot Nothing Then - picbox.Parent.Invalidate() + If (picbox.InvokeRequired) Then + picbox.BeginInvoke(Sub() + picbox.Left = xpos + picbox.Top = ypos + picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height) + If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate() + End Sub) + Else + picbox.Left = xpos + picbox.Top = ypos + picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height) + If picbox.Parent IsNot Nothing Then picbox.Parent.Invalidate() End If End If End If From 2e9f6266b86e09b84f1766768bbfffa26465f87b Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Sat, 13 Jul 2024 12:16:22 +0200 Subject: [PATCH 3/9] #111 Remodel GUI work and split between threads: Make DLL behave more like EXE --- .../b2sbackglassserver/Classes/B2SScreen.vb | 10 +- .../b2sbackglassserver/Classes/B2SSettings.vb | 2 +- .../b2sbackglassserver/Forms/formBackglass.vb | 236 +++++++----------- .../b2sbackglassserver/Forms/formDMD.vb | 1 - .../Forms/formSettings.Designer.vb | 36 +-- .../Forms/formSettings.resx | 2 +- .../b2sbackglassserver/Forms/formSettings.vb | 11 +- .../My Project/AssemblyInfo.vb | 3 +- 8 files changed, 114 insertions(+), 187 deletions(-) diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb index 54880b5..5986d6e 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb @@ -368,9 +368,9 @@ Public Class B2SScreen ((Me.DMDViewMode = eDMDViewMode.ShowDMD) OrElse (Me.DMDViewMode = eDMDViewMode.ShowDMDOnlyAtDefaultLocation AndAlso Me.DMDAtDefaultLocation) OrElse (Me.DMDViewMode = eDMDViewMode.DoNotShowDMDAtDefaultLocation AndAlso Not Me.DMDAtDefaultLocation))) -#If B2S = "DLL" Then + On Error Resume Next -#End If + ' get the correct screen Me.BackglassScreen = ScreensOrdered(0) Dim s As Screen @@ -423,7 +423,7 @@ Public Class B2SScreen Me.formbackground.Size = Me.BackgroundSize Me.formbackground.Text = "B2S Backglass Server" Me.formbackground.BackColor = Color.Black - If (IO.File.Exists(Me.BackgroundPath)) Then + If (File.Exists(Me.BackgroundPath)) Then Me.formbackground.BackgroundImage = Image.FromFile(Me.BackgroundPath) ' ("C:\backglass.png") End If Me.formbackground.Show() @@ -515,7 +515,7 @@ Public Class B2SScreen formBackglass.Text = "B2S Backglass Server" formBackglass.Show() End If -#If B2S = "DLL" Then +#If B2S = "DLLBefore" Then ' bring backglass screen to the front If B2SSettings.FormToFront Then formBackglass.TopMost = True formBackglass.BringToFront() @@ -529,7 +529,7 @@ Public Class B2SScreen Me.formDMD.ControlBox = False Me.formDMD.MaximizeBox = False Me.formDMD.MinimizeBox = False -#If B2S = "DLL" Then +#If B2S = "DLLBefore" Then Me.formDMD.Location = formBackglass.Location + Me.DMDLocation #Else Me.formDMD.Location = Me.BackglassScreen.Bounds.Location + DMDKeepBackglassLocation + Me.DMDLocation diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb index 0e1b995..dfdd4d8 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb @@ -256,7 +256,7 @@ Public Class B2SSettings Public Shared Function GetSettingFilename() As String If IO.File.Exists(filename) Then Return filename -#If B2S = "DLL" Then +#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 diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index eeb5376..7de9353 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -58,7 +58,7 @@ Public Class formBackglass #Region "constructor and closing" -#If B2S = "DLL" Then + Public Sub New() InitializeComponent() @@ -70,16 +70,56 @@ Public Class formBackglass ' set key preview to allow some key action Me.KeyPreview = True - B2SScreen = New B2SScreen() +#If B2S = "EXE" Then + If My.Application.CommandLineArgs.Count > 0 Then + B2SData.TableFileName = My.Application.CommandLineArgs(0).ToString - ' load settings - B2SSettings.Load() + If B2SData.TableFileName.EndsWith(".directb2s") Then + B2SData.TableFileName = Path.GetFileNameWithoutExtension(B2SData.TableFileName) + B2SSettings.PureEXE = True + End If + + If My.Application.CommandLineArgs.Count > 1 Then + If My.Application.CommandLineArgs(1).ToString = "1" Then + Me.TopMost = True + End If + End If + Else + MessageBox.Show("Please do not start the EXE this way.", My.Resources.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error) + End + End If + + + ' get the game name + 'B2SSettings.GameName = "bguns_l8" + 'B2SSettings.GameName = "closeenc" + 'B2SSettings.B2SName = "Baseball" + 'B2SSettings.B2SName = "Spider-Man(Stern 2007) alt full dmdON127" + '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 + End If If B2SSettings.CPUAffinityMask > 0 Then Dim Proc = Process.GetCurrentProcess Proc.ProcessorAffinity = B2SSettings.CPUAffinityMask End If +#Else + Me.TopMost = True +#End If + B2SScreen = New B2SScreen() + ' load settings + B2SSettings.Load() ' get B2S xml and start Try LoadB2SData() @@ -87,7 +127,11 @@ Public Class formBackglass If B2SSettings.ShowStartupError Then MessageBox.Show(ex.Message, My.Resources.AppTitle, Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Error) End If +#If B2S = "DLL" Then Stop +#Else + End +#End If End Try ' initialize screen settings InitB2SScreen() @@ -98,11 +142,29 @@ 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() + + ' create 'table is still running' timer + tableTimer = New Timer + tableTimer.Interval = 207 + AddHandler tableTimer.Tick, AddressOf TableTimer_Tick + + ' create B2S data timer + B2STimer = New Timer + B2STimer.Interval = 13 + AddHandler B2STimer.Tick, AddressOf B2STimer_Tick +#End If ' create rotation timer rotateTimer = New Timer @@ -112,13 +174,12 @@ Public Class formBackglass AddHandler rotateTimer.Tick, AddressOf RotateTimer_Tick End Sub - +#If B2S = "DLL" Then Public Sub New(ByVal doNotLoadBackglassData As Boolean) InitializeComponent() ' set some styles - 'Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint, True) Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer, True) Me.DoubleBuffered = True @@ -172,136 +233,30 @@ Public Class formBackglass snifferTimer.Start() End Sub -#Else - Public Sub New() - - InitializeComponent() - - ' set some styles - Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer, True) - Me.DoubleBuffered = True - - ' set key peview to allow some key action - Me.KeyPreview = True - - ' mabye create the base registry key - If Registry.CurrentUser.OpenSubKey("Software\B2S") Is Nothing Then Registry.CurrentUser.CreateSubKey("Software\B2S") - If Registry.CurrentUser.OpenSubKey("Software\B2S\VPinMAME") Is Nothing Then Registry.CurrentUser.CreateSubKey("Software\B2S\VPinMAME") - - ' get the table - 'IO.Directory.SetCurrentDirectory("C:\Visual Pinball\Tables") - 'B2SData.TableFileName = "Big Guns (Williams 1987)_1.0" - 'B2SData.TableFileName = "ScaredStiff_FS_B2S_GI8" - 'B2SData.TableFileName = "ACDC_B2S" '"Baseball 1.0 FS" '"Elvira_and_the_Party_Monsters_VP91x_v1.2FS" '"Close_Encounters_FS" - 'B2SData.TableFileName = "Close_Encounters_FS" - 'B2SData.TableFileName = "Pinbot.uw.V1.02.1_JF_91x_BMPR_MOD_FS" - 'B2SData.TableFileName = "ScaredStiff_FS_B2S" - If My.Application.CommandLineArgs.Count > 0 Then - B2SData.TableFileName = My.Application.CommandLineArgs(0).ToString - - If B2SData.TableFileName.EndsWith(".directb2s") Then - B2SData.TableFileName = Path.GetFileNameWithoutExtension(B2SData.TableFileName) - B2SSettings.PureEXE = True - End If - - If My.Application.CommandLineArgs.Count > 1 Then - If My.Application.CommandLineArgs(1).ToString = "1" Then - Me.TopMost = True - End If - End If - Else - MessageBox.Show("Please do not start the EXE this way.", My.Resources.AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error) - End - End If - - - ' get the game name - 'B2SSettings.GameName = "bguns_l8" - 'B2SSettings.GameName = "closeenc" - 'B2SSettings.B2SName = "Baseball" - 'B2SSettings.B2SName = "Spider-Man(Stern 2007) alt full dmdON127" - '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 - End If - B2SScreen = New B2SScreen() ' was started before Tablename was identified, so alternativ ScreenRes was failing - - - ' load settings - B2SSettings.Load() - - If B2SSettings.CPUAffinityMask > 0 Then - Dim Proc = Process.GetCurrentProcess - Proc.ProcessorAffinity = B2SSettings.CPUAffinityMask - End If - - ' get B2S xml and start - Try - LoadB2SData() - Catch ex As Exception - If B2SSettings.ShowStartupError Then - MessageBox.Show(ex.Message, My.Resources.AppTitle, Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Error) - End If - End - End Try - - ' initialize screen settings - InitB2SScreen() - - ' resize images - ResizeSomeImages() - - ' show snippits - ShowStartupSnippits() - - ' create 'image on' timer and start it - timer = New Timer() - timer.Interval = 2000 - AddHandler timer.Tick, AddressOf Timer_Tick - timer.Start() - - ' create 'table is still running' timer - tableTimer = New Timer - tableTimer.Interval = 207 - AddHandler tableTimer.Tick, AddressOf TableTimer_Tick - - ' create B2S data timer - B2STimer = New Timer - B2STimer.Interval = 13 - AddHandler B2STimer.Tick, AddressOf B2STimer_Tick - - ' create rotation timer - rotateTimer = New Timer - If rotateTimerInterval > 0 Then - rotateTimer.Interval = rotateTimerInterval - End If - AddHandler rotateTimer.Tick, AddressOf RotateTimer_Tick - - End Sub +#End If Private Sub formBackglass_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown +#If B2S = "EXE" Then If Not B2SSettings.FormToFront Then Me.SendToBack() End If - - - 'Me.TopMost = False - SetFocusToVPPlayer() +#Else + If Not B2SSettings.FormToFront Then + Me.SendToBack() + Else + Dim StoreTopMost As Boolean = Me.TopMost - End Sub + Me.TopMost = True + Me.BringToFront() + SetFocusToVPPlayer() + Me.TopMost = StoreTopMost + End If #End If + End Sub + Private Sub formBackglass_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing On Error Resume Next @@ -402,23 +357,22 @@ Public Class formBackglass B2SStatistics.ClearAll() End Sub -#If B2S = "DLL" Then Private Sub formBackglass_Disposed(sender As Object, e As System.EventArgs) Handles Me.Disposed On Error Resume Next - If startupTimer IsNot Nothing Then RemoveHandler startupTimer.Tick, AddressOf StartupTimer_Tick If rotateTimer IsNot Nothing Then RemoveHandler rotateTimer.Tick, AddressOf RotateTimer_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 timer IsNot Nothing Then RemoveHandler timer.Tick, AddressOf Timer_Tick + If tabletimer IsNot Nothing Then RemoveHandler tabletimer.Tick, AddressOf TableTimer_Tick 'If B2STimer IsNot Nothing Then RemoveHandler B2STimer.Tick, AddressOf B2STimer_Tick - 'If rotateTimer IsNot Nothing Then RemoveHandler rotateTimer.Tick, AddressOf RotateTimer_Tick +#End If End Sub -#End If #End Region #Region "painting" @@ -1756,8 +1710,7 @@ Public Class formBackglass B2SScreen.MakeScreenShot(filename, imageformat) My.Computer.Audio.Play(My.Resources.camera1, AudioPlayMode.Background) End If -#If B2S = "DLL" Then -#Else +#If B2S = "EXE" Then ElseIf e.KeyCode = Keys.Escape Then ' stop the app @@ -2968,18 +2921,14 @@ Public Class formBackglass End If Next End If -#If B2S = "DLL" Then - Me.TopMost = True - Me.BringToFront() - Me.TopMost = False -#Else + +#If B2S = "EXE" Then Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S", True) regkey.SetValue("B2SSetSwitch", If(animationpulseswitch, 1, 0), RegistryValueKind.DWord) End Using #End If End If - ' set info flags to dirty to load them #If B2S = "DLL" Then B2SData.IsInfoDirty = True @@ -3534,16 +3483,15 @@ Public Class formBackglass Return Drawing.Color.FromArgb(CInt(colorvalues(0)), CInt(colorvalues(1)), CInt(colorvalues(2))) End Function -#If B2S = "EXE" Then Private Sub SetFocusToVPPlayer() ' set focus to the VP player Dim proc As Processes = New Processes() SetForegroundWindow(proc.TableHandle) +#If B2S = "EXE" Then tableHandle = proc.TableHandle - - End Sub #End If + End Sub Private Function RandomStarter(ByVal top As Integer) As Integer diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formDMD.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formDMD.vb index 11e8a41..179c24e 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formDMD.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formDMD.vb @@ -72,7 +72,6 @@ Public Class formDMD Private Sub formDMD_MouseClick(sender As Object, e As MouseEventArgs) Handles MyBase.MouseClick If e.Button = Windows.Forms.MouseButtons.Right Then B2SScreen.formBackglass.formBackglass_MouseClick(sender, e) - 'formBackglass.formBackglass_MouseClick(sender, e) End If End Sub diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb index 1225976..89ccde4 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.Designer.vb @@ -29,7 +29,6 @@ Partial Class formSettings Me.lowerPanel = New System.Windows.Forms.Panel() Me.btnCloseSettings = New System.Windows.Forms.Button() Me.btnSaveSettings = New System.Windows.Forms.Button() - Me.lblNonAvailableSettings = New System.Windows.Forms.Label() Me.btnEditScreenRes = New System.Windows.Forms.Button() Me.btnMore = New System.Windows.Forms.Button() Me.headerPanel = New System.Windows.Forms.Panel() @@ -127,27 +126,26 @@ Partial Class formSettings Me.PanelSettings.Location = New System.Drawing.Point(0, 0) Me.PanelSettings.Margin = New System.Windows.Forms.Padding(6) Me.PanelSettings.Name = "PanelSettings" - Me.PanelSettings.Size = New System.Drawing.Size(536, 693) + Me.PanelSettings.Size = New System.Drawing.Size(536, 673) Me.PanelSettings.TabIndex = 2 ' 'lowerPanel ' Me.lowerPanel.Controls.Add(Me.btnCloseSettings) Me.lowerPanel.Controls.Add(Me.btnSaveSettings) - Me.lowerPanel.Controls.Add(Me.lblNonAvailableSettings) Me.lowerPanel.Controls.Add(Me.btnEditScreenRes) Me.lowerPanel.Controls.Add(Me.btnMore) Me.lowerPanel.Dock = System.Windows.Forms.DockStyle.Bottom - Me.lowerPanel.Location = New System.Drawing.Point(0, 620) + Me.lowerPanel.Location = New System.Drawing.Point(0, 624) Me.lowerPanel.Name = "lowerPanel" - Me.lowerPanel.Size = New System.Drawing.Size(536, 73) + Me.lowerPanel.Size = New System.Drawing.Size(536, 49) Me.lowerPanel.TabIndex = 42 ' 'btnCloseSettings ' Me.btnCloseSettings.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.btnCloseSettings.DialogResult = System.Windows.Forms.DialogResult.Cancel - Me.btnCloseSettings.Location = New System.Drawing.Point(446, 37) + Me.btnCloseSettings.Location = New System.Drawing.Point(446, 13) Me.btnCloseSettings.Name = "btnCloseSettings" Me.btnCloseSettings.Size = New System.Drawing.Size(78, 24) Me.btnCloseSettings.TabIndex = 35 @@ -157,26 +155,17 @@ Partial Class formSettings 'btnSaveSettings ' Me.btnSaveSettings.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.btnSaveSettings.Location = New System.Drawing.Point(312, 37) + Me.btnSaveSettings.Location = New System.Drawing.Point(312, 13) Me.btnSaveSettings.Name = "btnSaveSettings" Me.btnSaveSettings.Size = New System.Drawing.Size(128, 24) Me.btnSaveSettings.TabIndex = 34 Me.btnSaveSettings.Text = "Save settings" Me.btnSaveSettings.UseVisualStyleBackColor = True ' - 'lblNonAvailableSettings - ' - Me.lblNonAvailableSettings.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.lblNonAvailableSettings.Location = New System.Drawing.Point(229, 16) - Me.lblNonAvailableSettings.Name = "lblNonAvailableSettings" - Me.lblNonAvailableSettings.Size = New System.Drawing.Size(295, 13) - Me.lblNonAvailableSettings.TabIndex = 40 - Me.lblNonAvailableSettings.Text = "* all settings in Italic is only available when run in EXE mode!" - ' 'btnEditScreenRes ' 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, 37) + Me.btnEditScreenRes.Location = New System.Drawing.Point(91, 13) Me.btnEditScreenRes.Name = "btnEditScreenRes" Me.btnEditScreenRes.Size = New System.Drawing.Size(99, 24) Me.btnEditScreenRes.TabIndex = 39 @@ -186,7 +175,7 @@ Partial Class formSettings 'btnMore ' Me.btnMore.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) - Me.btnMore.Location = New System.Drawing.Point(12, 37) + Me.btnMore.Location = New System.Drawing.Point(12, 13) Me.btnMore.Name = "btnMore" Me.btnMore.Size = New System.Drawing.Size(73, 24) Me.btnMore.TabIndex = 32 @@ -239,7 +228,7 @@ 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, 533) + Me.grpPlugins.Location = New System.Drawing.Point(12, 535) Me.grpPlugins.Name = "grpPlugins" Me.grpPlugins.Size = New System.Drawing.Size(515, 75) Me.grpPlugins.TabIndex = 37 @@ -292,7 +281,7 @@ Partial Class formSettings 'chkDisableFuzzyMatching ' Me.chkDisableFuzzyMatching.AutoSize = True - Me.chkDisableFuzzyMatching.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.chkDisableFuzzyMatching.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!) Me.chkDisableFuzzyMatching.Location = New System.Drawing.Point(327, 23) Me.chkDisableFuzzyMatching.Name = "chkDisableFuzzyMatching" Me.chkDisableFuzzyMatching.Size = New System.Drawing.Size(134, 17) @@ -312,7 +301,6 @@ Partial Class formSettings 'chkStartAsEXE ' Me.chkStartAsEXE.Appearance = System.Windows.Forms.Appearance.Button - Me.chkStartAsEXE.Enabled = True Me.chkStartAsEXE.Location = New System.Drawing.Point(6, 20) Me.chkStartAsEXE.Name = "chkStartAsEXE" Me.chkStartAsEXE.Size = New System.Drawing.Size(151, 21) @@ -324,7 +312,6 @@ Partial Class formSettings 'cmbDefaultStartMode ' Me.cmbDefaultStartMode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList - Me.cmbDefaultStartMode.Enabled = True Me.cmbDefaultStartMode.FormattingEnabled = True Me.cmbDefaultStartMode.Items.AddRange(New Object() {"Standard", "In EXE"}) Me.cmbDefaultStartMode.Location = New System.Drawing.Point(242, 20) @@ -524,7 +511,7 @@ Partial Class formSettings 'chkFormNoFocus ' Me.chkFormNoFocus.AutoSize = True - Me.chkFormNoFocus.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.chkFormNoFocus.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!) Me.chkFormNoFocus.Location = New System.Drawing.Point(441, 50) Me.chkFormNoFocus.Name = "chkFormNoFocus" Me.chkFormNoFocus.Size = New System.Drawing.Size(72, 17) @@ -796,7 +783,7 @@ Partial Class formSettings ' Me.AutoScaleDimensions = New System.Drawing.SizeF(96.0!, 96.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi - Me.ClientSize = New System.Drawing.Size(536, 693) + Me.ClientSize = New System.Drawing.Size(536, 673) Me.Controls.Add(Me.PanelSettings) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow Me.KeyPreview = True @@ -894,7 +881,6 @@ Partial Class formSettings Friend WithEvents btnEditScreenRes As Windows.Forms.Button Friend WithEvents lblBackground As Windows.Forms.Label Friend WithEvents cmbBackground As Windows.Forms.ComboBox - Friend WithEvents lblNonAvailableSettings As Windows.Forms.Label Friend WithEvents B2SLogoToolTip As Windows.Forms.ToolTip Friend WithEvents lowerPanel As Windows.Forms.Panel Friend WithEvents headerPanel As Windows.Forms.Panel diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx index 3fc5ee6..3626916 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.resx @@ -124,7 +124,7 @@ iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL - EAAACxABrSO9dQAAHIZJREFUeF7tWQdYlOeyPhuUsp26lO27wNJ7L9LLAtJ7EUVAY1eiETR2jb0TBRVR + DwAACw8BkvkDpQAAHIZJREFUeF7tWQdYlOeyPhuUsp26lO27wNJ7L9LLAtJ7EUVAY1eiETR2jb0TBRVR LBELCoKACLajGFs0ydHEaGLUJDaMJ4pImTvfuhBWjfHec03OPc+d53mfXfb//vln3plvZr6fv/3V0paR T0G8pwRF+fO/l7Sl5lEQam1peRoI5sPUXM5PyTmiH1NyzBCSe2m5hm3pefS2jLwBylveKG2Z6GxmPvXn tOHcc9FpDiciEn1ORiR5XUnIsnqQkaeL195KDxF8LgVt6oPy5/+ZtCXnvodQa0vJVUdootP0e8nDDc9H diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb index fe0b454..54cc147 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb @@ -37,11 +37,9 @@ Public Class formSettings Return Name + If(SlowDown = 1, "", " (" & If(SlowDown = 0, "Off", SlowDown.ToString & "x") & ")") End Function End Class -#If B2S = "DLL" Then + Private Sub formSettings_Load(sender As System.Object, e As System.EventArgs) Handles Me.Load -#Else - Private Sub formSettings_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load -#End If + formSettingsMore = New formSettingsMore(Me, formBackglass) ' load data @@ -157,11 +155,8 @@ Public Class formSettings TimerOpacity.Start() End Sub -#If B2S = "DLL" Then + Private Sub formSettings_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp -#Else - Private Sub formSettings_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp -#End If If e.KeyCode = Keys.Escape OrElse e.KeyCode = Keys.S Then btnCloseSettings.PerformClick() End If diff --git a/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb b/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb index 0c323e5..43b3336 100644 --- a/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb +++ b/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb @@ -1,5 +1,4 @@ -Imports System -Imports System.Reflection +Imports System.Reflection Imports System.Runtime.InteropServices ' General Information about an assembly is controlled through the following From ba3ffad93280e60d52fb975e5653f33e9bcb1ce6 Mon Sep 17 00:00:00 2001 From: Steve Jones Date: Sat, 13 Jul 2024 09:58:47 -0700 Subject: [PATCH 4/9] Updates to Refactor thread management and cleanup code - Replaced `thread.Abort()` with `Application.Exit()` in the `Server` class for a safer application termination. - Updated code to stop timers before calling the `Stop` method and disposing of objects to prevent resource leaks. - Enhanced the `Stop` method to ensure execution within the correct synchronization context, avoiding cross-thread errors. - Removed outdated commented-out code blocks related to logging and statistics for hardware components. - Corrected a typo in a comment from "lightning" to "lighting" to clarify the context is related to lighting effects. --- .../b2sbackglassserver/Server.vb | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/b2sbackglassserver/b2sbackglassserver/Server.vb b/b2sbackglassserver/b2sbackglassserver/Server.vb index 9946fa3..620ebcd 100644 --- a/b2sbackglassserver/b2sbackglassserver/Server.vb +++ b/b2sbackglassserver/b2sbackglassserver/Server.vb @@ -104,10 +104,8 @@ Public Class Server ' Create new STA thread for this dll to run in, if the thread is already running then don't start another ' However if the thread is running, we need to stop the application from running, and then restart it by running StartThread again If thread IsNot Nothing Then - Try - thread.Abort() - Catch - End Try + ' stop the application from running + Application.Exit() End If thread = New Thread(AddressOf StartThread) @@ -170,6 +168,7 @@ Public Class Server If tableHandle <> 0 AndAlso Not IsWindow(tableHandle) Then Try + timer.Stop() Me.Stop() Finally Me.Dispose() @@ -469,6 +468,17 @@ Public Class Server Public Sub [Stop]() Try + If SynchronizationContext.Current IsNot threadContext Then + threadContext.Send(New SendOrPostCallback(AddressOf [Stop]), Nothing) + Return + End If + + Catch ex As Exception + 'If Exception is InvalidAsynchronousStateException then the thread is already stopped, so we can ignore it and return + Return + End Try + + Try Try timer.Stop() HideBackglassForm() @@ -654,21 +664,12 @@ Public Class Server Private statelogChangedGIStrings As Log = New Log("GIStringsState") Private statelogChangedLEDs As Log = New Log("LEDState") - 'Private timelogChangedLamps As Log = New Log("Lamps") - 'Private timelogChangedSolenoids As Log = New Log("Solenoids") - - 'Private statChangedLamps As Statistics = New Statistics(timelogChangedLamps) - 'Private statChangedSolenoids As Statistics = New Statistics(timelogChangedSolenoids) - Public ReadOnly Property ChangedLamps() As Object Get Try isChangedLampsCalled = True Dim chg As Object = VPinMAME.ChangedLamps() If B2SData.GetLampsData() Then - 'If B2SData.IsBackglassRunning AndAlso - ' (B2SData.IsBackglassStartedAsEXE OrElse B2SData.UseRomLamps OrElse B2SData.UseAnimationLamps OrElse B2SSettings.IsLampsStateLogOn OrElse B2SData.TestMode OrElse B2SStatistics.LogStatistics) AndAlso - ' Not B2SSettings.AllOff AndAlso Not B2SSettings.LampsOff Then CheckLamps(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then @@ -688,9 +689,6 @@ Public Class Server isChangedSolenoidsCalled = True Dim chg As Object = VPinMAME.ChangedSolenoids() If B2SData.GetSolenoidsData() Then - 'If B2SData.IsBackglassRunning AndAlso - ' (B2SData.IsBackglassStartedAsEXE OrElse B2SData.UseRomSolenoids OrElse B2SData.UseAnimationSolenoids OrElse B2SSettings.IsSolenoidsStateLogOn OrElse B2SData.TestMode OrElse B2SStatistics.LogStatistics) AndAlso - ' Not B2SSettings.AllOff AndAlso Not B2SSettings.SolenoidsOff Then CheckSolenoids(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then @@ -710,9 +708,6 @@ Public Class Server isChangedGIStringsCalled = True Dim chg As Object = VPinMAME.ChangedGIStrings() If B2SData.GetGIStringsData() Then - 'If B2SData.IsBackglassRunning AndAlso - ' (B2SData.IsBackglassStartedAsEXE OrElse B2SData.UseRomGIStrings OrElse B2SData.UseAnimationGIStrings OrElse B2SSettings.IsGIStringsStateLogOn OrElse B2SData.TestMode OrElse B2SStatistics.LogStatistics) AndAlso - ' Not B2SSettings.AllOff AndAlso Not B2SSettings.GIStringsOff Then CheckGIStrings(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then @@ -732,9 +727,6 @@ Public Class Server isChangedLEDsCalled = True Dim chg As Object = VPinMAME.ChangedLEDs(mask2, mask1, mask3, mask4) ' (&HFFFFFFFF, &HFFFFFFFF) If B2SData.GetLEDsData() Then - 'If B2SData.IsBackglassRunning AndAlso - ' (B2SData.IsBackglassStartedAsEXE OrElse B2SData.UseLEDs OrElse B2SData.UseLEDDisplays OrElse B2SData.UseReels OrElse B2SSettings.IsLEDsStateLogOn) AndAlso - ' Not B2SSettings.AllOff AndAlso Not B2SSettings.LEDsOff Then CheckLEDs(DirectCast(chg, Object(,))) End If If B2SSettings.ArePluginsOn AndAlso B2SSettings.PluginHost.Plugins.Count > 0 Then @@ -998,13 +990,6 @@ Public Class Server statelogChangedSolenoids.IsLogOn = B2SSettings.IsSolenoidsStateLogOn - 'If statelogChangedSolenoids.IsLogOn Then - ' Static stopwatch As Stopwatch = New Stopwatch() - ' If Not stopwatch.IsRunning Then stopwatch.Start() - ' statelogChangedSolenoids.WriteLogEntry(DateTime.Now & " (" & stopwatch.ElapsedMilliseconds & ")") - ' stopwatch.Restart() - 'End If - If solenoids IsNot Nothing AndAlso IsArray(solenoids) Then If B2SData.TestMode Then @@ -2173,7 +2158,7 @@ Public Class Server Else - ' only do the lightning stuff if the group has a name + ' only do the lighting stuff if the group has a name If Not String.IsNullOrEmpty(groupname) AndAlso B2SData.IlluminationGroups.ContainsKey(groupname) Then ' get all matching picture boxes For Each picbox As B2SPictureBox In B2SData.IlluminationGroups(groupname) From 66a2faf4dc8851a6866ab65e379df1869232cc76 Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Sun, 14 Jul 2024 09:58:55 +0200 Subject: [PATCH 5/9] One timer was lost --- b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index 7de9353..a73ba39 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -369,7 +369,7 @@ Public Class formBackglass ' 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 B2STimer IsNot Nothing Then RemoveHandler B2STimer.Tick, AddressOf B2STimer_Tick + If B2STimer IsNot Nothing Then RemoveHandler B2STimer.Tick, AddressOf B2STimer_Tick #End If End Sub @@ -560,7 +560,7 @@ Public Class formBackglass End If End Sub - Private Sub B2STimer_Tick() + Private Sub B2STimer_Tick(ByVal sender As Object, ByVal e As EventArgs) ' poll registry data PollingData() From 41285526c0b8500064a6493fbc4fe83a62c4aa2e Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Wed, 6 Nov 2024 06:51:23 +0100 Subject: [PATCH 6/9] #122 Only crop "standard" images which does not rotate --- .../b2sbackglassserver/Forms/formBackglass.vb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index a73ba39..c2586a0 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -89,7 +89,6 @@ Public Class formBackglass End End If - ' get the game name 'B2SSettings.GameName = "bguns_l8" 'B2SSettings.GameName = "closeenc" @@ -2096,7 +2095,10 @@ Public Class formBackglass If innerNode.Attributes("OffImage") IsNot Nothing Then offimage = Base64ToImage(innerNode.Attributes("OffImage").InnerText) End If - image = CropImageToTransparency(image, offimage, loc, size) + If picboxtype = B2SPictureBox.ePictureBoxType.StandardImage Then + ' Events of overlapping pictures get merged #76, crop image transparency + image = CropImageToTransparency(image, offimage, loc, size) + End If ' create new picturebox control Dim picbox As B2SPictureBox = New B2SPictureBox() Dim IsOnBackglass As Boolean = (parent = "Backglass") From 987cb079becbb4f96c831be9895caa67a8d6edaa Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Wed, 6 Nov 2024 06:57:02 +0100 Subject: [PATCH 7/9] #121 B2S 2.1.2 Throws System NullReferenceException Check for possible NullReference --- b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index c2586a0..847736b 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -1203,9 +1203,8 @@ Public Class formBackglass Dim currentvalue As Integer = CInt(gistringsData.Substring(gistringid, 1)) If gistrings(gistringid) <> currentvalue Then If Not B2SData.UsedAnimationGIStringIDs.ContainsKey(gistringid) AndAlso Not B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(gistringid) Then gistrings(gistringid) = currentvalue - If B2SData.UsedRomGIStringIDs.ContainsKey(gistringid) Then + If B2SData.UsedRomGIStringIDs.ContainsKey(gistringid) AndAlso B2SData.UsedRomGIStringIDs(gistringid) IsNot Nothing Then For Each picbox As B2SPictureBox In B2SData.UsedRomGIStringIDs(gistringid) - 'If picbox IsNot Nothing Then If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then Dim visible As Boolean = (currentvalue > 4) If picbox.RomInverted Then visible = Not visible From 0fc5728920d81888f21eaa4de3d31b2ccf2255eb Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Wed, 6 Nov 2024 19:20:33 +0100 Subject: [PATCH 8/9] Improve Fuzzy Matching to not use the DOS short names #96 --- .../b2sbackglassserver/Classes/B2SScreen.vb | 2 - .../b2sbackglassserver/Classes/B2SSettings.vb | 24 ++- .../b2sbackglassserver/Classes/Processes.vb | 5 + .../b2sbackglassserver/Forms/formBackglass.vb | 144 +++++++++--------- .../Forms/formSettings.Designer.vb | 43 +++--- .../Forms/formSettings.resx | 2 +- .../b2sbackglassserver/Forms/formSettings.vb | 14 +- .../b2sbackglassserver/Server.vb | 52 +++---- 8 files changed, 141 insertions(+), 145 deletions(-) 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 From ec67e494e848ddd58680eef17a6a867de84cc027 Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Wed, 6 Nov 2024 19:53:24 +0100 Subject: [PATCH 9/9] B2S Table Settings Saving But WIll Not Apply #119 --- b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb index 7124444..962f2a6 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb @@ -267,6 +267,7 @@ Public Class B2SSettings Public Shared Sub LoadGlobalAndTableSettings(xmlNode As Xml.XmlNode) If xmlNode.SelectSingleNode("DisableBuiltInEMReelSound") IsNot Nothing Then DisableBuiltInEMReelSound = (xmlNode.SelectSingleNode("DisableBuiltInEMReelSound").InnerText = "1") If xmlNode.SelectSingleNode("HideGrill") IsNot Nothing Then HideGrill = CInt(xmlNode.SelectSingleNode("HideGrill").InnerText) + If xmlNode.SelectSingleNode("HideB2SBackglass") IsNot Nothing Then HideB2SBackglass = (xmlNode.SelectSingleNode("HideB2SBackglass").InnerText = "1") If xmlNode.SelectSingleNode("HideB2SDMD") IsNot Nothing Then HideB2SDMD = (xmlNode.SelectSingleNode("HideB2SDMD").InnerText = "1") If xmlNode.SelectSingleNode("HideDMD") IsNot Nothing Then HideDMD = CInt(xmlNode.SelectSingleNode("HideDMD").InnerText) If xmlNode.SelectSingleNode("LampsBlackTurns") IsNot Nothing Then LampsSkipFrames = CInt(xmlNode.SelectSingleNode("LampsBlackTurns").InnerText)