Author: ilor
Date: Sat Jul 5 13:29:47 2008
New Revision: 27747
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27747&view=rev
Log:
Separate editor2 from old editor sources. This makes old-editor build and work
when editor2 is built. This also makes editor2 largely nonfunctonal as it lacks
basic features.
Modified:
trunk/src/CMakeLists.txt
trunk/src/Makefile.am
trunk/src/SConscript
trunk/src/editor/editor.hpp
trunk/src/editor2/editor_controller.cpp
trunk/src/editor2/editor_controller.hpp
trunk/src/editor2/editor_display.cpp
trunk/src/editor2/editor_main.cpp
trunk/src/editor2/editor_map.cpp
trunk/src/editor2/editor_map.hpp
Modified: trunk/src/CMakeLists.txt
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Sat Jul 5 13:29:47 2008
@@ -296,13 +296,10 @@
SET(wesnoth-editor2_SRC
editor2/editor_main.cpp
- editor/editor.cpp
- editor/editor_layout.cpp
- editor/map_manip.cpp
- editor/editor_display.cpp
- editor/editor_palettes.cpp
- editor/editor_dialogs.cpp
- editor/editor_undo.cpp
+ editor2/editor_controller.cpp
+ editor2/editor_display.cpp
+ editor2/editor_map.cpp
+ editor2/editor_display.cpp
)
SET(wesnoth_SRC
Modified: trunk/src/Makefile.am
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/Makefile.am?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sat Jul 5 13:29:47 2008
@@ -145,13 +145,10 @@
# used with editor2 option in the wesnoth target
wesnoth_editor2_SOURCES = \
editor2/editor_main.cpp \
- editor/editor.cpp \
- editor/editor_layout.cpp \
- editor/map_manip.cpp \
- editor/editor_display.cpp \
- editor/editor_palettes.cpp \
- editor/editor_dialogs.cpp \
- editor/editor_undo.cpp
+ editor2/editor_controller.cpp \
+ editor2/editor_display.cpp \
+ editor2/editor_map.cpp \
+ editor2/editor_display.cpp
if EDITOR2
wesnoth_source += $(wesnoth_editor2_SOURCES)
Modified: trunk/src/SConscript
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Sat Jul 5 13:29:47 2008
@@ -237,13 +237,10 @@
# used with editor2 option in the wesnoth target
wesnoth_editor2_sources = Split("""
editor2/editor_main.cpp
- editor/editor.cpp
- editor/editor_layout.cpp
- editor/map_manip.cpp
- editor/editor_display.cpp
- editor/editor_palettes.cpp
- editor/editor_dialogs.cpp
- editor/editor_undo.cpp
+ editor2/editor_controller.cpp
+ editor2/editor_display.cpp
+ editor2/editor_map.cpp
+ editor2/editor_display.cpp
""")
if env['editor2']:
Modified: trunk/src/editor/editor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.hpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor/editor.hpp (original)
+++ trunk/src/editor/editor.hpp Sat Jul 5 13:29:47 2008
@@ -335,9 +335,7 @@
// cycles.
bool mouse_moved_;
bool highlighted_locs_cleared_;
-#ifndef USE_EDITOR2
const hotkey::manager hotkey_manager_;
-#endif
const preferences::display_manager prefs_disp_manager_;
static config prefs_;
static config hotkeys_;
Modified: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Sat Jul 5 13:29:47 2008
@@ -14,29 +14,32 @@
#include "editor_controller.hpp"
#include "editor_display.hpp"
#include "editor_map.hpp"
+#include "../config_adapter.hpp"
#include "../preferences.hpp"
+
#include "SDL.h"
namespace editor2 {
editor_controller::editor_controller(const config &game_config, CVideo& video)
-: game_config_(game_config), gui_(NULL)
+: game_config_(game_config), map_(editor_map::new_map(game_config, 44, 33,
t_translation::GRASS_LAND))
+, gui_(NULL)
{
- map_ = editor_map::new_map(44, 33, t_translation::GRASS_LAND);
init(video);
- gui_.invalidate_game_status();
- gui_.invalidate_all();
- gui_.draw();
+ gui_->invalidate_game_status();
+ gui_->invalidate_all();
+ gui_->draw();
events::raise_draw_event();
- redraw_everything();
+ //redraw_everything();
}
-editor_controller::init(CVideo& video)
+void editor_controller::init(CVideo& video)
{
+ config dummy;
const config* theme_cfg = get_theme(game_config_, "editor2");
- const config theme = theme_cfg ? theme_cfg : config();
- gui_ = new editor_display(video, map_, theme, game_config_, config());
+ theme_cfg = theme_cfg ? theme_cfg : &dummy;
+ gui_ = new editor_display(video, map_, *theme_cfg, game_config_,
config());
}
editor_controller::~editor_controller()
@@ -54,26 +57,26 @@
const bool r_button_down = (0 != (mouse_flags &
SDL_BUTTON_RMASK));
const bool m_button_down = (0 != (mouse_flags &
SDL_BUTTON_MMASK));
- const gamemap::location cur_hex =
gui_.hex_clicked_on(mousex,mousey);
- const theme::menu* const m = gui_.menu_pressed();
+ const gamemap::location cur_hex =
gui_->hex_clicked_on(mousex,mousey);
+ const theme::menu* const m = gui_->menu_pressed();
if (m != NULL) {
- const SDL_Rect& menu_loc =
m->location(gui_.screen_area());
+ const SDL_Rect& menu_loc =
m->location(gui_->screen_area());
const int x = menu_loc.x + 1;
const int y = menu_loc.y + menu_loc.h + 1;
// show_menu(m->items(), x, y, false);
}
if(key_[SDLK_UP] || mousey == 0) {
- gui_.scroll(0,-scroll_speed);
+ gui_->scroll(0,-scroll_speed);
}
- if(key_[SDLK_DOWN] || mousey == gui_.h()-1) {
- gui_.scroll(0,scroll_speed);
+ if(key_[SDLK_DOWN] || mousey == gui_->h()-1) {
+ gui_->scroll(0,scroll_speed);
}
if(key_[SDLK_LEFT] || mousex == 0) {
- gui_.scroll(-scroll_speed,0);
+ gui_->scroll(-scroll_speed,0);
}
- if(key_[SDLK_RIGHT] || mousex == gui_.w()-1) {
- gui_.scroll(scroll_speed,0);
+ if(key_[SDLK_RIGHT] || mousex == gui_->w()-1) {
+ gui_->scroll(scroll_speed,0);
}
if (l_button_down) {
@@ -94,7 +97,7 @@
// middle_button_down(mousex, mousey);
}
- gui_.draw(true, true);
+ gui_->draw(true, true);
events::raise_draw_event();
// When the map has changed, wait until the left mouse button
@@ -111,7 +114,7 @@
// recalculate_starting_pos_labels();
// }
// }
- gui_.update_display();
+ gui_->update_display();
SDL_Delay(20);
events::pump();
// if (everything_dirty_) {
@@ -126,5 +129,10 @@
// mouse_moved_ = false;
}
}
+
+bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND, int) const
+{
+ return false;
+}
} //end namespace editor2
Modified: trunk/src/editor2/editor_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.hpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.hpp (original)
+++ trunk/src/editor2/editor_controller.hpp Sat Jul 5 13:29:47 2008
@@ -15,6 +15,8 @@
#define EDITOR2_EDITOR_CONTROLLER_HPP_INCLUDED
#include "editor_common.hpp"
+#include "editor_map.hpp"
+#include "editor_display.hpp"
#include <boost/utility.hpp>
@@ -22,6 +24,7 @@
#include "../config.hpp"
#include "../events.hpp"
#include "../hotkeys.hpp"
+#include "../sdl_utils.hpp"
namespace editor2 {
@@ -32,7 +35,7 @@
editor_controller(const config &game_config, CVideo& video);
~editor_controller();
void main_loop();
- bool can_execute_command(hotkey::HOTKEY_COMMAND, int) const {}
+ bool can_execute_command(hotkey::HOTKEY_COMMAND, int) const;
void handle_event(const SDL_Event&){}
private:
/** init the display object and general set-up */
Modified: trunk/src/editor2/editor_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_display.cpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor2/editor_display.cpp (original)
+++ trunk/src/editor2/editor_display.cpp Sat Jul 5 13:29:47 2008
@@ -48,8 +48,8 @@
{
// Fill in the terrain report
if(map_.on_board_with_border(mouseoverHex_)) {
- refresh_report(reports::TERRAIN,
reports::report(map_.get_terrain_string(mouseoverHex_);
- refresh_report(reports::POSITION,
reports::report(lexical_cast<std::string>(mouseoverHex_);
+ refresh_report(reports::TERRAIN,
reports::report(map_.get_terrain_string(mouseoverHex_)));
+ refresh_report(reports::POSITION,
reports::report(lexical_cast<std::string>(mouseoverHex_)));
}
refresh_report(reports::VILLAGES,
reports::report(lexical_cast<std::string>(map_.villages().size())));
}
Modified: trunk/src/editor2/editor_main.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_main.cpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor2/editor_main.cpp (original)
+++ trunk/src/editor2/editor_main.cpp Sat Jul 5 13:29:47 2008
@@ -16,6 +16,7 @@
#include "editor_common.hpp"
#include "../editor/editor.hpp"
+#include "editor_controller.hpp"
#include "config.hpp"
#include "filesystem.hpp"
@@ -27,42 +28,11 @@
#include "serialization/preprocessor.hpp"
#include "serialization/string_utils.hpp"
namespace editor2 {
-
+
EXIT_STATUS start(config& game_conf, CVideo& video)
{
- SCOPE_ED;
- std::string mapdata = map_editor::new_map(22, 22,
t_translation::GRASS_LAND);
- config* theme_cfg = game_conf.find_child("theme", "name", "editor");
- config dummy_theme;
- if (!theme_cfg) {
- std::cerr << "Editor theme could not be loaded." << std::endl;
- theme_cfg = &dummy_theme;
- }
- const config dummy_cfg;
- std::string filename = "";
- bool from_scenario = true;
-
- for(;;) {
- try {
- editormap map(game_conf, mapdata);
- editor_display gui(video, map, *theme_cfg, game_conf,
config());
- map_editor::map_editor editor(gui, map, *theme_cfg,
game_conf);
- editor.set_file_to_save_as(filename, from_scenario);
- editor.main_loop();
- break;
- } catch (map_editor::map_editor::new_map_exception &e) {
- mapdata = e.new_map;
- filename = e.new_filename;
- from_scenario = e.from_scenario;
- } catch (gamemap::incorrect_format_exception) {
- std::cerr << "The map is not in a correct format,
sorry." << std::endl;
- return EXIT_ERROR;
- } catch (twml_exception& e) {
- std::cerr << "WML exception:\nUser message: "
- << e.user_message << "\nDev message: " <<
e.dev_message << '\n';
- return EXIT_ERROR;
- }
- }
+ editor_controller editor(game_conf, video);
+ editor.main_loop();
return EXIT_ERROR;
}
Modified: trunk/src/editor2/editor_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_map.cpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor2/editor_map.cpp (original)
+++ trunk/src/editor2/editor_map.cpp Sat Jul 5 13:29:47 2008
@@ -21,7 +21,7 @@
{
}
-editor_map editor_map::create_map(const config& terrain_cfg, size_t width,
size_t height, t_translation::t_terrain filler)
+editor_map editor_map::new_map(const config& terrain_cfg, size_t width, size_t
height, t_translation::t_terrain filler)
{
const t_translation::t_list column(height, filler);
const t_translation::t_map map(width, column);
Modified: trunk/src/editor2/editor_map.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_map.hpp?rev=27747&r1=27746&r2=27747&view=diff
==============================================================================
--- trunk/src/editor2/editor_map.hpp (original)
+++ trunk/src/editor2/editor_map.hpp Sat Jul 5 13:29:47 2008
@@ -25,6 +25,7 @@
class editor_map : public gamemap
{
+public:
editor_map(const config& terrain_cfg, const std::string& data);
static editor_map new_map(const config& terrain_cfg, size_t width,
size_t height, t_translation::t_terrain filler);
};
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits