Optimizado el renderizado de notificaciones
This commit is contained in:
@@ -12,7 +12,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
this->asset = asset;
|
||||
|
||||
// Crea los objetos
|
||||
//notify = new Notify(renderer, asset->get("smb2_big.png"), asset->get("smb2_big.txt"));
|
||||
notify = new Notify(renderer, asset->get("smb2.png"), asset->get("smb2.txt"));
|
||||
|
||||
gameCanvasWidth = gameInternalResX;
|
||||
@@ -41,6 +40,9 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
anchor.top = 0;
|
||||
anchor.bottom = gameCanvasHeight;
|
||||
anchor.middle = gameCanvasHeight / 2;
|
||||
|
||||
// Inicializa variables
|
||||
notifyActive = false;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -171,15 +173,7 @@ void Screen::setVideoMode(int fullScreenMode)
|
||||
// Camibia entre pantalla completa y ventana
|
||||
void Screen::switchVideoMode()
|
||||
{
|
||||
if (options->fullScreenMode == 0)
|
||||
{
|
||||
options->fullScreenMode = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
options->fullScreenMode = 0;
|
||||
}
|
||||
|
||||
options->fullScreenMode = (options->fullScreenMode == 0) ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0;
|
||||
setVideoMode(options->fullScreenMode);
|
||||
}
|
||||
|
||||
@@ -303,30 +297,12 @@ void Screen::iniSpectrumFade()
|
||||
|
||||
spectrumColor.clear();
|
||||
|
||||
color_t c;
|
||||
c = stringToColor("black");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("blue");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("red");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("magenta");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("green");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("cyan");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("yellow");
|
||||
spectrumColor.push_back(c);
|
||||
|
||||
c = stringToColor("bright_white");
|
||||
spectrumColor.push_back(c);
|
||||
// Inicializa el vector de colores
|
||||
const std::vector<std::string> vColors = {"black", "blue", "red", "magenta", "green", "cyan", "yellow", "bright_white"};
|
||||
for (auto v : vColors)
|
||||
{
|
||||
spectrumColor.push_back(stringToColor(p_zxspectrum, v));
|
||||
}
|
||||
}
|
||||
|
||||
// Actualiza el spectrum fade
|
||||
@@ -378,6 +354,7 @@ void Screen::renderFX()
|
||||
void Screen::updateNotifier()
|
||||
{
|
||||
notify->update();
|
||||
notifyActive = notify->active();
|
||||
}
|
||||
|
||||
// Muestra una notificación de texto por pantalla;
|
||||
@@ -389,6 +366,11 @@ void Screen::showText(std::string text)
|
||||
// Dibuja las notificaciones
|
||||
void Screen::renderNotifications()
|
||||
{
|
||||
if (!notifyActive)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_RenderSetLogicalSize(renderer, screenWidth, screenHeight);
|
||||
notify->render();
|
||||
SDL_RenderSetLogicalSize(renderer, gameCanvasWidth, gameCanvasHeight);
|
||||
|
||||
Reference in New Issue
Block a user