diff options
Diffstat (limited to 'src/PowderToySDL.cpp')
| -rw-r--r-- | src/PowderToySDL.cpp | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/src/PowderToySDL.cpp b/src/PowderToySDL.cpp index 5bbd5dc..eac1bc5 100644 --- a/src/PowderToySDL.cpp +++ b/src/PowderToySDL.cpp @@ -22,6 +22,7 @@ #endif #include "Format.h" +#include "Style.h" #include "interface/Engine.h" #include "interface/Button.h" #include "interface/Panel.h" @@ -365,7 +366,9 @@ int main(int argc, char * argv[]) if(arguments["open"].length()) { - std::cout << arguments["open"] << std::endl; +#ifdef DEBUG + std::cout << "Loading " << arguments["open"] << std::endl; +#endif if(Client::Ref().FileExists(arguments["open"])) { try @@ -396,6 +399,66 @@ int main(int argc, char * argv[]) } } + if(arguments["ptsave"].length()) + { + engine->g->fillrect((engine->GetWidth()/2)-101, (engine->GetHeight()/2)-26, 202, 52, 0, 0, 0, 210); + engine->g->drawrect((engine->GetWidth()/2)-100, (engine->GetHeight()/2)-25, 200, 50, 255, 255, 255, 180); + engine->g->drawtext((engine->GetWidth()/2)-(Graphics::textwidth("Loading save...")/2), (engine->GetHeight()/2)-5, "Loading save...", style::Colour::InformationTitle.Red, style::Colour::InformationTitle.Green, style::Colour::InformationTitle.Blue, 255); + +#ifdef OGLI + blit(); +#else + if(engine->Scale==2) + blit2(engine->g->vid, engine->Scale); + else + blit(engine->g->vid); +#endif + std::string ptsaveArg = arguments["ptsave"]; + try + { + if(!ptsaveArg.find("ptsave:")) + { + std::string saveIdPart = ""; + int saveId; + int hashPos = ptsaveArg.find('#'); + if(hashPos != std::string::npos) + { + saveIdPart = ptsaveArg.substr(7, hashPos-7); + } + else + { + saveIdPart = ptsaveArg.substr(7); + } + if(saveIdPart.length()) + { +#ifdef DEBUG + std::cout << "Got Ptsave: id: " << saveIdPart << std::endl; +#endif + saveId = format::StringToNumber<int>(saveIdPart); + if(!saveId) + throw std::runtime_error("Invalid Save ID"); + + SaveInfo * newSave = Client::Ref().GetSave(saveId, 0); + GameSave * newGameSave = new GameSave(Client::Ref().GetSaveData(saveId, 0)); + newSave->SetGameSave(newGameSave); + if(!newSave) + throw std::runtime_error("Could not load save"); + + gameController->LoadSave(newSave); + delete newSave; + } + else + { + throw std::runtime_error("No Save ID"); + } + } + } + catch (std::exception & e) + { + new ErrorMessage("Error", "Invalid save link"); + } + } + SDL_Event event; while(engine->Running()) { |
