Make wesnoth --editor --load DIR (wesnoth -e -l DIR)...
...start the editor with a load map dialog pointed at DIR, and make DIR the default map directory for the current session, per ESR's request. Also make wesnoth -e foo work like wesnoth -e --load foo, and change how -e MAP is processed internally.
This commit is contained in:
parent
7a60e7cc13
commit
cf0c6e872b
6 changed files with 39 additions and 28 deletions
|
@ -27,6 +27,10 @@ Version 1.7.0-svn:
|
|||
* New feature: exporting of selection coordinates to system clipboard
|
||||
* Made auto terrain transition mode tri-state: on (editor2's on), partial
|
||||
(1.4 editor's on / editor2's off) and off (1.4's off).
|
||||
* Made "wesnoth -e FILE" work like "wesnoth -e --load FILE" (load the map)
|
||||
* Made "wesnoth -e --load DIR" (and consequently "wesnoth -e DIR") set
|
||||
DIR as the default map directory for the current session, and start with
|
||||
the map load dialog open
|
||||
* FormulaAI:
|
||||
* Fixed bug #13230: added debug_float FormulaAI function to allow debugging
|
||||
via floating popups on the specified hex
|
||||
|
|
|
@ -66,8 +66,11 @@ enables additional command mode options in-game
|
|||
use special dummy locales to switch to any language even if that language
|
||||
isn't installed system-wide.
|
||||
.TP
|
||||
.B -e, --editor
|
||||
start the in-game map editor directly.
|
||||
.B -e, --editor \ file
|
||||
start the in-game map editor directly. If
|
||||
.I file
|
||||
is specified, equivalent to
|
||||
.B -e --load
|
||||
.TP
|
||||
.B --fps
|
||||
displays the number of frames per second the game is currently running
|
||||
|
@ -101,7 +104,7 @@ or
|
|||
.B --editor
|
||||
option is used as well, starts the editor with the map from
|
||||
.I file
|
||||
open.
|
||||
open. If it is a directory, the editor will start with a load map dialog opened there.
|
||||
.TP
|
||||
.BI --log- level = domain1 , domain2 , ...
|
||||
sets the severity level of the log domains.
|
||||
|
|
|
@ -409,10 +409,15 @@ bool editor_controller::confirm_discard()
|
|||
}
|
||||
}
|
||||
|
||||
void editor_controller::load_map_dialog()
|
||||
void editor_controller::set_default_dir(const std::string& str)
|
||||
{
|
||||
default_dir_ = str;
|
||||
}
|
||||
|
||||
void editor_controller::load_map_dialog(bool force_same_context /* = false */)
|
||||
{
|
||||
if (!use_mdi_ && !confirm_discard()) return;
|
||||
std::string fn = get_map_context().get_filename();
|
||||
std::string fn = directory_name(get_map_context().get_filename());
|
||||
if (fn.empty()) {
|
||||
fn = default_dir_;
|
||||
}
|
||||
|
@ -425,7 +430,7 @@ void editor_controller::load_map_dialog()
|
|||
return;
|
||||
}
|
||||
}
|
||||
load_map(fn, use_mdi_);
|
||||
load_map(fn, force_same_context ? false : use_mdi_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -123,8 +123,11 @@ class editor_controller : public controller_base,
|
|||
/** Switches the context to the one under the specified index. */
|
||||
void switch_context(const int index);
|
||||
|
||||
/** Set the default dir (where the filebrowser is pointing at when there is no map file opened) */
|
||||
void set_default_dir(const std::string& str);
|
||||
|
||||
/** Display a load map dialog and process user input. */
|
||||
void load_map_dialog();
|
||||
void load_map_dialog(bool force_same_context = false);
|
||||
|
||||
/** Display a new map dialog and process user input. */
|
||||
void new_map_dialog();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "../construct_dialog.hpp"
|
||||
#include "../gettext.hpp"
|
||||
#include "../filesystem.hpp"
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
|
@ -30,28 +31,15 @@ EXIT_STATUS start(config& game_conf, CVideo& video, const std::string& filename
|
|||
hotkey::deactivate_all_scopes();
|
||||
hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
|
||||
hotkey::set_scope_active(hotkey::SCOPE_EDITOR);
|
||||
std::auto_ptr<map_context> mc(NULL);
|
||||
std::string map_error;
|
||||
editor_controller editor(game_conf, video, NULL);
|
||||
if (!filename.empty()) {
|
||||
try {
|
||||
mc.reset(new map_context(game_conf, filename));
|
||||
LOG_ED << "Map " << filename << " loaded. "
|
||||
<< mc->get_map().w() << " by " << mc->get_map().h() << "\n";
|
||||
} catch (editor_map_load_exception& e) {
|
||||
std::stringstream ss;
|
||||
ss << "\"" << boost::replace_all_copy(filename, "\\", "\\\\") << "\"";
|
||||
ss << ":\n";
|
||||
ss << e.what();
|
||||
map_error = ss.str();
|
||||
ERR_ED << map_error << "\n";
|
||||
mc.reset();
|
||||
if (is_directory(filename)) {
|
||||
editor.set_default_dir(filename);
|
||||
editor.load_map_dialog(true);
|
||||
} else {
|
||||
editor.load_map(filename, false);
|
||||
}
|
||||
}
|
||||
editor_controller editor(game_conf, video, mc.get());
|
||||
mc.release();
|
||||
if (!map_error.empty()) {
|
||||
gui::message_dialog(editor.gui(), _("Error loading map"), map_error).show();
|
||||
}
|
||||
e = editor.main_loop();
|
||||
} catch (editor_exception& e) {
|
||||
ERR_ED << "Editor exception in editor2::start: " << e.what() << "\n";
|
||||
|
|
12
src/game.cpp
12
src/game.cpp
|
@ -401,6 +401,12 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
#ifndef DISABLE_EDITOR2
|
||||
} else if(val == "-e" || val == "--editor") {
|
||||
jump_to_editor_ = true;
|
||||
if(arg_+1 != argc_) {
|
||||
if (argv_[arg_ + 1][0] != '-') {
|
||||
++arg_;
|
||||
loaded_game_ = argv_[arg_];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
} else if(val == "--dummy-locales") {
|
||||
#ifdef USE_DUMMYLOCALES
|
||||
|
@ -1718,7 +1724,8 @@ static int process_command_args(int argc, char** argv) {
|
|||
<< " --dummy-locales enables dummy locales for switching to non-system\n"
|
||||
<< " locales.\n"
|
||||
#ifndef DISABLE_EDITOR2
|
||||
<< " -e, --editor starts the in-game map editor directly.\n"
|
||||
<< " -e, --editor [<file>] starts the in-game map editor directly. If <file>\n"
|
||||
<< " is specified, equivalent to -e --load <file>.\n"
|
||||
#endif
|
||||
<< " --fps displays the number of frames per second the\n"
|
||||
<< " game is currently running at, in a corner of\n"
|
||||
|
@ -1735,7 +1742,8 @@ static int process_command_args(int argc, char** argv) {
|
|||
#ifndef DISABLE_EDITOR2
|
||||
<< " When launching the map editor via -e, the map\n"
|
||||
<< " <file> is loaded, relative to the current\n"
|
||||
<< " directory.\n"
|
||||
<< " directory. If it is a directory, the editor\n"
|
||||
<< " will start with a load map dialog opened there.\n"
|
||||
#endif
|
||||
<< " --log-<level>=<domain1>,<domain2>,...\n"
|
||||
<< " sets the severity level of the log domains.\n"
|
||||
|
|
Loading…
Add table
Reference in a new issue