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
2636f461
Unverified
Commit
2636f461
authored
7 months ago
by
David Hermann
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring: Renaming MainMenu to Menu
Removing BaseMenu and PauseMenu
parent
88ba577a
Branches
Branches containing commit
No related tags found
1 merge request
!14
Refactoring CMakeLists.txt
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.cpp
+1
-1
1 addition, 1 deletion
src/main.cpp
src/ui/Menu.cpp
+5
-5
5 additions, 5 deletions
src/ui/Menu.cpp
src/ui/Menu.hpp
+3
-21
3 additions, 21 deletions
src/ui/Menu.hpp
with
9 additions
and
27 deletions
src/main.cpp
+
1
−
1
View file @
2636f461
...
...
@@ -15,7 +15,7 @@ int main() {
// render main menu
Main
Menu
menu
(
0
);
Menu
menu
(
0
);
std
::
string
basePath
=
SDL_GetBasePath
();
std
::
string
relativePath
=
"assets/main_background.png"
;
...
...
This diff is collapsed.
Click to expand it.
src/ui/Menu.cpp
+
5
−
5
View file @
2636f461
...
...
@@ -9,7 +9,7 @@
namespace
advanced_wars
{
Main
Menu
::
Main
Menu
(
int
selectedOption
)
Menu
::
Menu
(
int
selectedOption
)
:
selectedOption
(
selectedOption
),
options
({
"Start Game"
,
"Options"
,
"Exit"
}),
backgroundTexture
(
nullptr
)
...
...
@@ -19,14 +19,14 @@ namespace advanced_wars
}
}
Main
Menu
::~
Main
Menu
()
{
Menu
::~
Menu
()
{
if
(
backgroundTexture
)
{
SDL_DestroyTexture
(
backgroundTexture
);
}
IMG_Quit
();
};
void
Main
Menu
::
render
(
SDL_Renderer
*
renderer
,
std
::
vector
<
SDL_Event
>
&
events
)
{
void
Menu
::
render
(
SDL_Renderer
*
renderer
,
std
::
vector
<
SDL_Event
>
&
events
)
{
if
(
events
.
size
()
>
0
)
{
SDL_Event
event
=
events
.
back
();
...
...
@@ -96,7 +96,7 @@ namespace advanced_wars
}
void
Main
Menu
::
handleEvent
(
SDL_Event
&
event
)
{
void
Menu
::
handleEvent
(
SDL_Event
&
event
)
{
if
(
event
.
type
==
SDL_KEYDOWN
)
{
if
(
event
.
key
.
keysym
.
sym
==
SDLK_DOWN
)
{
selectedOption
=
(
selectedOption
+
1
)
%
options
.
size
();
...
...
@@ -111,7 +111,7 @@ namespace advanced_wars
}
}
void
Main
Menu
::
loadBackground
(
SDL_Renderer
*
renderer
,
const
std
::
string
&
imagePath
)
{
void
Menu
::
loadBackground
(
SDL_Renderer
*
renderer
,
const
std
::
string
&
imagePath
)
{
// Lade das Hintergrundbild
SDL_Surface
*
backgroundSurface
=
IMG_Load
(
imagePath
.
c_str
());
if
(
!
backgroundSurface
)
{
...
...
This diff is collapsed.
Click to expand it.
src/ui/Menu.hpp
+
3
−
21
View file @
2636f461
...
...
@@ -10,13 +10,7 @@
namespace
advanced_wars
{
class
BaseMenu
:
public
Scene
{
public:
virtual
void
handleEvent
(
SDL_Event
&
event
);
virtual
~
BaseMenu
();
};
class
MainMenu
:
public
Scene
{
class
Menu
:
public
Scene
{
private:
size_t
selectedOption
;
std
::
array
<
std
::
string
,
3
>
options
;
...
...
@@ -24,7 +18,7 @@ private:
public:
Main
Menu
(
int
selectedOption
);
Menu
(
int
selectedOption
);
void
render
(
SDL_Renderer
*
renderer
,
std
::
vector
<
SDL_Event
>
&
events
);
...
...
@@ -32,19 +26,7 @@ public:
void
loadBackground
(
SDL_Renderer
*
renderer
,
const
std
::
string
&
imagePath
);
~
MainMenu
();
};
class
PauseMenu
:
public
BaseMenu
{
private:
std
::
vector
<
std
::
string
>
options
;
int
selectedOption
;
public:
void
render
(
SDL_Renderer
*
renderer
,
std
::
vector
<
SDL_Event
>
&
events
);
void
handleEvent
(
SDL_Event
&
event
);
~
Menu
();
};
}
...
...
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