Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cpp-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Maul
cpp-project
Commits
99d68544
Commit
99d68544
authored
5 months ago
by
TheUltimateOptimist
Browse files
Options
Downloads
Patches
Plain Diff
implemented command line application for launching advanced wars
parent
674c64d3
No related branches found
No related tags found
1 merge request
!43
Command Line Application for launching advanced_wars
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+4
-1
4 additions, 1 deletion
CMakeLists.txt
src/game/main.cpp
+34
-5
34 additions, 5 deletions
src/game/main.cpp
with
38 additions
and
6 deletions
CMakeLists.txt
+
4
−
1
View file @
99d68544
...
...
@@ -78,6 +78,8 @@ add_executable(advanced_wars ${ADVANCED_WARS_SOURCES})
set
(
CMAKE_MODULE_PATH
${
ADVANCED_WARS_SOURCE_DIR
}
/cmake/
${
CMAKE_MODULE_PATH
}
)
find_package
(
Qt6 REQUIRED COMPONENTS Widgets
)
# Plattform-spezifische Konfiguration
if
(
APPLE
)
# SDL2 Frameworks für macOS
...
...
@@ -96,6 +98,7 @@ if(APPLE)
${
SDL2_PATH
}
/SDL2.framework/SDL2
${
SDL2_PATH
}
/SDL2_image.framework/SDL2_image
${
SDL2_PATH
}
/SDL2_ttf.framework/SDL2_ttf
Qt6::Core
Boost::graph
box2d
)
...
...
@@ -127,6 +130,7 @@ else()
target_link_libraries
(
advanced_wars
${
HDF5_LIBRARIES
}
Qt6::Core
-lSDL2
-lSDL2_image
-lSDL2_ttf
...
...
@@ -138,7 +142,6 @@ endif()
# leveleditor
# Find Qt
find_package
(
Qt6 REQUIRED COMPONENTS Widgets
)
file
(
GLOB_RECURSE LEVELEDITOR_SOURCES
"
${
PROJECT_SOURCE_DIR
}
/src/editor/*.cpp"
...
...
This diff is collapsed.
Click to expand it.
src/game/main.cpp
+
34
−
5
View file @
99d68544
...
...
@@ -6,20 +6,49 @@
#include
<SDL2/SDL.h>
#include
<SDL_image.h>
#include
<QCoreApplication>
#include
<QCommandLineParser>
#include
<iostream>
#include
<memory>
#include
<stdexcept>
#include
<vector>
#include
<string>
#include
<optional>
#include
<filesystem>
using
namespace
advanced_wars
;
std
::
optional
<
std
::
string
>
get_level_filepath
(
int
argc
,
char
*
argv
[])
{
QCoreApplication
app
(
argc
,
argv
);
QCoreApplication
::
setApplicationVersion
(
"1.0.0"
);
QCommandLineParser
parser
;
parser
.
addVersionOption
();
parser
.
addHelpOption
();
parser
.
setApplicationDescription
(
"Advanced Wars is a multi player strategy game.
\n
Capture citys, build units and defeat your opponents. No mercy!"
);
parser
.
addPositionalArgument
(
"path"
,
"The path to the HDF5 level file from which the level should be loaded."
,
"<path>"
);
parser
.
process
(
app
);
if
(
parser
.
positionalArguments
().
size
()
!=
1
)
{
std
::
cerr
<<
"Command not recognized."
<<
std
::
endl
;
parser
.
showHelp
();
return
std
::
nullopt
;
}
std
::
string
filepath
=
parser
.
positionalArguments
()[
0
].
toStdString
();
if
(
!
std
::
filesystem
::
exists
(
filepath
))
{
std
::
cerr
<<
"The hdf5 level file path: '"
<<
filepath
<<
"' does not exist."
<<
std
::
endl
;
return
std
::
nullopt
;
}
return
parser
.
positionalArguments
()[
0
].
toStdString
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
<=
1
)
std
::
optional
<
std
::
string
>
level_filepath
=
get_level_filepath
(
argc
,
argv
);
if
(
!
level_filepath
.
has_value
())
{
std
::
cerr
<<
"Please provide the path to the level that you want to play as a command line "
"argument."
<<
std
::
endl
;
return
1
;
}
...
...
@@ -43,7 +72,7 @@ int main(int argc, char* argv[])
engine
.
setSpritesheet
(
spritesheet
);
std
::
shared_ptr
<
Menu
>
menu
=
std
::
make_shared
<
Menu
>
(
0
,
argv
[
1
]
);
std
::
shared_ptr
<
Menu
>
menu
=
std
::
make_shared
<
Menu
>
(
0
,
level_filepath
.
value
()
);
std
::
shared_ptr
<
ContextMenu
>
context_menu
=
std
::
make_shared
<
ContextMenu
>
();
context_menu
->
setOptions
({
"Move"
,
"Info"
,
"Wait"
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment