|
15Slide
|
A UI for commands from the terminal for 15Slide. More...
#include <CommandUI.h>
Public Types | |
| enum | command { command::invalid, command::help, command::demo, command::newgame, command::slide, command::print, command::save, command::load, command::options, command::enable, command::disable, command::about, command::licence, command::exit, command::debug } |
| Possible commands. More... | |
Public Member Functions | |
| void | start (Grid15::Grid &grid) |
| The main loop for the CommandUI. More... | |
| void | handleCommand (const std::string &inputtedLine, Grid15::Grid &grid) |
| Handles a command from the user and does something acordingly. More... | |
Static Public Member Functions | |
| static void | printGrid (Grid15::Grid::gridArray_t grid) |
| Prints a grid array. More... | |
| static void | printGrid (const Grid15::Grid &grid) |
| Prints a Grid. More... | |
Private Member Functions | |
| void | handleOptions (const std::string &option, bool optionSetting) |
| Handles an option string and sets the appropriate option. More... | |
| void | handleDebug (const std::string &inputtedLine) |
| Handles the debug commands. Only avaliable if ProgramStuff::Build::DEBUG equals true. More... | |
| void | saveGame (const std::string &saveFile, const Grid15::Grid &grid) |
| Saves the game. More... | |
| void | loadGame (const std::string &saveFile, Grid15::Grid &grid) |
| Loads the game. More... | |
| void | swapTile (const std::int64_t tile, Grid15::Grid &grid) |
| Swaps a tile. More... | |
Static Private Member Functions | |
| static void | runDemo () |
| The 15Slide demo. More... | |
| static void | displayHelp () |
| List commands to user. More... | |
| static void | displayAbout () |
| About 15Slide. More... | |
| static void | displayLicence () |
| Licence information for 15Slide and other libraries. More... | |
| static void | displayOptions () |
| List options to user. More... | |
Private Attributes | |
| bool | autoSave {ProgramStuff::AUTOSAVE_ON_SLIDE_DEFAULT} |
| Autosave to last savefile. More... | |
| bool | autoGrid {true} |
| Autoprint the grid. More... | |
| bool | autoExit {false} |
| Exit the game on win automatically. More... | |
| bool | easySlide {true} |
| Slide a tile without having to type "slide" first. More... | |
| std::string | defaultSaveFile {""} |
| The savefile to use for autoSaving, found during CommandUI::saveGame or CommandUI::loadGame. More... | |
| bool | wantsToExit {false} |
| Whether the user wants to exit or not; used internally to exit CommandUI::start. More... | |
Static Private Attributes | |
| static const std::unordered_map< std::string, CommandUI::command > | commandMap |
| A map from std::string to CommandUI::command for input parsing. More... | |
A UI for commands from the terminal for 15Slide.
Valid Commands
| Command | Function |
|---|---|
| help | Displays a list of valid commands |
| demo | Walks you through the game |
| newgame | Ends the current game and starts a new one |
| slide num | Slides the tile with the number given |
| print str | Prints the current "grid" or the "goal" grid |
| save str | Saves the game to the specified file |
| load str | Loads the game from the specified file |
| options | Displays a list of valid options |
| enable str | Enables the specified option |
| disable str | Disables the specified option |
| about | Cool stuff about 15Slide |
| licence | Licence information for 15Slide and other libraries |
| exit | Exit 15Slide |
|
strong |
|
staticprivate |
About 15Slide.
|
staticprivate |
List commands to user.
|
staticprivate |
Licence information for 15Slide and other libraries.
|
staticprivate |
List options to user.
| void CommandUI::handleCommand | ( | const std::string & | inputtedLine, |
| Grid15::Grid & | grid | ||
| ) |
Handles a command from the user and does something acordingly.
| inputtedLine | The line to parse |
| grid | The Grid to change |
|
private |
Handles the debug commands. Only avaliable if ProgramStuff::Build::DEBUG equals true.
| inputtedLine | The arguments to parse |
| std::runtime_error | If the user uses the "crash" command |
|
private |
Handles an option string and sets the appropriate option.
| option | The option string to set |
| optionSetting | Turn it on or off |
|
private |
Loads the game.
| saveFile | The file to load from |
| grid | The Grid to load to |
|
static |
Prints a grid array.
| grid | The grid array to print |
|
static |
Prints a Grid.
| grid | The Grid to print |
|
staticprivate |
The 15Slide demo.
|
private |
Saves the game.
| saveFile | The file to save to |
| grid | The Grid to save |
| void CommandUI::start | ( | Grid15::Grid & | grid | ) |
The main loop for the CommandUI.
| grid | A Grid to use |
|
private |
Swaps a tile.
| tile | The tile to swap |
| grid | The Grid to use |
|
private |
Exit the game on win automatically.
|
private |
Autoprint the grid.
|
private |
Autosave to last savefile.
|
staticprivate |
A map from std::string to CommandUI::command for input parsing.
|
private |
The savefile to use for autoSaving, found during CommandUI::saveGame or CommandUI::loadGame.
|
private |
Slide a tile without having to type "slide" first.
|
private |
Whether the user wants to exit or not; used internally to exit CommandUI::start.