Cambiada la variable section por un puntero

This commit is contained in:
2022-12-16 09:32:33 +01:00
parent 2abde36a5e
commit 4d8bb46a52
22 changed files with 191 additions and 216 deletions

View File

@@ -14,11 +14,12 @@
// Constructor
Director::Director(int argc, char *argv[])
{
section.name = SECTION_PROG_LOGO;
section.subsection = SUBSECTION_LOGO_TO_INTRO;
section = new section_t();
section->name = SECTION_PROG_LOGO;
section->subsection = SUBSECTION_LOGO_TO_INTRO;
#ifdef DEBUG
section.name = SECTION_PROG_LOGO;
section->name = SECTION_PROG_LOGO;
#endif
// Crea e inicializa las opciones del programa
@@ -65,6 +66,7 @@ Director::~Director()
saveConfig();
// Libera la memoria
delete section;
delete options;
delete asset;
delete input;
@@ -463,14 +465,14 @@ void Director::createSystemFolder()
}
// Carga los recursos
void Director::loadResources(section_t section)
void Director::loadResources(section_t *section)
{
if (options->console)
{
std::cout << "** LOAD RESOURCES" << std::endl;
}
if (section.name == SECTION_PROG_LOGO)
if (section->name == SECTION_PROG_LOGO)
{
std::vector<std::string> textureList;
textureList.push_back("jailgames.png");
@@ -479,7 +481,7 @@ void Director::loadResources(section_t section)
resource->loadTextures(textureList);
}
else if (section.name == SECTION_PROG_INTRO)
else if (section->name == SECTION_PROG_INTRO)
{
std::vector<std::string> textureList;
textureList.push_back("loading_screen_bn.png");
@@ -490,7 +492,7 @@ void Director::loadResources(section_t section)
resource->loadTextures(textureList);
}
else if (section.name == SECTION_PROG_TITLE)
else if (section->name == SECTION_PROG_TITLE)
{
std::vector<std::string> textureList;
textureList.push_back("loading_screen_color.png");
@@ -506,7 +508,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_CREDITS)
else if (section->name == SECTION_PROG_CREDITS)
{
// Texturas
std::vector<std::string> textureList;
@@ -528,7 +530,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_ENDING)
else if (section->name == SECTION_PROG_ENDING)
{
// Texturas
std::vector<std::string> textureList;
@@ -553,7 +555,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_ENDING2)
else if (section->name == SECTION_PROG_ENDING2)
{
// Texturas
std::vector<std::string> textureList;
@@ -691,7 +693,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_GAME_OVER)
else if (section->name == SECTION_PROG_GAME_OVER)
{
// Texturas
std::vector<std::string> textureList;
@@ -715,7 +717,7 @@ void Director::loadResources(section_t section)
resource->loadOffsets(offsetsList);
}
else if (section.name == SECTION_PROG_GAME || section.name == SECTION_PROG_DEMO)
else if (section->name == SECTION_PROG_GAME || section->name == SECTION_PROG_DEMO)
{
// Texturas
std::vector<std::string> textureList;
@@ -1686,24 +1688,6 @@ bool Director::setFileList()
return asset->check();
}
// Obtiene el valor de la variable
Uint8 Director::getSubsection()
{
return section.subsection;
}
// Obtiene el valor de la variable
Uint8 Director::getSection()
{
return section.name;
}
// Establece el valor de la variable
void Director::setSection(section_t section)
{
this->section = section;
}
// Ejecuta la seccion de juego con el logo
void Director::runLogo()
{
@@ -1712,8 +1696,8 @@ void Director::runLogo()
std::cout << "\n* SECTION: LOGO" << std::endl;
}
loadResources(section);
logo = new Logo(renderer, screen, resource, asset, options, section.subsection);
setSection(logo->run());
logo = new Logo(renderer, screen, resource, asset, options, section);
logo->run();
delete logo;
resource->free();
}
@@ -1726,8 +1710,8 @@ void Director::runIntro()
std::cout << "\n* SECTION: INTRO" << std::endl;
}
loadResources(section);
intro = new Intro(renderer, screen, resource, asset, options);
setSection(intro->run());
intro = new Intro(renderer, screen, resource, asset, options, section);
intro->run();
delete intro;
resource->free();
}
@@ -1744,8 +1728,8 @@ void Director::runTitle()
JA_PlayMusic(music);
}
loadResources(section);
title = new Title(renderer, screen, resource, asset, options);
setSection(title->run());
title = new Title(renderer, screen, resource, asset, options, section);
title->run();
delete title;
resource->free();
}
@@ -1758,8 +1742,8 @@ void Director::runCredits()
std::cout << "\n* SECTION: CREDITS" << std::endl;
}
loadResources(section);
credits = new Credits(renderer, screen, resource, asset, options);
setSection(credits->run());
credits = new Credits(renderer, screen, resource, asset, options, section);
credits->run();
delete credits;
resource->free();
}
@@ -1772,8 +1756,8 @@ void Director::runDemo()
std::cout << "\n* SECTION: DEMO" << std::endl;
}
loadResources(section);
demo = new Demo(renderer, screen, resource, asset, options, debug);
setSection(demo->run());
demo = new Demo(renderer, screen, resource, asset, options, section, debug);
demo->run();
delete demo;
resource->free();
}
@@ -1787,7 +1771,7 @@ void Director::runEnterID()
}
// loadResources(section);
enterID = new EnterID(renderer, screen, asset, options, section);
setSection(enterID->run());
enterID->run();
delete enterID;
resource->free();
}
@@ -1800,8 +1784,8 @@ void Director::runEnding()
std::cout << "\n* SECTION: ENDING" << std::endl;
}
loadResources(section);
ending = new Ending(renderer, screen, resource, asset, options);
setSection(ending->run());
ending = new Ending(renderer, screen, resource, asset, options, section);
ending->run();
delete ending;
resource->free();
}
@@ -1814,8 +1798,8 @@ void Director::runEnding2()
std::cout << "\n* SECTION: ENDING2" << std::endl;
}
loadResources(section);
ending2 = new Ending2(renderer, screen, resource, asset, options);
setSection(ending2->run());
ending2 = new Ending2(renderer, screen, resource, asset, options, section);
ending2->run();
delete ending2;
resource->free();
}
@@ -1828,8 +1812,8 @@ void Director::runGameOver()
std::cout << "\n* SECTION: GAME OVER" << std::endl;
}
loadResources(section);
gameOver = new GameOver(renderer, screen, resource, asset, options);
setSection(gameOver->run());
gameOver = new GameOver(renderer, screen, resource, asset, options, section);
gameOver->run();
delete gameOver;
resource->free();
}
@@ -1843,8 +1827,8 @@ void Director::runGame()
}
JA_StopMusic();
loadResources(section);
game = new Game(renderer, screen, resource, asset, options, input, debug);
setSection(game->run());
game = new Game(renderer, screen, resource, asset, options, input, section, debug);
game->run();
delete game;
resource->free();
}
@@ -1852,9 +1836,9 @@ void Director::runGame()
void Director::run()
{
// Bucle principal
while (getSection() != SECTION_PROG_QUIT)
while (section->name != SECTION_PROG_QUIT)
{
switch (getSection())
switch (section->name)
{
case SECTION_PROG_LOGO:
runLogo();