forked from jaildesigner-jailgames/jaildoctors_dilemma
JA VA! Nomes s'havia de fer les coses be i no ser un ansias
This commit is contained in:
@@ -10,26 +10,24 @@
|
||||
#include "sprite.h" // for Sprite
|
||||
#include "texture.h" // for Texture
|
||||
#include "utils.h" // for options_t, section_t, color_t, stringToC...
|
||||
#include "options.h"
|
||||
|
||||
// Constructor
|
||||
LoadingScreen::LoadingScreen(Resource *resource, options_t *options, section_t *section)
|
||||
LoadingScreen::LoadingScreen(Resource *resource)
|
||||
: screen_(Screen::get()),
|
||||
renderer_(Screen::get()->getRenderer()),
|
||||
resource_(resource),
|
||||
asset_(Asset::get()),
|
||||
input_(Input::get()),
|
||||
options_(options),
|
||||
section_(section)
|
||||
|
||||
input_(Input::get())
|
||||
{
|
||||
// Reserva memoria para los punteros
|
||||
eventHandler = new SDL_Event();
|
||||
if (options->palette == p_zxspectrum)
|
||||
if (options.palette == p_zxspectrum)
|
||||
{
|
||||
mono_loading_screen_texture_ = resource->getTexture("loading_screen_bn.png");
|
||||
color_loading_screen_texture_ = resource->getTexture("loading_screen_color.png");
|
||||
}
|
||||
else if (options->palette == p_zxarne)
|
||||
else if (options.palette == p_zxarne)
|
||||
{
|
||||
mono_loading_screen_texture_ = resource->getTexture("loading_screen_bn_zxarne.png");
|
||||
color_loading_screen_texture_ = resource->getTexture("loading_screen_color_zxarne.png");
|
||||
@@ -41,8 +39,8 @@ LoadingScreen::LoadingScreen(Resource *resource, options_t *options, section_t *
|
||||
loading_sound3_ = JA_LoadMusic(asset_->get("loading_sound3.ogg").c_str());
|
||||
|
||||
// Inicializa variables
|
||||
section->name = SECTION_LOADING_SCREEN;
|
||||
section->subsection = 0;
|
||||
options.section.name = SECTION_LOADING_SCREEN;
|
||||
options.section.subsection = 0;
|
||||
|
||||
// Establece el orden de las lineas para imitar el direccionamiento de memoria del spectrum
|
||||
for (int i = 0; i < 192; ++i)
|
||||
@@ -64,7 +62,7 @@ LoadingScreen::LoadingScreen(Resource *resource, options_t *options, section_t *
|
||||
}
|
||||
|
||||
// Cambia el color del borde
|
||||
screen_->setBorderColor(stringToColor(options->palette, "black"));
|
||||
screen_->setBorderColor(stringToColor(options.palette, "black"));
|
||||
}
|
||||
|
||||
// Destructor
|
||||
@@ -87,7 +85,7 @@ void LoadingScreen::checkEvents()
|
||||
// Evento de salida de la aplicación
|
||||
if (eventHandler->type == SDL_QUIT)
|
||||
{
|
||||
section_->name = SECTION_QUIT;
|
||||
options.section.name = SECTION_QUIT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +97,7 @@ void LoadingScreen::checkInput()
|
||||
|
||||
if (input_->checkInput(input_exit, REPEAT_FALSE))
|
||||
{
|
||||
section_->name = SECTION_QUIT;
|
||||
options.section.name = SECTION_QUIT;
|
||||
}
|
||||
|
||||
else if (input_->checkInput(input_toggle_border, REPEAT_FALSE))
|
||||
@@ -129,8 +127,8 @@ void LoadingScreen::checkInput()
|
||||
|
||||
else if (input_->checkInput(input_pause, REPEAT_FALSE) || input_->checkInput(input_accept, REPEAT_FALSE) || input_->checkInput(input_jump, REPEAT_FALSE))
|
||||
{
|
||||
section_->name = SECTION_TITLE;
|
||||
section_->subsection = 0;
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +173,8 @@ void LoadingScreen::updateLoad()
|
||||
// Comprueba si ha terminado la intro
|
||||
if (load_counter_ >= 768)
|
||||
{
|
||||
section_->name = SECTION_TITLE;
|
||||
section_->subsection = SUBSECTION_TITLE_WITH_LOADING_SCREEN;
|
||||
options.section.name = SECTION_TITLE;
|
||||
options.section.subsection = SUBSECTION_TITLE_WITH_LOADING_SCREEN;
|
||||
JA_StopMusic();
|
||||
}
|
||||
}
|
||||
@@ -203,15 +201,15 @@ void LoadingScreen::renderLoad()
|
||||
void LoadingScreen::renderBorder()
|
||||
{
|
||||
// Pinta el borde de colro azul
|
||||
color_t color = stringToColor(options_->palette, "blue");
|
||||
color_t color = stringToColor(options.palette, "blue");
|
||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
|
||||
SDL_RenderClear(renderer_);
|
||||
|
||||
// Añade lineas amarillas
|
||||
color = stringToColor(options_->palette, "yellow");
|
||||
color = stringToColor(options.palette, "yellow");
|
||||
SDL_SetRenderDrawColor(renderer_, color.r, color.g, color.b, 0xFF);
|
||||
const int width = GAMECANVAS_WIDTH + (options_->borderWidth * 2);
|
||||
const int height = GAMECANVAS_HEIGHT + (options_->borderHeight * 2);
|
||||
const int width = GAMECANVAS_WIDTH + (options.borderWidth * 2);
|
||||
const int height = GAMECANVAS_HEIGHT + (options.borderHeight * 2);
|
||||
bool drawEnabled = rand() % 2 == 0 ? true : false;
|
||||
// Para (int i = 0; i < height; ++i)
|
||||
//{
|
||||
@@ -261,7 +259,7 @@ void LoadingScreen::update()
|
||||
// Dibuja en pantalla
|
||||
void LoadingScreen::render()
|
||||
{
|
||||
if (options_->borderEnabled)
|
||||
if (options.borderEnabled)
|
||||
{
|
||||
// Prepara para empezar a dibujar en la textura del borde
|
||||
screen_->startDrawOnBorder();
|
||||
@@ -292,7 +290,7 @@ void LoadingScreen::run()
|
||||
screen_->clean();
|
||||
screen_->render();
|
||||
|
||||
while (section_->name == SECTION_LOADING_SCREEN)
|
||||
while (options.section.name == SECTION_LOADING_SCREEN)
|
||||
{
|
||||
update();
|
||||
checkEvents();
|
||||
@@ -305,15 +303,15 @@ void LoadingScreen::run()
|
||||
// Cambia la paleta
|
||||
void LoadingScreen::switchPalette()
|
||||
{
|
||||
if (options_->palette == p_zxspectrum)
|
||||
if (options.palette == p_zxspectrum)
|
||||
{
|
||||
options_->palette = p_zxarne;
|
||||
options.palette = p_zxarne;
|
||||
mono_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_bn_zxarne.png"));
|
||||
color_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_color_zxarne.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
options_->palette = p_zxspectrum;
|
||||
options.palette = p_zxspectrum;
|
||||
mono_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_bn.png"));
|
||||
color_loading_screen_sprite_->setTexture(resource_->getTexture("loading_screen_color.png"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user