editor/editor_main.cpp

Go to the documentation of this file.
00001 /* $Id: editor_main.cpp 53576 2012-03-20 20:32:17Z fendrin $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Tomasz Sniatowski <kailoran@gmail.com>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #define GETTEXT_DOMAIN "wesnoth-editor"
00016 
00017 #include "editor_controller.hpp"
00018 
00019 #include "../construct_dialog.hpp"
00020 #include "../gettext.hpp"
00021 #include "../filesystem.hpp"
00022 
00023 #include <boost/algorithm/string/replace.hpp>
00024 
00025 lg::log_domain log_editor("editor");
00026 
00027 namespace editor {
00028 
00029 EXIT_STATUS start(const config& game_conf, CVideo& video, const std::string& filename /* = "" */,
00030     bool take_screenshot /* = false */, const std::string& screenshot_filename /* = "map_screenshot.bmp" */)
00031 {
00032     EXIT_STATUS e = EXIT_ERROR;
00033     try {
00034         hotkey::scope_changer h_(game_conf, "hotkey_editor");
00035         hotkey::deactivate_all_scopes();
00036         hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
00037         hotkey::set_scope_active(hotkey::SCOPE_EDITOR);
00038         editor_controller editor(game_conf, video);
00039         if (!filename.empty()) {
00040             if (is_directory(filename)) {
00041 //TODO
00042                 //          editor.set_default_dir(filename);
00043                 editor.context_manager_->load_map_dialog(true);
00044             } else {
00045                 editor.context_manager_->load_map(filename, false);
00046             }
00047         }
00048         if(take_screenshot) {
00049             editor.do_screenshot(screenshot_filename);
00050             e = EXIT_NORMAL;
00051         } else {
00052             e = editor.main_loop();
00053         }
00054     } catch (editor_exception& e) {
00055         ERR_ED << "Editor exception in editor::start: " << e.what() << "\n";
00056         throw;
00057     }
00058     //TODO
00059     /*
00060     if (editor_action::get_instance_count() != 0) {
00061         ERR_ED << "Possibly leaked " << editor_action::get_instance_count() << " action objects\n";
00062     }
00063     */
00064     return e;
00065 }
00066 
00067 } //end namespace editor
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:34 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs