La sección del programa se controla ahora mediante un puntero a una variable
This commit is contained in:
@@ -16,7 +16,8 @@
|
||||
Director::Director(int argc, char *argv[])
|
||||
{
|
||||
// Inicializa variables
|
||||
section.name = SECTION_PROG_LOGO;
|
||||
section = new section_t();
|
||||
section->name = SECTION_PROG_LOGO;
|
||||
|
||||
// Inicializa las opciones del programa
|
||||
initOptions();
|
||||
@@ -73,6 +74,7 @@ Director::~Director()
|
||||
delete screen;
|
||||
delete lang;
|
||||
delete options;
|
||||
delete section;
|
||||
|
||||
SDL_DestroyRenderer(renderer);
|
||||
SDL_DestroyWindow(window);
|
||||
@@ -662,47 +664,41 @@ bool Director::saveConfigFile()
|
||||
return success;
|
||||
}
|
||||
|
||||
// Establece el valor de la variable
|
||||
void Director::setSection(section_t section)
|
||||
{
|
||||
this->section = section;
|
||||
}
|
||||
|
||||
void Director::runLogo()
|
||||
{
|
||||
logo = new Logo(renderer, screen, asset, input);
|
||||
setSection(logo->run());
|
||||
logo = new Logo(renderer, screen, asset, input, section);
|
||||
logo->run();
|
||||
delete logo;
|
||||
}
|
||||
|
||||
void Director::runIntro()
|
||||
{
|
||||
intro = new Intro(renderer, screen, asset, input, lang);
|
||||
setSection(intro->run());
|
||||
intro = new Intro(renderer, screen, asset, input, lang, section);
|
||||
intro->run();
|
||||
delete intro;
|
||||
}
|
||||
|
||||
void Director::runTitle()
|
||||
{
|
||||
title = new Title(renderer, screen, input, asset, options, lang, section);
|
||||
setSection(title->run());
|
||||
title->run();
|
||||
delete title;
|
||||
}
|
||||
|
||||
void Director::runGame()
|
||||
{
|
||||
const int numPlayers = section.subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||
game = new Game(numPlayers, 0, renderer, screen, asset, lang, input, false, options);
|
||||
setSection(game->run());
|
||||
const int numPlayers = section->subsection == SUBSECTION_GAME_PLAY_1P ? 1 : 2;
|
||||
game = new Game(numPlayers, 0, renderer, screen, asset, lang, input, false, options, section);
|
||||
game->run();
|
||||
delete game;
|
||||
}
|
||||
|
||||
void Director::run()
|
||||
{
|
||||
// Bucle principal
|
||||
while (section.name != SECTION_PROG_QUIT)
|
||||
while (section->name != SECTION_PROG_QUIT)
|
||||
{
|
||||
switch (section.name)
|
||||
switch (section->name)
|
||||
{
|
||||
case SECTION_PROG_LOGO:
|
||||
runLogo();
|
||||
|
||||
Reference in New Issue
Block a user