#include "supertux/command_line_arguments.hpp"
-#include <stdexcept>
-#include <physfs.h>
#include <boost/format.hpp>
+#include <iostream>
+#include <physfs.h>
+#include <stdexcept>
#include "supertux/gameconfig.hpp"
#include "supertux/main.hpp"
CommandLineArguments::CommandLineArguments() :
m_action(NO_ACTION),
m_log_level(LOG_WARNING),
+ datadir(),
+ userdir(),
fullscreen_size(),
fullscreen_refresh_rate(),
window_size(),
start_level(),
enable_script_debugger(),
start_demo(),
- record_demo()
+ record_demo(),
+ developer_mode()
{
}
// Print the datadir searchpath to stdout, one path per
// line. Then exit. Intended for use by the supertux-editor.
char **sp;
- size_t sp_index;
sp = PHYSFS_getSearchPath();
if (sp)
- for (sp_index = 0; sp[sp_index]; sp_index++)
+ for (size_t sp_index = 0; sp[sp_index]; sp_index++)
std::cout << sp[sp_index] << std::endl;
PHYSFS_freeList(sp);
}
void
-CommandLineArguments::print_help(const char* argv0)
+CommandLineArguments::print_help(const char* arg0)
{
- std::string default_user_data_dir =
- std::string(PHYSFS_getUserDir()) + WRITEDIR_NAME;
+ std::cerr
+ << boost::format(_( "Usage: %s [OPTIONS] [LEVELFILE]")) % arg0 << "\n" << "\n"
+ << _( "General Options:" ) << "\n"
+ << _( " -h, --help Show this help message and quit") << "\n"
+ << _( " -v, --version Show SuperTux version and quit") << "\n"
+ << _( " --verbose Print verbose messages") << "\n"
+ << _( " --debug Print extra verbose messages") << "\n"
+ << _( " --print-datadir Print supertux's primary data directory.") << "\n" << "\n"
+ << _( "Video Options:") << "\n"
+ << _( " -f, --fullscreen Run in fullscreen mode") << "\n"
+ << _( " -w, --window Run in window mode") << "\n"
+ << _( " -g, --geometry WIDTHxHEIGHT Run SuperTux in given resolution") << "\n"
+ << _( " -a, --aspect WIDTH:HEIGHT Run SuperTux with given aspect ratio") << "\n"
+ << _( " -d, --default Reset video settings to default values") << "\n"
+ << _( " --renderer RENDERER Use sdl, opengl, or auto to render") << "\n" << "\n"
+ << _( "Audio Options:") << "\n"
+ << _( " --disable-sound Disable sound effects") << "\n"
+ << _( " --disable-music Disable music") << "\n" << "\n"
+ << _( "Game Options:") << "\n"
+ << _( " --console Enable ingame scripting console") << "\n"
+ << _( " --noconsole Disable ingame scripting console") << "\n"
+ << _( " --show-fps Display framerate in levels") << "\n"
+ << _( " --no-show-fps Do not display framerate in levels") << "\n"
+ << _( " --developer Switch on developer feature") << "\n"
+ << _( " -s, --debug-scripts Enable script debugger.") << "\n" << "\n"
+ << _( "Demo Recording Options:") << "\n"
+ << _( " --record-demo FILE LEVEL Record a demo to FILE") << "\n"
+ << _( " --play-demo FILE LEVEL Play a recorded demo") << "\n" << "\n"
+ << _( "Directory Options:") << "\n"
+ << _( " --datadir DIR Set the directory for the games datafiles") << "\n"
+ << _( " --userdir DIR Set the directory for user data (savegames, etc.)") << "\n" << "\n"
+ << _( "Environment variables:") << "\n"
+ << _( " SUPERTUX2_USER_DIR Directory for user data (savegames, etc.)" ) << "\n"
+ << _( " SUPERTUX2_DATA_DIR Directory for the games datafiles" ) << "\n"<< "\n"
+
+
- std::cerr << boost::format(_(
- "\n"
- "Usage: %s [OPTIONS] [LEVELFILE]\n\n"
- "CommandLineArguments:\n"
- " --verbose Print verbose messages\n"
- " --debug Print extra verbose messages\n"
- " -f, --fullscreen Run in fullscreen mode\n"
- " -w, --window Run in window mode\n"
- " -g, --geometry WIDTHxHEIGHT Run SuperTux in given resolution\n"
- " -a, --aspect WIDTH:HEIGHT Run SuperTux with given aspect ratio\n"
- " -d, --default Reset video settings to default values\n"
- " --renderer RENDERER Use sdl, opengl, or auto to render\n"
- " --disable-sound Disable sound effects\n"
- " --disable-music Disable music\n"
- " -h, --help Show this help message and quit\n"
- " -v, --version Show SuperTux version and quit\n"
- " --console Enable ingame scripting console\n"
- " --noconsole Disable ingame scripting console\n"
- " --show-fps Display framerate in levels\n"
- " --no-show-fps Do not display framerate in levels\n"
- " --record-demo FILE LEVEL Record a demo to FILE\n"
- " --play-demo FILE LEVEL Play a recorded demo\n"
- " -s, --debug-scripts Enable script debugger.\n"
- " --print-datadir Print supertux's primary data directory.\n"
- "\n"
- "Environment variables:\n"
- " SUPERTUX2_USER_DIR Directory for user data (savegames, etc.);\n"
- " default %s\n"
- "\n"
- ))
- % argv0 % default_user_data_dir
<< std::flush;
}
m_log_level = LOG_INFO;
}
}
+ else if (arg == "--datadir")
+ {
+ if (i+1 >= argc)
+ {
+ throw std::runtime_error("Need to specify a directory for --datadir");
+ }
+ else
+ {
+ datadir = argv[++i];
+ }
+ }
+ else if (arg == "--userdir")
+ {
+ if (i+1 >= argc)
+ {
+ throw std::runtime_error("Need to specify a directory for --userdir");
+ }
+ else
+ {
+ userdir = argv[++i];
+ }
+ }
else if (arg == "--fullscreen" || arg == "-f")
{
use_fullscreen = true;
{
use_fullscreen = false;
- window_size = Size(800, 600);
- fullscreen_size = Size(800, 600);
+ window_size = Size(1280, 800);
+ fullscreen_size = Size(1280, 800);
fullscreen_refresh_rate = 0;
aspect_size = Size(0, 0); // auto detect
}
else
{
int width, height;
- if (sscanf(argv[i], "%dx%d", &width, &height) != 2)
+ if (sscanf(argv[i], "%9dx%9d", &width, &height) != 2)
{
throw std::runtime_error("Invalid geometry spec, should be WIDTHxHEIGHT");
}
aspect_width = 0;
aspect_height = 0;
}
- else if (sscanf(argv[i], "%d:%d", &aspect_width, &aspect_height) != 2)
+ else if (sscanf(argv[i], "%9d:%9d", &aspect_width, &aspect_height) != 2)
{
throw std::runtime_error("Invalid aspect spec, should be WIDTH:HEIGHT or auto");
}
{
show_fps = false;
}
+ else if (arg == "--developer")
+ {
+ developer_mode = true;
+ }
else if (arg == "--console")
{
console_enabled = true;
merge_option(enable_script_debugger);
merge_option(start_demo);
merge_option(record_demo);
+ merge_option(developer_mode);
#undef merge_option
}