Rendu
A lightweight rendering engine for experimentations
Main Page
Modules
Namespaces
Classes
Files
Related Pages
File List
Loading...
Searching...
No Matches
src
apps
snakegame
GameMenu.hpp
1
#pragma once
2
3
#include "Common.hpp"
4
#include "GameMenu.hpp"
5
#include "resources/Font.hpp"
6
11
class
MenuButton
{
12
13
public
:
21
MenuButton
(
const
glm::vec2 & screenPos,
const
glm::vec2 & meshSize,
float
screenScale,
int
actionTag,
const
Texture
* texture);
22
27
bool
contains
(
const
glm::vec2 & mousePos)
const
;
28
32
enum class
State
: uint {
33
OFF,
34
HOVER,
35
ON
36
};
37
State
state
= State::OFF;
38
39
glm::vec2
pos
= glm::vec2(0.0f);
40
glm::vec2
size
= glm::vec2(1.0f);
41
glm::vec2
scale
= glm::vec2(1.0f);
42
float
displayScale
= 1.0f;
43
int
tag
= 0;
44
const
Texture
*
tid
=
nullptr
;
45
};
46
47
48
STD_HASH(
MenuButton::State
)
49
50
54
class
MenuToggle
: public
MenuButton
{
55
public
:
63
MenuToggle
(
const
glm::vec2 & screenPos,
const
glm::vec2 & meshSize,
float
screenScale,
int
actionTag,
const
Texture
* texture);
64
65
glm::vec2 posBox = glm::vec2(0.0f);
66
glm::vec2 posImg = glm::vec2(0.0f);
67
glm::vec2 scaleBox = glm::vec2(1.0f);
68
const
float
checkBoxScale = 0.65f;
69
};
70
75
class
MenuImage
{
76
public
:
82
MenuImage
(
const
glm::vec2 & screenPos,
float
screenScale,
const
Texture
* texture);
83
84
glm::vec2
pos
= glm::vec2(0.0f);
85
glm::vec2
size
= glm::vec2(1.0f);
86
glm::vec2
scale
= glm::vec2(1.0f);
87
const
Texture
*
tid
=
nullptr
;
88
};
89
94
class
MenuLabel
{
95
public
:
103
MenuLabel
(
const
glm::vec2 & screenPos,
float
verticalScale,
const
Font
* font,
Font::Alignment
alignment);
104
108
void
update
(
const
std::string & text);
109
110
Mesh
mesh
=
Mesh
(
""
);
111
glm::vec2
pos
= glm::vec2(0.0f);
112
const
Texture
*
tid
=
nullptr
;
113
114
private
:
115
float
_vScale
= 1.0f;
116
const
Font
*
_font
=
nullptr
;
117
Font::Alignment
_align
= Font::Alignment::LEFT;
118
};
119
124
class
GameMenu
{
125
public
:
130
void
update
(
const
glm::vec2 & screenResolution,
float
initialRatio);
131
132
~GameMenu
();
133
134
std::vector<MenuButton>
buttons
;
135
std::vector<MenuToggle>
toggles
;
136
std::vector<MenuImage>
images
;
137
std::vector<MenuLabel>
labels
;
138
const
Texture
*
backgroundImage
=
nullptr
;
139
};
Font
Font loading and storage: texture atlas, codepoints supported, dimensions of each glyph.
Definition:
Font.hpp:12
Font::Alignment
Alignment
Text alignment.
Definition:
Font.hpp:15
GameMenu
A game menu containing buttons, toggles and images.
Definition:
GameMenu.hpp:124
GameMenu::update
void update(const glm::vec2 &screenResolution, float initialRatio)
Definition:
GameMenu.cpp:34
GameMenu::backgroundImage
const Texture * backgroundImage
The background texure.
Definition:
GameMenu.hpp:138
GameMenu::images
std::vector< MenuImage > images
The menu images.
Definition:
GameMenu.hpp:136
GameMenu::buttons
std::vector< MenuButton > buttons
The menu buttons.
Definition:
GameMenu.hpp:134
GameMenu::toggles
std::vector< MenuToggle > toggles
The menu toggles.
Definition:
GameMenu.hpp:135
GameMenu::labels
std::vector< MenuLabel > labels
The menu custom labels.
Definition:
GameMenu.hpp:137
MenuButton
Represents a button in a menu.
Definition:
GameMenu.hpp:11
MenuButton::tag
int tag
Action ID.
Definition:
GameMenu.hpp:43
MenuButton::contains
bool contains(const glm::vec2 &mousePos) const
Definition:
GameMenu.cpp:8
MenuButton::size
glm::vec2 size
Screen size.
Definition:
GameMenu.hpp:40
MenuButton::pos
glm::vec2 pos
Screen position.
Definition:
GameMenu.hpp:39
MenuButton::displayScale
float displayScale
Initial display scale.
Definition:
GameMenu.hpp:42
MenuButton::scale
glm::vec2 scale
Screen scale.
Definition:
GameMenu.hpp:41
MenuButton::State
State
Button state.
Definition:
GameMenu.hpp:32
MenuButton::state
State state
The button interaction state.
Definition:
GameMenu.hpp:37
MenuButton::tid
const Texture * tid
Text texture.
Definition:
GameMenu.hpp:44
MenuImage
Represents a fixed image displayed in a menu.
Definition:
GameMenu.hpp:75
MenuImage::scale
glm::vec2 scale
Scaling.
Definition:
GameMenu.hpp:86
MenuImage::pos
glm::vec2 pos
Image position.
Definition:
GameMenu.hpp:84
MenuImage::size
glm::vec2 size
Screen size.
Definition:
GameMenu.hpp:85
MenuImage::tid
const Texture * tid
Texture.
Definition:
GameMenu.hpp:87
MenuLabel
A dynamic text label.
Definition:
GameMenu.hpp:94
MenuLabel::_vScale
float _vScale
Vertical size on screen.
Definition:
GameMenu.hpp:115
MenuLabel::mesh
Mesh mesh
Label mesh.
Definition:
GameMenu.hpp:110
MenuLabel::_font
const Font * _font
Font atlas.
Definition:
GameMenu.hpp:116
MenuLabel::tid
const Texture * tid
Font texture shortcut.
Definition:
GameMenu.hpp:112
MenuLabel::_align
Font::Alignment _align
Text alignement.
Definition:
GameMenu.hpp:117
MenuLabel::update
void update(const std::string &text)
Definition:
GameMenu.cpp:30
MenuLabel::pos
glm::vec2 pos
Label position.
Definition:
GameMenu.hpp:111
MenuToggle
Represents a toggle in a menu.
Definition:
GameMenu.hpp:54
Mesh
Represents a geometric mesh composed of vertices, other attributes and triangles.
Definition:
Mesh.hpp:15
Texture
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition:
Texture.hpp:12
Generated by
Doxygen
1.9.5 - Theme by
Simon Rodriguez