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
8f3e3495
Commit
8f3e3495
authored
5 months ago
by
David Maul
Browse files
Options
Downloads
Patches
Plain Diff
cleanup clang-tidy warnings
parent
3288c79f
No related branches found
No related tags found
1 merge request
!48
cleanup clang-tidy warnings
Changes
63
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/game/ui/modals/HelpMenu.hpp
+2
-3
2 additions, 3 deletions
src/game/ui/modals/HelpMenu.hpp
src/game/ui/modals/UnitInfoMenu.cpp
+30
-30
30 additions, 30 deletions
src/game/ui/modals/UnitInfoMenu.cpp
src/game/ui/modals/UnitInfoMenu.hpp
+6
-6
6 additions, 6 deletions
src/game/ui/modals/UnitInfoMenu.hpp
with
38 additions
and
39 deletions
src/game/ui/modals/HelpMenu.hpp
+
2
−
3
View file @
8f3e3495
...
@@ -26,10 +26,9 @@ class HelpMenu : public Scene
...
@@ -26,10 +26,9 @@ class HelpMenu : public Scene
void
renderTextPortion
(
void
renderTextPortion
(
Engine
&
engine
,
std
::
string
text
,
TTF_Font
*
font
,
SDL_Color
color
,
int
boxWidth
,
Engine
&
engine
,
std
::
string
text
,
TTF_Font
*
font
,
SDL_Color
color
,
int
boxWidth
,
int
text
_x
,
int
text
_y
);
int
text
X
,
int
text
Y
);
void
void
renderTexture
(
SDL_Texture
*
texture
,
Engine
&
engine
,
int
x
,
int
y
,
int
srcX
,
int
srcY
);
renderTexture
(
SDL_Texture
*
texture
,
Engine
&
engine
,
int
x
,
int
y
,
int
src_x
,
int
src_y
);
};
};
}
// namespace advanced_wars
}
// namespace advanced_wars
This diff is collapsed.
Click to expand it.
src/game/ui/modals/UnitInfoMenu.cpp
+
30
−
30
View file @
8f3e3495
...
@@ -60,12 +60,7 @@ std::unordered_map<UnitTypeId, std::string> unitDescriptions = {
...
@@ -60,12 +60,7 @@ std::unordered_map<UnitTypeId, std::string> unitDescriptions = {
{
UnitTypeId
::
SUBMARINE
,
"U-Boot Versteckt sich und kann Ueberwasserziele angreifen"
}
{
UnitTypeId
::
SUBMARINE
,
"U-Boot Versteckt sich und kann Ueberwasserziele angreifen"
}
};
};
void
UnitInfoMenu
::
handleEvent
(
Engine
&
engine
,
SDL_Event
&
event
)
void
UnitInfoMenu
::
handleEvent
(
Engine
&
/*engine*/
,
SDL_Event
&
/*event*/
)
{}
{
// Hier kannst du den Code hinzufügen, um die Ereignisse für das UnitInfoMenu zu behandeln
// Wenn keine spezifische Ereignisbehandlung erforderlich ist, kann diese Methode auch leer
// bleiben.
}
void
UnitInfoMenu
::
setUnit
(
Unit
&
unit
)
void
UnitInfoMenu
::
setUnit
(
Unit
&
unit
)
{
{
...
@@ -75,8 +70,10 @@ void UnitInfoMenu::setUnit(Unit& unit)
...
@@ -75,8 +70,10 @@ void UnitInfoMenu::setUnit(Unit& unit)
void
UnitInfoMenu
::
render
(
Engine
&
engine
)
void
UnitInfoMenu
::
render
(
Engine
&
engine
)
{
{
if
(
!
m_currentUnit
||
!
m_isVisible
)
if
((
m_currentUnit
==
nullptr
)
||
!
m_isVisible
)
{
return
;
return
;
}
// TTF Initialisierung
// TTF Initialisierung
if
(
TTF_Init
()
==
-
1
)
if
(
TTF_Init
()
==
-
1
)
...
@@ -89,7 +86,7 @@ void UnitInfoMenu::render(Engine& engine)
...
@@ -89,7 +86,7 @@ void UnitInfoMenu::render(Engine& engine)
std
::
string
fullPath
=
basePath
+
"res/ARCADECLASSIC.TTF"
;
std
::
string
fullPath
=
basePath
+
"res/ARCADECLASSIC.TTF"
;
TTF_Font
*
font
=
TTF_OpenFont
(
fullPath
.
c_str
(),
16
);
TTF_Font
*
font
=
TTF_OpenFont
(
fullPath
.
c_str
(),
16
);
if
(
!
font
)
if
(
font
==
nullptr
)
{
{
std
::
cerr
<<
"Failed to load font: "
<<
TTF_GetError
()
<<
"
\n
"
;
std
::
cerr
<<
"Failed to load font: "
<<
TTF_GetError
()
<<
"
\n
"
;
return
;
return
;
...
@@ -100,7 +97,7 @@ void UnitInfoMenu::render(Engine& engine)
...
@@ -100,7 +97,7 @@ void UnitInfoMenu::render(Engine& engine)
UnitTypeId
unitId
=
m_currentUnit
->
getUnitTypeId
();
UnitTypeId
unitId
=
m_currentUnit
->
getUnitTypeId
();
// Textzeilen, einschließlich der Beschreibung
// Textzeilen, einschließlich der Beschreibung
std
::
vector
<
std
::
string
>
info
_l
ines
=
{
std
::
vector
<
std
::
string
>
info
L
ines
=
{
"HP "
+
std
::
to_string
(
m_currentUnit
->
getHealth
()),
"HP "
+
std
::
to_string
(
m_currentUnit
->
getHealth
()),
"Movement "
+
std
::
to_string
(
m_currentUnit
->
getMovementPoints
()),
"Movement "
+
std
::
to_string
(
m_currentUnit
->
getMovementPoints
()),
"Ammo "
+
std
::
to_string
(
m_currentUnit
->
getAmmo
()),
"Ammo "
+
std
::
to_string
(
m_currentUnit
->
getAmmo
()),
...
@@ -109,26 +106,28 @@ void UnitInfoMenu::render(Engine& engine)
...
@@ -109,26 +106,28 @@ void UnitInfoMenu::render(Engine& engine)
unitDescriptions
[
unitId
]
// Beschreibung einfügen
unitDescriptions
[
unitId
]
// Beschreibung einfügen
};
};
int
max
_t
ext
_w
idth
=
0
;
int
max
T
ext
W
idth
=
0
;
int
total
_h
eight
=
0
;
int
total
H
eight
=
0
;
std
::
vector
<
SDL_Texture
*>
textures
;
std
::
vector
<
SDL_Texture
*>
textures
;
for
(
const
auto
&
line
:
info
_l
ines
)
for
(
const
auto
&
line
:
info
L
ines
)
{
{
SDL_Surface
*
textSurface
=
TTF_RenderText_Solid
(
font
,
line
.
c_str
(),
yellow
);
SDL_Surface
*
textSurface
=
TTF_RenderText_Solid
(
font
,
line
.
c_str
(),
yellow
);
if
(
!
textSurface
)
if
(
textSurface
==
nullptr
)
{
continue
;
continue
;
}
max
_t
ext
_w
idth
=
std
::
max
(
max
_t
ext
_w
idth
,
textSurface
->
w
);
max
T
ext
W
idth
=
std
::
max
(
max
T
ext
W
idth
,
textSurface
->
w
);
total
_h
eight
+=
textSurface
->
h
+
spacing
;
total
H
eight
+=
textSurface
->
h
+
spacing
;
SDL_Texture
*
textTexture
=
SDL_CreateTextureFromSurface
(
engine
.
renderer
(),
textSurface
);
SDL_Texture
*
textTexture
=
SDL_CreateTextureFromSurface
(
engine
.
renderer
(),
textSurface
);
textures
.
push_back
(
textTexture
);
textures
.
push_back
(
textTexture
);
SDL_FreeSurface
(
textSurface
);
SDL_FreeSurface
(
textSurface
);
}
}
int
width
=
std
::
max
(
max
_t
ext
_w
idth
+
20
*
RENDERING_SCALE
,
16
*
RENDERING_SCALE
+
20
);
int
width
=
std
::
max
(
max
T
ext
W
idth
+
(
20
*
RENDERING_SCALE
)
,
(
16
*
RENDERING_SCALE
)
+
20
);
int
height
=
int
height
=
totalHeight
+
total_height
+
30
*
RENDERING_SCALE
;
// Die Höhe anpassen, um alle Textzeilen zu integrieren
(
30
*
RENDERING_SCALE
)
;
// Die Höhe anpassen, um alle Textzeilen zu integrieren
SDL_Rect
box
=
{
m_x
,
m_y
,
width
,
height
};
SDL_Rect
box
=
{
m_x
,
m_y
,
width
,
height
};
SDL_SetRenderDrawColor
(
engine
.
renderer
(),
75
,
87
,
219
,
255
);
// Schwarzes Hintergrundrechteck
SDL_SetRenderDrawColor
(
engine
.
renderer
(),
75
,
87
,
219
,
255
);
// Schwarzes Hintergrundrechteck
...
@@ -139,26 +138,27 @@ void UnitInfoMenu::render(Engine& engine)
...
@@ -139,26 +138,27 @@ void UnitInfoMenu::render(Engine& engine)
// Render unit sprite
// Render unit sprite
Spritesheet
*
spritesheet
=
engine
.
getSpritesheet
();
Spritesheet
*
spritesheet
=
engine
.
getSpritesheet
();
SDL_Texture
*
unit
_t
exture
=
spritesheet
->
getUnitTextures
()
SDL_Texture
*
unit
T
exture
=
spritesheet
->
getUnitTextures
()
.
at
(
static_cast
<
int
>
(
m_currentUnit
->
getFaction
()))
.
at
(
static_cast
<
int
>
(
m_currentUnit
->
getFaction
()))
.
at
(
static_cast
<
int
>
(
unitId
))
.
at
(
static_cast
<
int
>
(
unitId
))
.
at
(
static_cast
<
int
>
(
UnitState
::
IDLE
))
.
at
(
static_cast
<
int
>
(
UnitState
::
IDLE
))
.
first
;
.
first
;
SDL_Rect
sprite
_r
ect
=
{
m_x
+
10
,
m_y
+
10
,
16
*
RENDERING_SCALE
,
16
*
RENDERING_SCALE
};
SDL_Rect
sprite
R
ect
=
{
m_x
+
10
,
m_y
+
10
,
16
*
RENDERING_SCALE
,
16
*
RENDERING_SCALE
};
SDL_Rect
source
_r
ect
=
{
0
,
0
,
16
,
16
};
SDL_Rect
source
R
ect
=
{
0
,
0
,
16
,
16
};
SDL_RenderCopy
(
engine
.
renderer
(),
unit
_t
exture
,
&
source
_r
ect
,
&
sprite
_r
ect
);
SDL_RenderCopy
(
engine
.
renderer
(),
unit
T
exture
,
&
source
R
ect
,
&
sprite
R
ect
);
// Text zeichnen
// Text zeichnen
int
text
_y
=
m_y
+
20
*
RENDERING_SCALE
;
// Starte etwas unterhalb des Sprites
int
text
Y
=
m_y
+
(
20
*
RENDERING_SCALE
)
;
// Starte etwas unterhalb des Sprites
for
(
auto
*
texture
:
textures
)
for
(
auto
*
texture
:
textures
)
{
{
int
w
,
h
;
int
w
;
int
h
;
SDL_QueryTexture
(
texture
,
nullptr
,
nullptr
,
&
w
,
&
h
);
SDL_QueryTexture
(
texture
,
nullptr
,
nullptr
,
&
w
,
&
h
);
SDL_Rect
textRect
=
{
m_x
+
10
,
text
_y
,
w
,
h
};
SDL_Rect
textRect
=
{
m_x
+
10
,
text
Y
,
w
,
h
};
SDL_RenderCopy
(
engine
.
renderer
(),
texture
,
nullptr
,
&
textRect
);
SDL_RenderCopy
(
engine
.
renderer
(),
texture
,
nullptr
,
&
textRect
);
SDL_DestroyTexture
(
texture
);
SDL_DestroyTexture
(
texture
);
text
_y
+=
(
h
+
spacing
);
text
Y
+=
(
h
+
spacing
);
}
}
TTF_CloseFont
(
font
);
TTF_CloseFont
(
font
);
...
...
This diff is collapsed.
Click to expand it.
src/game/ui/modals/UnitInfoMenu.hpp
+
6
−
6
View file @
8f3e3495
...
@@ -16,11 +16,11 @@ class UnitInfoMenu : public Scene
...
@@ -16,11 +16,11 @@ class UnitInfoMenu : public Scene
void
handleEvent
(
Engine
&
engine
,
SDL_Event
&
event
)
override
;
void
handleEvent
(
Engine
&
engine
,
SDL_Event
&
event
)
override
;
void
setUnit
(
Unit
&
unit
);
void
setUnit
(
Unit
&
unit
);
void
render
(
Engine
&
engine
);
void
render
(
Engine
&
engine
)
override
;
void
update
(
int
x
,
int
y
);
void
update
(
int
x
,
int
y
);
private:
private:
int
RENDERING_SCALE
=
3
;
const
int
RENDERING_SCALE
=
3
;
int
m_x
;
int
m_x
;
int
m_y
;
int
m_y
;
Unit
*
m_currentUnit
;
Unit
*
m_currentUnit
;
...
...
This diff is collapsed.
Click to expand it.
Prev
1
2
3
4
Next
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