Skip to content

Commit b116e4e

Browse files
authored
Merge branch 'develop' into feat/command-priority
2 parents 1e3129d + 08cf0c4 commit b116e4e

27 files changed

+162
-55
lines changed

.github/workflows/cmake.yml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
name: CMake
2+
concurrency:
3+
group: build-${{ github.ref }}
4+
cancel-in-progress: true
25

36
on:
47
push:
@@ -12,49 +15,46 @@ jobs:
1215
fail-fast: false
1316
matrix:
1417
arch: [x64]
15-
os: [ubuntu-18.04, ubuntu-latest]
18+
os: [ubuntu-20.04, ubuntu-22.04]
1619
compiler: [gcc, clang]
1720
runs-on: ${{ matrix.os }}
18-
21+
env:
22+
MATRIX_COMPILER: ${{matrix.compiler}}
23+
MATRIX_OS: ${{matrix.os}}
1924
steps:
20-
- uses: actions/checkout@v2
21-
25+
- uses: actions/checkout@v3
2226
- name: Get dependencies
2327
run: |
24-
sudo apt update
28+
sudo apt-get update && sudo apt-get upgrade
2529
sudo mk/linux/setupBuildDeps.sh
26-
27-
- name: Bulid MegaGlest With GCC Compiler
28-
if: ${{ matrix.compiler == 'gcc' }}
29-
env:
30-
CC: gcc
31-
CXX: g++
32-
run: mk/linux/build-mg.sh
30+
- name: Build
31+
run: |
32+
if [ "${MATRIX_COMPILER}" = "clang" ]; then
33+
EXTRA_OPTS="-f"
34+
fi
35+
mk/linux/build-mg.sh -m -d ${EXTRA_OPTS}
36+
make -C mk/linux/build -j$(nproc) VERBOSE=1
3337
34-
- name: Bulid MegaGlest With Clang Compiler
35-
if: ${{ matrix.compiler == 'clang' }}
36-
env:
37-
CC: clang
38-
CXX: clang++
39-
run: mk/linux/build-mg.sh
40-
41-
- name: Prepare Snapshot
42-
if: ${{ matrix.compiler == 'gcc' && matrix.os == 'ubuntu-latest' }}
38+
build-linux-other:
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
compiler: [10, 12] # 11 is on 22.04 by default, tested above
43+
runs-on: ubuntu-22.04
44+
env:
45+
CC: gcc-${{matrix.compiler}}
46+
CXX: g++-${{matrix.compiler}}
47+
steps:
48+
- uses: actions/checkout@v3
49+
- name: Get dependencies
4350
run: |
44-
cp mk/shared/*.ini mk/linux/
45-
strip -g mk/linux/megaglest mk/linux/megaglest_editor mk/linux/megaglest_g3dviewer
46-
47-
- name: Create Mega Glest Snapshot
48-
if: ${{ matrix.compiler == 'gcc' && matrix.os == 'ubuntu-latest' }}
49-
uses: actions/upload-artifact@v2
50-
with:
51-
name: megaglest-${{ matrix.arch }}-${{ matrix.os }}-${{ matrix.compiler }}
52-
path: |
53-
mk/linux/megaglest
54-
mk/linux/megaglest_editor
55-
mk/linux/megaglest_g3dviewer
56-
mk/linux/*.ini
57-
!mk/linux/glest-dev.ini
51+
sudo apt-get update && sudo apt-get upgrade
52+
sudo apt-get install -y $CXX
53+
sudo mk/linux/setupBuildDeps.sh
54+
- name: Build
55+
run: |
56+
mk/linux/build-mg.sh -d -m
57+
make -C mk/linux/build -j$(nproc) VERBOSE=1
5858
5959
build-win64:
6060
# The CMake configure and build commands are platform agnostic and should work equally
@@ -72,16 +72,16 @@ jobs:
7272
runs-on: windows-latest
7373

7474
steps:
75-
- uses: actions/checkout@v2
76-
75+
- uses: actions/checkout@v3
76+
7777
- name: Cache Vcpkg Libs
7878
uses: actions/cache@v2
7979
env:
8080
cache-name: cache-vcpkg-deps
8181
with:
8282
path: c:/vcpkg/installed
8383
key: vcpkg-deps
84-
84+
8585
- name: Install Dependencies
8686
run: |
8787
vcpkg integrate install
@@ -121,15 +121,15 @@ jobs:
121121
- name: Build Mega Glest
122122
# Build your program with the given configuration
123123
run: cmake --build ${{github.workspace}}/build --config Release --target ALL_BUILD
124-
124+
125125
- name: Prepare Snapshot
126126
run: |
127127
cd mk/windoze
128128
cp ..\shared\*.ini .
129129
$7zPath = $(Get-Command 7z).Source
130130
cp $7zPath .
131131
cd ../..
132-
132+
133133
- name: Create Mega Glest Snapshot
134134
uses: actions/upload-artifact@v2
135135
with:
@@ -154,7 +154,7 @@ jobs:
154154
# - name: Get dependencies
155155
# run: |
156156
# brew install pkg-config cmake sdl2 lua jpeg libpng freetype ftgl libogg glew libvorbis cppunit fribidi miniupnpc curl wxmac xquartz zstd xml2 openldap
157-
157+
158158
# - name: Bulid MegaGlest With Clang Compiler
159159
# if: ${{ matrix.compiler == 'clang' }}
160160
# env:
@@ -166,6 +166,6 @@ jobs:
166166
# mk/macos/build-mg.sh
167167
# - name: Test
168168
# working-directory: ${{github.workspace}}/build
169-
# Execute tests defined by the CMake configuration.
169+
# Execute tests defined by the CMake configuration.
170170
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
171171
# run: ctest -C ${{env.BUILD_TYPE}}

.github/workflows/snapshot.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Make Snapshot
2+
concurrency:
3+
group: build-${{ github.ref }}
4+
cancel-in-progress: true
5+
on:
6+
push:
7+
branches: [ develop ]
8+
9+
# The artifact only runs on the same distro that it was built on.
10+
# TODO: make AppImage instead
11+
jobs:
12+
make-snapshot:
13+
strategy:
14+
fail-fast: false
15+
runs-on: ubuntu-22.04
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Get dependencies
19+
run: |
20+
sudo apt-get update && sudo apt-get upgrade
21+
sudo mk/linux/setupBuildDeps.sh
22+
- name: Build
23+
run: |
24+
mk/linux/build-mg.sh -m
25+
make -C mk/linux/build -j$(nproc) VERBOSE=1
26+
- name: Prepare Snapshot
27+
run: |
28+
cp mk/shared/*.ini mk/linux/
29+
strip -g mk/linux/megaglest mk/linux/megaglest_editor mk/linux/megaglest_g3dviewer
30+
- name: Create Mega Glest Snapshot
31+
uses: actions/upload-artifact@v2
32+
with:
33+
name: megaglest-x64-ubuntu-20.04-gcc
34+
path: |
35+
mk/linux/megaglest
36+
mk/linux/megaglest_editor
37+
mk/linux/megaglest_g3dviewer
38+
mk/linux/*.ini
39+
!mk/linux/glest-dev.ini

mk/linux/setupBuildDeps.sh

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,9 @@ case $distribution in
159159
#name > zesty, EoL January 2018
160160
installcommand="apt-get install $APT_OPTIONS build-essential cmake libcurl4-gnutls-dev libsdl2-dev libopenal-dev liblua5.3-dev libjpeg-dev libpng-dev libfreetype6-dev libwxgtk3.0-dev libcppunit-dev libfribidi-dev libftgl-dev libglew-dev libogg-dev libvorbis-dev libminiupnpc-dev libircclient-dev libvlc-dev libvlccore-dev libxml2-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev librtmp-dev libkrb5-dev libldap2-dev libidn11-dev libgnutls28-dev libnghttp2-dev libssh2-1-dev libidn2-dev libpsl-dev"
161161
;;
162-
18.04)
163-
#name > bionic
164-
installcommand="apt-get install $APT_OPTIONS build-essential cmake libcurl4-gnutls-dev libsdl2-dev libopenal-dev liblua5.3-dev libjpeg-dev libpng-dev libfreetype6-dev libwxgtk3.0-dev libcppunit-dev libfribidi-dev libftgl-dev libglew-dev libogg-dev libvorbis-dev libminiupnpc-dev libircclient-dev libvlc-dev libvlccore-dev libxml2-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev librtmp-dev libkrb5-dev libldap2-dev libidn11-dev libgnutls28-dev libnghttp2-dev libssh2-1-dev libidn2-dev libpsl-dev"
165-
;;
166-
20.04)
167-
#name > Focal Fossa
168-
installcommand="apt-get install $APT_OPTIONS build-essential cmake libcurl4-gnutls-dev libsdl2-dev libopenal-dev liblua5.3-dev libjpeg-dev libpng-dev libfreetype6-dev libwxgtk3.0-gtk3-dev libcppunit-dev libfribidi-dev libftgl-dev libglew-dev libogg-dev libvorbis-dev libminiupnpc-dev libircclient-dev libvlc-dev libvlccore-dev libxml2-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev librtmp-dev libkrb5-dev libldap2-dev libidn2-dev libpsl-dev libgnutls28-dev libnghttp2-dev libssh-dev libbrotli-dev"
162+
"18.04"|"20.04"|"22.04")
163+
#name > Bionic, Focal Fossa, Jammy Jellyfish
164+
installcommand="apt-get install $APT_OPTIONS build-essential cmake libcurl4-gnutls-dev libsdl2-dev libopenal-dev liblua5.3-dev libjpeg-dev libpng-dev libfreetype6-dev libwxgtk3.0-gtk3-dev libcppunit-dev libfribidi-dev libftgl-dev libglew-dev libogg-dev libvorbis-dev libminiupnpc-dev libircclient-dev libxml2-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev librtmp-dev libkrb5-dev libldap2-dev libidn2-dev libpsl-dev libgnutls28-dev libnghttp2-dev libssh-dev libbrotli-dev"
169165
;;
170166
*)
171167
installcommand="apt-get install $APT_OPTIONS $packages_for_next_debian_ubuntu_mint"
@@ -177,15 +173,15 @@ case $distribution in
177173
case $release in
178174
20.04)
179175
#name > Focal Fossa
180-
installcommand="apt-get install $APT_OPTIONS build-essential cmake libcurl4-gnutls-dev libsdl2-dev libopenal-dev liblua5.3-dev libjpeg-dev libpng-dev libfreetype6-dev libwxgtk3.0-gtk3-dev libcppunit-dev libfribidi-dev libftgl-dev libglew-dev libogg-dev libvorbis-dev libminiupnpc-dev libircclient-dev libvlc-dev libvlccore-dev libxml2-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev librtmp-dev libkrb5-dev libldap2-dev libidn2-dev libpsl-dev libgnutls28-dev libnghttp2-dev libssh-dev libbrotli-dev"
176+
installcommand="apt-get install $APT_OPTIONS build-essential cmake libcurl4-gnutls-dev libsdl2-dev libopenal-dev liblua5.3-dev libjpeg-dev libpng-dev libfreetype6-dev libwxgtk3.0-gtk3-dev libcppunit-dev libfribidi-dev libftgl-dev libglew-dev libogg-dev libvorbis-dev libminiupnpc-dev libircclient-dev libxml2-dev libx11-dev libgl1-mesa-dev libglu1-mesa-dev librtmp-dev libkrb5-dev libldap2-dev libidn2-dev libpsl-dev libgnutls28-dev libnghttp2-dev libssh-dev libbrotli-dev"
181177
;;
182178
*)
183179
installcommand="apt-get install $APT_OPTIONS $packages_for_next_debian_ubuntu_mint"
184180
unsupported_currently_this_OS="release"
185181
;;
186182
esac
187183
;;
188-
184+
189185
LinuxMint|Linuxmint)
190186
case $release in
191187
2)

source/glest_game/gui/gui.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -705,13 +705,21 @@ void Gui::mouseDownDisplayUnitSkills(int posDisplay) {
705705
else {
706706
activeCommandType= NULL;
707707
activeCommandClass= display.getCommandClass(posDisplay);
708+
if (activeCommandClass == ccAttack) {
709+
unit= selection.getUnitFromCC(ccAttack);
710+
}
711+
708712
}
709713

710714
//give orders depending on command type
711715
if(!selection.isEmpty()){
712716
const CommandType *ct= selection.getUnit(0)->getType()->getFirstCtOfClass(activeCommandClass);
713717
auto mct= unit->getCurrMorphCt();
714718
if(mct) ct= mct->getMorphUnit()->getFirstCtOfClass(activeCommandClass);
719+
if (activeCommandClass == ccAttack) {
720+
ct = selection.getUnitFromCC(ccAttack)->getType()->getFirstCtOfClass(activeCommandClass);
721+
}
722+
715723
if(activeCommandType!=NULL && activeCommandType->getClass()==ccBuild){
716724
assert(selection.isUniform());
717725
selectingBuilding= true;
@@ -844,8 +852,13 @@ void Gui::computeInfoString(int posDisplay){
844852
const UnitType *ut= selection.getFrontUnit()->getType();
845853
CommandClass cc= display.getCommandClass(posDisplay);
846854
if(cc!=ccNull){
847-
display.setInfoText(lang.getString("CommonCommand") + ": " + ut->getFirstCtOfClass(cc)->toString(true));
848-
}
855+
if (cc == ccAttack) {
856+
const Unit* attackingUnit = selection.getUnitFromCC(ccAttack);
857+
display.setInfoText(lang.getString("CommonCommand") + ": " + attackingUnit->getType()->getFirstCtOfClass(cc)->toString(true));
858+
} else {
859+
display.setInfoText(lang.getString("CommonCommand") + ": " + ut->getFirstCtOfClass(cc)->toString(true));
860+
}
861+
}
849862
}
850863
}
851864
}
@@ -1032,9 +1045,19 @@ void Gui::computeDisplay(){
10321045

10331046
//printf("computeDisplay i = %d cc = %d isshared = %d lastCommand = %d\n",i,cc,isSharedCommandClass(cc),lastCommand);
10341047

1035-
if(isSharedCommandClass(cc) && cc != ccBuild){
1048+
const Unit* attackingUnit = NULL;
1049+
if (cc == ccAttack) {
1050+
attackingUnit = selection.getUnitFromCC(ccAttack);
1051+
}
1052+
1053+
if((cc == ccAttack && attackingUnit != NULL) || (isSharedCommandClass(cc) && cc != ccBuild)){
10361054
display.setDownLighted(lastCommand, true);
1037-
display.setDownImage(lastCommand, ut->getFirstCtOfClass(cc)->getImage());
1055+
1056+
if (cc == ccAttack && attackingUnit != NULL) {
1057+
display.setDownImage(lastCommand, attackingUnit->getType()->getFirstCtOfClass(cc)->getImage());
1058+
} else {
1059+
display.setDownImage(lastCommand, ut->getFirstCtOfClass(cc)->getImage());
1060+
}
10381061
display.setCommandClass(lastCommand, cc);
10391062
lastCommand++;
10401063
}
@@ -1195,6 +1218,7 @@ bool Gui::isSharedCommandClass(CommandClass commandClass){
11951218
return true;
11961219
}
11971220

1221+
11981222
void Gui::computeSelected(bool doubleClick, bool force){
11991223
Selection::UnitContainer units;
12001224

source/glest_game/gui/selection.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,16 @@ void Selection::removeUnitFromGroup(int groupIndex,int unitId) {
324324
}
325325
}
326326

327+
const Unit* Selection::getUnitFromCC(CommandClass commandClass){
328+
const Unit *unit = NULL;
329+
for(int i=0; i<(int)selectedUnits.size(); ++i){
330+
const Unit *unit= selectedUnits[i];
331+
const CommandType *ct= unit->getType()->getFirstCtOfClass(commandClass);
332+
if(ct != NULL && ct->getClass() == commandClass) return unit;
333+
}
334+
return unit;
335+
}
336+
327337
//vector<Unit*> Selection::getUnitsForGroup(int groupIndex) {
328338
// if(groupIndex < 0 || groupIndex >= maxGroups) {
329339
// throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));

source/glest_game/gui/selection.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ class Selection: public UnitObserver {
8686
const Unit *getUnit(int i) const {return selectedUnits[i];}
8787
Unit *getUnitPtr(int i) {return selectedUnits[i];}
8888
const Unit *getFrontUnit() const {return selectedUnits.front();}
89+
const Unit *getUnitFromCC(CommandClass commandClass);
8990
Vec3f getRefPos() const;
9091
bool hasUnit(const Unit* unit) const;
9192

source/glest_game/menu/main_menu.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,16 @@ void MainMenu::mouseDownLeft(int x, int y){
227227
state->mouseClick(x, y, mbLeft);
228228
}
229229

230+
void MainMenu::mouseDoubleClickLeft(int x, int y){
231+
if(GraphicComponent::getFade()<0.2f) return;
232+
state->mouseDoubleClick(x, y, mbLeft);
233+
}
234+
235+
void MainMenu::mouseDoubleClickRight(int x, int y){
236+
if(GraphicComponent::getFade()<0.2f) return;
237+
state->mouseDoubleClick(x, y, mbRight);
238+
}
239+
230240
void MainMenu::mouseDownRight(int x, int y){
231241
if(GraphicComponent::getFade()<0.2f) return;
232242
state->mouseClick(x, y, mbRight);

source/glest_game/menu/main_menu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ class MainMenu: public ProgramState {
7474
virtual void mouseMove(int x, int y, const MouseState *mouseState);
7575
virtual void eventMouseWheel(int x, int y,int zDelta);
7676
virtual void mouseDownLeft(int x, int y);
77+
virtual void mouseDoubleClickLeft(int x, int y);
78+
virtual void mouseDoubleClickRight(int x, int y);
7779
virtual void mouseDownRight(int x, int y);
7880
virtual void mouseUpLeft(int x, int y);
7981
virtual bool textInput(std::string text);
@@ -119,6 +121,7 @@ class MenuState {
119121
MenuState(Program *program, MainMenu *mainMenu, const string &stateName);
120122
virtual ~MenuState();
121123
virtual void mouseClick(int x, int y, MouseButton mouseButton)=0;
124+
virtual void mouseDoubleClick(int x, int y, MouseButton mouseButton)=0;
122125
virtual void mouseUp(int x, int y, const MouseButton mouseButton){};
123126
virtual void mouseMove(int x, int y, const MouseState *mouseState)=0;
124127
virtual void eventMouseWheel(int x, int y, int zDelta){};

source/glest_game/menu/menu_state_about.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class MenuStateAbout: public MenuState{
5959
virtual ~MenuStateAbout();
6060

6161
void mouseClick(int x, int y, MouseButton mouseButton);
62+
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
6263
void mouseMove(int x, int y, const MouseState *mouseState);
6364
void render();
6465
virtual void keyDown(SDL_KeyboardEvent key);

source/glest_game/menu/menu_state_connected_game.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ class MenuStateConnectedGame: public MenuState, public FTPClientCallbackInterfac
266266
virtual ~MenuStateConnectedGame();
267267

268268
void mouseClick(int x, int y, MouseButton mouseButton);
269+
void mouseDoubleClick(int x, int y, MouseButton mouseButton){};
269270
void mouseMove(int x, int y, const MouseState *mouseState);
270271
void eventMouseWheel(int x, int y,int zDelta);
271272
void render();

0 commit comments

Comments
 (0)