Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <SDL.h>
#include <SDL_image.h>
#include <SDL2_gfxPrimitives.h>
#include <SDL_ttf.h>
#include <vector>
#include <iostream>
#include "Menu.hpp"
#include "Math.hpp"
#include "RenderWindow.hpp"
#include "Cursor.hpp"
#include "Input.hpp"
SDL_Point getsize(SDL_Texture* texture) {
SDL_Point size;
SDL_QueryTexture(texture, NULL, NULL, &size.x, &size.y);
return size;
}
Menu::Menu(RenderWindow pWindow)
{
window = pWindow;
//Create texture
tTitle = window.loadString("PayloadReboot");
chdir("romfs:/");
tExit = window.loadTexture("gfx/exit.png");
tInfo = window.loadTexture("gfx/info.png");
tHekate = window.loadTexture("gfx/hekate.png");
tAMS = window.loadTexture("gfx/fusee.png");
tLockpick = window.loadTexture("gfx/lockpick.png");
tLakka = window.loadTexture("gfx/lakka.png");
//Create rect
/*rectHekate = { 107, 0, 258, 258};
rectHekate.y = vertical / 2 - rectHekate.w / 2 - 20;
rectAms = { rectHekate.x + rectHekate.w + 14, 0, 258, 258};
rectAms.y = vertical / 2 - rectAms.w / 2 - 20;
rectLockpick = { rectAms.x + rectAms.w +14, 0, 258, 258};
rectLockpick.y = vertical / 2 - rectLockpick.w / 2 - 20;
rectLakka = { rectLakka.x + rectLakka.w + 14, 0, 258, 258};
rectLakka.y = vertical / 2 - rectLakka.w / 2 - 20;*/
rectTemplate = {105, vertical / 2 - 258 / 2 - 20, 258, 258};
}
void Menu::printMenu()
{
std::vector<Entity> vEntity {};
std::vector<Entity> vEntityCursor {};
SDL_Point size = getsize(tTitle);
vEntity.push_back(Entity (Vector2f(horizontal / 2 - size.x / 2, 0), tTitle, size.x, size.y, 0, 0));
/*REBOOT TEMPLATE*/
for (int i = 0; i < 4; ++i)
{
window.fillRect(rectTemplate, 80, 80, 80);
rectTemplate.x += rectTemplate.w + 14;
}
rectTemplate.x = 105;
/*ICONS HEKATE AMS...*/
vEntityCursor.push_back(Entity (Vector2f(rectTemplate.x, rectTemplate.y), tHekate, 258, 258, 0, 0));
vEntityCursor.push_back(Entity (Vector2f(rectTemplate.x + rectTemplate.w + 14, rectTemplate.y), tAMS, 258, 258, 0, 0));
vEntityCursor.push_back(Entity (Vector2f(rectTemplate.x + (rectTemplate.w + 14) * 2, rectTemplate.y), tLockpick, 258, 258, 0, 0));
vEntityCursor.push_back(Entity (Vector2f(rectTemplate.x + (rectTemplate.w + 14) * 3, rectTemplate.y), tLakka, 258, 258, 0, 0));
/*CIRCLE BEHIND SMALL ICONS*/
window.drawCircleBehindIcons();
/*BUTTON UNDER ICONS*/
size = getsize(tExit);
vEntity.push_back(Entity (Vector2f(horizontal / 2 - size.x * 1.5, 550), tExit, size.x, size.y, 0, 0));
size = getsize(tInfo);
vEntity.push_back(Entity (Vector2f(horizontal / 2 + size.x * 0.5, 550), tInfo, size.x, size.y, 0, 0));
for (auto i : vEntity)
{
window.render(i, 1);
}
for (auto i : vEntityCursor)
{
window.render(i, 1);
}
}
void Menu::printAbout(){
bool isOpen = true;
SDL_Event eventAbout;
std::vector<Entity> vEntity {};
SDL_Rect rect {320, 180, 640, 360};
window.fillRect(rect, 80, 80, 80);
//The code is disgusting but idk how to do better because \n doesn't work
SDL_Texture* tCredit = window.loadString("Thanks to :");
SDL_Texture* tSciresM = window.loadString("- SciresM for fusee");
SDL_Texture* tCTCaer = window.loadString("- CTCaer for hekate");
SDL_Texture* tshchmue = window.loadString("- shchmue for lockpick");
SDL_Texture* tpressA = window.loadString("- PRESS A TO EXIT !");
SDL_Point size = getsize(tCredit);
vEntity.push_back(Entity(Vector2f(340, 200), tCredit, size.x, size.y , 0, 0));
size = getsize(tSciresM);
vEntity.push_back(Entity(Vector2f(340, 230), tSciresM, size.x, size.y , 0, 0));
size = getsize(tCTCaer);
vEntity.push_back(Entity(Vector2f(340, 260), tCTCaer, size.x, size.y , 0, 0));
size = getsize(tshchmue);
vEntity.push_back(Entity(Vector2f(340, 290), tshchmue, size.x, size.y , 0, 0));
size = getsize(tpressA);
vEntity.push_back(Entity(Vector2f(340, 350), tpressA, size.x, size.y , 0, 0));
for (auto i : vEntity){
window.render(i, 1);
}
window.display();
while (isOpen){
while (SDL_PollEvent(&eventAbout)){
if (eventAbout.type == SDL_JOYBUTTONDOWN){
if (eventAbout.jbutton.button == 0) //button A
{
return;
}
}
}
}
}