Skip to content

Commit 517791e

Browse files
committed
[GEN][ZH] add superhackers release version to in-game options screen
1 parent 329a958 commit 517791e

File tree

8 files changed

+138
-43
lines changed

8 files changed

+138
-43
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ on:
2525
default: false
2626
type: boolean
2727
description: "Build extras"
28+
release:
29+
required: false
30+
type: string
31+
description: "Release build (true/false)"
2832

2933
jobs:
3034
build:
@@ -35,6 +39,13 @@ jobs:
3539
- name: Checkout Code
3640
uses: actions/checkout@v4
3741

42+
- uses: actions/checkout@v4
43+
- name: Download version file
44+
if: inputs.release == 'true'
45+
uses: actions/download-artifact@v4
46+
with:
47+
name: version_files
48+
3849
- name: Cache VC6 Installation
3950
if: startsWith(inputs.preset, 'vc6')
4051
id: cache-vc6

.github/workflows/weekly-release.yml

Lines changed: 67 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,46 @@ jobs:
5454
echo "changed=true" >> $GITHUB_OUTPUT
5555
fi
5656
57+
calculate-version:
58+
name: Generate version files
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0
65+
fetch-tags: true
66+
67+
- name: Create Version Files
68+
run: |
69+
BASE_TAG=$(cat .github/workflows/base-version.txt)
70+
IFS='.' read -r major minor patch <<<"$BASE_TAG"
71+
CURRENT_TAG=$(git tag --list "$major.$minor*" --sort=-v:refname | head -n1)
72+
73+
if [ -z "$CURRENT_TAG" ]; then
74+
CURRENT_TAG="$BASE_TAG"
75+
NEXT_TAG="$BASE_TAG"
76+
else
77+
IFS='.' read -r major minor patch <<<"$CURRENT_TAG"
78+
NEXT_TAG="$major.$minor.$((patch+1))"
79+
fi
80+
81+
echo "CURRENT_TAG: $CURRENT_TAG"
82+
echo "NEXT_TAG: $NEXT_TAG"
83+
84+
echo "$CURRENT_TAG" > current_tag.txt
85+
echo "$NEXT_TAG" > next_tag.txt
86+
87+
- name: Upload version files
88+
uses: actions/upload-artifact@v4
89+
with:
90+
name: version_files
91+
path: |
92+
next_tag.txt
93+
current_tag.txt
94+
5795
build-generals:
58-
needs: detect-scm-changes
96+
needs: [detect-scm-changes, calculate-version]
5997
if: needs.detect-scm-changes.outputs.changed == 'true'
6098
name: Build Generals${{ matrix.preset && '' }}
6199
strategy:
@@ -64,20 +102,23 @@ jobs:
64102
- preset: "vc6"
65103
tools: true
66104
extras: true
105+
release: true
67106
- preset: "win32-vcpkg"
68107
tools: true
69108
extras: true
109+
release: true
70110
fail-fast: false
71111
uses: ./.github/workflows/build-toolchain.yml
72112
with:
73113
game: "Generals"
74114
preset: ${{ matrix.preset }}
75115
tools: ${{ matrix.tools }}
76116
extras: ${{ matrix.extras }}
117+
release: ${{ matrix.release }}
77118
secrets: inherit
78119

79120
build-generalsmd:
80-
needs: detect-scm-changes
121+
needs: [detect-scm-changes, calculate-version]
81122
if: needs.detect-scm-changes.outputs.changed == 'true'
82123
name: Build GeneralsMD${{ matrix.preset && '' }}
83124
strategy:
@@ -86,16 +127,19 @@ jobs:
86127
- preset: "vc6"
87128
tools: true
88129
extras: true
130+
release: true
89131
- preset: "win32"
90132
tools: true
91133
extras: true
134+
release: true
92135
fail-fast: false
93136
uses: ./.github/workflows/build-toolchain.yml
94137
with:
95138
game: "GeneralsMD"
96139
preset: ${{ matrix.preset }}
97140
tools: ${{ matrix.tools }}
98141
extras: ${{ matrix.extras }}
142+
release: ${{ matrix.release }}
99143
secrets: inherit
100144

101145
create-release:
@@ -109,43 +153,40 @@ jobs:
109153
fetch-depth: 0
110154
fetch-tags: true
111155

156+
- uses: actions/checkout@v4
157+
- name: Download version file
158+
uses: actions/download-artifact@v4
159+
with:
160+
name: version_files
161+
112162
- name: Read base version
113163
id: base_version
114164
run: echo "base_version=$(cat .github/workflows/base-version.txt)" >> $GITHUB_OUTPUT
115165

116166
- name: Get latest semver tag
117167
id: get_tag
118-
run: |
119-
BASE=${{ steps.base_version.outputs.base_version }}
120-
IFS='.' read -r major minor patch <<<"$BASE"
121-
TAG=$(git tag --list "$major.$minor*" --sort=-v:refname | head -n1)
122-
echo "latest_tag=$TAG" >> $GITHUB_OUTPUT
168+
run: echo "current_tag=$(cat current_tag.txt)" >> $GITHUB_OUTPUT
123169

124170
- name: Calculate next version
125171
id: next_version
126-
run: |
127-
BASE=${{ steps.base_version.outputs.base_version }}
128-
TAG=${{ steps.get_tag.outputs.latest_tag }}
129-
if [ -z "$TAG" ]; then
130-
NEXT_TAG="$BASE"
131-
else
132-
IFS='.' read -r major minor patch <<<"$TAG"
133-
NEXT_TAG="$major.$minor.$((patch+1))"
134-
fi
135-
echo "next_tag=$NEXT_TAG" >> $GITHUB_OUTPUT
172+
run: echo "next_tag=$(cat next_tag.txt)" >> $GITHUB_OUTPUT
136173

137174
- name: Collect commits since last release
138175
id: changelog
139176
run: |
140-
TAG=${{ steps.get_tag.outputs.latest_tag }}
177+
TAG=${{ steps.get_tag.outputs.current_tag }}
141178
if [ -z "$TAG" ]; then
142-
echo "commits<<EOF" >> $GITHUB_OUTPUT
143-
git log --pretty=format:"- %s" >> $GITHUB_OUTPUT
144-
echo "EOF" >> $GITHUB_OUTPUT
179+
{
180+
echo "commits<<EOF"
181+
git log --pretty=format:"- %s" | head -n10 | grep -v "Sync Generals repos"
182+
echo "EOF"
183+
} >> $GITHUB_OUTPUT
145184
else
146-
echo "commits<<EOF" >> $GITHUB_OUTPUT
147-
git log "$TAG"..HEAD --pretty=format:"- %s" |grep -v "Sync Generals repos" >> $GITHUB_OUTPUT
148-
echo "EOF" >> $GITHUB_OUTPUT
185+
{
186+
echo "commits<<EOF"
187+
git log "$TAG"..HEAD --pretty=format:"- %s" | grep -v "Sync Generals repos"
188+
echo "EOF"
189+
} >> $GITHUB_OUTPUT
149190
fi
150191
151192
# Generals vc6
@@ -221,8 +262,8 @@ jobs:
221262
222263
### Known issues
223264
224-
- Fullscreen executable is currently broken. You must add the `-win` parameter to run the game in windowed mode.
225-
265+
- Fullscreen execution can freeze the game. For that case, you should add the `-win` parameter to run the game in windowed mode.
266+
226267
### Changelog
227268
${{ steps.changelog.outputs.commits }}
228269
files: |

Generals/Code/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,7 @@ target_include_directories(g_gameengine PUBLIC
10771077

10781078
target_include_directories(g_gameengine PRIVATE
10791079
Include/Precompiled
1080+
${CMAKE_BINARY_DIR}/Generals/Code/Main
10801081
)
10811082

10821083
target_link_libraries(g_gameengine PRIVATE

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "Common/GameLOD.h"
4141
#include "Common/Registry.h"
4242
#include "Common/version.h"
43+
#include "GeneratedVersion.h"
4344

4445
#include "GameClient/ClientInstance.h"
4546
#include "GameClient/GameClient.h"
@@ -1426,7 +1427,9 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
14261427
}
14271428
else
14281429
{
1429-
GadgetStaticTextSetText( labelVersion, versionString );
1430+
UnicodeString fullVersion;
1431+
fullVersion.format(L"%s - TheSuperHackers %s", versionString.str(), SUPERHACKERS_VERSION_WIDE);
1432+
GadgetStaticTextSetText(labelVersion, fullVersion);
14301433
}
14311434

14321435

Generals/Code/Main/CMakeLists.txt

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,32 @@ target_link_libraries(g_generals PRIVATE
2424
winmm
2525
)
2626

27+
if(EXISTS "${CMAKE_SOURCE_DIR}/next_tag.txt")
28+
file(READ "${CMAKE_SOURCE_DIR}/next_tag.txt" GAME_VERSION)
29+
string(STRIP "${GAME_VERSION}" GAME_VERSION)
30+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ "${GAME_VERSION}")
31+
set(VERSION_MAJOR "${CMAKE_MATCH_1}")
32+
set(VERSION_MINOR "${CMAKE_MATCH_2}")
33+
set(VERSION_BUILDNUM "${CMAKE_MATCH_3}")
34+
else()
35+
if (IS_VS6_BUILD)
36+
set(VERSION_MAJOR "1")
37+
set(VERSION_MINOR "7")
38+
set(VERSION_BUILDNUM "601")
39+
else()
40+
set(VERSION_MAJOR "1")
41+
set(VERSION_MINOR "8")
42+
set(VERSION_BUILDNUM "601")
43+
endif()
44+
endif()
45+
2746
# TODO Originally referred to build host and user, replace with git info perhaps?
2847
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/GeneratedVersion.h
2948
"#pragma once
3049
31-
#define VERSION_LOCALBUILDNUM 0
32-
#define VERSION_BUILDUSER \"Someone\"
33-
#define VERSION_BUILDLOC \"Someplace\"
50+
#define VERSION_BUILDUSER \"TheSuperHackers\"
51+
#define VERSION_BUILDLOC \"GitHub\"
52+
#define SUPERHACKERS_VERSION_WIDE L\"${GAME_VERSION}\"
3453
"
3554
)
3655

@@ -39,18 +58,20 @@ if (IS_VS6_BUILD)
3958
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BuildVersion.h
4059
"#pragma once
4160
42-
#define VERSION_MAJOR 1
43-
#define VERSION_MINOR 7
44-
#define VERSION_BUILDNUM 601
61+
#define VERSION_MAJOR ${VERSION_MAJOR}
62+
#define VERSION_MINOR ${VERSION_MINOR}
63+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
64+
#define VERSION_LOCALBUILDNUM 9001 // it's over 9000!
4565
"
4666
)
4767
else()
4868
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BuildVersion.h
4969
"#pragma once
5070
51-
#define VERSION_MAJOR 1
52-
#define VERSION_MINOR 8
53-
#define VERSION_BUILDNUM 601
71+
#define VERSION_MAJOR ${VERSION_MAJOR}
72+
#define VERSION_MINOR ${VERSION_MINOR}
73+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
74+
#define VERSION_LOCALBUILDNUM 602
5475
"
5576
)
5677
endif()

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,7 @@ target_include_directories(z_gameengine PUBLIC
11561156

11571157
target_include_directories(z_gameengine PRIVATE
11581158
Include/Precompiled
1159+
${CMAKE_BINARY_DIR}/GeneralsMD/Code/Main
11591160
)
11601161

11611162
target_link_libraries(z_gameengine PRIVATE

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "Common/GameLOD.h"
4141
#include "Common/Registry.h"
4242
#include "Common/version.h"
43+
#include "GeneratedVersion.h"
4344

4445
#include "GameClient/ClientInstance.h"
4546
#include "GameClient/GameClient.h"
@@ -1492,7 +1493,9 @@ void OptionsMenuInit( WindowLayout *layout, void *userData )
14921493
}
14931494
else
14941495
{
1495-
GadgetStaticTextSetText( labelVersion, versionString );
1496+
UnicodeString fullVersion;
1497+
fullVersion.format(L"%s - TheSuperHackers %s", versionString.str(), SUPERHACKERS_VERSION_WIDE);
1498+
GadgetStaticTextSetText(labelVersion, fullVersion);
14961499
}
14971500

14981501

GeneralsMD/Code/Main/CMakeLists.txt

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,37 @@ target_link_libraries(z_generals PRIVATE
2626
zi_always
2727
)
2828

29+
if(EXISTS "${CMAKE_SOURCE_DIR}/next_tag.txt")
30+
file(READ "${CMAKE_SOURCE_DIR}/next_tag.txt" GAME_VERSION)
31+
string(STRIP "${GAME_VERSION}" GAME_VERSION)
32+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.([0-9]+)" _ "${GAME_VERSION}")
33+
set(VERSION_MAJOR "${CMAKE_MATCH_1}")
34+
set(VERSION_MINOR "${CMAKE_MATCH_2}")
35+
set(VERSION_BUILDNUM "${CMAKE_MATCH_3}")
36+
else()
37+
set(VERSION_MAJOR "1")
38+
set(VERSION_MINOR "4")
39+
set(VERSION_BUILDNUM "601")
40+
endif()
41+
2942
# TODO Originally referred to build host and user, replace with git info perhaps?
3043
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/GeneratedVersion.h
3144
"#pragma once
3245
33-
#define VERSION_LOCALBUILDNUM 0
34-
#define VERSION_BUILDUSER \"Someone\"
35-
#define VERSION_BUILDLOC \"Someplace\"
46+
#define VERSION_BUILDUSER \"TheSuperHackers\"
47+
#define VERSION_BUILDLOC \"GitHub\"
48+
#define SUPERHACKERS_VERSION_WIDE L\"${GAME_VERSION}\"
3649
"
3750
)
3851

3952
# Based on original binary values for these variables.
4053
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BuildVersion.h
4154
"#pragma once
4255
43-
#define VERSION_MAJOR 1
44-
#define VERSION_MINOR 4
45-
#define VERSION_BUILDNUM 601
56+
#define VERSION_MAJOR ${VERSION_MAJOR}
57+
#define VERSION_MINOR ${VERSION_MINOR}
58+
#define VERSION_BUILDNUM ${VERSION_BUILDNUM}
59+
#define VERSION_LOCALBUILDNUM 9001 // it's over 9000!
4660
"
4761
)
4862

0 commit comments

Comments
 (0)