Skip to content

Commit

Permalink
Add option -l (load level) to ease playtesting
Browse files Browse the repository at this point in the history
Co-Authored-By: Carsten Teibes <4691314+carstene1ns@users.noreply.github.com>
  • Loading branch information
Apaczer and carstene1ns committed Jan 24, 2023
1 parent c589bb2 commit c73ad7b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern float sinf (float);

#define PI 3.141592f

int loadLevel = -1, loadWorld = -1;

/**
* Initialises OpenJazz.
Expand Down Expand Up @@ -231,6 +232,12 @@ void startUp (int argc, char *argv[]) {
setSoundVolume(0);
}

if (argv[count][1] == 'l' && argc > count + 2) {
loadWorld = strtol(argv[count+1], NULL , 10);
loadLevel = strtol(argv[count+2], NULL , 10);
count+=2;
}

}

}
Expand Down Expand Up @@ -402,6 +409,31 @@ int play () {

playMusic("MENUSNG.PSM");

// Try loading the user-specified level

if (loadLevel > -1 && loadWorld > -1) {

try {

mainMenu = new MainMenu();

} catch (int e) {

return e;

}

if (mainMenu->skip(loadLevel, loadWorld) == E_QUIT) {

delete mainMenu;

}

return E_NONE;

}


// Load and play the startup cutscene

try {
Expand Down
14 changes: 14 additions & 0 deletions src/menu/gamemenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ int GameMenu::loadGame () {
}


/**
* Directly load level.
*
* @return Error code
*/
int GameMenu::loadGame (int levelNum, int worldNum) {

if (newGameDifficulty(M_SINGLE, levelNum, worldNum) == E_QUIT) return E_QUIT;

return E_NONE;

}


/**
* Run the new game level selection menu.
*
Expand Down
13 changes: 13 additions & 0 deletions src/menu/mainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,3 +450,16 @@ int MainMenu::main () {
}


/**
* Skip the main menu. Directly loads game
*
* @return Error code
*/
int MainMenu::skip (int levelNum, int worldNum) {

if (gameMenu->loadGame(levelNum, worldNum) == E_QUIT) return E_QUIT;

return E_RETURN;

}

2 changes: 2 additions & 0 deletions src/menu/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class GameMenu : public Menu {

int newGame ();
int loadGame ();
int loadGame (int levelNum, int worldNum);

};

Expand Down Expand Up @@ -119,6 +120,7 @@ class MainMenu : public Menu {
~MainMenu ();

int main ();
int skip (int levelNum, int worldNum);

};

Expand Down
4 changes: 4 additions & 0 deletions unix/OpenJazz.6.pod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Start in full-screen mode

Start with muted audio

=item B<-l> <I<World>> <I<Level>>

Directly load specific world/level

=back

=head1 FILES
Expand Down

0 comments on commit c73ad7b

Please sign in to comment.