Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2012-01-22 17:46:40 +0000
committerStijn Buys <ingar@osirion.org>2012-01-22 17:46:40 +0000
commit3c8f200dd83d18839c8205ed630a104d67e0807d (patch)
tree6a1e847ca9788566dda7cb356e2a90944f858023 /src/client
parente38beeb8e048402de8ee46cbbba66436810c2f87 (diff)
Implemented autosave for single player games.
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cc22
-rw-r--r--src/client/savegamemenu.cc23
-rw-r--r--src/client/savegamemenu.h2
3 files changed, 33 insertions, 14 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index 1ee53d3..eee940d 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -171,10 +171,10 @@ void Client::init(int count, char **arguments)
func->set_info("[command] view menu functions");
func = core::Func::add("loadgame", func_loadgame);
- func->set_info("load game");
+ func->set_info("[savename] load game");
func = core::Func::add("savegame", func_savegame);
- func->set_info("save game");
+ func->set_info("[savename] [description] save game");
previous_timestamp = 0;
}
@@ -648,13 +648,25 @@ void Client::func_savegame(std::string const &args)
{
std::stringstream argstr(args);
std::string savename;
+ std::string descr;
+
argstr >> savename;
aux::to_label(savename);
if (!savename.size()) {
- savename.assign("quick");
+ savename.assign("quicksave");
+ descr.assign("QUICKSAVE");
+ } else {
+ std::string word;
+ while(argstr >> word)
+ {
+ if (descr.size()) {
+ descr += ' ';
+ }
+ descr.append(word);
+ }
}
- SaveGameMenu::savegame(savename);
+ SaveGameMenu::savegame(savename, descr);
}
// quik save
@@ -666,7 +678,7 @@ void Client::func_loadgame(std::string const &args)
aux::to_label(savename);
if (!savename.size()) {
- savename.assign("quick");
+ savename.assign("quicksave");
}
SaveGameMenu::loadgame(savename);
}
diff --git a/src/client/savegamemenu.cc b/src/client/savegamemenu.cc
index 5e8f369..ea766a2 100644
--- a/src/client/savegamemenu.cc
+++ b/src/client/savegamemenu.cc
@@ -378,7 +378,8 @@ bool SaveGameMenu::on_emit(ui::Widget *sender, const ui::Widget::Event event, vo
if (event == ui::Widget::EventButtonClicked) {
if (savegamemenu_mode == Save) {
if (savegamemenu_filelistview->selected()) {
- savegame(savegamemenu_filelistview->selected()->value());
+ std::string descr;
+ savegame(savegamemenu_filelistview->selected()->value(), descr);
parent()->hide();
}
} else {
@@ -470,7 +471,7 @@ void SaveGameMenu::deletegame(std::string savename)
::remove(filename.c_str());
}
-void SaveGameMenu::savegame(std::string savename)
+void SaveGameMenu::savegame(std::string savename, const std::string & description)
{
if (!core::server() || !core::server()->module())
return;
@@ -505,6 +506,7 @@ void SaveGameMenu::savegame(std::string savename)
filesystem::OFileStream ofs("savegames/" + savename + ".ini");
con_debug << "Saving " << ofs.filename() << std::endl;
+ core::application()->notify_message(core::Message::Info, "Saving '" + savename + "'");
ofs << "; Project::OSiRiON" << std::endl;
ofs << "; savegame data" << std::endl;
@@ -512,13 +514,16 @@ void SaveGameMenu::savegame(std::string savename)
ofs << "[savegame]" << std::endl;
ofs << "description=";
- if (core::localcontrol()->state() == core::Entity::Docked) {
- // FIXME implement entity->dock()
- ofs << core::localplayer()->view()->name() << std::endl;
+ if (description.size()) {
+ ofs << description << std::endl;
} else {
- ofs << core::localplayer()->zone()->name() << std::endl;
+ if (core::localcontrol()->state() == core::Entity::Docked) {
+ // FIXME implement entity->dock()
+ ofs << core::localplayer()->view()->name() << std::endl;
+ } else {
+ ofs << core::localplayer()->zone()->name() << std::endl;
+ }
}
-
ofs << "info=";
if (core::localcontrol()->state() == core::Entity::Docked) {
// FIXME implement entity->dock()
@@ -555,13 +560,15 @@ void SaveGameMenu::loadgame(std::string savename) {
return;
}
- con_debug << "Loading " << inifile.filename() << std::endl;
if (core::application()->connected())
core::application()->disconnect();
core::application()->connect("");
+ con_debug << "Loading " << inifile.filename() << std::endl;
+ core::application()->notify_message(core::Message::Info, "Loading '" + savename + "'");
+
if (core::application()->connected() && core::server() && core::server()->module()) {
core::server()->module()->game_load(core::localplayer(), inifile);
}
diff --git a/src/client/savegamemenu.h b/src/client/savegamemenu.h
index d615102..d8dde05 100644
--- a/src/client/savegamemenu.h
+++ b/src/client/savegamemenu.h
@@ -27,7 +27,7 @@ public:
static void loadgame(std::string savename);
- static void savegame(std::string savename);
+ static void savegame(std::string savename, const std::string & description);
static void deletegame(std::string savename);