Terminada la tabla de records
This commit is contained in:
@@ -530,8 +530,6 @@ void Director::initOnline()
|
||||
{
|
||||
if (!options->online.enabled)
|
||||
{
|
||||
//screen->showText("Modo Offline");
|
||||
//std::cout << "Modo Offline" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,20 +85,52 @@ void HiScoreTable::render()
|
||||
SDL_Rect srcRect = {0, 0, 16, 16};
|
||||
|
||||
const color_t orangeColor = {0xFF, 0x7A, 0x00};
|
||||
// hay 27 letras - 7 de puntos quedan 20 caracteres 20 - nameLenght 0 numDots
|
||||
const int spaceBetweenHeader = 32;
|
||||
const int spaceBetweenLines = text->getCharacterSize() * 1.8f;
|
||||
const int scorePosition = 180;
|
||||
|
||||
// Pinta en el backbuffer el texto y los sprites
|
||||
SDL_SetRenderTarget(renderer, backbuffer);
|
||||
SDL_SetRenderDrawColor(renderer, bgColor.r, bgColor.g, bgColor.b, 255);
|
||||
SDL_RenderClear(renderer);
|
||||
|
||||
// Escribe el texto
|
||||
// Escribe el texto: Mejores puntuaciones
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, lang->getText(42), 1, orangeColor, 1, shdwTxtColor);
|
||||
|
||||
// Escribe la lista de jugadores
|
||||
int numUsers = jscore::getNumUsers();
|
||||
for (int i = 0; i < numUsers; ++i)
|
||||
{
|
||||
text->writeShadowed(0, (i * text->getCharacterSize())+20, jscore::getUserName(i),shdwTxtColor);
|
||||
text->writeShadowed(100, (i * text->getCharacterSize())+20, std::to_string(jscore::getPoints(i)),shdwTxtColor);
|
||||
const int nameLenght = jscore::getUserName(i).length();
|
||||
const int numDots = 20 - nameLenght;
|
||||
std::string dots = "";
|
||||
for (int j = 0; j < numDots; ++j)
|
||||
{
|
||||
dots = dots + ".";
|
||||
}
|
||||
const std::string line = jscore::getUserName(i) + dots + scoreToString(jscore::getPoints(i));
|
||||
text->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
|
||||
}
|
||||
|
||||
// Rellena la lista con otros nombres
|
||||
if (numUsers < 10)
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
names.insert(names.end(), {"BRY", "USUFONDO", "G.LUCAS", "P.DELGAT", "P.ARRABALERA", "PELECHANO", "SAHUQUILLO"});
|
||||
|
||||
for (int i = numUsers; i < 10; ++i)
|
||||
{
|
||||
const int nameLenght = names.at(i - numUsers).length();
|
||||
const int numDots = 20 - nameLenght;
|
||||
std::string dots = "";
|
||||
for (int j = 0; j < numDots; ++j)
|
||||
{
|
||||
dots = dots + ".";
|
||||
}
|
||||
const std::string line = names.at(i - numUsers) + dots + "0000000";
|
||||
text->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor);
|
||||
}
|
||||
}
|
||||
|
||||
if ((mode == mhst_manual) && (counter % 50 > 14))
|
||||
@@ -177,3 +209,44 @@ section_t HiScoreTable::run(mode_hiScoreTable_e mode)
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
// Transforma un valor numérico en una cadena de 6 cifras
|
||||
std::string HiScoreTable::scoreToString(Uint32 num)
|
||||
{
|
||||
if ((num >= 0) && (num <= 9))
|
||||
{
|
||||
return ("000000" + std::to_string(num));
|
||||
}
|
||||
|
||||
if ((num >= 10) && (num <= 99))
|
||||
{
|
||||
return ("00000" + std::to_string(num));
|
||||
}
|
||||
|
||||
if ((num >= 100) && (num <= 999))
|
||||
{
|
||||
return ("0000" + std::to_string(num));
|
||||
}
|
||||
|
||||
if ((num >= 1000) && (num <= 9999))
|
||||
{
|
||||
return ("000" + std::to_string(num));
|
||||
}
|
||||
|
||||
if ((num >= 010000) && (num <= 99999))
|
||||
{
|
||||
return ("00" + std::to_string(num));
|
||||
}
|
||||
|
||||
if ((num >= 100000) && (num <= 999999))
|
||||
{
|
||||
return ("0" + std::to_string(num));
|
||||
}
|
||||
|
||||
if ((num >= 1000000) && (num <= 9999999))
|
||||
{
|
||||
return (std::to_string(num));
|
||||
}
|
||||
|
||||
return (std::to_string(num));
|
||||
}
|
||||
@@ -49,6 +49,9 @@ private:
|
||||
// Comprueba los eventos
|
||||
void checkEventHandler();
|
||||
|
||||
// Transforma un valor numérico en una cadena de 6 cifras
|
||||
std::string scoreToString(Uint32 num);
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *mAsset, Lang *lang, options_t *options);
|
||||
|
||||
@@ -666,6 +666,11 @@ void Title::checkEventHandler()
|
||||
break;
|
||||
}
|
||||
|
||||
else if (eventHandler->type == SDL_RENDER_DEVICE_RESET || eventHandler->type == SDL_RENDER_TARGETS_RESET)
|
||||
{
|
||||
reLoadTextures();
|
||||
}
|
||||
|
||||
else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0)
|
||||
{
|
||||
switch (eventHandler->key.keysym.scancode)
|
||||
@@ -676,27 +681,27 @@ void Title::checkEventHandler()
|
||||
|
||||
case SDL_SCANCODE_F:
|
||||
screen->switchVideoMode();
|
||||
reloadTextures();
|
||||
reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F1:
|
||||
screen->setWindowSize(1);
|
||||
reloadTextures();
|
||||
reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F2:
|
||||
screen->setWindowSize(2);
|
||||
reloadTextures();
|
||||
reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F3:
|
||||
screen->setWindowSize(3);
|
||||
reloadTextures();
|
||||
reLoadTextures();
|
||||
break;
|
||||
|
||||
case SDL_SCANCODE_F4:
|
||||
screen->setWindowSize(4);
|
||||
reloadTextures();
|
||||
reLoadTextures();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1113,7 +1118,7 @@ void Title::checkInputDevices()
|
||||
}
|
||||
|
||||
// Recarga las texturas
|
||||
void Title::reloadTextures()
|
||||
void Title::reLoadTextures()
|
||||
{
|
||||
dustTexture->reLoad();
|
||||
coffeeTexture->reLoad();
|
||||
|
||||
@@ -136,7 +136,7 @@ private:
|
||||
void checkInputDevices();
|
||||
|
||||
// Recarga las texturas
|
||||
void reloadTextures();
|
||||
void reLoadTextures();
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
|
||||
Reference in New Issue
Block a user