Author: ilor
Date: Mon Apr 13 22:09:35 2009
New Revision: 34883
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34883&view=rev
Log:
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.
Modified:
trunk/changelog
trunk/doc/man/wesnoth.6
trunk/src/editor2/editor_controller.cpp
trunk/src/editor2/editor_controller.hpp
trunk/src/editor2/editor_main.cpp
trunk/src/game.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=34883&r1=34882&r2=34883&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Mon Apr 13 22:09:35 2009
@@ -27,6 +27,10 @@
* 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
Modified: trunk/doc/man/wesnoth.6
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/doc/man/wesnoth.6?rev=34883&r1=34882&r2=34883&view=diff
==============================================================================
--- trunk/doc/man/wesnoth.6 (original)
+++ trunk/doc/man/wesnoth.6 Mon Apr 13 22:09:35 2009
@@ -66,8 +66,11 @@
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 @@
.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.
Modified: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=34883&r1=34882&r2=34883&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Mon Apr 13 22:09:35 2009
@@ -409,10 +409,15 @@
}
}
-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 @@
return;
}
}
- load_map(fn, use_mdi_);
+ load_map(fn, force_same_context ? false : use_mdi_);
}
}
Modified: trunk/src/editor2/editor_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.hpp?rev=34883&r1=34882&r2=34883&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.hpp (original)
+++ trunk/src/editor2/editor_controller.hpp Mon Apr 13 22:09:35 2009
@@ -123,8 +123,11 @@
/** 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();
Modified: trunk/src/editor2/editor_main.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_main.cpp?rev=34883&r1=34882&r2=34883&view=diff
==============================================================================
--- trunk/src/editor2/editor_main.cpp (original)
+++ trunk/src/editor2/editor_main.cpp Mon Apr 13 22:09:35 2009
@@ -17,6 +17,7 @@
#include "../construct_dialog.hpp"
#include "../gettext.hpp"
+#include "../filesystem.hpp"
#include <boost/algorithm/string/replace.hpp>
@@ -30,27 +31,14 @@
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) {
Modified: trunk/src/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=34883&r1=34882&r2=34883&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Mon Apr 13 22:09:35 2009
@@ -401,6 +401,12 @@
#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 @@
<< " --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 @@
#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"
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits