Ja es pot "enner llour neim". Falta decidir quin de tots els dissenys m'agrada mes
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
#include "scoreboard.h"
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <math.h> // for roundf
|
||||
#include "asset.h" // for Asset
|
||||
#include "lang.h" // for getText
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "text.h" // for Text
|
||||
#include "texture.h" // for Texture
|
||||
#include <SDL2/SDL_blendmode.h> // for SDL_BLENDMODE_BLEND
|
||||
#include <SDL2/SDL_pixels.h> // for SDL_PIXELFORMAT_RGBA8888
|
||||
#include <SDL2/SDL_timer.h> // for SDL_GetTicks
|
||||
#include <math.h> // for roundf
|
||||
#include "asset.h" // for Asset
|
||||
#include "lang.h" // for getText
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "text.h" // for Text
|
||||
#include "texture.h" // for Texture
|
||||
|
||||
// Constructor
|
||||
Scoreboard::Scoreboard(SDL_Renderer *renderer)
|
||||
@@ -23,9 +23,11 @@ Scoreboard::Scoreboard(SDL_Renderer *renderer)
|
||||
|
||||
// Inicializa variables
|
||||
stage = 1;
|
||||
for (int i = 0; i< SCOREBOARD_MAX_PANELS; ++i)
|
||||
for (int i = 0; i < SCOREBOARD_MAX_PANELS; ++i)
|
||||
{
|
||||
name[i] = "";
|
||||
recordName[i] = "";
|
||||
selectorPos[i] = 0;
|
||||
score[i] = 0;
|
||||
mult[i] = 0;
|
||||
continueCounter[i] = 0;
|
||||
@@ -149,6 +151,18 @@ void Scoreboard::setName(int panel, std::string name)
|
||||
this->name[panel] = name;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Scoreboard::setRecordName(int panel, std::string recordName)
|
||||
{
|
||||
this->recordName[panel] = recordName;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Scoreboard::setSelectorPos(int panel, int pos)
|
||||
{
|
||||
selectorPos[panel] = pos;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Scoreboard::setScore(int panel, int score)
|
||||
{
|
||||
@@ -274,7 +288,7 @@ void Scoreboard::fillPanelTextures()
|
||||
|
||||
// HI-SCORE
|
||||
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang::getText(56));
|
||||
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y, hiScoreName + " - " +updateScoreText(hiScore));
|
||||
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y, hiScoreName + " - " + updateScoreText(hiScore));
|
||||
break;
|
||||
|
||||
case SCOREBOARD_MODE_CONTINUE:
|
||||
@@ -288,8 +302,36 @@ void Scoreboard::fillPanelTextures()
|
||||
break;
|
||||
|
||||
case SCOREBOARD_MODE_ENTER_NAME:
|
||||
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, "ENTER NAME");
|
||||
{
|
||||
// SCORE
|
||||
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]);
|
||||
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score[i]));
|
||||
|
||||
// ENTER NAME
|
||||
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang::getText(106));
|
||||
//color_t selectorColor = lightenColor(color, 36);
|
||||
color_t textColor = {0xFB, 0xF2, 0x36};
|
||||
SDL_Rect rect = {enterNamePos.x, enterNamePos.y, 8, 8};
|
||||
for (int j = 0; j < (int)recordName[i].size(); ++j)
|
||||
{
|
||||
SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 255);
|
||||
SDL_RenderDrawLine(renderer, rect.x + 1, rect.y + rect.h + 1, rect.x + rect.w - 2, rect.y + rect.h + 1);
|
||||
if (j == selectorPos[i])
|
||||
{
|
||||
// SDL_SetRenderDrawColor(renderer, selectorColor.r, selectorColor.g, selectorColor.b, 255);
|
||||
// SDL_RenderFillRect(renderer, &rect);
|
||||
SDL_SetRenderDrawColor(renderer, textColor.r, textColor.g, textColor.b, 255);
|
||||
SDL_RenderDrawLine(renderer, rect.x + 1, rect.y + rect.h + 1, rect.x + rect.w - 2, rect.y + rect.h + 1);
|
||||
textScoreBoard->writeColored(rect.x + 1, rect.y + 1, recordName[i].substr(j, 1), textColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
textScoreBoard->write(rect.x + 1, rect.y + 1, recordName[i].substr(j, 1));
|
||||
}
|
||||
rect.x += 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -359,6 +401,11 @@ void Scoreboard::recalculateAnchors()
|
||||
slot4_3 = {col, row3};
|
||||
slot4_4 = {col, row4};
|
||||
|
||||
// Primer cuadrado para poner el nombre de record
|
||||
const int enterNameLenght = 8 * 8;
|
||||
enterNamePos.x = (panelWidth - enterNameLenght) / 2;
|
||||
enterNamePos.y = row4 - 1;
|
||||
|
||||
// Recoloca los sprites
|
||||
if (powerMeterSprite)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user