Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into 84-merge-th…
Browse files Browse the repository at this point in the history
…e-dll-and-exe-backglass-features
  • Loading branch information
JockeJarre committed May 9, 2024
2 parents 32685b6 + 2e001ca commit 564d1ed
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 89 deletions.
2 changes: 2 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
2 = new PWM mode (all solenoids but also lamps, and value if physic meaning, not smoothed out binary state)
For this new mode, we now hardcode a value 64, if the lamp intensity exceed this value, it is binary 1
- b2s_screenresidentifier: Add Comments hidded behind the taskbar #77
- "Fantasy" setting in B2STableSettings.xml is ignored #93
- re-registering B2S.Server should first cleanup earlier entries #98

2.1.0

Expand Down
2 changes: 1 addition & 1 deletion b2sbackglassserver/b2sbackglassserver/B2SInit.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ REM Cut holes in the destination "B2S Backglass Server" & "B2S DMD" forms
set "B2SWindowPunch=^B2S Backglass$|^B2S Backglass Server$|^B2S DMD$"

REM using "Virtual DMD", "Virtual Alphanumeric" and all "PUPSCREEN" forms as regular expressions
set "cutter=^Virtual DMD$|^Virtual Alphanumeric Display$|^PUPSCREEN[0-9]+$|^VPinMAME:"
set "cutter=^Virtual DMD$|^Virtual Alphanumeric Display$|^PUPSCREEN[0-9]+$|^VPinMAME:|^PROC:"

REM Check if there is any table specific settings for B2SWindowPunch
if exist "%resfile%" for /f "usebackq eol=# tokens=1,2 delims==" %%G in (`findstr /R "^[A-Za-z0-9][A-Za-z0-9]*=" "%resfile%"`) do set "%%G=%%H"
Expand Down
59 changes: 31 additions & 28 deletions b2sbackglassserver/b2sbackglassserver/Server.vb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Imports System.Text
Imports System.Runtime.InteropServices
Imports Microsoft.Win32
Imports System.Linq.Expressions

<ProgId("B2S.Server"), ComClass(Server.ClassID, Server.InterfaceID, Server.EventsID)>
Public Class Server
Expand All @@ -25,7 +26,8 @@ Public Class Server
Private tableHandle As Integer = 0
Private tableCount As Integer = 0
Private tableReset As Boolean = False
Private lamplighted As Integer = 0
Private lampThreshold As Integer = 0
Private giStringThreshold As Integer = 4

Private isChangedLampsCalled As Boolean = False
Private isChangedSolenoidsCalled As Boolean = False
Expand Down Expand Up @@ -809,7 +811,7 @@ Public Class Server

' get lamp data
Dim lampid As Integer = lampdata.Key
Dim lampstate As Integer = lampdata.Value.State
Dim lampstate As Boolean = lampdata.Value.State > lampThreshold
Dim datatypes As Integer = lampdata.Value.Types

' maybe write log
Expand All @@ -821,7 +823,7 @@ Public Class Server

' enter new lamp state
sb.Remove(lampid, 1)
If lampstate > lamplighted Then
If lampstate Then
sb.Insert(lampid, "1")
Else
sb.Insert(lampid, "0")
Expand All @@ -834,10 +836,10 @@ Public Class Server
Dim topvisible As Boolean = lastTopVisible
Dim secondvisible As Boolean = lastSecondVisible
If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 Then
topvisible = (lampstate > lamplighted)
topvisible = lampstate
If formBackglass.TopRomInverted Then topvisible = Not topvisible
ElseIf (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then
secondvisible = (lampstate > lamplighted)
secondvisible = lampstate
If formBackglass.SecondRomInverted Then topvisible = Not topvisible
End If
If lastTopVisible <> topvisible OrElse lastSecondVisible <> secondvisible OrElse Not isVisibleStateSet Then
Expand All @@ -861,7 +863,7 @@ Public Class Server
For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(lampid)
'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 = (lampstate > lamplighted)
Dim visible As Boolean = lampstate
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
Expand All @@ -880,7 +882,7 @@ Public Class Server
If (datatypes And B2SCollectData.eCollectedDataType.Animation) <> 0 Then
If B2SData.UsedAnimationLampIDs.ContainsKey(lampid) Then
For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationLampIDs(lampid)
Dim start As Boolean = (lampstate > lamplighted)
Dim start As Boolean = lampstate
If animation.Inverted Then start = Not start
If start Then
formBackglass.StartAnimation(animation.AnimationName)
Expand All @@ -891,7 +893,7 @@ Public Class Server
End If
' random animation start
If B2SData.UsedRandomAnimationLampIDs.ContainsKey(lampid) Then
Dim start As Boolean = (lampstate > lamplighted)
Dim start As Boolean = lampstate
Dim isrunning As Boolean = False
If start Then
For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationLampIDs(lampid)
Expand Down Expand Up @@ -1248,23 +1250,23 @@ Public Class Server
sb.Append(Registry.CurrentUser.OpenSubKey("Software\B2S").GetValue("B2SGIStrings", New String("0", 251)).ToString())
End If

For Each gistringdata As KeyValuePair(Of Integer, B2SCollectData.CollectData) In collectGIStringsData
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
Dim giStringId As Integer = giStringData.Key
Dim giStringBool As Boolean = giStringData.Value.State > giStringThreshold
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 & ")")
statelogChangedGIStrings.WriteLogEntry(DateTime.Now & ": Applying data (" & collectGIStringsData.Count & ") : " & giStringId & " - " & giStringBool & " (" & datatypes & ")")
End If

If B2SData.IsBackglassStartedAsEXE Then

' enter new gistring state
sb.Remove(gistringid, 1)
sb.Insert(gistringid, gistringstate.ToString())
sb.Remove(giStringId, 1)
sb.Insert(giStringId, If(giStringBool, "5", "0"))

Else

Expand All @@ -1273,10 +1275,10 @@ Public Class Server
Dim topvisible As Boolean = lastTopVisible
Dim secondvisible As Boolean = lastSecondVisible
If (datatypes And B2SCollectData.eCollectedDataType.TopImage) <> 0 Then
topvisible = (gistringstate > 4)
topvisible = giStringBool
If formBackglass.TopRomInverted Then topvisible = Not topvisible
ElseIf (datatypes And B2SCollectData.eCollectedDataType.SecondImage) <> 0 Then
secondvisible = (gistringstate > 4)
secondvisible = giStringBool
If formBackglass.SecondRomInverted Then topvisible = Not topvisible
End If
If lastTopVisible <> topvisible OrElse lastSecondVisible <> secondvisible OrElse Not isVisibleStateSet Then
Expand All @@ -1297,10 +1299,10 @@ Public Class Server
End If
End If
If (datatypes And B2SCollectData.eCollectedDataType.Standard) <> 0 Then
For Each picbox As B2SPictureBox In B2SData.UsedRomGIStringIDs(gistringid)
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 = (gistringstate > 4)
Dim visible As Boolean = giStringBool
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
Expand All @@ -1317,9 +1319,9 @@ Public Class Server

' animation stuff
If (datatypes And B2SCollectData.eCollectedDataType.Animation) <> 0 Then
If B2SData.UsedAnimationGIStringIDs.ContainsKey(gistringid) Then
For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationGIStringIDs(gistringid)
Dim start As Boolean = (gistringstate > 4)
If B2SData.UsedAnimationGIStringIDs.ContainsKey(giStringId) Then
For Each animation As B2SData.AnimationInfo In B2SData.UsedAnimationGIStringIDs(giStringId)
Dim start As Boolean = giStringBool
If animation.Inverted Then start = Not start
If start Then
formBackglass.StartAnimation(animation.AnimationName)
Expand All @@ -1329,11 +1331,11 @@ Public Class Server
Next
End If
' random animation start
If B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(gistringid) Then
Dim start As Boolean = (gistringstate > 4)
If B2SData.UsedRandomAnimationGIStringIDs.ContainsKey(giStringId) Then
Dim start As Boolean = giStringBool
Dim isrunning As Boolean = False
If start Then
For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationGIStringIDs(gistringid)
For Each matchinganimation As B2SData.AnimationInfo In B2SData.UsedRandomAnimationGIStringIDs(giStringId)
If formBackglass.IsAnimationRunning(matchinganimation.AnimationName) Then
isrunning = True
Exit For
Expand All @@ -1342,8 +1344,8 @@ Public Class Server
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)
Dim random As Integer = RandomStarter(B2SData.UsedRandomAnimationGIStringIDs(giStringId).Length)
Dim animation As B2SData.AnimationInfo = B2SData.UsedRandomAnimationGIStringIDs(giStringId)(random)
lastRandomStartedAnimation = animation.AnimationName
formBackglass.StartAnimation(lastRandomStartedAnimation)
End If
Expand Down Expand Up @@ -1578,7 +1580,8 @@ Public Class Server
' 1 = modulated (PWM) solenoid (exist for some years already)
' 2 = new PWM mode (all solenoids but also lamps, and value if physic meaning, not smoothed out binary state)
' For this new mode, we now hardcode a value 64, if the lamp intensity exceed this value, it is binary 1
If number = 2 Then lamplighted = If(value = 2, 64, 0)
If number = 2 Then lampThreshold = If(value = 2, 64, 0)
If number = 2 Then giStringThreshold = If(value = 2, 64, 4)
End Set
End Property

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Imports System
Imports System
Imports System.Drawing
Imports System.IO
Imports System.Windows.Forms
Expand Down Expand Up @@ -1800,7 +1800,7 @@ Public Class formBackglass
' get top node
Dim topnode As Xml.XmlElement = XML.SelectSingleNode("DirectB2SData")
Dim mergeBulbs As Boolean = topnode.SelectSingleNode("MergeBulbs") IsNot Nothing AndAlso topnode.SelectSingleNode("MergeBulbs").Attributes("Value").InnerText <> "0"

mergeBulbs = True
' clear all data
B2SData.ClearAll(True)

Expand Down
Loading

0 comments on commit 564d1ed

Please sign in to comment.