/* =========================================================================== * Sago Multi Scrambler Puzzle Copyright (C) 2022-2024 Poul Sander This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/ Source information and contacts persons can be found at https://github.com/sago007/saland =========================================================================== */ #include #include #include "sago/SagoDataHolder.hpp" #include "sago/SagoSpriteHolder.hpp" #include "sago/GameStateInterface.hpp" #include "sago/SagoTextField.hpp" #include "globals.hpp" #include "PuzzleSingleImageState.hpp" #include "ImageSelectState.hpp" #include "sago_common.hpp" #include "MainGameState.hpp" #include "editor/SagoTextureSelector.hpp" #include "version.h" GlobalData globalData; void runSinglePuzzle(const std::string& filename) { PuzzleSingleImageState psi; InitGame(); psi.LoadPictureFromFile(filename, globalData.screen); RunGameState(psi); UninitGame(); } void runGame() { MainGameState mgs; InitGame(); RunGameState(mgs); UninitGame(); } void runCollection(const std::string& collection_name) { InitGame(); ImageSelectState iss; iss.collection = collection_name; RunGameState(iss); UninitGame(); } void runFolder(const std::string& folder_name) { InitGame(); ImageSelectState iss; iss.folder = folder_name; iss.Init(); RunGameState(iss); UninitGame(); } void runEditor() { InitGame(); SagoTextureSelector sts; sts.Init(); RunGameState(sts); UninitGame(); } int main(int argc, const char* argv[]) { boost::program_options::options_description desc("Options"); boost::program_options::positional_options_description p; p.add("input-file", -1); desc.add_options() ("version", "Print version information and quit") ("help,h", "Print basic usage information to stdout and quit") ("input-file", boost::program_options::value< std::vector >(), "Image to open directly") ("collection", boost::program_options::value< std::string >(), "Jump straigt to a named collection. Like \"fairy_tales\"") ("folder", boost::program_options::value< std::string >(), "Open a specific folder.") ("editor", "Opens a build in editor. Not implemented yet.") ; boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::command_line_parser(argc, argv).options(desc).positional(p).run(), vm); boost::program_options::notify(vm); if (vm.count("help")) { std::cout << desc << "\n"; return 0; } if (vm.count("version")) { std::cout << GAMENAME << " " << VERSION_NUMBER << "\n"; return 0; } InitSagoFS(argc, argv); if (vm.count("input-file")) { const std::vector& input_files = vm["input-file"].as >(); runSinglePuzzle(input_files.at(0)); return 0; } if (vm.count("collection")) { const std::string& collection_name = vm["collection"].as(); runCollection(collection_name); return 0; } if (vm.count("folder")) { const std::string& folder = vm["folder"].as(); runFolder(folder); return 0; } if (vm.count("editor")) { runEditor(); return 0; } runGame(); return 0; }