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
3f727f13
Commit
3f727f13
authored
6 months ago
by
fdai7466
Browse files
Options
Downloads
Patches
Plain Diff
change sizing of context menu. add backround
parent
7a1ee6d1
Branches
Branches containing commit
No related tags found
1 merge request
!14
Refactoring CMakeLists.txt
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.cpp
+5
-1
5 additions, 1 deletion
src/main.cpp
src/ui/ContextMenu.cpp
+10
-2
10 additions, 2 deletions
src/ui/ContextMenu.cpp
with
15 additions
and
3 deletions
src/main.cpp
+
5
−
1
View file @
3f727f13
#include
"engine.hpp"
#include
"spritesheet.hpp"
#include
"ui/Menu.hpp"
#include
"ui/ContextMenu.hpp"
#include
"window.hpp"
#include
<memory>
...
...
@@ -15,13 +16,16 @@ int main() {
// render main menu
std
::
shared_ptr
<
Menu
>
menu
=
std
::
make_shared
<
Menu
>
(
0
);
std
::
shared_ptr
<
ContextMenu
>
context_menu
=
std
::
make_shared
<
ContextMenu
>
();
context_menu
->
setOptions
({
"Move"
,
"Info"
,
"Wait"
});
std
::
string
basePath
=
SDL_GetBasePath
();
std
::
string
relativePath
=
"assets/main_background.png"
;
std
::
string
fullPath
=
basePath
+
relativePath
;
menu
->
loadBackground
(
engine
.
renderer
(),
fullPath
.
c_str
());
engine
.
push_scene
(
menu
);
engine
.
push_scene
(
context_
menu
);
/* Level level("Osnabrück", 20, 20, std::vector<Tile>(),
std::vector<Building>(), std::vector<Unit>());
...
...
This diff is collapsed.
Click to expand it.
src/ui/ContextMenu.cpp
+
10
−
2
View file @
3f727f13
...
...
@@ -15,6 +15,7 @@ namespace advanced_wars {
}
void
ContextMenu
::
render
(
Engine
*
engine
)
{
if
(
!
options
.
empty
())
{
if
(
TTF_Init
()
==
-
1
)
{
std
::
cerr
<<
"Failed to initialize TTF: "
<<
TTF_GetError
()
<<
std
::
endl
;
...
...
@@ -24,7 +25,7 @@ namespace advanced_wars {
std
::
string
basePath
=
SDL_GetBasePath
();
std
::
string
relativePath
=
"assets/ARCADECLASSIC.TTF"
;
std
::
string
fullPath
=
basePath
+
relativePath
;
TTF_Font
*
font
=
TTF_OpenFont
(
fullPath
.
c_str
(),
48
);
TTF_Font
*
font
=
TTF_OpenFont
(
fullPath
.
c_str
(),
16
);
if
(
!
font
)
{
std
::
cerr
<<
"Failed to load font: "
<<
TTF_GetError
()
<<
std
::
endl
;
return
;
...
...
@@ -34,7 +35,14 @@ namespace advanced_wars {
SDL_Color
yellow
=
{
255
,
255
,
0
,
255
};
int
startY
=
100
;
// Startposition für das Menü
int
spacing
=
40
;
// Abstand zwischen den Optionen
int
spacing
=
20
;
// Abstand zwischen den Optionen
//box around options
SDL_SetRenderDrawColor
(
engine
->
renderer
(),
0
,
0
,
255
,
128
);
SDL_Rect
box
=
{
190
,
startY
-
3
,
50
,
static_cast
<
int
>
(
options
.
size
()
*
spacing
)};
SDL_RenderFillRect
(
engine
->
renderer
(),
&
box
);
SDL_SetRenderDrawColor
(
engine
->
renderer
(),
0
,
0
,
0
,
255
);
for
(
size_t
i
=
0
;
i
<
options
.
size
();
++
i
)
{
SDL_Surface
*
textSurface
=
TTF_RenderText_Solid
(
font
,
options
[
i
].
c_str
(),
(
i
==
selectedOption
)
?
yellow
:
white
);
...
...
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