[Add] New & Load in main menu now functioning properly.
This commit is contained in:
parent
db79f97f31
commit
9a23bd1547
@ -17,12 +17,19 @@ Game::~Game(void) {
|
||||
//delete _player;
|
||||
}
|
||||
|
||||
gameNavVal_t Game::Run(const string savegameIDArg) {
|
||||
void Game::New(const string& savegameIDArg) {
|
||||
NewSavegame(savegameIDArg);
|
||||
_map.Load("map");
|
||||
}
|
||||
|
||||
void Game::Load(const string& savegameIDArg) {
|
||||
LoadSavegame(savegameIDArg);
|
||||
}
|
||||
|
||||
gameNavVal_t Game::Run(void) {
|
||||
_player->SetXY(400, 400);
|
||||
_player->LoadSprites("../Data/Media/Images/Characters/Player.png", 40, 45);
|
||||
|
||||
LoadSavegame(savegameIDArg);
|
||||
|
||||
int fps = 0;
|
||||
int frame = 0;
|
||||
int nextGameTick = SDL_GetTicks();
|
||||
@ -307,8 +314,7 @@ void Game::LoadSavegame(const string savegameIDArg) {
|
||||
|
||||
// Create new save if can't load file.
|
||||
if(!mapFile.LoadFile()) {
|
||||
NewSavegame(savegameIDArg);
|
||||
_map.Load("map");
|
||||
New(savegameIDArg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,11 @@ class Game {
|
||||
public:
|
||||
Game(void);
|
||||
~Game(void);
|
||||
|
||||
void New(const string& savegameIDArg);
|
||||
void Load(const string& savegameIDArg);
|
||||
|
||||
gameNavVal_t Run(const string savegameIDArg);
|
||||
gameNavVal_t Run(void);
|
||||
|
||||
private:
|
||||
void HandleInput(void);
|
||||
|
@ -24,6 +24,23 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static gameNavVal_t RunGame(bool load) {
|
||||
Debug::logger->message("Entering game state..");
|
||||
Game* game = new Game;
|
||||
|
||||
if(load) {
|
||||
game->Load("save");
|
||||
} else {
|
||||
game->New("save");
|
||||
}
|
||||
|
||||
gameNavVal_t ret = game->Run();
|
||||
|
||||
delete game;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(_WIN32) || defined(_DEBUG)
|
||||
int main() {
|
||||
#else
|
||||
@ -78,10 +95,7 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {
|
||||
switch(menu->Run()) {
|
||||
case mainMenuNewGame:
|
||||
delete menu;
|
||||
Debug::logger->message("Entering game state..");
|
||||
game = new Game;
|
||||
|
||||
switch(game->Run("save")) {
|
||||
switch(RunGame(false)) {
|
||||
case gameMainMenu:
|
||||
menu = new MainMenu;
|
||||
break;
|
||||
@ -89,9 +103,17 @@ int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int) {
|
||||
menuRunning = false;
|
||||
break;
|
||||
}
|
||||
delete game;
|
||||
break;
|
||||
case mainMenuLoadGame:
|
||||
delete menu;
|
||||
switch(RunGame(true)) {
|
||||
case gameMainMenu:
|
||||
menu = new MainMenu;
|
||||
break;
|
||||
case gameQuitGame:
|
||||
menuRunning = false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case mainMenuOptions:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user