From c13ccd024ebc53a3aef1ce3d14ed9e3f9c044315 Mon Sep 17 00:00:00 2001 From: Jarr3 Date: Thu, 4 Jul 2024 05:50:42 +0200 Subject: [PATCH] Remodel version into one file Classes/B2SVersionInfo.vb which is then used everywhere. Add new B2SServerBuild COM method returning float: 20500.0123 --- .github/workflows/b2s-backglass.yml | 47 ++++++++++++++----- .../B2SBackglassServer.vbproj | 17 +++++-- .../B2SBackglassServerEXE.vbproj | 13 +++-- .../b2sbackglassserver/Classes/B2SSettings.vb | 1 - .../Classes/B2SVersionInfo.vb | 17 +++++++ .../b2sbackglassserver/Forms/formBackglass.vb | 4 +- .../b2sbackglassserver/Forms/formSettings.vb | 8 +--- .../b2sbackglassserver/Server.vb | 42 +++++++++++------ 8 files changed, 104 insertions(+), 45 deletions(-) create mode 100644 b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb diff --git a/.github/workflows/b2s-backglass.yml b/.github/workflows/b2s-backglass.yml index 59cdf4d..df6fea3 100644 --- a/.github/workflows/b2s-backglass.yml +++ b/.github/workflows/b2s-backglass.yml @@ -29,27 +29,48 @@ jobs: name: Update AssemblyInformationalVersion run: | SHA7="${GITHUB_SHA::7}" - : # B2SServerPluginInterface - ASSEMBLY_INFO="B2SServerPluginInterface/B2SServerPluginInterface/Properties/AssemblyInfo.cs" - VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1) - TAG="${VERSION}-${SHA7}" - echo -e "\n[assembly: AssemblyInformationalVersion(\"${TAG}\")]" >> "${ASSEMBLY_INFO}" + : # Fetch version + VERSION_INFO="b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb" + VERSION_MAJOR=$(grep -Eo "B2S_VERSION_MAJOR\s+=\s\"[0-9]+\"" "${VERSION_INFO}" | grep -Eo "[0-9]+" | tail -1) + VERSION_MINOR=$(grep -Eo "B2S_VERSION_MINOR\s+=\s\"[0-9]+\"" "${VERSION_INFO}" | grep -Eo "[0-9]+" | tail -1) + VERSION_REV=$(grep -Eo "B2S_VERSION_REVISION\s+=\s\"[0-9]+\"" "${VERSION_INFO}" | grep -Eo "[0-9]+" | tail -1) + VERSION_MINI="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}" + VERSION_SHORT="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}.${{ github.run_number }}" + VERSION_LONG="${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REV}.${{ github.run_number }}-${SHA7}" + echo VERSION_MINI ${VERSION_MINI} + echo VERSION_SHORT ${VERSION_SHORT} + echo VERSION_LONG ${VERSION_LONG} : # b2sbackglassserver + perl -i -pe"s/B2S_VERSION_BUILD\s+=\s+\".*\"/B2S_VERSION_BUILD = \"${{ github.run_number }}\"/g" "${VERSION_INFO}" + perl -i -pe"s/B2S_VERSION_HASH\s+=\s+\".*\"/B2S_VERSION_HASH = \"${SHA7}\"/g" "${VERSION_INFO}" ASSEMBLY_INFO="b2sbackglassserver/b2sbackglassserver/My Project/AssemblyInfo.vb" - VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1).${{ github.run_number }} - TAG="${VERSION}-${SHA7}" - perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}" : # b2s_screenresidentifier ASSEMBLY_INFO="b2s_screenresidentifier/b2s_screenresidentifier/My Project/AssemblyInfo.vb" - perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}" : # b2sbackglassserverregisterapp ASSEMBLY_INFO="b2sbackglassserverregisterapp/b2sbackglassserverregisterapp/My Project/AssemblyInfo.vb" - perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}" : # B2SWindowPunch ASSEMBLY_INFO="B2SWindowPunch/B2SWindowPunch/Properties/AssemblyInfo.cs" - perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${TAG}\"\)/g" "${ASSEMBLY_INFO}" - : # Keep the TAG for later - echo "tag=${TAG}" >> $GITHUB_OUTPUT + perl -i -pe"s/AssemblyVersion\(\".*\"\)/AssemblyVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyFileVersion\(\".*\"\)/AssemblyFileVersion\(\"${VERSION_SHORT}\"\)/g" "${ASSEMBLY_INFO}" + perl -i -pe"s/AssemblyInformationalVersion\(\".*\"\)/AssemblyInformationalVersion\(\"${VERSION_LONG}\"\)/g" "${ASSEMBLY_INFO}" + : # B2SServerPluginInterface + ASSEMBLY_INFO="B2SServerPluginInterface/B2SServerPluginInterface/Properties/AssemblyInfo.cs" + VERSION=$(grep -Eo "AssemblyVersion\(.*\)" "${ASSEMBLY_INFO}" | grep -Eo "[0-9\.]+" | tail -1) + TAG="${VERSION::5}.${{ github.run_number }}" + perl -i -pe"s/AssemblyConfiguration\(\"\"\)/AssemblyConfiguration\(\"Compiled by B2S.Server\"\)/g" "${ASSEMBLY_INFO}" + echo -e "\n[assembly: AssemblyFileVersion(\"${TAG}\")]" >> "${ASSEMBLY_INFO}" + echo -e "\n[assembly: AssemblyInformationalVersion(\"${TAG}-${SHA7}\")]" >> "${ASSEMBLY_INFO}" + : # Keep the VERSION_LONG for later + echo "tag=${VERSION_LONG}" >> $GITHUB_OUTPUT - uses: microsoft/setup-msbuild@v2 - name: Build B2SServerPluginInterface run: | diff --git a/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj b/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj index 48ea7d0..ac6d1b0 100644 --- a/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj +++ b/b2sbackglassserver/b2sbackglassserver/B2SBackglassServer.vbproj @@ -10,10 +10,14 @@ 512 Windows v4.8 - SAK - SAK - SAK - SAK + + + + + + + + B2S="DLL" @@ -99,6 +103,7 @@ + Component @@ -188,6 +193,7 @@ Background.vb + Designer formBackglass.vb @@ -195,9 +201,11 @@ formDMD.vb + Designer formMode.vb + Designer formSettings.vb @@ -205,6 +213,7 @@ formSettingsMore.vb + Designer VbMyResourcesResXFileCodeGenerator diff --git a/b2sbackglassserver/b2sbackglassserver/B2SBackglassServerEXE.vbproj b/b2sbackglassserver/b2sbackglassserver/B2SBackglassServerEXE.vbproj index 842b8f7..cb9cbe9 100644 --- a/b2sbackglassserver/b2sbackglassserver/B2SBackglassServerEXE.vbproj +++ b/b2sbackglassserver/b2sbackglassserver/B2SBackglassServerEXE.vbproj @@ -10,10 +10,14 @@ 512 WindowsFormsWithCustomSubMain v4.8 - SAK - SAK - SAK - SAK + + + + + + + + publish\ true @@ -160,6 +164,7 @@ + Component diff --git a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb index 337a85d..0e1b995 100644 --- a/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SSettings.vb @@ -7,7 +7,6 @@ Imports Microsoft.Win32 Public Class B2SSettings - 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/b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb b/b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb new file mode 100644 index 0000000..97e8d90 --- /dev/null +++ b/b2sbackglassserver/b2sbackglassserver/Classes/B2SVersionInfo.vb @@ -0,0 +1,17 @@ +' Add VersionInfo class + +Public Class B2SVersionInfo + Public Const B2S_VERSION_MAJOR = "2" + Public Const B2S_VERSION_MINOR = "5" + Public Const B2S_VERSION_REVISION = "0" + Public Const B2S_VERSION_BUILD = "999" + Public Const B2S_VERSION_HASH = "nonset" + ' 2.5.0 + Public Const B2S_VERSION_STRING = B2S_VERSION_MAJOR & "." & B2S_VERSION_MINOR & "." & B2S_VERSION_REVISION + ' 2.5.0.999 + Public Const B2S_BUILD_STRING = B2S_VERSION_MAJOR & "." & B2S_VERSION_MINOR & "." & + B2S_VERSION_REVISION & "." & B2S_VERSION_BUILD + ' 2.5.0.999-nonset Git hash + Public Const B2S_BUILD_STRING_HASH = B2S_VERSION_MAJOR & "." & B2S_VERSION_MINOR & "." & + B2S_VERSION_REVISION & "." & B2S_VERSION_BUILD & "-" & B2S_VERSION_HASH +End Class \ No newline at end of file diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb index 61bd542..f96265e 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formBackglass.vb @@ -2002,9 +2002,9 @@ Public Class formBackglass End Using #End If ' current backglass version is not allowed to be larger than server version and to be smaller minimum B2S version - If B2SSettings.BackglassFileVersion > B2SSettings.DirectB2SVersion Then + If B2SSettings.BackglassFileVersion > B2SVersionInfo.B2S_VERSION_STRING Then - Throw New Exception("B2S.Server version (" & B2SSettings.DirectB2SVersion & ") doesn't match 'directb2s' file version (" & B2SSettings.BackglassFileVersion & "). " & vbCrLf & vbCrLf & + Throw New Exception("B2S.Server version (" & B2SVersionInfo.B2S_VERSION_STRING & ") doesn't match 'directb2s' file version (" & B2SSettings.BackglassFileVersion & "). " & vbCrLf & vbCrLf & "Please update the B2S.Server.") ElseIf B2SSettings.BackglassFileVersion < B2SSettings.MinimumDirectB2SVersion Then diff --git a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb index fea7958..47d4d69 100644 --- a/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb +++ b/b2sbackglassserver/b2sbackglassserver/Forms/formSettings.vb @@ -53,16 +53,10 @@ Public Class formSettings ' set version info #If B2S = "DLL" Then lblCopyright.Text = String.Format(lblCopyright.Text, "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) #Else lblCopyright.Text = String.Format(lblCopyright.Text, "B2S.Server.EXE", My.Application.Info.Copyright.ToString) - lblVersion.Text = String.Format("Server version {0} {1}, backglass file version {2}", Application.ProductVersion, If(Environment.Is64BitProcess, "x64", "x86"), B2SSettings.BackglassFileVersion) #End If - - + lblVersion.Text = String.Format("Server version {0} {1}, backglass file version {2}", B2SVersionInfo.B2S_BUILD_STRING_HASH, If(Environment.Is64BitProcess, "x64", "x86"), B2SSettings.BackglassFileVersion) ' get more data diff --git a/b2sbackglassserver/b2sbackglassserver/Server.vb b/b2sbackglassserver/b2sbackglassserver/Server.vb index b47f9f5..8555ad3 100644 --- a/b2sbackglassserver/b2sbackglassserver/Server.vb +++ b/b2sbackglassserver/b2sbackglassserver/Server.vb @@ -4,6 +4,8 @@ Imports System.Runtime.InteropServices Imports Microsoft.Win32 Imports System.Linq.Expressions Imports System.Drawing +Imports System.Reflection +Imports System.Runtime.InteropServices.WindowsRuntime Public Class Server @@ -268,10 +270,20 @@ Public Class Server Public ReadOnly Property B2SServerVersion() As String Get - Return B2SSettings.DirectB2SVersion + Return B2SVersionInfo.B2S_VERSION_STRING End Get End Property + Public ReadOnly Property B2SServerBuild() As Double + Get + Return CInt(B2SVersionInfo.B2S_VERSION_MAJOR) * 10000 + + CInt(B2SVersionInfo.B2S_VERSION_MINOR) * 100 + + CInt(B2SVersionInfo.B2S_VERSION_REVISION) + + CInt(B2SVersionInfo.B2S_VERSION_BUILD) / 10000 + End Get + End Property + + Public ReadOnly Property B2SServerDirectory() As String Get Return System.Reflection.Assembly.GetExecutingAssembly().Location @@ -2148,13 +2160,15 @@ Public Class Server For Each picbox As B2SPictureBox In B2SData.UsedRomLampIDs(id) If picbox IsNot Nothing AndAlso (Not B2SData.UseIlluminationLocks OrElse String.IsNullOrEmpty(picbox.GroupName) OrElse Not B2SData.IlluminationLocks.ContainsKey(picbox.GroupName)) Then - picbox.Left = xpos - picbox.Top = ypos - ' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes. - picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height) - 'Invalidating this object does not work, need to Invalidate the parent. - If picbox.Parent IsNot Nothing Then - picbox.Parent.Invalidate() + If picbox.Left <> xpos OrElse picbox.Top <> ypos Then + picbox.Left = xpos + picbox.Top = ypos + ' Using RectangleF as this is used in the DrawImage within OnPaint for picturBoxes. + picbox.RectangleF = New RectangleF(CInt(picbox.Left / rescaleBackglass.Width), CInt(picbox.Top / rescaleBackglass.Height), picbox.RectangleF.Width, picbox.RectangleF.Height) + 'Invalidating this object does not work, need to Invalidate the parent. + If picbox.Parent IsNot Nothing Then + picbox.Parent.Invalidate() + End If End If End If Next @@ -2168,8 +2182,8 @@ Public Class Server If Not B2SData.IsBackglassRunning Then Return - Dim useLEDs As Boolean = (B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString()) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered) - Dim useLEDDisplays As Boolean = (B2SData.LEDDisplayDigits.ContainsKey(digit - 1) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7) + 'Dim useLEDs As Boolean = (B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString()) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered) + 'Dim useLEDDisplays As Boolean = (B2SData.LEDDisplayDigits.ContainsKey(digit - 1) AndAlso B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7) If B2SData.IsBackglassStartedAsEXE Then @@ -2177,16 +2191,16 @@ Public Class Server regkey.SetValue("B2SLED" & digit.ToString(), value) End Using - ElseIf useLEDs Then - + 'ElseIf useLEDs Then + ElseIf (B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Rendered AndAlso B2SData.LEDs.ContainsKey("LEDBox" & digit.ToString())) Then ' rendered LEDs are used Dim ledname As String = "LEDBox" & digit.ToString() If B2SData.LEDs.ContainsKey(ledname) Then B2SData.LEDs(ledname).Value = value End If - ElseIf useLEDDisplays Then - + 'ElseIf useLEDDisplays Then + ElseIf (B2SSettings.UsedLEDType = B2SSettings.eLEDTypes.Dream7 AndAlso B2SData.LEDDisplayDigits.ContainsKey(digit - 1)) Then ' Dream 7 displays are used If B2SData.LEDDisplayDigits.ContainsKey(digit - 1) Then With B2SData.LEDDisplayDigits(digit - 1)