Quan canvia de RendererSurface, torna a deixar la que havia, no la de per defecte
This commit is contained in:
@@ -142,6 +142,7 @@ void Credits::fillTexture()
|
|||||||
iniTexts();
|
iniTexts();
|
||||||
|
|
||||||
// Rellena la textura de texto
|
// Rellena la textura de texto
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(text_surface_);
|
Screen::get()->setRendererSurface(text_surface_);
|
||||||
text_surface_->clear(stringToColor("black"));
|
text_surface_->clear(stringToColor("black"));
|
||||||
|
|
||||||
@@ -164,10 +165,8 @@ void Credits::fillTexture()
|
|||||||
|
|
||||||
// Recoloca el sprite del brillo
|
// Recoloca el sprite del brillo
|
||||||
shining_sprite_->setPosX(POS_X + 2);
|
shining_sprite_->setPosX(POS_X + 2);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
|
||||||
|
|
||||||
// Rellena la textura que cubre el texto con color transparente
|
// Rellena la textura que cubre el texto con color transparente
|
||||||
Screen::get()->setRendererSurface(text_surface_);
|
|
||||||
text_surface_->clear(stringToColor("transparent"));
|
text_surface_->clear(stringToColor("transparent"));
|
||||||
|
|
||||||
// Los primeros 8 pixels crea una malla
|
// Los primeros 8 pixels crea una malla
|
||||||
@@ -203,7 +202,7 @@ void Credits::fillTexture()
|
|||||||
rect = {0, 8, 256, 192};
|
rect = {0, 8, 256, 192};
|
||||||
surface->fillRect(&rect, color);
|
surface->fillRect(&rect, color);
|
||||||
|
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza el contador
|
// Actualiza el contador
|
||||||
|
|||||||
@@ -91,13 +91,13 @@ Director::~Director()
|
|||||||
saveOptionsToFile(Asset::get()->get("config.txt"));
|
saveOptionsToFile(Asset::get()->get("config.txt"));
|
||||||
|
|
||||||
// Destruye los singletones
|
// Destruye los singletones
|
||||||
Asset::destroy();
|
|
||||||
Input::destroy();
|
|
||||||
Screen::destroy();
|
|
||||||
Notifier::destroy();
|
|
||||||
Debug::destroy();
|
|
||||||
Resource::destroy();
|
|
||||||
Cheevos::destroy();
|
Cheevos::destroy();
|
||||||
|
Debug::destroy();
|
||||||
|
Input::destroy();
|
||||||
|
Notifier::destroy();
|
||||||
|
Resource::destroy();
|
||||||
|
Screen::destroy();
|
||||||
|
Asset::destroy();
|
||||||
|
|
||||||
SDL_DestroyRenderer(renderer_);
|
SDL_DestroyRenderer(renderer_);
|
||||||
SDL_DestroyWindow(window_);
|
SDL_DestroyWindow(window_);
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ void Ending::iniTexts()
|
|||||||
|
|
||||||
// Crea la textura
|
// Crea la textura
|
||||||
st.image_surface = std::make_shared<Surface>(WIDTH, HEIGHT);
|
st.image_surface = std::make_shared<Surface>(WIDTH, HEIGHT);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(st.image_surface);
|
Screen::get()->setRendererSurface(st.image_surface);
|
||||||
text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, text_color, 2, shadow_color);
|
text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, text_color, 2, shadow_color);
|
||||||
|
|
||||||
@@ -216,7 +217,7 @@ void Ending::iniTexts()
|
|||||||
st.cover_clip_height = HEIGHT;
|
st.cover_clip_height = HEIGHT;
|
||||||
|
|
||||||
sprite_texts_.push_back(st);
|
sprite_texts_.push_back(st);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,6 +251,7 @@ void Ending::iniPics()
|
|||||||
|
|
||||||
// Crea la cover_surface
|
// Crea la cover_surface
|
||||||
sp.cover_surface = std::make_shared<Surface>(WIDTH, HEIGHT + 8);
|
sp.cover_surface = std::make_shared<Surface>(WIDTH, HEIGHT + 8);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(sp.cover_surface);
|
Screen::get()->setRendererSurface(sp.cover_surface);
|
||||||
|
|
||||||
// Rellena la cover_surface con color transparente
|
// Rellena la cover_surface con color transparente
|
||||||
@@ -283,7 +285,7 @@ void Ending::iniPics()
|
|||||||
sp.cover_clip_height = HEIGHT;
|
sp.cover_clip_height = HEIGHT;
|
||||||
|
|
||||||
sprite_pics_.push_back(sp);
|
sprite_pics_.push_back(sp);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,6 +475,7 @@ void Ending::checkChangeScene()
|
|||||||
void Ending::fillCoverTexture()
|
void Ending::fillCoverTexture()
|
||||||
{
|
{
|
||||||
// Rellena la textura que cubre el texto con color transparente
|
// Rellena la textura que cubre el texto con color transparente
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(cover_surface_);
|
Screen::get()->setRendererSurface(cover_surface_);
|
||||||
cover_surface_->clear(stringToColor("transparent"));
|
cover_surface_->clear(stringToColor("transparent"));
|
||||||
|
|
||||||
@@ -495,7 +498,7 @@ void Ending::fillCoverTexture()
|
|||||||
SDL_Rect rect = {0, 0, 256, options.game.height};
|
SDL_Rect rect = {0, 0, 256, options.game.height};
|
||||||
surface->fillRect(&rect, color);
|
surface->fillRect(&rect, color);
|
||||||
|
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja la cortinilla de cambio de escena
|
// Dibuja la cortinilla de cambio de escena
|
||||||
|
|||||||
@@ -424,6 +424,7 @@ void Ending2::createSpriteTexts()
|
|||||||
|
|
||||||
// Crea la surface
|
// Crea la surface
|
||||||
auto surface = std::make_shared<Surface>(W, H);
|
auto surface = std::make_shared<Surface>(W, H);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(surface);
|
Screen::get()->setRendererSurface(surface);
|
||||||
text->write(0, 0, txt);
|
text->write(0, 0, txt);
|
||||||
|
|
||||||
@@ -431,7 +432,7 @@ void Ending2::createSpriteTexts()
|
|||||||
SDL_Rect pos = {X, Y, W, H};
|
SDL_Rect pos = {X, Y, W, H};
|
||||||
sprite_texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
sprite_texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
||||||
sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,14 +457,15 @@ void Ending2::createTexts()
|
|||||||
|
|
||||||
// Crea la surface
|
// Crea la surface
|
||||||
auto surface = std::make_shared<Surface>(w, h);
|
auto surface = std::make_shared<Surface>(w, h);
|
||||||
Screen::get()->setRendererSurface(surface);
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
|
Screen::get()->setRendererSurface(surface);
|
||||||
text->write(0, 0, list[i]);
|
text->write(0, 0, list[i]);
|
||||||
|
|
||||||
// Crea el sprite
|
// Crea el sprite
|
||||||
SDL_Rect pos = {x + dx, y, w, h};
|
SDL_Rect pos = {x + dx, y, w, h};
|
||||||
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
||||||
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea los últimos textos
|
// Crea los últimos textos
|
||||||
@@ -485,6 +487,7 @@ void Ending2::createTexts()
|
|||||||
|
|
||||||
// Crea la surface
|
// Crea la surface
|
||||||
auto surface = std::make_shared<Surface>(w, h);
|
auto surface = std::make_shared<Surface>(w, h);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(surface);
|
Screen::get()->setRendererSurface(surface);
|
||||||
text->write(0, 0, list[i]);
|
text->write(0, 0, list[i]);
|
||||||
|
|
||||||
@@ -492,7 +495,7 @@ void Ending2::createTexts()
|
|||||||
SDL_Rect pos = {x + dx, y, w, h};
|
SDL_Rect pos = {x + dx, y, w, h};
|
||||||
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
texts_.emplace_back(std::make_shared<SMovingSprite>(surface, pos));
|
||||||
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
texts_.back()->setVelY(SPRITE_DESP_SPEED_);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -562,6 +562,7 @@ void Game::initStats()
|
|||||||
void Game::fillRoomNameTexture()
|
void Game::fillRoomNameTexture()
|
||||||
{
|
{
|
||||||
// Pone la textura como destino de renderizado
|
// Pone la textura como destino de renderizado
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(room_name_surface_);
|
Screen::get()->setRendererSurface(room_name_surface_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
@@ -572,7 +573,7 @@ void Game::fillRoomNameTexture()
|
|||||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room_->getName(), 1, room_->getBGColor());
|
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room_->getName(), 1, room_->getBGColor());
|
||||||
|
|
||||||
// Deja el renderizador por defecto
|
// Deja el renderizador por defecto
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Comprueba algunos logros
|
// Comprueba algunos logros
|
||||||
|
|||||||
@@ -136,8 +136,10 @@ void LoadingScreen::updateCounter()
|
|||||||
// Dibuja la pantalla de carga
|
// Dibuja la pantalla de carga
|
||||||
void LoadingScreen::renderLoad()
|
void LoadingScreen::renderLoad()
|
||||||
{
|
{
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(screen_surface_);
|
Screen::get()->setRendererSurface(screen_surface_);
|
||||||
loading_first_part_ ? mono_loading_screen_sprite_->render(1, stringToColor("black")) : color_loading_screen_sprite_->render();
|
loading_first_part_ ? mono_loading_screen_sprite_->render(1, stringToColor("black")) : color_loading_screen_sprite_->render();
|
||||||
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el efecto de carga en el borde
|
// Dibuja el efecto de carga en el borde
|
||||||
|
|||||||
@@ -183,13 +183,13 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
const auto padding_in_h = text_->getCharacterSize();
|
const auto PADDING_IN_H = text_->getCharacterSize();
|
||||||
const auto padding_in_v = text_->getCharacterSize() / 2;
|
const auto PADDING_IN_V = text_->getCharacterSize() / 2;
|
||||||
const int icon_space = icon >= 0 ? ICON_SIZE_ + padding_in_h : 0;
|
const int ICON_SPACE = icon >= 0 ? ICON_SIZE_ + PADDING_IN_H : 0;
|
||||||
text_is = icon_space > 0 ? NotificationText::LEFT : text_is;
|
text_is = ICON_SPACE > 0 ? NotificationText::LEFT : text_is;
|
||||||
const int width = options.game.width - (PADDING_OUT_ * 2);
|
const int WIDTH = options.game.width - (PADDING_OUT_ * 2);
|
||||||
const int height = (text_->getCharacterSize() * texts.size()) + (padding_in_v * 2);
|
const int HEIGHT = (text_->getCharacterSize() * texts.size()) + (PADDING_IN_V * 2);
|
||||||
const auto shape = NotificationShape::SQUARED;
|
const auto SHAPE = NotificationShape::SQUARED;
|
||||||
|
|
||||||
// Posición horizontal
|
// Posición horizontal
|
||||||
auto desp_h = 0;
|
auto desp_h = 0;
|
||||||
@@ -199,25 +199,25 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
|||||||
}
|
}
|
||||||
else if (options.notifications.getHorizontalPosition() == NotificationPosition::CENTER)
|
else if (options.notifications.getHorizontalPosition() == NotificationPosition::CENTER)
|
||||||
{
|
{
|
||||||
desp_h = ((options.game.width / 2) - (width / 2));
|
desp_h = ((options.game.width / 2) - (WIDTH / 2));
|
||||||
}
|
}
|
||||||
else if (options.notifications.getHorizontalPosition() == NotificationPosition::RIGHT)
|
else if (options.notifications.getHorizontalPosition() == NotificationPosition::RIGHT)
|
||||||
{
|
{
|
||||||
desp_h = options.game.width - width - PADDING_OUT_;
|
desp_h = options.game.width - WIDTH - PADDING_OUT_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Posición vertical
|
// Posición vertical
|
||||||
const int desp_v = (options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? PADDING_OUT_ : options.game.height - height - PADDING_OUT_;
|
const int DESP_V = (options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? PADDING_OUT_ : options.game.height - HEIGHT - PADDING_OUT_;
|
||||||
// Offset
|
// Offset
|
||||||
const auto travel_dist = height + PADDING_OUT_;
|
const auto TRAVEL_DIST = HEIGHT + PADDING_OUT_;
|
||||||
auto offset = 0;
|
auto offset = 0;
|
||||||
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
if (options.notifications.getVerticalPosition() == NotificationPosition::TOP)
|
||||||
{
|
{
|
||||||
offset = !notifications_.empty() ? notifications_.back().y + notifications_.back().travel_dist : desp_v;
|
offset = !notifications_.empty() ? notifications_.back().y + notifications_.back().travel_dist : DESP_V;
|
||||||
}
|
}
|
||||||
else if (options.notifications.getVerticalPosition() == NotificationPosition::BOTTOM)
|
else if (options.notifications.getVerticalPosition() == NotificationPosition::BOTTOM)
|
||||||
{
|
{
|
||||||
offset = !notifications_.empty() ? notifications_.back().y - notifications_.back().travel_dist : desp_v;
|
offset = !notifications_.empty() ? notifications_.back().y - notifications_.back().travel_dist : DESP_V;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea la notificacion
|
// Crea la notificacion
|
||||||
@@ -227,36 +227,37 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
|||||||
n.code = code;
|
n.code = code;
|
||||||
n.can_be_removed = can_be_removed;
|
n.can_be_removed = can_be_removed;
|
||||||
n.y = offset;
|
n.y = offset;
|
||||||
n.travel_dist = travel_dist;
|
n.travel_dist = TRAVEL_DIST;
|
||||||
n.texts = texts;
|
n.texts = texts;
|
||||||
n.shape = shape;
|
n.shape = SHAPE;
|
||||||
int y_pos = offset + ((options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? -travel_dist : travel_dist);
|
int y_pos = offset + ((options.notifications.getVerticalPosition() == NotificationPosition::TOP) ? -TRAVEL_DIST : TRAVEL_DIST);
|
||||||
n.rect = {desp_h, y_pos, width, height};
|
n.rect = {desp_h, y_pos, WIDTH, HEIGHT};
|
||||||
|
|
||||||
// Crea la textura
|
// Crea la textura
|
||||||
n.surface = std::make_shared<Surface>(width, height);
|
n.surface = std::make_shared<Surface>(WIDTH, HEIGHT);
|
||||||
|
|
||||||
// Prepara para dibujar en la textura
|
// Prepara para dibujar en la textura
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(n.surface);
|
Screen::get()->setRendererSurface(n.surface);
|
||||||
|
|
||||||
// Dibuja el fondo de la notificación
|
// Dibuja el fondo de la notificación
|
||||||
SDL_Rect rect;
|
SDL_Rect rect;
|
||||||
if (shape == NotificationShape::ROUNDED)
|
if (SHAPE == NotificationShape::ROUNDED)
|
||||||
{
|
{
|
||||||
rect = {4, 0, width - (4 * 2), height};
|
rect = {4, 0, WIDTH - (4 * 2), HEIGHT};
|
||||||
n.surface->fillRect(&rect, bg_color_);
|
n.surface->fillRect(&rect, bg_color_);
|
||||||
|
|
||||||
rect = {4 / 2, 1, width - 4, height - 2};
|
rect = {4 / 2, 1, WIDTH - 4, HEIGHT - 2};
|
||||||
n.surface->fillRect(&rect, bg_color_);
|
n.surface->fillRect(&rect, bg_color_);
|
||||||
|
|
||||||
rect = {1, 4 / 2, width - 2, height - 4};
|
rect = {1, 4 / 2, WIDTH - 2, HEIGHT - 4};
|
||||||
n.surface->fillRect(&rect, bg_color_);
|
n.surface->fillRect(&rect, bg_color_);
|
||||||
|
|
||||||
rect = {0, 4, width, height - (4 * 2)};
|
rect = {0, 4, WIDTH, HEIGHT - (4 * 2)};
|
||||||
n.surface->fillRect(&rect, bg_color_);
|
n.surface->fillRect(&rect, bg_color_);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (shape == NotificationShape::SQUARED)
|
else if (SHAPE == NotificationShape::SQUARED)
|
||||||
{
|
{
|
||||||
n.surface->clear(bg_color_);
|
n.surface->clear(bg_color_);
|
||||||
}
|
}
|
||||||
@@ -265,36 +266,37 @@ void Notifier::show(std::vector<std::string> texts, NotificationText text_is, in
|
|||||||
if (has_icons_ && icon >= 0 && texts.size() >= 2)
|
if (has_icons_ && icon >= 0 && texts.size() >= 2)
|
||||||
{
|
{
|
||||||
auto sp = std::make_unique<SSprite>(icon_surface_, (SDL_Rect){0, 0, ICON_SIZE_, ICON_SIZE_});
|
auto sp = std::make_unique<SSprite>(icon_surface_, (SDL_Rect){0, 0, ICON_SIZE_, ICON_SIZE_});
|
||||||
sp->setPosition({padding_in_h, padding_in_v, ICON_SIZE_, ICON_SIZE_});
|
sp->setPosition({PADDING_IN_H, PADDING_IN_V, ICON_SIZE_, ICON_SIZE_});
|
||||||
sp->setClip({ICON_SIZE_ * (icon % 10), ICON_SIZE_ * (icon / 10), ICON_SIZE_, ICON_SIZE_});
|
sp->setClip({ICON_SIZE_ * (icon % 10), ICON_SIZE_ * (icon / 10), ICON_SIZE_, ICON_SIZE_});
|
||||||
sp->render();
|
sp->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escribe el texto de la notificación
|
// Escribe el texto de la notificación
|
||||||
const Uint8 color = stringToColor("white");
|
const Uint8 COLOR = stringToColor("white");
|
||||||
int iterator = 0;
|
int iterator = 0;
|
||||||
for (const auto &text : texts)
|
for (const auto &text : texts)
|
||||||
{
|
{
|
||||||
if (text_is == NotificationText::LEFT)
|
switch (text_is)
|
||||||
{
|
{
|
||||||
text_->writeColored(padding_in_h + icon_space, padding_in_v + iterator * (text_->getCharacterSize() + 1), text, color);
|
case NotificationText::LEFT:
|
||||||
}
|
text_->writeColored(PADDING_IN_H + ICON_SPACE, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, COLOR);
|
||||||
else if (text_is == NotificationText::CENTER)
|
break;
|
||||||
{
|
case NotificationText::CENTER:
|
||||||
text_->writeDX(TEXT_CENTER | TEXT_COLOR, width / 2, padding_in_v + iterator * (text_->getCharacterSize() + 1), text, 1, color);
|
text_->writeDX(TEXT_CENTER | TEXT_COLOR, WIDTH / 2, PADDING_IN_V + iterator * (text_->getCharacterSize() + 1), text, 1, COLOR);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
++iterator;
|
++iterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deja de dibujar en la textura
|
// Deja de dibujar en la textura
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
|
|
||||||
// Crea el sprite de la notificación
|
// Crea el sprite de la notificación
|
||||||
n.sprite = std::make_shared<SSprite>(n.surface, n.rect);
|
n.sprite = std::make_shared<SSprite>(n.surface, n.rect);
|
||||||
|
|
||||||
// Deja la notificación invisible
|
|
||||||
// n.surface->setAlpha(0);
|
|
||||||
|
|
||||||
// Añade la notificación a la lista
|
// Añade la notificación a la lista
|
||||||
notifications_.emplace_back(n);
|
notifications_.emplace_back(n);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -474,6 +474,7 @@ void Room::initializeRoom(const RoomData &room)
|
|||||||
void Room::fillMapTexture()
|
void Room::fillMapTexture()
|
||||||
{
|
{
|
||||||
const Uint8 color = stringToColor(bg_color_);
|
const Uint8 color = stringToColor(bg_color_);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(map_surface_);
|
Screen::get()->setRendererSurface(map_surface_);
|
||||||
map_surface_->clear(color);
|
map_surface_->clear(color);
|
||||||
|
|
||||||
@@ -593,7 +594,7 @@ void Room::fillMapTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dibuja el mapa en pantalla
|
// Dibuja el mapa en pantalla
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ int Scoreboard::getMinutes()
|
|||||||
void Scoreboard::fillTexture()
|
void Scoreboard::fillTexture()
|
||||||
{
|
{
|
||||||
// Empieza a dibujar en la textura
|
// Empieza a dibujar en la textura
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(surface_);
|
Screen::get()->setRendererSurface(surface_);
|
||||||
|
|
||||||
// Limpia la textura
|
// Limpia la textura
|
||||||
@@ -179,5 +180,5 @@ void Scoreboard::fillTexture()
|
|||||||
text->writeColored(28 * BLOCK, LINE2, ROOMS_TEXT, stringToColor("white"));
|
text->writeColored(28 * BLOCK, LINE2, ROOMS_TEXT, stringToColor("white"));
|
||||||
|
|
||||||
// Deja el renderizador como estaba
|
// Deja el renderizador como estaba
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
@@ -147,10 +147,11 @@ std::shared_ptr<Surface> Text::writeToSurface(const std::string &text, int zoom,
|
|||||||
auto width = lenght(text, kerning) * zoom;
|
auto width = lenght(text, kerning) * zoom;
|
||||||
auto height = box_height_ * zoom;
|
auto height = box_height_ * zoom;
|
||||||
auto surface = std::make_shared<Surface>(width, height);
|
auto surface = std::make_shared<Surface>(width, height);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(surface);
|
Screen::get()->setRendererSurface(surface);
|
||||||
surface->clear(stringToColor("transparent"));
|
surface->clear(stringToColor("transparent"));
|
||||||
write(0, 0, text, kerning);
|
write(0, 0, text, kerning);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
@@ -161,10 +162,11 @@ std::shared_ptr<Surface> Text::writeDXToSurface(Uint8 flags, const std::string &
|
|||||||
auto width = Text::lenght(text, kerning) + shadow_distance;
|
auto width = Text::lenght(text, kerning) + shadow_distance;
|
||||||
auto height = box_height_ + shadow_distance;
|
auto height = box_height_ + shadow_distance;
|
||||||
auto surface = std::make_shared<Surface>(width, height);
|
auto surface = std::make_shared<Surface>(width, height);
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(surface);
|
Screen::get()->setRendererSurface(surface);
|
||||||
surface->clear(stringToColor("transparent"));
|
surface->clear(stringToColor("transparent"));
|
||||||
writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght);
|
writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght);
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -313,6 +313,7 @@ void Title::moveCheevosList(int direction)
|
|||||||
void Title::fillSurface()
|
void Title::fillSurface()
|
||||||
{
|
{
|
||||||
// Coloca el puntero del renderizador sobre la textura
|
// Coloca el puntero del renderizador sobre la textura
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(bg_surface_);
|
Screen::get()->setRendererSurface(bg_surface_);
|
||||||
|
|
||||||
// Rellena la textura de color
|
// Rellena la textura de color
|
||||||
@@ -332,7 +333,7 @@ void Title::fillSurface()
|
|||||||
text->writeColored(PLAY_AREA_CENTER_X, 30 * TEXT_SIZE, "ESC.EXIT GAME", COLOR);
|
text->writeColored(PLAY_AREA_CENTER_X, 30 * TEXT_SIZE, "ESC.EXIT GAME", COLOR);
|
||||||
|
|
||||||
// Devuelve el puntero del renderizador a su sitio
|
// Devuelve el puntero del renderizador a su sitio
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Crea y rellena la textura para mostrar los logros
|
// Crea y rellena la textura para mostrar los logros
|
||||||
@@ -350,6 +351,7 @@ void Title::createCheevosTexture()
|
|||||||
cheevos_surface_ = std::make_shared<Surface>(CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT);
|
cheevos_surface_ = std::make_shared<Surface>(CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT);
|
||||||
|
|
||||||
// Prepara para dibujar sobre la textura
|
// Prepara para dibujar sobre la textura
|
||||||
|
auto previuos_renderer = Screen::get()->getRendererSurface();
|
||||||
Screen::get()->setRendererSurface(cheevos_surface_);
|
Screen::get()->setRendererSurface(cheevos_surface_);
|
||||||
|
|
||||||
// Rellena la textura con color sólido
|
// Rellena la textura con color sólido
|
||||||
@@ -382,7 +384,7 @@ void Title::createCheevosTexture()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restablece el RenderSurface
|
// Restablece el RenderSurface
|
||||||
Screen::get()->setRendererSurface(nullptr);
|
Screen::get()->setRendererSurface(previuos_renderer);
|
||||||
|
|
||||||
// Crea el sprite para el listado de logros
|
// Crea el sprite para el listado de logros
|
||||||
cheevos_sprite_ = std::make_shared<SSprite>(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
|
cheevos_sprite_ = std::make_shared<SSprite>(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());
|
||||||
|
|||||||
Reference in New Issue
Block a user