summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-08 19:24:23 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-08 19:24:23 (GMT)
commit435c680f010508eced376dbe7e6fd659fbbb3415 (patch)
tree0f632b40d4d08ae4691934e0e25efab1bbb7d57a /src
parentbd296673558fe75fee039bd27b0a71960dc426bc (diff)
downloadpowder-435c680f010508eced376dbe7e6fd659fbbb3415.zip
powder-435c680f010508eced376dbe7e6fd659fbbb3415.tar.gz
Command line "open"
Diffstat (limited to 'src')
-rw-r--r--src/PowderToySDL.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp
index 82a6856..5bbd5dc 100644
--- a/src/PowderToySDL.cpp
+++ b/src/PowderToySDL.cpp
@@ -363,6 +363,39 @@ int main(int argc, char * argv[])
GameController * gameController = new GameController();
engine->ShowWindow(gameController->GetView());
+ if(arguments["open"].length())
+ {
+ std::cout << arguments["open"] << std::endl;
+ if(Client::Ref().FileExists(arguments["open"]))
+ {
+ try
+ {
+ std::vector<unsigned char> gameSaveData = Client::Ref().ReadFile(arguments["open"]);
+ if(!gameSaveData.size())
+ {
+ new ErrorMessage("Error", "Could not read file");
+ }
+ else
+ {
+ SaveFile * newFile = new SaveFile(arguments["open"]);
+ GameSave * newSave = new GameSave(gameSaveData);
+ newFile->SetGameSave(newSave);
+ gameController->LoadSaveFile(newFile);
+ delete newFile;
+ }
+
+ }
+ catch(std::exception & e)
+ {
+ new ErrorMessage("Error", "Could not open save file:\n"+std::string(e.what())) ;
+ }
+ }
+ else
+ {
+ new ErrorMessage("Error", "Could not open file");
+ }
+ }
+
SDL_Event event;
while(engine->Running())
{