Actualizadas librerias comunes a las ultimas versiones
This commit is contained in:
@@ -13,11 +13,10 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
|
||||
gameCanvasWidth = gameInternalResX;
|
||||
gameCanvasHeight = gameInternalResY;
|
||||
|
||||
// Establece el modo de video
|
||||
setVideoMode(options->fullScreenMode);
|
||||
iniFade();
|
||||
iniSpectrumFade();
|
||||
|
||||
// Define el color del borde para el modo de pantalla completa
|
||||
borderColor = {0x27, 0x27, 0x36};
|
||||
borderColor = {0x00, 0x00, 0x00};
|
||||
|
||||
// Crea la textura donde se dibujan los graficos del juego
|
||||
@@ -25,6 +24,9 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i
|
||||
if (gameCanvas == NULL)
|
||||
printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());
|
||||
|
||||
// Establece el modo de video
|
||||
setVideoMode(options->fullScreenMode);
|
||||
|
||||
// Calcula los anclajes
|
||||
anchor.left = 0;
|
||||
anchor.right = gameCanvasWidth;
|
||||
@@ -79,9 +81,21 @@ void Screen::setVideoMode(int fullScreenMode)
|
||||
// Si está activo el modo ventana quita el borde
|
||||
if (fullScreenMode == 0)
|
||||
{
|
||||
screenWidth = gameCanvasWidth;
|
||||
screenHeight = gameCanvasHeight;
|
||||
dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
||||
if (options->borderEnabled)
|
||||
{
|
||||
const int incWidth = gameCanvasWidth * options->borderSize;
|
||||
const int incHeight = gameCanvasHeight * options->borderSize;
|
||||
screenWidth = gameCanvasWidth + incWidth;
|
||||
screenHeight = gameCanvasHeight + incHeight;
|
||||
dest = {0 + (incWidth / 2), 0 + (incHeight / 2), gameCanvasWidth, gameCanvasHeight};
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
screenWidth = gameCanvasWidth;
|
||||
screenHeight = gameCanvasHeight;
|
||||
dest = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
||||
}
|
||||
|
||||
// Modifica el tamaño del renderizador y de la ventana
|
||||
SDL_RenderSetLogicalSize(renderer, screenWidth, screenHeight);
|
||||
@@ -147,12 +161,14 @@ void Screen::switchVideoMode()
|
||||
{
|
||||
if (options->fullScreenMode == 0)
|
||||
{
|
||||
setVideoMode(SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
options->fullScreenMode = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
setVideoMode(0);
|
||||
options->fullScreenMode = 0;
|
||||
}
|
||||
|
||||
setVideoMode(options->fullScreenMode);
|
||||
}
|
||||
|
||||
// Cambia el tamaño de la ventana
|
||||
@@ -166,4 +182,182 @@ void Screen::setWindowSize(int size)
|
||||
void Screen::setBorderColor(color_t color)
|
||||
{
|
||||
borderColor = color;
|
||||
}
|
||||
|
||||
// Cambia el tipo de mezcla
|
||||
void Screen::setBlendMode(SDL_BlendMode blendMode)
|
||||
{
|
||||
SDL_SetRenderDrawBlendMode(renderer, blendMode);
|
||||
}
|
||||
|
||||
// Establece el tamaño del borde
|
||||
void Screen::setBorderSize(float s)
|
||||
{
|
||||
options->borderSize = s;
|
||||
}
|
||||
|
||||
// Establece si se ha de ver el borde en el modo ventana
|
||||
void Screen::setBorderEnabled(bool value)
|
||||
{
|
||||
options->borderEnabled = value;
|
||||
}
|
||||
|
||||
// Cambia entre borde visible y no visible
|
||||
void Screen::switchBorder()
|
||||
{
|
||||
options->borderEnabled = !options->borderEnabled;
|
||||
setVideoMode(0);
|
||||
}
|
||||
|
||||
// Activa el fade
|
||||
void Screen::setFade()
|
||||
{
|
||||
fade = true;
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el fade
|
||||
bool Screen::fadeEnded()
|
||||
{
|
||||
if (fade || fadeCounter > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Activa el spectrum fade
|
||||
void Screen::setspectrumFade()
|
||||
{
|
||||
spectrumFade = true;
|
||||
}
|
||||
|
||||
// Comprueba si ha terminado el spectrum fade
|
||||
bool Screen::spectrumFadeEnded()
|
||||
{
|
||||
if (spectrumFade || spectrumFadeCounter > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Inicializa las variables para el fade
|
||||
void Screen::iniFade()
|
||||
{
|
||||
fade = false;
|
||||
fadeCounter = 0;
|
||||
fadeLenght = 200;
|
||||
}
|
||||
|
||||
// Actualiza el fade
|
||||
void Screen::updateFade()
|
||||
{
|
||||
if (!fade)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
fadeCounter++;
|
||||
if (fadeCounter > fadeLenght)
|
||||
{
|
||||
iniFade();
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el fade
|
||||
void Screen::renderFade()
|
||||
{
|
||||
if (!fade)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const SDL_Rect rect = {0, 0, gameCanvasWidth, gameCanvasHeight};
|
||||
color_t color = {0, 0, 0};
|
||||
const float step = (float)fadeCounter / (float)fadeLenght;
|
||||
const int alpha = 0 + (255 - 0) * step;
|
||||
SDL_SetRenderDrawColor(renderer, color.r, color.g, color.b, alpha);
|
||||
SDL_RenderFillRect(renderer, &rect);
|
||||
}
|
||||
|
||||
// Inicializa las variables para el fade spectrum
|
||||
void Screen::iniSpectrumFade()
|
||||
{
|
||||
spectrumFade = false;
|
||||
spectrumFadeCounter = 0;
|
||||
spectrumFadeLenght = 50;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// Actualiza el spectrum fade
|
||||
void Screen::updateSpectrumFade()
|
||||
{
|
||||
if (!spectrumFade)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spectrumFadeCounter++;
|
||||
if (spectrumFadeCounter > spectrumFadeLenght)
|
||||
{
|
||||
iniSpectrumFade();
|
||||
SDL_SetTextureColorMod(gameCanvas, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
|
||||
// Dibuja el spectrum fade
|
||||
void Screen::renderSpectrumFade()
|
||||
{
|
||||
if (!spectrumFade)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const float step = (float)spectrumFadeCounter / (float)spectrumFadeLenght;
|
||||
const int max = spectrumColor.size() - 1;
|
||||
const int index = max + (0 - max) * step;
|
||||
const color_t c = spectrumColor[index];
|
||||
SDL_SetTextureColorMod(gameCanvas, c.r, c.g, c.b);
|
||||
}
|
||||
|
||||
// Actualiza los efectos
|
||||
void Screen::updateFX()
|
||||
{
|
||||
updateFade();
|
||||
updateSpectrumFade();
|
||||
}
|
||||
|
||||
// Dibuja los efectos
|
||||
void Screen::renderFX()
|
||||
{
|
||||
renderFade();
|
||||
renderSpectrumFade();
|
||||
}
|
||||
Reference in New Issue
Block a user