Los menus permiten añadir lineas de separación entre los elementos
This commit is contained in:
@@ -25,7 +25,8 @@ defaultActionWhenCancel=15
|
|||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=DIFFICULTY
|
text=DIFFICULTY
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
@@ -38,7 +39,8 @@ linkedDown=true
|
|||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=KEYBOARD
|
text=KEYBOARD
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
selectable=false
|
selectable=false
|
||||||
greyed=false
|
greyed=false
|
||||||
[/item]
|
[/item]
|
||||||
@@ -53,14 +55,16 @@ linkedDown=true
|
|||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=GAME CONTROLLER
|
text=GAME CONTROLLER
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
selectable=false
|
selectable=false
|
||||||
greyed=false
|
greyed=false
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=LANGUAGE
|
text=LANGUAGE
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
@@ -73,7 +77,8 @@ linkedDown=true
|
|||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=WINDOW
|
text=WINDOW
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
selectable=false
|
selectable=false
|
||||||
greyed=false
|
greyed=false
|
||||||
[/item]
|
[/item]
|
||||||
@@ -90,22 +95,24 @@ hPaddingDown=2
|
|||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=VSYNC
|
text=VSYNC
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=HOW TO PLAY
|
text=HOW TO PLAY
|
||||||
hPaddingDown=5
|
hPaddingDown=2
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=HISCORE TABLE
|
text=HISCORE TABLE
|
||||||
hPaddingDown=5
|
hPaddingDown=2
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
text=JAILERID:
|
text=JAILERID:
|
||||||
hPaddingDown=5
|
hPaddingDown=6
|
||||||
|
line=true
|
||||||
[/item]
|
[/item]
|
||||||
|
|
||||||
[item]
|
[item]
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ bool Menu::load(std::string file_path)
|
|||||||
item.greyed = false;
|
item.greyed = false;
|
||||||
item.linkedDown = false;
|
item.linkedDown = false;
|
||||||
item.visible = true;
|
item.visible = true;
|
||||||
|
item.line = false;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@@ -142,7 +143,7 @@ bool Menu::load(std::string file_path)
|
|||||||
|
|
||||||
} while (line != "[/item]");
|
} while (line != "[/item]");
|
||||||
|
|
||||||
addItem(item.label, item.hPaddingDown, item.selectable, item.greyed, item.linkedDown, item.visible);
|
addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
// En caso contrario se parsea el fichero para buscar las variables y los valores
|
||||||
@@ -216,6 +217,11 @@ bool Menu::setItem(item_t *item, std::string var, std::string value)
|
|||||||
item->visible = value == "true" ? true : false;
|
item->visible = value == "true" ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
else if (var == "line")
|
||||||
|
{
|
||||||
|
item->line = value == "true" ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
else if ((var == "") || (var == "[/item]"))
|
else if ((var == "") || (var == "[/item]"))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -653,8 +659,19 @@ void Menu::render()
|
|||||||
// Renderiza el texto
|
// Renderiza el texto
|
||||||
for (int i = 0; i < (int)item.size(); ++i)
|
for (int i = 0; i < (int)item.size(); ++i)
|
||||||
{
|
{
|
||||||
|
h_line_t line;
|
||||||
|
line.x1 = selector.rect.x + (selector.rect.w / 6);
|
||||||
|
line.x2 = line.x1 + ((selector.rect.w / 6) * 4);
|
||||||
if (item[i].visible)
|
if (item[i].visible)
|
||||||
{
|
{
|
||||||
|
// Comprueba si ha de dibujar una linea en el elemento del menu
|
||||||
|
if (item[i].line)
|
||||||
|
{
|
||||||
|
line.y = item[i].rect.y + item[i].rect.h + (item[i].hPaddingDown / 2) - 1;
|
||||||
|
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 64);
|
||||||
|
SDL_RenderDrawLine(renderer, line.x1, line.y, line.x2, line.y);
|
||||||
|
}
|
||||||
|
|
||||||
if (i == selector.index)
|
if (i == selector.index)
|
||||||
{
|
{
|
||||||
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
const color_t color = {selector.itemColor.r, selector.itemColor.g, selector.itemColor.b};
|
||||||
@@ -832,9 +849,9 @@ void Menu::centerMenuElementsOnX()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Añade un item al menu
|
// Añade un item al menu
|
||||||
void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool greyed, bool linkedDown, bool visible)
|
void Menu::addItem(item_t temp)
|
||||||
{
|
{
|
||||||
item_t temp;
|
// item_t temp;
|
||||||
|
|
||||||
if (item.empty())
|
if (item.empty())
|
||||||
{ // Si es el primer item coge la posición en el eje Y del propio menu
|
{ // Si es el primer item coge la posición en el eje Y del propio menu
|
||||||
@@ -846,15 +863,10 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
|||||||
}
|
}
|
||||||
|
|
||||||
temp.rect.x = x;
|
temp.rect.x = x;
|
||||||
temp.hPaddingDown = hPaddingDown;
|
|
||||||
temp.selectable = selectable;
|
|
||||||
temp.greyed = greyed;
|
|
||||||
temp.linkedDown = linkedDown;
|
|
||||||
temp.visible = visible;
|
|
||||||
|
|
||||||
item.push_back(temp);
|
item.push_back(temp);
|
||||||
|
|
||||||
setItemCaption(item.size() - 1, text);
|
setItemCaption(item.size() - 1, temp.label);
|
||||||
|
|
||||||
if (item.size() > 1)
|
if (item.size() > 1)
|
||||||
{
|
{
|
||||||
@@ -868,12 +880,6 @@ void Menu::addItem(std::string text, int hPaddingDown, bool selectable, bool gre
|
|||||||
reorganize();
|
reorganize();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Elimina un item del menu
|
|
||||||
void Menu::removeItem(int index)
|
|
||||||
{
|
|
||||||
/* POR HACER */
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cambia el texto de un item
|
// Cambia el texto de un item
|
||||||
void Menu::setItemCaption(int index, std::string text)
|
void Menu::setItemCaption(int index, std::string text)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ private:
|
|||||||
bool linkedDown; // Indica si el elemento actual y el siguiente se tratan como uno solo. Afecta al selector
|
bool linkedDown; // Indica si el elemento actual y el siguiente se tratan como uno solo. Afecta al selector
|
||||||
bool linkedUp; // Indica si el elemento actual y el anterior se tratan como uno solo. Afecta al selector
|
bool linkedUp; // Indica si el elemento actual y el anterior se tratan como uno solo. Afecta al selector
|
||||||
bool visible; // Indica si el elemento es visible
|
bool visible; // Indica si el elemento es visible
|
||||||
|
bool line; // Indica si el elemento lleva una linea a continuación
|
||||||
};
|
};
|
||||||
|
|
||||||
struct selector_t
|
struct selector_t
|
||||||
@@ -193,10 +194,7 @@ public:
|
|||||||
void centerMenuElementsOnX();
|
void centerMenuElementsOnX();
|
||||||
|
|
||||||
// Añade un item al menu
|
// Añade un item al menu
|
||||||
void addItem(std::string text, int hPaddingDown = 1, bool selectable = true, bool greyed = false, bool linkedDown = false, bool visible = true);
|
void addItem(item_t item);
|
||||||
|
|
||||||
// Elimina un item del menu
|
|
||||||
void removeItem(int index);
|
|
||||||
|
|
||||||
// Cambia el texto de un item
|
// Cambia el texto de un item
|
||||||
void setItemCaption(int index, std::string text);
|
void setItemCaption(int index, std::string text);
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ void EnterID::fillTexture()
|
|||||||
// Añade el efecto de degradado en el fondo
|
// Añade el efecto de degradado en el fondo
|
||||||
Texture *gradient = new Texture(renderer, asset->get("title_gradient.png"));
|
Texture *gradient = new Texture(renderer, asset->get("title_gradient.png"));
|
||||||
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
|
SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT};
|
||||||
gradient->render(renderer, 0, 0, &rect);
|
//gradient->render(renderer, 0, 0, &rect);
|
||||||
delete gradient;
|
delete gradient;
|
||||||
|
|
||||||
// Escribe el texto en la textura
|
// Escribe el texto en la textura
|
||||||
|
|||||||
Reference in New Issue
Block a user