diff --git a/.github/workflows/b2s-backglass.yml b/.github/workflows/b2s-backglass.yml index 77218eb..93fd951 100644 --- a/.github/workflows/b2s-backglass.yml +++ b/.github/workflows/b2s-backglass.yml @@ -36,10 +36,6 @@ jobs: VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1) TAG="${VERSION}-${SHA7}" perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}" - ASSEMBLY_INFO="b2sbackglassserverexe/b2sbackglassserverexe/My Project/AssemblyInfo.vb" - VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1) - TAG="${VERSION}-${SHA7}" - perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}" ASSEMBLY_INFO="b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb" VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1) TAG="${VERSION}-${SHA7}" @@ -66,7 +62,7 @@ jobs: - name: Build Server run: | msbuild b2s_screenresidentifier/B2S_ScreenResIdentifier.sln /t:Rebuild /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }} - msbuild b2sbackglassserverexe/B2SBackglassServerEXE.sln /t:Rebuild /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }} + msbuild b2sbackglassserverexe/B2SBackglassServerEXE.sln /t:Restore,Rebuild /p:Configuration=${{ matrix.config }} /p:Platform="Any CPU" msbuild b2sbackglassserverregisterapp/B2SBackglassServerRegisterApp.sln /t:Rebuild /p:Configuration=${{ matrix.config }} /p:Platform=${{ matrix.platform }} msbuild b2sbackglassserver/B2SBackglassServer.sln /t:Rebuild /p:Configuration=${{ matrix.config }} msbuild B2SWindowPunch/B2SWindowPunch.sln /t:Rebuild /p:Configuration=${{ matrix.config }} @@ -76,8 +72,9 @@ jobs: mkdir tmp cp b2s_screenresidentifier/b2s_screenresidentifier/bin/${{ matrix.platform }}/${{ matrix.config }}/B2S_ScreenResIdentifier.exe tmp cp b2s_screenresidentifier/b2s_screenresidentifier/bin/${{ matrix.platform }}/${{ matrix.config }}/B2S_ScreenResIdentifier.exe.config tmp - cp b2sbackglassserverexe/b2sbackglassserverexe/bin/${{ matrix.platform }}/${{ matrix.config }}/B2SBackglassServerEXE.exe tmp - cp b2sbackglassserverexe/b2sbackglassserverexe/bin/${{ matrix.platform }}/${{ matrix.config }}/B2SBackglassServerEXE.exe.config tmp + : # ls -R b2sbackglassserverexe + cp b2sbackglassserverexe/bin/${{ matrix.config }}/B2SBackglassServerEXE.exe tmp + : # cp b2sbackglassserverexe/bin/${{ matrix.config }}/B2SBackglassServerEXE.exe.config tmp cp b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/bin/${{ matrix.platform }}/${{ matrix.config }}/B2SBackglassServerRegisterApp.exe tmp cp b2sbackglassserver/b2sbackglassserver/bin/${{ matrix.config }}/B2SServerPluginInterface.dll tmp cp b2sbackglassserver/b2sbackglassserver/bin/${{ matrix.config }}/B2SBackglassServer.dll tmp @@ -85,7 +82,7 @@ jobs: cp B2SWindowPunch/B2SWindowPunch/bin/${{ matrix.config }}/B2SWindowPunch.exe tmp if [[ "${{ matrix.config }}" == "Debug" ]]; then cp b2s_screenresidentifier/b2s_screenresidentifier/bin/${{ matrix.platform }}/${{ matrix.config }}/B2S_ScreenResIdentifier.pdb tmp - cp b2sbackglassserverexe/b2sbackglassserverexe/bin/${{ matrix.platform }}/${{ matrix.config }}/B2SBackglassServerEXE.pdb tmp + : # cp b2sbackglassserverexe/bin/${{ matrix.config }}/*/B2SBackglassServerEXE.pdb tmp cp b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/bin/${{ matrix.platform }}/${{ matrix.config }}/B2SBackglassServerRegisterApp.pdb tmp cp b2sbackglassserver/b2sbackglassserver/bin/${{ matrix.config }}/B2SServerPluginInterface.pdb tmp cp b2sbackglassserver/b2sbackglassserver/bin/${{ matrix.config }}/B2SBackglassServer.pdb tmp diff --git a/b2s_screenresidentifier/b2s_screenresidentifier/My Project/AssemblyInfo.vb b/b2s_screenresidentifier/b2s_screenresidentifier/My Project/AssemblyInfo.vb index 561336b..7064b2e 100644 --- a/b2s_screenresidentifier/b2s_screenresidentifier/My Project/AssemblyInfo.vb +++ b/b2s_screenresidentifier/b2s_screenresidentifier/My Project/AssemblyInfo.vb @@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - - + + + diff --git a/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj b/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj index 95be463..4d3c2fb 100644 --- a/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj +++ b/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj @@ -25,7 +25,7 @@ bin\Debug\ B2SBackglassServer.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - true + false false @@ -37,7 +37,7 @@ bin\Release\ B2SBackglassServer.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 - true + false true false @@ -116,6 +116,7 @@ + Background.vb @@ -164,7 +165,6 @@ Form - True @@ -181,6 +181,7 @@ Settings.settings True + diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb index 79e7077..ca7706c 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SScreen.vb @@ -53,6 +53,7 @@ Public Class B2SScreen debugLog.IsLogOn = B2SSettings.B2SDebugLog debugLog.WriteLogEntry("B2SScreen.New") + 'searchPathLog.WriteLogEntry("Start Search ScreenRes") ' read settings file @@ -114,7 +115,7 @@ Public Class B2SScreen B2SSettings.B2SScreenResFileName, ' .\ScreenRes.txt IO.Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), B2SSettings.B2SScreenResFileName)' B2SFolder\ScreenRes.txt } - + ' TODO IO.Path.Combine(Application.StartupPath(), B2SSettings.B2SScreenResFileName)' B2SFolder\ScreenRes.txt For Each testFileName As String In loadFileNames Server.errorlog.WriteLogEntry("B2SScreen.ReadB2SSettingsFromFile Test " & testFileName) 'searchPathLog.WriteLogEntry(" Test " & testFileName) diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb index d338f7b..7415a61 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb @@ -7,7 +7,7 @@ Imports Microsoft.Win32 Public Class B2SSettings - Public Const DirectB2SVersion As String = "2.1.2" + Public Const DirectB2SVersion As String = "3.0.0" Public Const MinimumDirectB2SVersion As String = "1.0" Public Shared Property BackglassFileVersion() As String = String.Empty @@ -233,6 +233,8 @@ Public Class B2SSettings Public Shared Function GetSettingFilename() As String If IO.File.Exists(filename) Then Return filename + ElseIf StartAsEXE And B2STableSettingsExtendedPath And IO.File.Exists(IO.Path.Combine(Application.StartupPath(), filename)) Then + Return IO.Path.Combine(Application.StartupPath(), filename) 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) End If diff --git a/b2sbackglassserver/b2sbackglassserver/EXEServer.vb b/b2sbackglassserver/b2sbackglassserver/EXEServer.vb new file mode 100644 index 0000000..93484bb --- /dev/null +++ b/b2sbackglassserver/b2sbackglassserver/EXEServer.vb @@ -0,0 +1,851 @@ +Imports System.Text +Imports Microsoft.Win32 + + +Public Class EXEServer + Inherits Server + + Implements IDisposable + + 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 + + Private formBackglass As formBackglass = Nothing + + Private timer As Windows.Forms.Timer = Nothing + + Private tableHandle As Integer = 0 + + Private isChangedLampsCalled As Boolean = False + Private isChangedSolenoidsCalled As Boolean = False + Private isChangedGIStringsCalled As Boolean = False + Private isChangedLEDsCalled As Boolean = False + +#Region "constructor and end timer" + + Public Sub New() + + ' config main timer + timer = New Windows.Forms.Timer + AddHandler timer.Tick, AddressOf Timer_Tick + timer.Interval = 37 + + End Sub + + Private Sub Timer_Tick() + + ' check whether the table is left + If tableHandle <> 0 AndAlso Not IsWindow(tableHandle) Then + Me.Stop() + End If + + ' have a look for important pollings + Static counter As Integer = 0 + Static callLamps As Boolean = False + Static callSolenoids As Boolean = False + Static callGIStrings As Boolean = False + Static callLEDs As Boolean = False + If counter <= 25 Then + counter += 1 + callLamps = Not isChangedLampsCalled AndAlso B2SData.UseRomLamps + callSolenoids = Not isChangedSolenoidsCalled AndAlso B2SData.UseRomSolenoids + callGIStrings = Not isChangedGIStringsCalled AndAlso B2SData.UseRomGIStrings + callLEDs = Not isChangedLEDsCalled AndAlso (B2SData.UseLEDs OrElse B2SData.UseLEDDisplays OrElse B2SData.UseReels) + CheckTableHandle() + Else + If B2SSettings.IsROMControlled Then + If callLamps Then Dim chg As Object = ChangedLamps() + If callSolenoids Then Dim chg As Object = ChangedSolenoids() + If callGIStrings Then Dim chg As Object = ChangedGIStrings() + If callLEDs Then Dim chg As Object = ChangedLEDs(&HFFFFFFFF, &HFFFFFFFF) + End If + End If + + End Sub + +#End Region + + +#Region "Visual PinMAME COM object" + + Private _vpinmame As Object = Nothing + Private ReadOnly Property VPinMAME() As Object + Get + If _vpinmame Is Nothing Then + _vpinmame = CreateObject("VPinMAME.Controller") + End If + Return _vpinmame + End Get + End Property + +#End Region + +#Region "Visual PinMAME control" + Public Shadows Sub WorkingDir(value As String) + IO.Directory.SetCurrentDirectory(value) + B2SData.TestMode = True + End Sub + + Public Shadows Sub Run(Optional ByVal handle As Object = 0) + tableHandle = handle + Startup() + ShowBackglassForm() + If B2SSettings.IsROMControlled Then + VPinMAME.Run(handle) + End If + End Sub + + Public Shadows Sub [Stop]() + HideBackglassForm() + timer.Stop() + VPinMAME.Stop() + KillBackglassForm() + End Sub +#End Region + +#Region "customization" + + Private _startBackglassEXE As Boolean = True + Public Property StartBackglassEXE() As Boolean + Get + Return _startBackglassEXE + End Get + Set(ByVal value As Boolean) + _startBackglassEXE = value + End Set + End Property + + Private _hidden As Boolean + Public Overloads Property Hidden() As Boolean + Get + Return _hidden + End Get + Set(ByVal value As Boolean) + _hidden = value + VPinMAME.hidden = True + End Set + End Property + +#End Region + + +#Region "polling functions" + + Private statelogChangedLamps As Log = New Log("LampsState") + Private statelogChangedSolenoids As Log = New Log("SolenoidsState") + 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 Overloads ReadOnly Property ChangedLamps() As Object + Get + isChangedLampsCalled = True + Dim chg As Object = VPinMAME.ChangedLamps() + If (B2SData.UseRomLamps OrElse B2SData.UseAnimationLamps OrElse B2SSettings.IsLampsStateLogOn) AndAlso Not B2SSettings.AllOff AndAlso Not B2SSettings.LampsOff AndAlso B2SData.IsBackglassVisible Then + CheckLamps(DirectCast(chg, Object(,))) + End If + Return chg + End Get + End Property + + Public Overloads ReadOnly Property ChangedSolenoids() As Object + Get + isChangedSolenoidsCalled = True + Dim chg As Object = VPinMAME.ChangedSolenoids() + If (B2SData.UseRomSolenoids OrElse B2SData.UseAnimationSolenoids OrElse B2SSettings.IsSolenoidsStateLogOn) AndAlso Not B2SSettings.AllOff AndAlso Not B2SSettings.SolenoidsOff AndAlso B2SData.IsBackglassVisible Then + CheckSolenoids(DirectCast(chg, Object(,))) + End If + Return chg + End Get + End Property + + Public Overloads ReadOnly Property ChangedGIStrings() As Object + Get + isChangedGIStringsCalled = True + Dim chg As Object = VPinMAME.ChangedGIStrings() + If (B2SData.UseRomGIStrings OrElse B2SData.UseAnimationGIStrings OrElse B2SSettings.IsGIStringsStateLogOn) AndAlso Not B2SSettings.AllOff AndAlso Not B2SSettings.GIStringsOff AndAlso B2SData.IsBackglassVisible Then + CheckGIStrings(DirectCast(chg, Object(,))) + End If + Return chg + End Get + End Property + + Public Overloads 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) + If (B2SData.UseLEDs OrElse B2SData.UseLEDDisplays OrElse B2SData.UseReels OrElse B2SSettings.IsLEDsStateLogOn) AndAlso Not B2SSettings.AllOff AndAlso Not B2SSettings.LEDsOff AndAlso B2SData.IsBackglassVisible Then + CheckLEDs(DirectCast(chg, Object(,))) + End If + Return chg + End Get + End Property + + Public Overloads ReadOnly Property NewSoundCommands() As Object + Get + Dim chg As Object = VPinMAME.NewSoundCommands() + Return chg + End Get + End Property + +#Region "private polling functions" + + Private isVisibleStateSet As Boolean = False + Private lastTopVisible As Boolean = False + Private lastSecondVisible As Boolean = False + + Private collectLampsData As B2SCollectData = New B2SCollectData(B2SSettings.LampsSkipFrames) + Private collectSolenoidsData As B2SCollectData = New B2SCollectData(B2SSettings.SolenoidsSkipFrames) + Private collectGIStringsData As B2SCollectData = New B2SCollectData(B2SSettings.GIStringsSkipFrames) + Private collectLEDsData As B2SCollectData = New B2SCollectData(B2SSettings.LEDsSkipFrames) + + Private Sub CheckLamps(ByVal lamps As Object(,)) + + statelogChangedLamps.IsLogOn = B2SSettings.IsLampsStateLogOn + + If StartBackglassEXE Then + + If lamps IsNot Nothing AndAlso IsArray(lamps) Then + + Dim sb As StringBuilder = New StringBuilder + sb.Append(Registry.CurrentUser.OpenSubKey("B2S").GetValue("B2SLamps", New String("0", 250)).ToString()) + + ' get thru all lamp info + For i As Integer = 0 To lamps.GetUpperBound(0) + + ' get lamp data + Dim lampid As Integer = CInt(lamps(i, 0)) + Dim lampstate As Integer = CInt(lamps(i, 1)) + + ' maybe write log + If statelogChangedLamps.IsLogOn Then + statelogChangedLamps.WriteLogEntry(DateTime.Now & ": Collecting data (" & (lamps.GetUpperBound(0) + 1) & "): " & lampid & " - " & lampstate) + End If + + ' check whether there is need to do something + If B2SData.UseRomLamps OrElse B2SData.UseAnimationLamps Then + + sb.Remove(lampid, 1) + sb.Insert(lampid, lampstate.ToString()) + + End If + + Next + + Registry.CurrentUser.OpenSubKey("B2S", True).SetValue("B2SLamps", sb.ToString()) + + End If + + Else + + If lamps IsNot Nothing AndAlso IsArray(lamps) Then + + ' get thru all lamp info + For i As Integer = 0 To lamps.GetUpperBound(0) + + ' get lamp data + Dim lampid As Integer = CInt(lamps(i, 0)) + Dim lampstate As Integer = CInt(lamps(i, 1)) + + ' maybe write log + If statelogChangedLamps.IsLogOn Then + statelogChangedLamps.WriteLogEntry(DateTime.Now & ": Collecting data (" & (lamps.GetUpperBound(0) + 1) & "): " & lampid & " - " & lampstate) + End If + + ' check whether there is need to do something + If B2SData.UseRomLamps OrElse B2SData.UseAnimationLamps Then + + ' collect illumination data + If formBackglass.TopRomIDType = B2SBaseBox.eRomIDType.Lamp AndAlso formBackglass.TopRomID = lampid Then + collectLampsData.Add(lampid, New B2SCollectData.CollectData(lampstate, B2SCollectData.eCollectedDataType.TopImage)) + ElseIf formBackglass.SecondRomIDType = B2SBaseBox.eRomIDType.Lamp AndAlso formBackglass.SecondRomID = lampid Then + collectLampsData.Add(lampid, New B2SCollectData.CollectData(lampstate, B2SCollectData.eCollectedDataType.SecondImage)) + End If + If B2SData.UsedRomLampIDs.ContainsKey(lampid) Then + collectLampsData.Add(lampid, New B2SCollectData.CollectData(lampstate, B2SCollectData.eCollectedDataType.Standard)) + End If + + ' collect animation data + If B2SData.UsedAnimationLampIDs.ContainsKey(lampid) Then + collectLampsData.Add(lampid, New B2SCollectData.CollectData(lampstate, B2SCollectData.eCollectedDataType.Animation)) + End If + + End If + + Next + + End If + + ' one collection loop is done + collectLampsData.DataAdded() + + ' maybe show the collected data + If collectLampsData.ShowData() Then + + For Each lampdata As KeyValuePair(Of Integer, B2SCollectData.CollectData) In collectLampsData + + ' get lamp data + Dim lampid As Integer = lampdata.Key + Dim lampstate As Integer = lampdata.Value.State + Dim datatypes As Integer = lampdata.Value.Types + + ' maybe write log + If statelogChangedLamps.IsLogOn Then + statelogChangedLamps.WriteLogEntry(DateTime.Now & ": Applying data (" & collectLampsData.Count & ") : " & lampid & " - " & lampstate & " - (" & datatypes & ")") + End If + + ' illumination stuff + If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 OrElse (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then + Dim topvisible As Boolean = lastTopVisible + Dim secondvisible As Boolean = lastSecondVisible + If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 Then + topvisible = (lampstate <> 0) + If formBackglass.TopRomInverted Then topvisible = Not topvisible + ElseIf (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then + secondvisible = (lampstate <> 0) + If formBackglass.SecondRomInverted Then topvisible = Not topvisible + End If + If lastTopVisible <> topvisible OrElse lastSecondVisible <> secondvisible OrElse Not isVisibleStateSet Then + B2SData.IsOffImageVisible = False + isVisibleStateSet = True + lastTopVisible = topvisible + lastSecondVisible = secondvisible + If topvisible AndAlso secondvisible Then + formBackglass.BackgroundImage = formBackglass.TopAndSecondLightImage + ElseIf topvisible Then + formBackglass.BackgroundImage = formBackglass.TopLightImage + ElseIf secondvisible Then + formBackglass.BackgroundImage = formBackglass.SecondLightImage + Else + formBackglass.BackgroundImage = formBackglass.DarkImage + B2SData.IsOffImageVisible = True + End If + End If + End If + If (datatypes And B2SCollectData.eCollectedDataType.Standard) <> 0 Then + For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(lampid) + If picbox IsNot Nothing Then + Dim visible As Boolean = (lampstate <> 0) + If picbox.RomInverted Then visible = Not visible + picbox.Visible = visible + End If + Next + End If + + ' animation stuff + If (datatypes And B2SCollectData.eCollectedDataType.Animation) <> 0 Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationLampIDs(lampid) + Dim start As Boolean = (lampstate <> 0) + If animation.Inverted Then start = Not start + If start Then + formBackglass.StartAnimation(animation.AnimationName) + Else + formBackglass.StopAnimation(animation.AnimationName) + End If + Next + End If + + Next + + ' reset all current data + collectLampsData.ClearData(B2SSettings.LampsSkipFrames) + + End If + + End If + + End Sub + Private Sub CheckSolenoids(ByVal solenoids As Object(,)) + + 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 StartBackglassEXE Then + + If solenoids IsNot Nothing AndAlso IsArray(solenoids) Then + + Dim sb As StringBuilder = New StringBuilder + sb.Append(Registry.CurrentUser.OpenSubKey("B2S").GetValue("B2SSolenoids", New String("0", 250)).ToString()) + + ' get thru all lamp info + For i As Integer = 0 To solenoids.GetUpperBound(0) + + ' get lamp data + Dim solenoidid As Integer = CInt(solenoids(i, 0)) + Dim solenoidstate As Integer = CInt(solenoids(i, 1)) + + ' maybe write log + If statelogChangedSolenoids.IsLogOn Then + statelogChangedSolenoids.WriteLogEntry(DateTime.Now & ": Collecting data (" & (solenoids.GetUpperBound(0) + 1) & "): " & solenoidid & " - " & solenoidstate) + End If + + ' check whether there is need to do something + If B2SData.UseRomSolenoids OrElse B2SData.UseAnimationSolenoids Then + + sb.Remove(solenoidid, 1) + sb.Insert(solenoidid, solenoidstate.ToString()) + + End If + + Next + + Registry.CurrentUser.OpenSubKey("B2S", True).SetValue("B2SSolenoids", sb.ToString()) + + End If + + Else + + If solenoids IsNot Nothing AndAlso IsArray(solenoids) Then + + ' get thru all solenoid info + For i As Integer = 0 To solenoids.GetUpperBound(0) + + ' get solenoid data + Dim solenoidid As Integer = CInt(solenoids(i, 0)) + Dim solenoidstate As Integer = CInt(solenoids(i, 1)) + + ' maybe write log + If statelogChangedSolenoids.IsLogOn Then + statelogChangedSolenoids.WriteLogEntry(DateTime.Now & ": Collecting data (" & (solenoids.GetUpperBound(0) + 1) & "): " & solenoidid & " - " & solenoidstate) + End If + + ' check whether there is need to do something + If B2SData.UseRomSolenoids OrElse B2SData.UseAnimationSolenoids Then + + ' collect illumination data + If formBackglass.TopRomIDType = B2SBaseBox.eRomIDType.Solenoid AndAlso formBackglass.TopRomID = solenoidid Then + collectSolenoidsData.Add(solenoidid, New B2SCollectData.CollectData(solenoidstate, B2SCollectData.eCollectedDataType.TopImage)) + ElseIf formBackglass.SecondRomIDType = B2SBaseBox.eRomIDType.Solenoid AndAlso formBackglass.SecondRomID = solenoidid Then + collectSolenoidsData.Add(solenoidid, New B2SCollectData.CollectData(solenoidstate, B2SCollectData.eCollectedDataType.SecondImage)) + End If + If B2SData.UsedRomSolenoidIDs.ContainsKey(solenoidid) Then + collectSolenoidsData.Add(solenoidid, New B2SCollectData.CollectData(solenoidstate, B2SCollectData.eCollectedDataType.Standard)) + End If + + ' collect animation data + If B2SData.UsedAnimationSolenoidIDs.ContainsKey(solenoidid) Then + collectSolenoidsData.Add(solenoidid, New B2SCollectData.CollectData(solenoidstate, B2SCollectData.eCollectedDataType.Animation)) + End If + + End If + + Next + + End If + + ' one collection loop is done + collectSolenoidsData.DataAdded() + + ' maybe show the collected data + If collectSolenoidsData.ShowData() Then + + For Each solenoiddata As KeyValuePair(Of Integer, B2SCollectData.CollectData) In collectSolenoidsData + + ' get solenoid data + Dim solenoidid As Integer = solenoiddata.Key + Dim solenoidstate As Integer = solenoiddata.Value.State + Dim datatypes As Integer = solenoiddata.Value.Types + + ' maybe write log + If statelogChangedSolenoids.IsLogOn Then + statelogChangedSolenoids.WriteLogEntry(DateTime.Now & ": Applying data (" & collectSolenoidsData.Count & ") : " & solenoidid & " - " & solenoidstate & " (" & datatypes & ")") + End If + + ' illumination stuff + If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 OrElse (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then + Dim topvisible As Boolean = lastTopVisible + Dim secondvisible As Boolean = lastSecondVisible + If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 Then + topvisible = (solenoidstate <> 0) + If formBackglass.TopRomInverted Then topvisible = Not topvisible + ElseIf (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then + secondvisible = (solenoidstate <> 0) + If formBackglass.SecondRomInverted Then topvisible = Not topvisible + End If + If lastTopVisible <> topvisible OrElse lastSecondVisible <> secondvisible OrElse Not isVisibleStateSet Then + B2SData.IsOffImageVisible = False + isVisibleStateSet = True + lastTopVisible = topvisible + lastSecondVisible = secondvisible + If topvisible AndAlso secondvisible Then + formBackglass.BackgroundImage = formBackglass.TopAndSecondLightImage + ElseIf topvisible Then + formBackglass.BackgroundImage = formBackglass.TopLightImage + ElseIf secondvisible Then + formBackglass.BackgroundImage = formBackglass.SecondLightImage + Else + formBackglass.BackgroundImage = formBackglass.DarkImage + B2SData.IsOffImageVisible = True + End If + End If + End If + If (datatypes And B2SCollectData.eCollectedDataType.Standard) <> 0 Then + For Each picbox As B2SPictureBox In B2SData.UsedRomSolenoidIDs(solenoidid) + If picbox IsNot Nothing Then + Dim visible As Boolean = (solenoidstate <> 0) + If picbox.RomInverted Then visible = Not visible + picbox.Visible = visible + End If + Next + End If + + ' animation stuff + If (datatypes And B2SCollectData.eCollectedDataType.Animation) <> 0 Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationSolenoidIDs(solenoidid) + Dim start As Boolean = (solenoidstate <> 0) + If animation.Inverted Then start = Not start + If start Then + formBackglass.StartAnimation(animation.AnimationName) + Else + formBackglass.StopAnimation(animation.AnimationName) + End If + Next + End If + + Next + + ' reset all current data + collectSolenoidsData.ClearData(B2SSettings.SolenoidsSkipFrames) + + End If + + End If + + End Sub + Private Sub CheckGIStrings(ByVal gistrings As Object(,)) + + statelogChangedGIStrings.IsLogOn = B2SSettings.IsGIStringsStateLogOn + + If gistrings IsNot Nothing AndAlso IsArray(gistrings) Then + + ' get thru all gistring info + For i As Integer = 0 To gistrings.GetUpperBound(0) + + ' get gistring data + Dim gistringid As Integer = CInt(gistrings(i, 0)) + Dim gistringstate As Integer = CInt(gistrings(i, 1)) + + ' maybe write log(s) + If statelogChangedGIStrings.IsLogOn Then + statelogChangedGIStrings.WriteLogEntry(DateTime.Now & ": Collecting data (" & (gistrings.GetUpperBound(0) + 1) & "): " & gistringid & " - " & gistringstate) + End If + + ' check whether there is need to do something + If B2SData.UseRomGIStrings OrElse B2SData.UseAnimationGIStrings Then + + ' collect illumination data + If formBackglass.TopRomIDType = B2SBaseBox.eRomIDType.GIString AndAlso formBackglass.TopRomID = gistringid Then + collectGIStringsData.Add(gistringid, New B2SCollectData.CollectData(gistringstate, B2SCollectData.eCollectedDataType.TopImage)) + ElseIf formBackglass.SecondRomIDType = B2SBaseBox.eRomIDType.GIString AndAlso formBackglass.SecondRomID = gistringid Then + collectGIStringsData.Add(gistringid, New B2SCollectData.CollectData(gistringstate, B2SCollectData.eCollectedDataType.SecondImage)) + End If + If B2SData.UsedRomGIStringIDs.ContainsKey(gistringid) Then + collectGIStringsData.Add(gistringid, New B2SCollectData.CollectData(gistringstate, B2SCollectData.eCollectedDataType.Standard)) + End If + + ' collect animation data + If B2SData.UsedAnimationGIStringIDs.ContainsKey(gistringid) Then + collectGIStringsData.Add(gistringid, New B2SCollectData.CollectData(gistringstate, B2SCollectData.eCollectedDataType.Animation)) + End If + + End If + + Next + + End If + + ' one collection loop is done + collectGIStringsData.DataAdded() + + ' maybe show the collected data + If collectGIStringsData.ShowData() Then + + For Each gistringdata As KeyValuePair(Of Integer, B2SCollectData.CollectData) In collectGIStringsData + + ' get gistring data + Dim gistringid As Integer = gistringdata.Key + Dim gistringstate As Integer = gistringdata.Value.State + Dim datatypes As Integer = gistringdata.Value.Types + + ' maybe write log + If statelogChangedGIStrings.IsLogOn Then + statelogChangedGIStrings.WriteLogEntry(DateTime.Now & ": Applying data (" & collectGIStringsData.Count & ") : " & gistringid & " - " & gistringstate & " (" & datatypes & ")") + End If + + ' illumination stuff + If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 OrElse (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then + Dim topvisible As Boolean = lastTopVisible + Dim secondvisible As Boolean = lastSecondVisible + If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 Then + topvisible = (gistringstate > 4) + If formBackglass.TopRomInverted Then topvisible = Not topvisible + ElseIf (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then + secondvisible = (gistringstate > 4) + If formBackglass.SecondRomInverted Then topvisible = Not topvisible + End If + If lastTopVisible <> topvisible OrElse lastSecondVisible <> secondvisible OrElse Not isVisibleStateSet Then + B2SData.IsOffImageVisible = False + isVisibleStateSet = True + lastTopVisible = topvisible + lastSecondVisible = secondvisible + If topvisible AndAlso secondvisible Then + formBackglass.BackgroundImage = formBackglass.TopAndSecondLightImage + ElseIf topvisible Then + formBackglass.BackgroundImage = formBackglass.TopLightImage + ElseIf secondvisible Then + formBackglass.BackgroundImage = formBackglass.SecondLightImage + Else + formBackglass.BackgroundImage = formBackglass.DarkImage + B2SData.IsOffImageVisible = True + End If + End If + End If + If (datatypes And B2SCollectData.eCollectedDataType.Standard) <> 0 Then + For Each picbox As B2SPictureBox In B2SData.UsedRomGIStringIDs(gistringid) + If picbox IsNot Nothing Then + Dim visible As Boolean = (gistringstate > 4) + If picbox.RomInverted Then visible = Not visible + picbox.Visible = visible + End If + Next + End If + + ' animation stuff + If (datatypes And B2SCollectData.eCollectedDataType.Animation) <> 0 Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationGIStringIDs(gistringid) + Dim start As Boolean = (gistringstate > 4) + If animation.Inverted Then start = Not start + If start Then + formBackglass.StartAnimation(animation.AnimationName) + Else + formBackglass.StopAnimation(animation.AnimationName) + End If + Next + End If + + Next + + ' reset all current data + collectGIStringsData.ClearData(B2SSettings.GIStringsSkipFrames) + + End If + + End Sub + Private Sub CheckLEDs(ByVal leds As Object(,)) + + statelogChangedLEDs.IsLogOn = B2SSettings.IsLEDsStateLogOn + + If leds IsNot Nothing AndAlso IsArray(leds) Then + + ' get thru all changed LEDs + For i As Integer = 0 To leds.GetUpperBound(0) + + Dim digit As Integer = CInt(leds(i, 0)) + Dim value As Integer = CInt(leds(i, 2)) + + ' maybe write log + If statelogChangedLEDs.IsLogOn Then + statelogChangedLEDs.WriteLogEntry(DateTime.Now & ": Collecting data (" & (leds.GetUpperBound(0) + 1) & ") : " & digit & " - " & value) + End If + + ' check whether leds are used + If B2SData.UseLEDs OrElse B2SData.UseLEDDisplays OrElse B2SData.UseReels Then + collectLEDsData.Add(digit, New B2SCollectData.CollectData(value, 0)) + End If + + Next + + End If + + ' one collection loop is done + collectLEDsData.DataAdded() + + ' maybe show the collected data + If collectLEDsData.ShowData() Then + + Dim useLEDs As Boolean = (B2SData.UseLEDs AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered) + Dim useLEDDisplays As Boolean = (B2SData.UseLEDDisplays AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7) + Dim useReels As Boolean = (B2SData.UseReels) + + For Each leddata As KeyValuePair(Of Integer, B2SCollectData.CollectData) In collectLEDsData + + Dim digit As Integer = leddata.Key + Dim value As Integer = leddata.Value.State + + ' maybe write log + If statelogChangedLEDs.IsLogOn Then + statelogChangedLEDs.WriteLogEntry(DateTime.Now & ": Applying data (" & (leds.GetUpperBound(0) + 1) & ") : " & digit & " - " & value) + End If + + ' check whether leds or reels are used + If useLEDs Then + + ' rendered LEDs are used + Dim ledname As String = "LEDBox" & (digit + 1).ToString() + If B2SData.LEDs.ContainsKey(ledname) Then + B2SData.LEDs(ledname).Value = value + End If + + ElseIf useLEDDisplays Then + + ' Dream 7 displays are used + If B2SData.LEDDisplayDigits.ContainsKey(digit) Then + With B2SData.LEDDisplayDigits(digit) + .LEDDisplay.SetValue(.Digit, value) + End With + End If + + ElseIf useReels Then + + ' reels are used + Dim reelname As String = "ReelBox" & (digit + 1).ToString() + If B2SData.Reels.ContainsKey(reelname) Then + B2SData.Reels(reelname).Value = value + End If + + End If + + Next + + ' reset all current data + collectLEDsData.ClearData(B2SSettings.LEDsSkipFrames) + + End If + + End Sub + +#End Region +#End Region + +#Region "game input/output" + + Public Overloads Property Switch(ByVal number As Object) As Boolean + Get + Return VPinMAME.Switch(number) + End Get + Set(ByVal value As Boolean) + VPinMAME.Switch(number) = value + End Set + End Property + + Public Overloads Property Mech(ByVal number As Object) As Integer + Get + Return VPinMAME.Mech(number) + End Get + Set(ByVal value As Integer) + VPinMAME.Mech(number) = value + End Set + End Property + Public Overloads ReadOnly Property GetMech(ByVal number As Object) As Object + Get + Return VPinMAME.GetMech(number) + End Get + End Property + +#End Region + +#Region "non VPinMAME support" + + Public Sub SetScore(ByVal digit As Integer, ByVal value As Integer) + + End Sub + + Public Sub SetPlayer(ByVal player As Integer) + + End Sub + +#End Region + +#Region "private stuff" + + Private Sub Startup() + + ' get thru all processes + Dim processes As Processes = New Processes() + B2SData.TableFileName = processes.TableName + If processes.TableCount > 1 Then + ' maybe do here something anytime + End If + + ' start end timer + timer.Start() + + End Sub + + Private Sub CheckTableHandle() + + If tableHandle = 0 Then + Dim processes As Processes = New Processes() + tableHandle = processes.TableHandle + End If + + End Sub + + Private Sub ShowBackglassForm() + + Try + If formBackglass Is Nothing Then + formBackglass = New formBackglass() + End If + VPinMAME.hidden = B2SData.UseLEDs OrElse B2SData.UseLEDDisplays OrElse B2SData.UseReels OrElse B2SSettings.HideDMD + formBackglass.Show() + formBackglass.TopMost = True + formBackglass.BringToFront() + formBackglass.TopMost = False + B2SData.IsBackglassVisible = True + Catch ex As Exception + Windows.Forms.MessageBox.Show(ex.Message, My.Resources.AppTitle, Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Error) + End Try + + End Sub + Private Sub HideBackglassForm() + If formBackglass IsNot Nothing Then + formBackglass.Hide() + End If + End Sub + Private Sub KillBackglassForm() + + If formBackglass IsNot Nothing Then + On Error Resume Next + For I As Integer = formBackglass.Controls.Count - 1 To 0 Step -1 + formBackglass.Controls(I).BackgroundImage.Dispose() + formBackglass.Controls(I).BackgroundImage = Nothing + formBackglass.Controls(I).Dispose() + Next + formBackglass.TopLightImage.Dispose() + 'formBackglass.TopLightImage = Nothing + If formBackglass.SecondLightImage IsNot Nothing Then + formBackglass.SecondLightImage.Dispose() + 'formBackglass.SecondLightImage = Nothing + formBackglass.TopAndSecondLightImage.Dispose() + 'formBackglass.TopAndSecondLightImage = Nothing + End If + formBackglass.BackgroundImage.Dispose() + formBackglass.BackgroundImage = Nothing + B2SData.ClearAll() + B2SSettings.ClearAll() + formBackglass.Close() + formBackglass.Dispose() + GC.Collect() + GC.SuppressFinalize(formBackglass) + GC.SuppressFinalize(Me) + GC.Collect() + B2SData.IsBackglassVisible = False + End If + + End Sub + +#End Region + +End Class diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index 9e20a7c..d30f621 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -1,12 +1,16 @@ -Imports System -Imports System.Drawing +Imports System.Drawing +Imports System.IO Imports System.Windows.Forms +Imports Microsoft.Win32 Public Class formBackglass + Inherits System.Windows.Forms.Form + Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hwnd As IntPtr) As Integer + Private Declare Function IsWindow Lib "user32.dll" (ByVal hwnd As IntPtr) As Boolean Private Const minSize4Image As Integer = 300000 - Private B2SScreen As B2SScreen = New B2SScreen() + Private B2SScreen As B2SScreen = Nothing ' was New B2SScreen(), delayed to do later - Westworld, 2016-11-18 Private B2SLED As B2SLED = New B2SLED() Private B2SAnimation As B2SAnimation = New B2SAnimation() @@ -15,6 +19,10 @@ Public Class formBackglass Private formMode As formMode = Nothing Private startupTimer As Timer = Nothing + Private timer As Timer = Nothing + Private tabletimer As Timer = Nothing + Private B2STimer As Timer = Nothing + Private tableHandle As Integer = 0 Private rotateTimer As Timer = Nothing Private rotateSlowDownSteps As Integer = 0 @@ -23,6 +31,8 @@ Public Class formBackglass Private rotateSteps As Integer = 0 Private rotateAngle As Single = 0 Private rotateTimerInterval As Integer = 0 + Private Const MA_NOACTIVATE As System.Int32 = 3 + Private Const WM_MOUSEACTIVATE As Integer = &H21 Private snifferLamps As B2SSnifferPanel = Nothing Private snifferSolenoids As B2SSnifferPanel = Nothing @@ -31,7 +41,16 @@ Public Class formBackglass Private snifferTimer As Timer = Nothing Private Const snifferTimerInterval As Integer = 311 - +#Region " Properties " + Protected Overrides Sub WndProc(ByRef m As Message) + 'Don't allow the window to be activated by swallowing the mouse event. + If B2SSettings.FormNoFocus And m.Msg = WM_MOUSEACTIVATE Then + m.Result = New IntPtr(MA_NOACTIVATE) + Return + End If + MyBase.WndProc(m) + End Sub +#End Region 'Properties #Region "constructor and closing" Public Sub New() @@ -45,12 +64,25 @@ Public Class formBackglass ' set key preview to allow some key action Me.KeyPreview = True + B2SScreen = New B2SScreen() + ' load settings B2SSettings.Load() - ' get B2S xml and start - LoadB2SData() + 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 + Stop + End Try ' initialize screen settings InitB2SScreen() @@ -74,6 +106,7 @@ Public Class formBackglass AddHandler rotateTimer.Tick, AddressOf RotateTimer_Tick End Sub + Public Sub New(ByVal doNotLoadBackglassData As Boolean) InitializeComponent() @@ -134,21 +167,149 @@ Public Class formBackglass End Sub + Public Sub New(tableName As String, TopMost As Boolean) + ' This is the constructor for the server when run from the wrapper + InitializeComponent() + + ' set some styles + Me.SetStyle(ControlStyles.AllPaintingInWmPaint Or ControlStyles.UserPaint Or ControlStyles.OptimizedDoubleBuffer, True) + Me.DoubleBuffered = True + + ' set key preview 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 tableName.EndsWith(".directb2s") Then + tableName = System.IO.Path.GetFileNameWithoutExtension(tableName) + B2SSettings.PureEXE = True + End If + B2SData.TableFileName = tableName + Me.TopMost = TopMost + + ' 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 + Stop + 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 + + Private Sub formBackglass_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown + + If Not B2SSettings.FormToFront Then + Me.SendToBack() + End If + + + 'Me.TopMost = False + + SetFocusToVPPlayer() + + End Sub + Private Sub formBackglass_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing On Error Resume Next - ' stop all timers + ' stop all timers as DLL If startupTimer IsNot Nothing Then startupTimer.Stop() If rotateTimer IsNot Nothing Then rotateTimer.Stop() If snifferTimer IsNot Nothing Then snifferTimer.Stop() + ' 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() + If rotateTimer IsNot Nothing Then rotateTimer.Stop() + ' unload DMD form stuff If formDMD IsNot Nothing Then formDMD.Close() formDMD.Dispose() End If + If B2SScreen.formbackground IsNot Nothing Then + B2SScreen.formbackground.Close() + B2SScreen.formbackground.Dispose() + End If + ' unload mode form If formMode IsNot Nothing Then formMode.Close() @@ -233,6 +394,12 @@ Public Class formBackglass If rotateTimer IsNot Nothing Then RemoveHandler rotateTimer.Tick, AddressOf RotateTimer_Tick If snifferTimer IsNot Nothing Then RemoveHandler snifferTimer.Tick, AddressOf SnifferTimer_Tick + ' 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 rotateTimer IsNot Nothing Then RemoveHandler rotateTimer.Tick, AddressOf RotateTimer_Tick + End Sub #End Region @@ -370,6 +537,47 @@ Public Class formBackglass #Region "some timer events" + Private Sub Timer_Tick() + + timer.Stop() + + ' set focus to the VP player + SetFocusToVPPlayer() + + ' start autostarted animations + B2SAnimation.AutoStart() + + ' start B2S data timer + B2STimer.Start() + + ' set focus to the VP player + SetFocusToVPPlayer() + + ' start table check timer + tabletimer.Start() + + End Sub + + Private Sub TableTimer_Tick() + + If tableHandle <> 0 AndAlso Not IsWindow(tableHandle) Then + ' get out here + tabletimer.Stop() + Me.Close() + Me.Dispose() + End If + + End Sub + + Private Sub B2STimer_Tick() + + ' poll registry data + PollingData() + + ' show some 'startup on' images (one time) + ShowStartupImages() + + End Sub Private Sub StartupTimer_Tick(ByVal sender As Object, ByVal e As EventArgs) @@ -445,6 +653,995 @@ Public Class formBackglass #End Region +#Region "polling action B2SBackglassServerEXE" + + Private isVisibleStateSet As Boolean = False + Private lastTopVisible As Boolean = False + Private lastSecondVisible As Boolean = False + + Private pollingInit As Boolean = False + Private lamps(400) As Integer + Private solenoids(400) As Integer + Private gistrings(400) As Integer + Private b2sSets(400) As Integer + Private mechs(5) As Integer + Private leds(100) As Integer + + Private animations As Generic.Dictionary(Of String, Integer) = Nothing + Private lastRandomStartedAnimation As String = String.Empty + + Private rotation As Integer = 0 + + Private sounds As Generic.Dictionary(Of String, Integer) = Nothing + + Private Sub PollingData() + + ' initialize the value storage - this storage is to avoid too much update traffic + InitializePollArrays() + + ' open registry sub key + Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S", True) + + ' get current data + Dim lampsData As String = GetLampsPollingData(regkey) + Dim solenoidsData As String = GetSolenoidsPollingData(regkey) + Dim gistringsData As String = GetGIStringsPollingData(regkey) + Dim b2sSetsData As String = GetB2SSetsPollingData(regkey) + Dim mechsData As Integer() = GetMechPollingData(regkey) + Dim animationsdata As String = GetAnimationsPollingData(regkey) + Dim rotationsdata As String = GetRotationsPollingData(regkey) + Dim soundsdata As String = GetSoundsPollingData(regkey) + + ' first of all have a look at the both top images + Dim topVisible As Boolean = lastTopVisible + topVisible = GetLampsTopVisible(lampsData, topVisible) + topVisible = GetSolenoidsTopVisible(solenoidsData, topVisible) + topVisible = GetGIStringsTopVisible(gistringsData, topVisible) + topVisible = GetB2SSetsTopVisible(b2sSetsData, topVisible) + Dim secondVisible As Boolean = lastSecondVisible + secondVisible = GetLampsSecondVisible(lampsData, secondVisible) + secondVisible = GetSolenoidsSecondVisible(solenoidsData, secondVisible) + secondVisible = GetGIStringsSecondVisible(gistringsData, secondVisible) + secondVisible = GetB2SSetsSecondVisible(b2sSetsData, secondVisible) + ' maybe show or hide top images + If lastTopVisible <> topVisible OrElse lastSecondVisible <> secondVisible OrElse Not isVisibleStateSet Then + B2SData.IsOffImageVisible = False + isVisibleStateSet = True + lastTopVisible = topVisible + lastSecondVisible = secondVisible + If topVisible AndAlso secondVisible Then + BackgroundImage = TopAndSecondLightImage + ElseIf topVisible Then + BackgroundImage = TopLightImage + ElseIf secondVisible Then + BackgroundImage = SecondLightImage + Else + BackgroundImage = DarkImage + B2SData.IsOffImageVisible = True + End If + End If + + ' get thru all lamps + GetThruAllLamps(lampsData) + + ' get thru all solenoids + GetThruAllSolenoids(solenoidsData) + + ' get thru all gistrings + GetThruAllGIStrings(gistringsData) + + ' get thru all B2SSetData + GetThruAllB2SData(b2sSetsData) + + ' get thru all mechs + GetThruAllMechs(mechsData) + + ' get thru all LEDs + GetThruAllLEDs(regkey) + + ' get thru all animations + GetThruAllAnimations(regkey, animationsdata) + + ' get thru all rotations + GetThruAllRotations(regkey, rotationsdata) + + ' get thru all sounds + GetThruAllSounds(regkey, soundsdata) + + ' maybe hide score display + GetThruAllScoreDisplays(regkey) + + ' maybe show or hide some illus by groupname + GetThruAllIlluGroups(regkey) + + End Using + + End Sub + + Private Sub InitializePollArrays() + + If Not pollingInit Then + + pollingInit = True + + For I As Integer = 0 To 250 + lamps(I) = 0 + Next + For I As Integer = 0 To 250 + solenoids(I) = 0 + Next + For I As Integer = 0 To 250 + gistrings(I) = 0 + Next + For I As Integer = 0 To 250 + b2sSets(I) = 0 + Next + For I As Integer = 0 To 5 + mechs(I) = -1 + Next + For I As Integer = 0 To 100 + leds(I) = 0 + Next + animations = New Generic.Dictionary(Of String, Integer) + sounds = New Generic.Dictionary(Of String, Integer) + + End If + + End Sub + + Private Function GetLampsPollingData(ByVal regkey As RegistryKey) As String + + Dim lampsData As String = String.Empty + + If B2SData.UseRomLamps OrElse B2SData.UseAnimationLamps Then + lampsData = regkey.GetValue("B2SLamps", New String("0", 401)) + 'If B2SSettings.IsROMControlled AndAlso lampsData.Contains("2") Then + ' regkey.SetValue("B2SLamps", lampsData.Replace("2", "0")) + 'End If + End If + + Return lampsData + + End Function + Private Function GetSolenoidsPollingData(ByVal regkey As RegistryKey) As String + + Dim solenoidsData As String = String.Empty + + If B2SData.UseRomSolenoids OrElse B2SData.UseAnimationSolenoids Then + solenoidsData = regkey.GetValue("B2SSolenoids", New String("0", 251)) + If B2SSettings.IsROMControlled AndAlso solenoidsData.Contains("2") Then + regkey.SetValue("B2SSolenoids", solenoidsData.Replace("2", "0")) + End If + End If + + Return solenoidsData + + End Function + Private Function GetGIStringsPollingData(ByVal regkey As RegistryKey) As String + + Dim gistringsData As String = String.Empty + + If B2SData.UseRomGIStrings OrElse B2SData.UseAnimationGIStrings Then + gistringsData = regkey.GetValue("B2SGIStrings", New String("0", 251)) + End If + + Return gistringsData + + End Function + Private Function GetB2SSetsPollingData(ByVal regkey As RegistryKey) As String + + Dim b2sSetsData As String = String.Empty + + If B2SData.UseRomLamps OrElse B2SData.UseAnimationLamps Then + b2sSetsData = regkey.GetValue("B2SSetData", New String(Chr(0), 251)) + 'If B2SSettings.IsROMControlled AndAlso b2sSetsData.Contains("2") Then + ' regkey.SetValue("B2SSetData", b2sSetsData.Replace("2", "0")) + 'End If + End If + + Return b2sSetsData + + End Function + Private Function GetMechPollingData(ByVal regkey As RegistryKey) As Integer() + + Dim mechsData As Integer() = New Integer() {-1, -1, -1, -1, -1, -1} + + If B2SData.UseRomMechs Then + For i As Integer = 1 To Math.Min(B2SData.UsedRomMechIDs.Count, 5) + mechsData(i) = regkey.GetValue("B2SMechs" & i.ToString(), -1) + Next + End If + + Return mechsData + + End Function + Private Function GetAnimationsPollingData(ByVal regkey As RegistryKey) As String + + Dim animationsdata As String = String.Empty + + If B2SAnimation.AreThereAnimations Then + animationsdata = regkey.GetValue("B2SAnimations", String.Empty) + End If + + Return animationsdata + + End Function + Private Function GetRotationsPollingData(ByVal regkey As RegistryKey) As String + + Dim rotationsdata As String = String.Empty + + rotationsdata = regkey.GetValue("B2SRotations", String.Empty) + + Return rotationsdata + + End Function + Private Function GetSoundsPollingData(ByVal regkey As RegistryKey) As String + + Dim soundsdata As String = String.Empty + + soundsdata = regkey.GetValue("B2SSounds", String.Empty) + + Return soundsdata + + End Function + + Private Function GetLampsTopVisible(ByVal lampsData As String, ByVal currentTopVisible As Boolean) As Boolean + + Dim topVisible As Boolean = currentTopVisible + + If B2SData.UseRomLamps AndAlso TopRomIDType = B2SBaseBox.eRomIDType.Lamp Then + Dim lampid As Integer = TopRomID + Dim currentvalue As Integer = CInt(lampsData.Substring(lampid, 1)) + If lamps(lampid) <> currentvalue Then + If Not B2SData.UsedRomLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedAnimationLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then lamps(lampid) = currentvalue + topVisible = (currentvalue <> 0) + If TopRomInverted Then topVisible = Not topVisible + End If + End If + + Return topVisible + + End Function + Private Function GetSolenoidsTopVisible(ByVal solenoidsData As String, ByVal currentTopVisible As Boolean) As Boolean + + Dim topVisible As Boolean = currentTopVisible + + If B2SData.UseRomSolenoids AndAlso TopRomIDType = B2SBaseBox.eRomIDType.Solenoid Then + Dim solenoidid As Integer = TopRomID + Dim currentvalue As Integer = CInt(solenoidsData.Substring(solenoidid, 1)) + If solenoids(solenoidid) <> currentvalue Then + If Not B2SData.UsedRomSolenoidIDs.ContainsKey(solenoidid) AndAlso Not B2SData.UsedAnimationSolenoidIDs.ContainsKey(solenoidid) AndAlso Not B2SData.UsedRandomAnimationSolenoidIDs.ContainsKey(solenoidid) Then solenoids(solenoidid) = currentvalue + topVisible = (currentvalue <> 0) + If TopRomInverted Then topVisible = Not topVisible + End If + End If + + Return topVisible + + End Function + Private Function GetGIStringsTopVisible(ByVal gistringsData As String, ByVal currentTopVisible As Boolean) As Boolean + + Dim topVisible As Boolean = currentTopVisible + + If B2SData.UseRomGIStrings AndAlso TopRomIDType = B2SBaseBox.eRomIDType.GIString Then + Dim gistringid As Integer = TopRomID + Dim currentvalue As Integer = CInt(gistringsData.Substring(gistringid, 1)) + If gistrings(gistringid) <> currentvalue Then + If Not B2SData.UsedRomGIStringIDs.ContainsKey(gistringid) AndAlso Not B2SData.UsedAnimationGIStringIDs.ContainsKey(gistringid) AndAlso Not B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(gistringid) Then gistrings(gistringid) = currentvalue + topVisible = (currentvalue > 4) + If TopRomInverted Then topVisible = Not topVisible + End If + End If + + Return topVisible + + End Function + Private Function GetB2SSetsTopVisible(ByVal b2sSetsData As String, ByVal currentTopVisible As Boolean) As Boolean + + Dim topVisible As Boolean = currentTopVisible + + If B2SData.UseRomLamps AndAlso TopRomIDType = B2SBaseBox.eRomIDType.Lamp Then + Dim b2ssetid As Integer = TopRomID + Dim currentvalue As Integer = Asc(b2sSetsData.Substring(b2ssetid, 1)) + If b2sSets(b2ssetid) <> currentvalue Then + If Not B2SData.UsedRomLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedAnimationLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(b2ssetid) Then b2sSets(b2ssetid) = currentvalue + topVisible = (currentvalue <> 0) + If TopRomInverted Then topVisible = Not topVisible + End If + End If + + Return topVisible + + End Function + Private Function GetLampsSecondVisible(ByVal lampsData As String, ByVal currentSecondVisible As Boolean) As Boolean + + Dim secondVisible As Boolean = currentSecondVisible + + If B2SData.UseRomLamps AndAlso SecondRomIDType = B2SBaseBox.eRomIDType.Lamp Then + Dim lampid As Integer = SecondRomID + Dim currentvalue As Integer = CInt(lampsData.Substring(lampid, 1)) + If lamps(lampid) <> currentvalue Then + If Not B2SData.UsedRomLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedAnimationLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then lamps(lampid) = currentvalue + secondVisible = (currentvalue <> 0) + If SecondRomInverted Then secondVisible = Not secondVisible + End If + End If + + Return secondVisible + + End Function + Private Function GetSolenoidsSecondVisible(ByVal solenoidsData As String, ByVal currentSecondVisible As Boolean) As Boolean + + Dim secondVisible As Boolean = currentSecondVisible + + If B2SData.UseRomSolenoids AndAlso SecondRomIDType = B2SBaseBox.eRomIDType.Solenoid Then + Dim solenoidid As Integer = SecondRomID + Dim currentvalue As Integer = CInt(solenoidsData.Substring(solenoidid, 1)) + If solenoids(solenoidid) <> currentvalue Then + If Not B2SData.UsedRomSolenoidIDs.ContainsKey(solenoidid) AndAlso Not B2SData.UsedAnimationSolenoidIDs.ContainsKey(solenoidid) AndAlso Not B2SData.UsedRandomAnimationSolenoidIDs.ContainsKey(solenoidid) Then solenoids(solenoidid) = currentvalue + secondVisible = (currentvalue <> 0) + If SecondRomInverted Then secondVisible = Not secondVisible + End If + End If + + Return secondVisible + + End Function + Private Function GetGIStringsSecondVisible(ByVal gistringsData As String, ByVal currentSecondVisible As Boolean) As Boolean + + Dim secondVisible As Boolean = currentSecondVisible + + If B2SData.UseRomGIStrings AndAlso SecondRomIDType = B2SBaseBox.eRomIDType.GIString Then + Dim gistringid As Integer = SecondRomID + Dim currentvalue As Integer = CInt(gistringsData.Substring(gistringid, 1)) + If gistrings(gistringid) <> currentvalue Then + If Not B2SData.UsedRomGIStringIDs.ContainsKey(gistringid) AndAlso Not B2SData.UsedAnimationGIStringIDs.ContainsKey(gistringid) AndAlso Not B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(gistringid) Then gistrings(gistringid) = currentvalue + secondVisible = (currentvalue > 4) + If SecondRomInverted Then secondVisible = Not secondVisible + End If + End If + + Return secondVisible + + End Function + Private Function GetB2SSetsSecondVisible(ByVal b2sSetsData As String, ByVal currentSecondVisible As Boolean) As Boolean + + Dim secondVisible As Boolean = currentSecondVisible + + If B2SData.UseRomLamps AndAlso SecondRomIDType = B2SBaseBox.eRomIDType.Lamp Then + Dim b2ssetid As Integer = SecondRomID + Dim currentvalue As Integer = Asc(b2sSetsData.Substring(b2ssetid, 1)) + If b2sSets(b2ssetid) <> currentvalue Then + If Not B2SData.UsedRomLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedAnimationLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(b2ssetid) Then b2sSets(b2ssetid) = currentvalue + secondVisible = (currentvalue <> 0) + If SecondRomInverted Then secondVisible = Not secondVisible + End If + End If + + Return secondVisible + + End Function + + Private Sub GetThruAllLamps(ByVal lampsData As String) + + If B2SData.UseRomLamps Then + For Each lampid As Integer In B2SData.UsedRomLampIDs.Keys + If lampid < lampsData.Length And lampid < lamps.Length Then + Dim currentvalue As Integer = CInt(lampsData.Substring(lampid, 1)) + If lamps(lampid) <> currentvalue Then + If Not B2SData.UsedRomReelLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedAnimationLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then lamps(lampid) = currentvalue + If B2SData.UsedRomLampIDs.ContainsKey(lampid) Then + For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(lampid) + If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then + If picbox.RomIDValue > 0 Then + picbox.Visible = (picbox.RomIDValue = currentvalue) + Else + Dim visible As Boolean = (currentvalue <> 0) + If picbox.RomInverted Then visible = Not visible + If B2SData.UseRotatingImage AndAlso B2SData.RotatingPictureBox(0) IsNot Nothing AndAlso picbox.Equals(B2SData.RotatingPictureBox(0)) Then + If visible Then + StartRotation() + Else + StopRotation() + End If + Else + picbox.Visible = visible + End If + End If + End If + Next + End If + End If + End If + Next + End If + If B2SData.UseRomReelLamps Then + For Each lampid As Integer In B2SData.UsedRomReelLampIDs.Keys + If lampid < lampsData.Length And lampid < lamps.Length Then + Dim currentvalue As Integer = CInt(lampsData.Substring(lampid, 1)) + If lamps(lampid) <> currentvalue Then + If Not B2SData.UsedAnimationLampIDs.ContainsKey(lampid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then lamps(lampid) = currentvalue + If B2SData.UsedRomReelLampIDs.ContainsKey(lampid) Then + For Each reelbox As B2SReelBox In B2SData.UsedRomReelLampIDs(lampid) + If reelbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(reelbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(reelbox.GroupName)) Then + If reelbox.RomIDValue > 0 Then + reelbox.Illuminated = (reelbox.RomIDValue = currentvalue) + Else + Dim illuminated As Boolean = (currentvalue <> 0) + If reelbox.RomInverted Then illuminated = Not illuminated + reelbox.Illuminated = illuminated + End If + End If + Next + End If + End If + End If + Next + End If + If B2SData.UseAnimationLamps Then + For Each lampid As Integer In B2SData.UsedAnimationLampIDs.Keys + If lampid < lampsData.Length And lampid < lamps.Length Then + Dim currentvalue As Integer = CInt(lampsData.Substring(lampid, 1)) + If lamps(lampid) <> currentvalue Then + If Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then lamps(lampid) = currentvalue + If B2SData.UsedAnimationLampIDs.ContainsKey(lampid) Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationLampIDs(lampid) + Dim start As Boolean = (currentvalue <> 0) + If animation.Inverted Then start = Not start + If start Then + StartAnimation(animation.AnimationName) + Else + StopAnimation(animation.AnimationName) + End If + Next + End If + End If + End If + Next + ' random animation start + For Each lampid As Integer In B2SData.UsedRandomAnimationLampIDs.Keys + If lampid < lampsData.Length And lampid < lamps.Length Then + Dim currentvalue As Integer = CInt(lampsData.Substring(lampid, 1)) + If lamps(lampid) <> currentvalue Then + lamps(lampid) = currentvalue + If B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then + Dim start As Boolean = (currentvalue <> 0) + Dim isrunning As Boolean = False + If start Then + For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationLampIDs(lampid) + If IsAnimationRunning(matchinganimation.AnimationName) Then + isrunning = True + Exit For + End If + Next + End If + If start Then + If Not isrunning Then + Dim random As Integer = RandomStarter(B2SData.UsedRandomAnimationLampIDs(lampid).Length) + Dim animation As B2SData.AnimationInfo = B2SData.UsedRandomAnimationLampIDs(lampid)(random) + lastRandomStartedAnimation = animation.AnimationName + StartAnimation(lastRandomStartedAnimation) + End If + Else + If Not String.IsNullOrEmpty(lastRandomStartedAnimation) Then + StopAnimation(lastRandomStartedAnimation) + lastRandomStartedAnimation = String.Empty + End If + End If + End If + End If + End If + Next + End If + + End Sub + + Private Sub GetThruAllSolenoids(ByVal solenoidsData As String) + + If B2SData.UseRomSolenoids Then + For Each solenoidid As Integer In B2SData.UsedRomSolenoidIDs.Keys + If solenoidid < solenoidsData.Length Then + Dim currentvalue As Integer = CInt(solenoidsData.Substring(solenoidid, 1)) + If solenoids(solenoidid) <> currentvalue Then + If Not B2SData.UsedAnimationSolenoidIDs.ContainsKey(solenoidid) AndAlso Not B2SData.UsedRandomAnimationSolenoidIDs.ContainsKey(solenoidid) Then solenoids(solenoidid) = currentvalue + If B2SData.UsedRomSolenoidIDs.ContainsKey(solenoidid) Then + For Each picbox As B2SPictureBox In B2SData.UsedRomSolenoidIDs(solenoidid) + '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 <> 0) + If picbox.RomInverted Then visible = Not visible + If B2SData.UseRotatingImage AndAlso B2SData.RotatingPictureBox(0) IsNot Nothing AndAlso picbox.Equals(B2SData.RotatingPictureBox(0)) Then + If visible Then + StartRotation() + Else + StopRotation() + End If + Else + picbox.Visible = visible + End If + End If + Next + End If + End If + End If + Next + End If + If B2SData.UseAnimationSolenoids Then + For Each solenoidid As Integer In B2SData.UsedAnimationSolenoidIDs.Keys + If solenoidid < solenoidsData.Length Then + Dim currentvalue As Integer = CInt(solenoidsData.Substring(solenoidid, 1)) + If solenoids(solenoidid) <> currentvalue Then + If Not B2SData.UsedRandomAnimationSolenoidIDs.ContainsKey(solenoidid) Then solenoids(solenoidid) = currentvalue + If B2SData.UsedAnimationSolenoidIDs.ContainsKey(solenoidid) Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationSolenoidIDs(solenoidid) + Dim start As Boolean = (currentvalue <> 0) + If animation.Inverted Then start = Not start + If start Then + StartAnimation(animation.AnimationName) + Else + StopAnimation(animation.AnimationName) + End If + Next + End If + End If + End If + Next + ' random animation start + For Each solenoidid As Integer In B2SData.UsedRandomAnimationSolenoidIDs.Keys + If solenoidid < solenoidsData.Length Then + Dim currentvalue As Integer = CInt(solenoidsData.Substring(solenoidid, 1)) + If solenoids(solenoidid) <> currentvalue Then + solenoids(solenoidid) = currentvalue + If B2SData.UsedRandomAnimationSolenoidIDs.ContainsKey(solenoidid) Then + Dim start As Boolean = (currentvalue <> 0) + Dim isrunning As Boolean = False + If start Then + For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationSolenoidIDs(solenoidid) + If IsAnimationRunning(matchinganimation.AnimationName) Then + isrunning = True + Exit For + End If + Next + End If + If start Then + If Not isrunning Then + Dim random As Integer = RandomStarter(B2SData.UsedRandomAnimationSolenoidIDs(solenoidid).Length) + Dim animation As B2SData.AnimationInfo = B2SData.UsedRandomAnimationSolenoidIDs(solenoidid)(random) + lastRandomStartedAnimation = animation.AnimationName + StartAnimation(lastRandomStartedAnimation) + End If + Else + If Not String.IsNullOrEmpty(lastRandomStartedAnimation) Then + StopAnimation(lastRandomStartedAnimation) + lastRandomStartedAnimation = String.Empty + End If + End If + End If + End If + End If + Next + End If + + End Sub + + Private Sub GetThruAllGIStrings(ByVal gistringsData As String) + + If B2SData.UseRomGIStrings Then + For Each gistringid As Integer In B2SData.UsedRomGIStringIDs.Keys + If gistringid < gistringsData.Length Then + 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 + 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 + If B2SData.UseRotatingImage AndAlso B2SData.RotatingPictureBox(0) IsNot Nothing AndAlso picbox.Equals(B2SData.RotatingPictureBox(0)) Then + If visible Then + StartRotation() + Else + StopRotation() + End If + Else + picbox.Visible = visible + End If + End If + Next + End If + End If + End If + Next + End If + If B2SData.UseAnimationGIStrings Then + For Each gistringid As Integer In B2SData.UsedAnimationGIStringIDs.Keys + If gistringid < gistringsData.Length Then + Dim currentvalue As Integer = CInt(gistringsData.Substring(gistringid, 1)) + If gistrings(gistringid) <> currentvalue Then + If Not B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(gistringid) Then gistrings(gistringid) = currentvalue + If B2SData.UsedAnimationGIStringIDs.ContainsKey(gistringid) Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationGIStringIDs(gistringid) + Dim start As Boolean = (currentvalue > 4) + If animation.Inverted Then start = Not start + If start Then + StartAnimation(animation.AnimationName) + Else + StopAnimation(animation.AnimationName) + End If + Next + End If + End If + End If + Next + ' random animation start + For Each gistringid As Integer In B2SData.UsedRandomAnimationGIStringIDs.Keys + If gistringid < gistringsData.Length Then + Dim currentvalue As Integer = CInt(gistringsData.Substring(gistringid, 1)) + If gistrings(gistringid) <> currentvalue Then + gistrings(gistringid) = currentvalue + If B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(gistringid) Then + Dim start As Boolean = (currentvalue > 4) + Dim isrunning As Boolean = False + If start Then + For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationGIStringIDs(gistringid) + If IsAnimationRunning(matchinganimation.AnimationName) Then + isrunning = True + Exit For + End If + Next + End If + If start Then + If Not isrunning Then + Dim random As Integer = RandomStarter(B2SData.UsedRandomAnimationGIStringIDs(gistringid).Length) + Dim animation As B2SData.AnimationInfo = B2SData.UsedRandomAnimationGIStringIDs(gistringid)(random) + lastRandomStartedAnimation = animation.AnimationName + StartAnimation(lastRandomStartedAnimation) + End If + Else + If Not String.IsNullOrEmpty(lastRandomStartedAnimation) Then + StopAnimation(lastRandomStartedAnimation) + lastRandomStartedAnimation = String.Empty + End If + End If + End If + End If + End If + Next + End If + + End Sub + + Private Sub GetThruAllB2SData(ByVal b2sSetData As String) + + If B2SData.UseRomLamps Then + For Each b2ssetid As Integer In B2SData.UsedRomLampIDs.Keys + If b2ssetid < b2sSetData.Length Then + Dim currentvalue As Integer = Asc(b2sSetData.Substring(b2ssetid, 1)) + If b2sSets(b2ssetid) <> currentvalue Then + If Not B2SData.UsedRomReelLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedAnimationLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(b2ssetid) Then b2sSets(b2ssetid) = currentvalue + If B2SData.UsedRomLampIDs.ContainsKey(b2ssetid) Then + For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(b2ssetid) + If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then + If picbox.RomIDValue > 0 Then + picbox.Visible = (picbox.RomIDValue = currentvalue) + Else + Dim visible As Boolean = (currentvalue <> 0) + If picbox.RomInverted Then visible = Not visible + If B2SData.UseRotatingImage AndAlso B2SData.RotatingPictureBox(0) IsNot Nothing AndAlso picbox.Equals(B2SData.RotatingPictureBox(0)) Then + If visible Then + StartRotation() + Else + StopRotation() + End If + Else + picbox.Visible = visible + End If + End If + End If + Next + End If + End If + End If + Next + End If + If B2SData.UseRomReelLamps Then + For Each b2ssetid As Integer In B2SData.UsedRomReelLampIDs.Keys + If b2ssetid < b2sSetData.Length Then + Dim currentvalue As Integer = Asc(b2sSetData.Substring(b2ssetid, 1)) + If b2sSets(b2ssetid) <> currentvalue Then + If Not B2SData.UsedAnimationLampIDs.ContainsKey(b2ssetid) AndAlso Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(b2ssetid) Then b2sSets(b2ssetid) = currentvalue + If B2SData.UsedRomReelLampIDs.ContainsKey(b2ssetid) Then + For Each reelbox As B2SReelBox In B2SData.UsedRomReelLampIDs(b2ssetid) + If reelbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(reelbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(reelbox.GroupName)) Then + If reelbox.RomIDValue > 0 Then + reelbox.Illuminated = (reelbox.RomIDValue = currentvalue) + Else + Dim illuminated As Boolean = (currentvalue <> 0) + If reelbox.RomInverted Then illuminated = Not illuminated + reelbox.Illuminated = illuminated + End If + End If + Next + End If + End If + End If + Next + End If + If B2SData.UseAnimationLamps Then + For Each b2ssetid As Integer In B2SData.UsedAnimationLampIDs.Keys + If b2ssetid < b2sSetData.Length Then + Dim currentvalue As Integer = Asc(b2sSetData.Substring(b2ssetid, 1)) + If b2sSets(b2ssetid) <> currentvalue Then + If Not B2SData.UsedRandomAnimationLampIDs.ContainsKey(b2ssetid) Then b2sSets(b2ssetid) = currentvalue + If B2SData.UsedAnimationLampIDs.ContainsKey(b2ssetid) Then + For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationLampIDs(b2ssetid) + Dim start As Boolean = (currentvalue <> 0) + If animation.Inverted Then start = Not start + If start Then + StartAnimation(animation.AnimationName) + Else + StopAnimation(animation.AnimationName) + End If + Next + End If + End If + End If + Next + ' random animation start + For Each b2ssetid As Integer In B2SData.UsedRandomAnimationLampIDs.Keys + If b2ssetid < b2sSetData.Length Then + Dim currentvalue As Integer = Asc(b2sSetData.Substring(b2ssetid, 1)) + If b2sSets(b2ssetid) <> currentvalue Then + b2sSets(b2ssetid) = currentvalue + If B2SData.UsedRandomAnimationLampIDs.ContainsKey(b2ssetid) Then + Dim start As Boolean = (currentvalue <> 0) + Dim isrunning As Boolean = False + If start Then + For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationLampIDs(b2ssetid) + If IsAnimationRunning(matchinganimation.AnimationName) Then + isrunning = True + Exit For + End If + Next + End If + If start Then + If Not isrunning Then + Dim random As Integer = RandomStarter(B2SData.UsedRandomAnimationLampIDs(b2ssetid).Length) + Dim animation As B2SData.AnimationInfo = B2SData.UsedRandomAnimationLampIDs(b2ssetid)(random) + lastRandomStartedAnimation = animation.AnimationName + StartAnimation(lastRandomStartedAnimation) + End If + Else + If Not String.IsNullOrEmpty(lastRandomStartedAnimation) Then + StopAnimation(lastRandomStartedAnimation) + lastRandomStartedAnimation = String.Empty + End If + End If + End If + End If + End If + Next + End If + + End Sub + + Private Sub GetThruAllMechs(ByVal mechsData As Integer()) + + If B2SData.UseRomMechs Then + For Each mechid As Integer In B2SData.UsedRomMechIDs.Keys + If mechid >= 1 AndAlso mechid <= 5 Then + Dim currentvalue As Integer = mechsData(mechid) + If mechs(mechid) <> currentvalue Then + mechs(mechid) = currentvalue + If B2SData.UsedRomMechIDs.ContainsKey(mechid) Then + If B2SData.RotatingPictureBox(mechid) IsNot Nothing AndAlso B2SData.RotatingImages(mechid) IsNot Nothing AndAlso B2SData.RotatingImages(mechid).Count > 0 AndAlso B2SData.RotatingImages(mechid).ContainsKey(currentvalue) Then + B2SData.RotatingPictureBox(mechid).BackgroundImage = B2SData.RotatingImages(mechid)(currentvalue) + B2SData.RotatingPictureBox(mechid).Visible = True + End If + End If + End If + End If + Next + End If + + End Sub + + Private Sub GetThruAllLEDs(ByVal regkey As RegistryKey) + + If B2SData.UseLEDs OrElse B2SData.UseLEDDisplays OrElse B2SData.UseReels Then + For digit As Integer = 1 To B2SData.ScoreMaxDigit + Dim currentvalue As Integer = regkey.GetValue("B2SLED" & digit.ToString(), 0) + If leds(digit) <> currentvalue Then + leds(digit) = currentvalue + If B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString()) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered Then + ' rendered LEDs are used + Dim ledname As String = "LEDBox" & digit.ToString() + B2SData.LEDs(ledname).Value = currentvalue + ElseIf B2SData.LEDDisplayDigits.ContainsKey(digit - 1) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7 Then + ' Dream 7 displays are used + With B2SData.LEDDisplayDigits(digit - 1) + .LEDDisplay.SetValue(.Digit, currentvalue) + End With + ElseIf B2SData.Reels.ContainsKey("ReelBox" & digit.ToString()) Then + ' reels are used + Dim reelname As String = "ReelBox" & digit.ToString() + Dim reelbox As B2SReelBox = B2SData.Reels(reelname) + If B2SSettings.IsROMControlled Then + reelbox.Value = currentvalue 'ConvertLEDValue4Reels(currentvalue) + Else + If reelbox.ScoreType = B2SReelBox.eScoreType.Scores Then + reelbox.Text(True) = ConvertLEDValue4Reels(currentvalue) + Else + reelbox.Text(False) = currentvalue + End If + End If + End If + End If + Next + End If + + End Sub + + Private Sub GetThruAllAnimations(ByVal regkey As RegistryKey, ByVal animationsdata As String) + + If B2SAnimation.AreThereAnimations Then + If Not String.IsNullOrEmpty(animationsdata) Then + Dim writeAnimationsData As Boolean = False + For Each animationinfo As String In animationsdata.Split(Chr(1)) + If Not String.IsNullOrEmpty(animationinfo) Then + Dim animationname As String = animationinfo.Substring(0, animationinfo.Length - 2) + Dim animationstate As Integer = CInt(animationinfo.Substring(animationinfo.Length - 1)) + If animations.ContainsKey(animationname) Then + If animations(animationname) <> animationstate Then + animations(animationname) = animationstate + If animationstate = 1 OrElse animationstate = 2 Then + B2SAnimation.StartAnimation(animationname, (animationstate = 2)) + ElseIf animationstate = 0 Then + B2SAnimation.StopAnimation(animationname) + End If + writeAnimationsData = True + animationsdata = animationsdata.Replace(animationinfo, animationname & "=9") + End If + Else + animations.Add(animationname, animationstate) + If animationstate = 1 OrElse animationstate = 2 Then + B2SAnimation.StartAnimation(animationname, (animationstate = 2)) + ElseIf animationstate = 0 Then + B2SAnimation.StopAnimation(animationname) + End If + writeAnimationsData = True + animationsdata = animationsdata.Replace(animationinfo, animationname & "=9") + End If + End If + Next + If writeAnimationsData Then + regkey.SetValue("B2SAnimations", animationsdata) + End If + End If + End If + + End Sub + + Private Sub GetThruAllRotations(ByVal regkey As RegistryKey, ByVal rotationsdata As String) + + If Not String.IsNullOrEmpty(rotationsdata) Then + Dim rotationstate As Integer = CInt(rotationsdata) + If rotation <> rotationstate Then + rotation = rotationstate + If rotationstate = 1 Then + StartRotation() + ElseIf rotationstate = 0 Then + StopRotation() + End If + End If + End If + + End Sub + + Private Sub GetThruAllSounds(ByVal regkey As RegistryKey, ByVal soundsdata As String) + + If Not String.IsNullOrEmpty(soundsdata) Then + Dim writeSoundsData As Boolean = False + For Each soundinfo As String In soundsdata.Split(Chr(1)) + If Not String.IsNullOrEmpty(soundinfo) Then + Dim soundname As String = soundinfo.Substring(0, soundinfo.Length - 2) + Dim soundstate As Integer = CInt(soundinfo.Substring(soundinfo.Length - 1)) + If sounds.ContainsKey(soundname) Then + If sounds(soundname) <> soundstate Then + sounds(soundname) = soundstate + If soundstate = 1 Then + PlaySound(soundname) + ElseIf soundstate = 0 Then + StopSound(soundname) + End If + writeSoundsData = True + soundsdata = soundsdata.Replace(soundinfo, soundname & "=9") + End If + Else + sounds.Add(soundname, soundstate) + If soundstate = 1 Then + PlaySound(soundname) + ElseIf soundstate = 0 Then + StopSound(soundname) + End If + writeSoundsData = True + soundsdata = soundsdata.Replace(soundinfo, soundname & "=9") + End If + End If + Next + If writeSoundsData Then + regkey.SetValue("B2SSounds", soundsdata) + End If + End If + + End Sub + + Private Sub GetThruAllScoreDisplays(ByVal regkey As RegistryKey) + + Dim hide As Integer = regkey.GetValue("B2SHideScoreDisplays", -1) + If hide <> -1 Then + regkey.DeleteValue("B2SHideScoreDisplays", False) + If hide = 0 Then + ' show all score displays + ShowScoreDisplays() + ElseIf hide = 1 Then + ' hide all score display + HideScoreDisplays() + End If + End If + + End Sub + + Private Sub GetThruAllIlluGroups(ByVal regkey As RegistryKey) + + Dim illugroups As String = regkey.GetValue("B2SIlluGroupsByName", String.Empty) + If Not String.IsNullOrEmpty(illugroups) Then + regkey.DeleteValue("B2SIlluGroupsByName", False) + ' get thru all illu groups + For Each illugroupinfo As String In illugroups.Split(Chr(1)) + ' only do the lightning stuff if the group has a name + If Not String.IsNullOrEmpty(illugroupinfo) And illugroupinfo.Contains("=") Then + Dim pos As Integer = illugroupinfo.IndexOf("=") + Dim groupname As String = illugroupinfo.Substring(0, pos) + Dim value As Integer = CInt(illugroupinfo.Substring(pos + 1)) + If B2SData.IlluminationGroups.ContainsKey(groupname) Then + ' get all matching picture boxes + For Each picbox As B2SPictureBox In B2SData.IlluminationGroups(groupname) + If picbox.RomIDValue > 0 Then + picbox.Visible = (picbox.RomIDValue = value) + Else + picbox.Visible = (value <> 0) + End If + Next + End If + End If + Next + End If + + End Sub + + Private Function ConvertLEDValue4Reels(ByVal ledvalue As Integer) As Integer + + Dim ret As Integer = 0 + Select Case ledvalue + Case 0, 63 : ret = 0 + Case 6 : ret = 1 + Case 91 : ret = 2 + Case 79 : ret = 3 + Case 102 : ret = 4 + Case 109 : ret = 5 + Case 125 : ret = 6 + Case 7 : ret = 7 + Case 127 : ret = 8 + Case 111 : ret = 9 + End Select + Return ret + + End Function + +#End Region + #Region "settings action" @@ -1691,11 +2888,10 @@ Public Class formBackglass End If Next End If + End If - End If - - ' set info flags to dirty to load them - B2SData.IsInfoDirty = True + ' set info flags to dirty to load them + B2SData.IsInfoDirty = True End If @@ -2157,6 +3353,27 @@ Public Class formBackglass Return Drawing.Color.FromArgb(CInt(colorvalues(0)), CInt(colorvalues(1)), CInt(colorvalues(2))) End Function + Private Sub SetFocusToVPPlayer() + + ' set focus to the VP player + Dim proc As Processes = New Processes() + SetForegroundWindow(proc.TableHandle) + tableHandle = proc.TableHandle + + End Sub + + Private Function RandomStarter(ByVal top As Integer) As Integer + + Static lastone As Integer = -1 + Dim ret As Integer = -1 + Do Until ret >= 0 AndAlso ret < top AndAlso ret <> lastone + Dim random As Random = New Random(Date.Now.Millisecond) + ret = CInt(Math.Truncate(random.NextDouble() * top)) + Loop + lastone = ret + Return ret + + End Function #End Region diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb index 572027e..2e0764e 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb @@ -1,9 +1,9 @@ -Imports System -Imports System.Drawing +Imports System.Drawing Imports System.Windows.Forms Imports System.IO Imports System.Reflection Imports System.Security.Principal +Imports Microsoft.Win32 Public Class formSettings @@ -45,15 +45,17 @@ Public Class formSettings ' load data Dim _isdirty As Boolean = isSettingsScreenDirty Me.Text = "Settings... [" & B2SData.TableFileName & "] " & " (" & If(Not String.IsNullOrEmpty(B2SSettings.GameName), B2SSettings.GameName, B2SSettings.B2SName) & ")" & If(IsAdmin(), " (Administrator)", "") + If B2SSettings.PureEXE Then btnSaveSettings.Enabled = False ' set version info - lblCopyright.Text = String.Format(lblCopyright.Text, My.Application.Info.ProductName.ToString, My.Application.Info.Copyright.ToString) + lblCopyright.Text = String.Format(lblCopyright.Text, If(B2SData.IsBackglassStartedAsEXE, "B2S.Server.EXE", "B2S.Server.DLL"), My.Application.Info.Copyright.ToString) Dim Assembly As Assembly = Assembly.GetExecutingAssembly() Dim FileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Assembly.Location) lblVersion.Text = String.Format("Server version {0} {1}, backglass file version {2}", FileVersionInfo.ProductVersion, If(Environment.Is64BitProcess, "x64", "x86"), B2SSettings.BackglassFileVersion) ' get more data + formSettingsMore.btnLogPath.Text = "Log path: " & B2SSettings.LogPath formSettingsMore.chkLogLamps.Checked = B2SSettings.IsLampsStateLogOn formSettingsMore.chkLogSolenoids.Checked = B2SSettings.IsSolenoidsStateLogOn @@ -415,6 +417,14 @@ Public Class formSettings End Sub Private Sub btnPluginSettings_Click(sender As Object, e As EventArgs) Handles btnPluginSettings.Click B2SSettings.PluginHost.ShowPluginWindow(Me) + If B2SSettings.StartAsEXE And B2SData.IsBackglassStartedAsEXE Then + Using regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("Software\B2S", True) + With Me 'B2SScreen.BackglassScreen.Bounds + regkey.SetValue("PluginsScreen", .Location.X & "," & .Location.Y & "," & .Size.Width & "," & .Size.Height) + End With + regkey.SetValue("PluginsOpenDialog", 1) + End Using + End If End Sub Private Function IsDirty() As Boolean diff --git a/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb b/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb index 874d9ad..8493b9b 100644 --- a/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb +++ b/b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb @@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - - + + + diff --git a/b2sbackglassserverexe/B2SBackglassServerEXE.ico b/b2sbackglassserverexe/B2SBackglassServerEXE.ico new file mode 100644 index 0000000..6cbc31c Binary files /dev/null and b/b2sbackglassserverexe/B2SBackglassServerEXE.ico differ diff --git a/b2sbackglassserverexe/B2SBackglassServerEXE.sln b/b2sbackglassserverexe/B2SBackglassServerEXE.sln new file mode 100644 index 0000000..7ec4776 --- /dev/null +++ b/b2sbackglassserverexe/B2SBackglassServerEXE.sln @@ -0,0 +1,44 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.9.34728.123 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "B2SBackglassServer", "..\b2sbackglassserver\b2sbackglassserver\B2SBackglassServer.vbproj", "{42A57D3D-5D76-4D46-9CF0-0909C7C799C4}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "B2SBackglassServerEXE", "B2SBackglassServerEXE.vbproj", "{1BC7B930-694D-48FC-8C26-98A4398BD51B}" + ProjectSection(ProjectDependencies) = postProject + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4} = {42A57D3D-5D76-4D46-9CF0-0909C7C799C4} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Debug|x64.ActiveCfg = Debug|x64 + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Debug|x64.Build.0 = Debug|x64 + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Release|Any CPU.Build.0 = Release|Any CPU + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Release|x64.ActiveCfg = Release|x64 + {42A57D3D-5D76-4D46-9CF0-0909C7C799C4}.Release|x64.Build.0 = Release|x64 + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Debug|x64.ActiveCfg = Debug|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Debug|x64.Build.0 = Debug|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Release|Any CPU.Build.0 = Release|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Release|x64.ActiveCfg = Release|Any CPU + {1BC7B930-694D-48FC-8C26-98A4398BD51B}.Release|x64.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5F9BB968-681A-4FB2-8074-C179F66DB0F2} + EndGlobalSection +EndGlobal diff --git a/b2sbackglassserverexe/B2SBackglassServerEXE.vbproj b/b2sbackglassserverexe/B2SBackglassServerEXE.vbproj new file mode 100644 index 0000000..aeeab93 --- /dev/null +++ b/b2sbackglassserverexe/B2SBackglassServerEXE.vbproj @@ -0,0 +1,79 @@ + + + + WinExe + net6.0-windows10.0.17763.0 + B2SBackglassServerEXE.Main + True + WindowsFormsWithCustomSubMain + B2SBackglassServerEXE.ico + My Project\app.manifest + 10.0.17763.0 + + + + + + + + + + + + false + false + + + + + + + + + + + + + + + + + + + True + True + Application.myapp + + + True + True + Resources.resx + + + True + True + Settings.settings + + + + + + My.Resources + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + My + SettingsSingleFileGenerator + Settings.Designer.vb + + + + \ No newline at end of file diff --git a/b2sbackglassserverexe/My Project/Application.Designer.vb b/b2sbackglassserverexe/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/b2sbackglassserverexe/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/b2sbackglassserverexe/My Project/Application.myapp b/b2sbackglassserverexe/My Project/Application.myapp new file mode 100644 index 0000000..b56becd --- /dev/null +++ b/b2sbackglassserverexe/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + Form1 + false + 0 + false + 0 + true + \ No newline at end of file diff --git a/b2sbackglassserverexe/My Project/Settings.Designer.vb b/b2sbackglassserverexe/My Project/Settings.Designer.vb new file mode 100644 index 0000000..f016c55 --- /dev/null +++ b/b2sbackglassserverexe/My Project/Settings.Designer.vb @@ -0,0 +1,73 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "My.Settings Auto-Save Functionality" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.B2SBackglassServerEXE.My.MySettings + Get + Return Global.B2SBackglassServerEXE.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/b2sbackglassserverexe/My Project/Settings.settings b/b2sbackglassserverexe/My Project/Settings.settings new file mode 100644 index 0000000..392df0a --- /dev/null +++ b/b2sbackglassserverexe/My Project/Settings.settings @@ -0,0 +1,6 @@ + + + + + + diff --git a/b2sbackglassserverexe/My Project/app.manifest b/b2sbackglassserverexe/My Project/app.manifest new file mode 100644 index 0000000..9ce67d2 --- /dev/null +++ b/b2sbackglassserverexe/My Project/app.manifest @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/b2sbackglassserverexe/My Project/launchSettings.json b/b2sbackglassserverexe/My Project/launchSettings.json new file mode 100644 index 0000000..084405a --- /dev/null +++ b/b2sbackglassserverexe/My Project/launchSettings.json @@ -0,0 +1,8 @@ +{ + "profiles": { + "B2SBackglassServerEXE": { + "commandName": "Project", + "commandLineArgs": "\"4 Square (Gottlieb 1971)\"" + } + } +} \ No newline at end of file diff --git a/b2sbackglassserverexe/Program.vb b/b2sbackglassserverexe/Program.vb new file mode 100644 index 0000000..52c25fb --- /dev/null +++ b/b2sbackglassserverexe/Program.vb @@ -0,0 +1,27 @@ +Imports B2S + +Public Module Main + Sub Main() + + Dim myServer As New EXEServer + + Dim TableFileName As String = "" + Dim topMost As Boolean = False + + If My.Application.CommandLineArgs.Count > 0 Then + TableFileName = My.Application.CommandLineArgs(0).ToString + If My.Application.CommandLineArgs.Count > 1 AndAlso My.Application.CommandLineArgs(1).ToString = "1" Then + topMost = True + End If + Else + MessageBox.Show("Please do not start the EXE this way.", "B2S.Server", MessageBoxButtons.OK, MessageBoxIcon.Error) + End + End If + + Application.EnableVisualStyles() + Application.SetCompatibleTextRenderingDefault(False) + Application.Run(New formBackglass(TableFileName, topMost)) + 'myServer.Run(New formBackglass(TableFileName, topMost)) + End Sub + +End Module diff --git a/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Classes/B2SSettings.vb b/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Classes/B2SSettings.vb index 2ebe7ea..4a0067a 100644 --- a/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Classes/B2SSettings.vb +++ b/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Classes/B2SSettings.vb @@ -7,7 +7,7 @@ Imports Microsoft.Win32 Public Class B2SSettings - Public Const DirectB2SVersion As String = "2.1.2" + Public Const DirectB2SVersion As String = "3.0.0" Public Const MinimumDirectB2SVersion As String = "1.0" Public Shared Property BackglassFileVersion() As String = String.Empty diff --git a/b2sbackglassserverexe_tmp/b2sbackglassserverexe/My Project/AssemblyInfo.vb b/b2sbackglassserverexe_tmp/b2sbackglassserverexe/My Project/AssemblyInfo.vb index 6b461ea..5c728d1 100644 --- a/b2sbackglassserverexe_tmp/b2sbackglassserverexe/My Project/AssemblyInfo.vb +++ b/b2sbackglassserverexe_tmp/b2sbackglassserverexe/My Project/AssemblyInfo.vb @@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - - + + + diff --git a/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Server.vb b/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Server.vb index 6a81e37..87710e6 100644 --- a/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Server.vb +++ b/b2sbackglassserverexe_tmp/b2sbackglassserverexe/Server.vb @@ -452,7 +452,7 @@ Public Class Server ElseIf secondvisible Then formBackglass.BackgroundImage = formBackglass.SecondLightImage Else - formBackglass.BackgroundImage = formBackglass.LightImage + formBackglass.BackgroundImage = formBackglass.DarkImage B2SData.IsOffImageVisible = True End If End If @@ -615,7 +615,7 @@ Public Class Server ElseIf secondvisible Then formBackglass.BackgroundImage = formBackglass.SecondLightImage Else - formBackglass.BackgroundImage = formBackglass.LightImage + formBackglass.BackgroundImage = formBackglass.DarkImage B2SData.IsOffImageVisible = True End If End If @@ -736,7 +736,7 @@ Public Class Server ElseIf secondvisible Then formBackglass.BackgroundImage = formBackglass.SecondLightImage Else - formBackglass.BackgroundImage = formBackglass.LightImage + formBackglass.BackgroundImage = formBackglass.DarkImage B2SData.IsOffImageVisible = True End If End If diff --git a/b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb b/b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb index 9e79be9..abcb5d5 100644 --- a/b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb +++ b/b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb @@ -31,6 +31,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - - + + +