changed std::cerr to LOG_NG*...

...change new editor dir and namespace to editor2 for consistency

* wire the current editor into the main title screen (this is temporary)

* some work-in-progress in edito2003-09-15T11:52:41Z!davewx7@gmail.com/
This commit is contained in:
Tomasz Śniatowski 2008-05-29 21:59:17 +01:00
parent 65bf4171ef
commit 1ab8dd43c5
6 changed files with 122 additions and 44 deletions

View file

@ -1,6 +1,6 @@
/* $Id$ */
/*
Copyright (C) 2008 by Tomasz Œniatowski <kailoran@gmail.com>
Copyright (C) 2008 by Tomasz Sniatowski <kailoran@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
@ -18,7 +18,7 @@
#include "action.hpp"
#include "../foreach.hpp"
namespace map_editor {
namespace editor2 {
editor_action_whole_map* editor_action_whole_map::perform(editor_map& m) {
editor_action_whole_map* undo = new editor_action_whole_map(m);
@ -122,4 +122,4 @@ void editor_action_plot_route::perform_without_undo(editor_map& map)
throw editor_action_not_implemented();
}
} //namespace map_editor
} //end namespace editor2

View file

@ -1,6 +1,6 @@
/* $Id$ */
/*
Copyright (C) 2008 by Tomasz Œniatowski <kailoran@gmail.com>
Copyright (C) 2008 by Tomasz Sniatowski <kailoran@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
@ -15,13 +15,24 @@
//! @file action.hpp
//! Editor action classes
#ifndef EDITOR2_ACTION_HPP
#define EDITOR2_ACTION_HPP
#include "action_base.hpp"
#include "../map.hpp"
#include "../terrain.hpp"
namespace map_editor {
namespace editor2 {
//Replace contents of the entirem map action
class editor_map : public gamemap
{
};
class brush
{
};
//Replace contents of the entire map action
//useful as a fallback undo method when something else would be impractical
class editor_action_whole_map : public editor_action
{
@ -51,6 +62,35 @@ class editor_action_chain : public editor_action
std::vector<editor_action*> actions_;
};
//class editor_action_chain_whole_map : public editor_action_chain
//{
// public:
// explicit editor_action_chain_whole_map(std::vector<editor_action*> actions)
// : editor_action_chain(actions)
// {
// }
// editor_action_whole_map* perform(editor_map& m)
// {
// editor_action_whole_map* undo = new editor_action_whole_map(m);
// perform_without_undo(m);
// return undo;
// }
//
//};
//class editor_action_undo_wrapper : public editor_action
//{
// public:
// editor_action_undo_wrapper(editor_action* undo, editor_action* redo)
// : undo_(undo)
// , redo_(redo)
// {
// }
// ~editor_action_undo_wrapper();
// protected:
//
//};
//common base classes for actions with common behaviour
//actions which act on a specified location (and possibly on other locations
@ -199,4 +239,6 @@ class editor_action_plot_route : public editor_action_location_terrain
gamemap::location loc2_;
};
} //namespace map_editor
} //end namespace editor2
#endif

View file

@ -1,6 +1,6 @@
/* $Id$ */
/*
Copyright (C) 2008 by Tomasz Œniatowski <kailoran@gmail.com>
Copyright (C) 2008 by Tomasz Sniatowski <kailoran@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
@ -22,9 +22,12 @@
//! Code that only deals with actions polymorphically should only need to
//! include this header file.
#ifndef EDITOR2_ACTION_BASE_HPP_INCLUDED
#define EDITOR2_ACTION_BASE_HPP_INCLUDED
#include "editor_common.hpp"
namespace map_editor {
namespace editor2 {
//base class (interface) for editor actions.
class editor_action
@ -56,4 +59,6 @@ struct editor_action_creation_fail : public editor_action_exception
{
};
} //namespace map_editor
} //end namespace editor2
#endif

View file

@ -0,0 +1,43 @@
/* $Id$ */
/*
Copyright (C) 2008 by Tomasz Sniatowski <kailoran@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
//! @file editor_common.hpp
//! Main (common) editor header
#ifndef EDITOR2_EDITOR_COMMON_HPP_INCLUDED
#define EDITOR2_EDITOR_COMMON_HPP_INCLUDED
#include "../log.hpp"
#define DBG_ED LOG_STREAM_INDENT(debug, editor)
#define LOG_ED LOG_STREAM_INDENT(info, editor)
#define WRN_ED LOG_STREAM_INDENT(warn, editor)
#define ERR_ED LOG_STREAM_INDENT(err, editor)
#define SCOPE_ED log_scope(__FUNCTION__)
namespace editor2 {
struct editor_exception
{
};
// forward declarations
class editor_display;
class editor_map;
class brush;
} //end namespace editor2
#endif

View file

@ -66,6 +66,10 @@
#include "ai_python.hpp"
#endif
#ifdef MAP_EDITOR
#include "editor2/editor_main.hpp"
#endif
#include "wesconfig.h"
#include <clocale>
@ -139,6 +143,9 @@ public:
enum RELOAD_GAME_DATA { RELOAD_DATA, NO_RELOAD_DATA };
void play_game(RELOAD_GAME_DATA reload=RELOAD_DATA);
void play_replay();
#ifdef MAP_EDITOR
editor2::EXIT_STATUS start_editor();
#endif
const config& game_config(){return game_config_;};
private:
@ -2016,6 +2023,11 @@ void game_controller::reset_game_cfg()
defines_map_["NORMAL"] = preproc_define();
defines_map_["MEDIUM"] = preproc_define();
}
#ifdef MAP_EDITOR
defines_map_["EDITOR"] = preproc_define();
defines_map_["NORMAL"] = preproc_define();
defines_map_["MEDIUM"] = preproc_define();
#endif
//refresh_game_cfg();
}
@ -2116,6 +2128,13 @@ void game_controller::play_replay()
}
}
#ifdef MAP_EDITOR
editor2::EXIT_STATUS game_controller::start_editor()
{
editor2::start(game_config_, video_);
}
#endif
game_controller::~game_controller()
{
delete gui::empty_menu;
@ -2527,8 +2546,9 @@ static int play_game(int argc, char** argv)
continue;
#ifdef MAP_EDITOR
} else if(res == gui::START_MAP_EDITOR) {
gui::show_error_message(game.disp(), "The map editor is not available. Yet.");
gui::set_background_dirty()
//@todo editor can ask the game to quit completely
game.start_editor();
gui::set_background_dirty();
continue;
#endif
}

View file

@ -1,32 +0,0 @@
/* $Id$ */
/*
Copyright (C) 2008 by Tomasz Œniatowski <kailoran@gmail.com>
Part of the Battle for Wesnoth Project http://www.wesnoth.org/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2
or at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
*/
//! @file editor_common.hpp
//! Main (common) editor header
namespace map_editor {
struct editor_exception
{
};
class editor_map
{
};
class brush
{
};
} //namespace map_editor