Chargement dynamique du niveau dans l'éditeur
This commit is contained in:
parent
6dbea09bcb
commit
b2a9309ee7
|
@ -22,14 +22,19 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Affiche les règles du jeu
|
* Affiche le menu principal
|
||||||
*/
|
*/
|
||||||
void loadRules();
|
void loadMainMenu();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Démarre l'éditeur
|
* Affiche le menu de choix des niveaux
|
||||||
*/
|
*/
|
||||||
void launchEditor();
|
void loadLevelMenu();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Affiche le menu de choix des niveaux
|
||||||
|
*/
|
||||||
|
void loadEditorMenu();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Démarre le jeu avec le niveau dont le chemin
|
* Démarre le jeu avec le niveau dont le chemin
|
||||||
|
@ -38,7 +43,19 @@ protected:
|
||||||
void launchGame(std::string path);
|
void launchGame(std::string path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quitte le jeu et le menu
|
* Démarre les règles
|
||||||
|
*/
|
||||||
|
void launchRules();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Démarre l'éditeur avec le niveau dont le chemin
|
||||||
|
* complet absolu est donné en paramètre, ou bien
|
||||||
|
* en édition de nouveau niveau
|
||||||
|
*/
|
||||||
|
void launchEditor(std::string path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quitte le menu
|
||||||
*/
|
*/
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
|
@ -55,16 +72,6 @@ public:
|
||||||
* Demande le dessin d'une frame
|
* Demande le dessin d'une frame
|
||||||
*/
|
*/
|
||||||
virtual void frame();
|
virtual void frame();
|
||||||
|
|
||||||
/**
|
|
||||||
* Affiche le menu principal
|
|
||||||
*/
|
|
||||||
void loadMainMenu();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Affiche le menu de choix des niveaux
|
|
||||||
*/
|
|
||||||
void loadLevelMenu();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
46
src/menu.cpp
46
src/menu.cpp
|
@ -158,10 +158,10 @@ void Menu::loadMainMenu() {
|
||||||
actions.push_back(std::bind(&Menu::loadLevelMenu, this));
|
actions.push_back(std::bind(&Menu::loadLevelMenu, this));
|
||||||
|
|
||||||
choices.push_back(sf::String(L"Règles du jeu"));
|
choices.push_back(sf::String(L"Règles du jeu"));
|
||||||
actions.push_back(std::bind(&Menu::loadRules, this));
|
actions.push_back(std::bind(&Menu::launchRules, this));
|
||||||
|
|
||||||
choices.push_back(sf::String(L"Éditeur"));
|
choices.push_back(sf::String(L"Éditeur"));
|
||||||
actions.push_back(std::bind(&Menu::launchEditor, this));
|
actions.push_back(std::bind(&Menu::loadEditorMenu, this));
|
||||||
|
|
||||||
choices.push_back(sf::String(L"Quitter"));
|
choices.push_back(sf::String(L"Quitter"));
|
||||||
actions.push_back(std::bind(&Menu::quit, this));
|
actions.push_back(std::bind(&Menu::quit, this));
|
||||||
|
@ -184,15 +184,24 @@ void Menu::loadLevelMenu() {
|
||||||
actions.push_back(std::bind(&Menu::loadMainMenu, this));
|
actions.push_back(std::bind(&Menu::loadMainMenu, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::loadRules() {
|
void Menu::loadEditorMenu() {
|
||||||
auto rules = std::unique_ptr<Rules>(new Rules(getManager()));
|
choices.clear();
|
||||||
getManager().pushState(std::move(rules));
|
actions.clear();
|
||||||
}
|
selection = 0;
|
||||||
|
|
||||||
void Menu::launchEditor() {
|
std::vector<std::string> path_list = getResourceManager().getLevelList();
|
||||||
auto editor = std::unique_ptr<Editor>(new Editor(getManager()));
|
std::vector<std::string> name_list;
|
||||||
editor->load(getResourceManager().getLevelPath("editor_result.dat"));
|
|
||||||
getManager().pushState(std::move(editor));
|
choices.push_back(L"Créer un nouveau niveau");
|
||||||
|
actions.push_back(std::bind(&Menu::launchEditor, this, ""));
|
||||||
|
|
||||||
|
for (auto it = path_list.begin(); it != path_list.end(); it++) {
|
||||||
|
choices.push_back(Level::getLevelName(*it));
|
||||||
|
actions.push_back(std::bind(&Menu::launchEditor, this, *it));
|
||||||
|
}
|
||||||
|
|
||||||
|
choices.push_back("Retour");
|
||||||
|
actions.push_back(std::bind(&Menu::loadMainMenu, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::launchGame(std::string path) {
|
void Menu::launchGame(std::string path) {
|
||||||
|
@ -201,6 +210,23 @@ void Menu::launchGame(std::string path) {
|
||||||
getManager().pushState(std::move(game));
|
getManager().pushState(std::move(game));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Menu::launchRules() {
|
||||||
|
auto rules = std::unique_ptr<Rules>(new Rules(getManager()));
|
||||||
|
getManager().pushState(std::move(rules));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Menu::launchEditor(std::string path) {
|
||||||
|
auto editor = std::unique_ptr<Editor>(new Editor(getManager()));
|
||||||
|
|
||||||
|
if (path == "") {
|
||||||
|
editor->load();
|
||||||
|
} else {
|
||||||
|
editor->load(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
getManager().pushState(std::move(editor));
|
||||||
|
}
|
||||||
|
|
||||||
void Menu::quit() {
|
void Menu::quit() {
|
||||||
getManager().popState();
|
getManager().popState();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue