From 534e30270a8636ab8e2cc5e8b750747186dd06af Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 15 Jan 2012 16:59:07 +0000 Subject: Implement the savegame and loadgame console functions. --- src/client/client.cc | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src/client/client.cc') diff --git a/src/client/client.cc b/src/client/client.cc index 897ab41..1ee53d3 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -17,6 +17,7 @@ #include "client/video.h" #include "client/input.h" #include "client/soundext.h" +#include "client/savegamemenu.h" #include "core/core.h" #include "core/loader.h" #include "core/zone.h" @@ -643,30 +644,31 @@ void Client::func_testmodel(std::string const &args) } // quick load -void Client::func_loadgame(std::string const &args) +void Client::func_savegame(std::string const &args) { - std::string savegamepath(filesystem::writedir()); - savegamepath.append("savegames"); - - filesystem::Directory directory(savegamepath); + std::stringstream argstr(args); + std::string savename; + argstr >> savename; + aux::to_label(savename); - for (filesystem::Directory::FileNames::const_iterator it = directory.filenames().begin(); - it != directory.filenames().end(); ++it) - { - con_print << (*it) << std::endl; - } + if (!savename.size()) { + savename.assign("quick"); + } + SaveGameMenu::savegame(savename); } // quik save -void Client::func_savegame(std::string const &args) +void Client::func_loadgame(std::string const &args) { - // make sure the screenshots folder exists - std::string savegamepath(filesystem::writedir()); - savegamepath.append("savegames"); + std::stringstream argstr(args); + std::string savename; + argstr >> savename; + aux::to_label(savename); - if (!sys::directory_exists(savegamepath)) { - sys::mkdir(savegamepath); + if (!savename.size()) { + savename.assign("quick"); } + SaveGameMenu::loadgame(savename); } } // namespace client -- cgit v1.2.3