fix: petada per tancar mal director (supose que introduit per Claude al pasar a sdl_callbacks)
eliminat codi mort d'screen
This commit is contained in:
@@ -23,9 +23,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options
|
||||
borderWidth = options->borderWidth * 2;
|
||||
borderHeight = options->borderHeight * 2;
|
||||
|
||||
iniFade();
|
||||
iniSpectrumFade();
|
||||
|
||||
// Define el color del borde para el modo de pantalla completa
|
||||
borderColor = {0x00, 0x00, 0x00};
|
||||
|
||||
@@ -243,120 +240,6 @@ void Screen::switchBorder() {
|
||||
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_FRect rect = {0, 0, (float)gameCanvasWidth, (float)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();
|
||||
|
||||
// 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(options->palette, v));
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
// Muestra una notificación en la línea superior durante durationMs
|
||||
void Screen::notify(const std::string &text, color_t textColor, color_t outlineColor, Uint32 durationMs) {
|
||||
notificationMessage = text;
|
||||
@@ -377,7 +260,11 @@ void Screen::renderNotification() {
|
||||
return;
|
||||
}
|
||||
notificationText->writeDX(TXT_CENTER | TXT_COLOR | TXT_STROKE,
|
||||
gameCanvasWidth / 2, notificationY,
|
||||
notificationMessage, 1,
|
||||
notificationTextColor, 1, notificationOutlineColor);
|
||||
gameCanvasWidth / 2,
|
||||
notificationY,
|
||||
notificationMessage,
|
||||
1,
|
||||
notificationTextColor,
|
||||
1,
|
||||
notificationOutlineColor);
|
||||
}
|
||||
Reference in New Issue
Block a user