[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pingus-CVS] r3557 - in trunk/pingus/src: . components editor
From: |
grumbel at BerliOS |
Subject: |
[Pingus-CVS] r3557 - in trunk/pingus/src: . components editor |
Date: |
Mon, 24 Mar 2008 08:42:50 +0100 |
Author: grumbel
Date: 2008-03-24 08:42:49 +0100 (Mon, 24 Mar 2008)
New Revision: 3557
Modified:
trunk/pingus/src/client.hpp
trunk/pingus/src/components/playfield.cpp
trunk/pingus/src/demo_recorder.cpp
trunk/pingus/src/editor/editor_screen.cpp
trunk/pingus/src/editor/file_dialog.cpp
trunk/pingus/src/pingus_main.cpp
trunk/pingus/src/pingus_options.hpp
trunk/pingus/src/savegame_manager.cpp
trunk/pingus/src/screenshot.cpp
trunk/pingus/src/stat_manager.cpp
trunk/pingus/src/system.cpp
trunk/pingus/src/system.hpp
Log:
- added --userdir switch to set the directory where savegames and stuff is
stored
Modified: trunk/pingus/src/client.hpp
===================================================================
--- trunk/pingus/src/client.hpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/client.hpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -81,9 +81,6 @@
ButtonPanel* get_button_panel () { return button_panel; }
- void on_primary_button_press(int x, int y);
- void on_primary_button_release(int x, int y);
-
// Overloaded GUIScreen stuff
void on_startup ();
void on_shutdown ();
Modified: trunk/pingus/src/components/playfield.cpp
===================================================================
--- trunk/pingus/src/components/playfield.cpp 2008-03-23 16:43:54 UTC (rev
3556)
+++ trunk/pingus/src/components/playfield.cpp 2008-03-24 07:42:49 UTC (rev
3557)
@@ -175,8 +175,7 @@
void
Playfield::on_primary_button_press(int x, int y)
{
- UNUSED_ARG(x);
- UNUSED_ARG(y);
+ current_pingu = current_pingu_find(state.screen2world( Vector2i(x,y) ));
if (current_pingu)
{
Modified: trunk/pingus/src/demo_recorder.cpp
===================================================================
--- trunk/pingus/src/demo_recorder.cpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/demo_recorder.cpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -39,7 +39,7 @@
if (!levelname.empty())
{
- std::string filename = System::get_statdir() + "demos/" + flat_levelname
+ "-" + get_date() + ".xml";
+ std::string filename = System::get_userdir() + "demos/" + flat_levelname
+ "-" + get_date() + ".xml";
out.open(filename.c_str());
if (!out)
Modified: trunk/pingus/src/editor/editor_screen.cpp
===================================================================
--- trunk/pingus/src/editor/editor_screen.cpp 2008-03-23 16:43:54 UTC (rev
3556)
+++ trunk/pingus/src/editor/editor_screen.cpp 2008-03-24 07:42:49 UTC (rev
3557)
@@ -329,7 +329,7 @@
void
EditorScreen::level_play()
{
- Pathname tmp(System::get_statdir() + "backup/editortmpfile.pingus",
Pathname::SYSTEM_PATH);
+ Pathname tmp(System::get_userdir() + "backup/editortmpfile.pingus",
Pathname::SYSTEM_PATH);
if (!plf->save_level(tmp.get_sys_path()))
{
// FIXME: save failed, prompt user
Modified: trunk/pingus/src/editor/file_dialog.cpp
===================================================================
--- trunk/pingus/src/editor/file_dialog.cpp 2008-03-23 16:43:54 UTC (rev
3556)
+++ trunk/pingus/src/editor/file_dialog.cpp 2008-03-24 07:42:49 UTC (rev
3557)
@@ -203,7 +203,7 @@
void
FileDialog::on_userdir()
{
- set_directory(System::get_statdir() + "levels/");
+ set_directory(System::get_userdir() + "levels/");
}
void
Modified: trunk/pingus/src/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus_main.cpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/pingus_main.cpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -164,7 +164,7 @@
std::string rcfile;
if (!cmd_options.config_file.is_set())
- rcfile = System::get_statdir() + "config";
+ rcfile = System::get_userdir() + "config";
else
rcfile = cmd_options.config_file.get();
@@ -301,6 +301,8 @@
argp.add_group(_("Misc Options:"));
argp.add_option('d', "datadir", _("PATH"),
_("Set the path to load the data files to 'path'"));
+ argp.add_option('u', "userdir", _("PATH"),
+ _("Set the path to load and save user files (savegames,
etc.) to PATH"));
argp.add_option(337, "disable-auto-scrolling", "",
_("Disable automatic scrolling"));
@@ -398,6 +400,10 @@
cmd_options.datadir.set(argp.get_argument());
break;
+ case 'u': // -u, --userdir
+ cmd_options.userdir.set(argp.get_argument());
+ break;
+
case 'v':
std::cout << "Pingus " << VERSION << std::endl;
std::cout << "\n"
@@ -582,6 +588,9 @@
void
PingusMain::init_path_finder()
{
+ if (cmd_options.userdir.is_set())
+ System::set_userdir(cmd_options.userdir.get());
+
System::init_directories();
if (cmd_options.datadir.is_set())
Modified: trunk/pingus/src/pingus_options.hpp
===================================================================
--- trunk/pingus/src/pingus_options.hpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/pingus_options.hpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -80,6 +80,7 @@
// Misc
Value<std::string> language;
Value<std::string> datadir;
+ Value<std::string> userdir;
Value<bool> auto_scrolling;
Value<bool> no_config_file;
Modified: trunk/pingus/src/savegame_manager.cpp
===================================================================
--- trunk/pingus/src/savegame_manager.cpp 2008-03-23 16:43:54 UTC (rev
3556)
+++ trunk/pingus/src/savegame_manager.cpp 2008-03-24 07:42:49 UTC (rev
3557)
@@ -45,7 +45,7 @@
}
SavegameManager::SavegameManager(const std::string& arg_filename)
- : filename(System::get_statdir() + arg_filename)
+ : filename(System::get_userdir() + arg_filename)
{
boost::shared_ptr<lisp::Lisp> sexpr;
Modified: trunk/pingus/src/screenshot.cpp
===================================================================
--- trunk/pingus/src/screenshot.cpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/screenshot.cpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -198,7 +198,7 @@
do {
snprintf(str, 16, "%d.png", i);
- tmp_filename = System::get_statdir() + "screenshots/"
+ tmp_filename = System::get_userdir() + "screenshots/"
+ "pingus-" + get_date() + "-" + std::string(str);
++i;
} while (System::exist(tmp_filename));
Modified: trunk/pingus/src/stat_manager.cpp
===================================================================
--- trunk/pingus/src/stat_manager.cpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/stat_manager.cpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -70,7 +70,7 @@
}
StatManager::StatManager(const std::string& arg_filename)
- : statfilename(System::get_statdir() + arg_filename)
+ : statfilename(System::get_userdir() + arg_filename)
{
load(statfilename);
}
Modified: trunk/pingus/src/system.cpp
===================================================================
--- trunk/pingus/src/system.cpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/system.cpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -52,7 +52,8 @@
#include "gettext.h"
-int System::verbose;
+int System::verbose;
+std::string System::userdir;
std::string System::default_email;
std::string System::default_username;
@@ -263,42 +264,8 @@
chdir(dir.c_str());
}
-void
-System::init_directories()
-{
- std::string statdir = get_statdir();
- std::string vardir = get_vardir();
-
- create_dir(statdir);
-
- // FIXME: We need a better seperation between user created levels,
- // FIXME: third party levels and levels from the base distri
- create_dir(statdir + "levels/");
- create_dir(statdir + "levels/dist");
- create_dir(statdir + "themes/");
-
- // Savegames (FIXME: rename to savegames/?)
- create_dir(statdir + "savegames/");
-
- // User created images
- create_dir(statdir + "images/");
-
- // Thumbnail cache
- create_dir(statdir + "cache/");
-
- // Recorded demos will per default be writen in this directory
- create_dir(statdir + "demos/");
-
- // User created images
- create_dir(statdir + "backup/");
-
- // Screenshots will be dumped to that directory:
- create_dir(statdir + "screenshots/");
- // create_dir(vardir);
-}
-
std::string
-System::get_statdir()
+System::find_userdir()
{
#ifdef WIN32
std::string tmpstr;
@@ -330,33 +297,57 @@
#endif
}
-std::string
-System::get_cachedir()
+void
+System::init_directories()
{
- return get_statdir() + "cache/";
+ if (userdir.empty())
+ userdir = find_userdir();
+
+ std::string statdir = get_userdir();
+
+ create_dir(statdir);
+
+ // FIXME: We need a better seperation between user created levels,
+ // FIXME: third party levels and levels from the base distri
+ create_dir(statdir + "levels/");
+ create_dir(statdir + "levels/dist");
+ create_dir(statdir + "themes/");
+
+ // Savegames (FIXME: rename to savegames/?)
+ create_dir(statdir + "savegames/");
+
+ // User created images
+ create_dir(statdir + "images/");
+
+ // Thumbnail cache
+ create_dir(statdir + "cache/");
+
+ // Recorded demos will per default be writen in this directory
+ create_dir(statdir + "demos/");
+
+ // User created images
+ create_dir(statdir + "backup/");
+
+ // Screenshots will be dumped to that directory:
+ create_dir(statdir + "screenshots/");
}
+void
+System::set_userdir(const std::string& u)
+{
+ userdir = u + "/";
+}
+
std::string
-System::get_vardir()
+System::get_userdir()
{
-#ifdef WIN32
- return "var/";
-#else
- return "/var/games/pingus/";
-#endif
+ return userdir;
}
std::string
-System::get_tmpdir()
+System::get_cachedir()
{
-#ifdef WIN32
- char* tmpdir = getenv("TEMP");
- if (!tmpdir) tmpdir = getenv("TMP");
- if (!tmpdir) return get_statdir() + "tmp/";
- else return std::string(tmpdir);
-#else
- return "/tmp/";
-#endif
+ return get_userdir() + "cache/";
}
/** Returns the username of the current user or an empty string */
Modified: trunk/pingus/src/system.hpp
===================================================================
--- trunk/pingus/src/system.hpp 2008-03-23 16:43:54 UTC (rev 3556)
+++ trunk/pingus/src/system.hpp 2008-03-24 07:42:49 UTC (rev 3557)
@@ -37,6 +37,8 @@
static std::string default_email;
static std::string default_username;
+ static std::string userdir;
+
public:
enum FileType { DE_DIRECTORY, DE_FILE };
@@ -88,23 +90,19 @@
static std::string extension (std::string filename);
static std::string cut_ext (std::string filename);
+ static std::string find_userdir();
+
+ /** Sets the directory to save users data to */
+ static void set_userdir(const std::string&);
+
/** Returns the directory where Pingus can store its user specific
state and config data (savegames, config files, demos, etc.) */
- static std::string get_statdir();
+ static std::string get_userdir();
/** Returns the directory where Pingus can store things that needs
to be cached, for example thumbnails */
static std::string get_cachedir();
- /** Returns the directory were Pingus can store its system wide
- variable game data (highscores, cache images, ...) */
- static std::string get_vardir();
-
- /** Asks different variables to check were the directory for
- temporary files is located
- @return The location of the tmp directory */
- static std::string get_tmpdir();
-
/** Returns the Username how the current user or an empty string */
static std::string get_username();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pingus-CVS] r3557 - in trunk/pingus/src: . components editor,
grumbel at BerliOS <=