Author: mog
Date: Sun May 18 12:56:04 2008
New Revision: 26688
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26688&view=rev
Log:
Add "default_base" parameter to [terrain].
The editor will use this do draw a default base for overlay terrains.
Modified:
trunk/changelog
trunk/src/editor/editor.cpp
trunk/src/editor/editor.hpp
trunk/src/terrain.cpp
trunk/src/terrain.hpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=26688&r1=26687&r2=26688&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun May 18 12:56:04 2008
@@ -53,6 +53,8 @@
* fix [teleport] capturing villages with the wrong side (bug #11683)
* SideWML recruit= no longer locks the faction except if explicitely wanted
with the new key faction_from_recruit=yes
+ * add "default_base" parameter to overlay terrains, which specifies the
+ base terrain the editor draws by default.
* wesnothd
* added expiration time to bans
* added restart command to server that does gracefull restart
Modified: trunk/src/editor/editor.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.cpp?rev=26688&r1=26687&r2=26688&view=diff
==============================================================================
--- trunk/src/editor/editor.cpp (original)
+++ trunk/src/editor/editor.cpp Sun May 18 12:56:04 2008
@@ -415,7 +415,7 @@
else if ( (key_[SDLK_RALT] || key_[SDLK_LALT]) && l_button_func_ ==
DRAW) {
reset_mouseover_overlay();
draw_on_mouseover_hexes(palette_.selected_fg_terrain(), true);
- l_button_held_func_ = DRAW_BASE_TERRAIN;
+ l_button_held_func_ = DRAW_TERRAIN_LAYER;
}
else if (selected_hexes_.find(hex_clicked) != selected_hexes_.end()) {
l_button_held_func_ = MOVE_SELECTION;
@@ -1184,7 +1184,7 @@
reset_mouseover_overlay();
draw_on_mouseover_hexes(palette_.selected_fg_terrain());
}
- else if (l_button_held_func_ == DRAW_BASE_TERRAIN && mouse_moved_) {
+ else if (l_button_held_func_ == DRAW_TERRAIN_LAYER && mouse_moved_) {
reset_mouseover_overlay();
draw_on_mouseover_hexes(palette_.selected_fg_terrain(), true);
}
@@ -1203,16 +1203,16 @@
}
}
-void map_editor::draw_on_mouseover_hexes(const t_translation::t_terrain
terrain, const bool base_only) {
+void map_editor::draw_on_mouseover_hexes(const t_translation::t_terrain
terrain, const bool one_layer_only) {
if(map_.on_board(selected_hex_, true)) {
std::vector<gamemap::location> hexes =
get_tiles(map_, selected_hex_,
brush_.selected_brush_size());
- draw_terrain(terrain, hexes, base_only);
+ draw_terrain(terrain, hexes, one_layer_only);
}
}
void map_editor::draw_terrain(const t_translation::t_terrain terrain,
- const std::vector<gamemap::location> &hexes,
const bool base_only)
+ const std::vector<gamemap::location> &hexes,
const bool one_layer_only)
{
map_undo_action undo_action;
@@ -1223,8 +1223,14 @@
undo_action.add_terrain(old_terrain, terrain, *it);
if (terrain.base == t_translation::NO_LAYER) {
map_.set_overlay(*it, terrain);
- }
- else if (base_only) {
+
+ const terrain_type& t_info = map_.get_terrain_info(terrain);
+
+ if (!one_layer_only && t_info.default_base() !=
t_translation::NONE_TERRAIN) {
+ map_.set_base(*it, t_info.default_base());
+ }
+ }
+ else if (one_layer_only) {
map_.set_base(*it, terrain);
}
else {
Modified: trunk/src/editor/editor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.hpp?rev=26688&r1=26687&r2=26688&view=diff
==============================================================================
--- trunk/src/editor/editor.hpp (original)
+++ trunk/src/editor/editor.hpp Sun May 18 12:56:04 2008
@@ -155,7 +155,7 @@
private:
//! What to perform while the left button is held down.
- enum LEFT_BUTTON_HELD_FUNC {DRAW_TERRAIN, DRAW_BASE_TERRAIN,
ADD_SELECTION, REMOVE_SELECTION,
+ enum LEFT_BUTTON_HELD_FUNC {DRAW_TERRAIN, DRAW_TERRAIN_LAYER,
ADD_SELECTION, REMOVE_SELECTION,
MOVE_SELECTION,
NONE};
//! What to perform on a left button click.
@@ -205,7 +205,7 @@
//! Draw terrain at a location. The operation is saved in the undo
//! stack. Update the map to reflect the change.
void draw_terrain(const t_translation::t_terrain terrain,
- const std::vector<gamemap::location>
&hexes, const bool base_only);
+ const std::vector<gamemap::location>
&hexes, const bool one_layer_only);
//! Re-set the labels for the starting positions of the
//! players. Should be called when the terrain has changed, which
@@ -272,7 +272,7 @@
//! Draw the terrain on the hexes the mouse is over, taking account
//! for brush size.
- void draw_on_mouseover_hexes(const t_translation::t_terrain t, const
bool base_only = false);
+ void draw_on_mouseover_hexes(const t_translation::t_terrain t, const
bool one_layer_only = false);
// Load the tooltips for each button
void load_tooltips(void);
Modified: trunk/src/terrain.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/terrain.cpp?rev=26688&r1=26687&r2=26688&view=diff
==============================================================================
--- trunk/src/terrain.cpp (original)
+++ trunk/src/terrain.cpp Sun May 18 12:56:04 2008
@@ -51,7 +51,8 @@
castle_(false),
keep_(false),
overlay_(false),
- combined_(false)
+ combined_(false),
+ editor_default_base_(t_translation::VOID_TERRAIN)
{}
terrain_type::terrain_type(const config& cfg) :
@@ -75,7 +76,8 @@
editor_group_(cfg["editor_group"]),
village_(utils::string_bool(cfg["gives_income"])),
castle_(utils::string_bool(cfg["recruit_onto"])),
- keep_(utils::string_bool(cfg["recruit_from"]))
+ keep_(utils::string_bool(cfg["recruit_from"])),
+
editor_default_base_(t_translation::read_terrain_code(cfg["default_base"]))
{
//! @todo reenable these validations. The problem is that all MP
//! scenarios/campaigns share the same namespace and one rogue scenario
Modified: trunk/src/terrain.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/terrain.hpp?rev=26688&r1=26687&r2=26688&view=diff
==============================================================================
--- trunk/src/terrain.hpp (original)
+++ trunk/src/terrain.hpp Sun May 18 12:56:04 2008
@@ -68,6 +68,8 @@
bool is_overlay() const { return overlay_; }
bool is_combined() const { return combined_; }
+ t_translation::t_terrain default_base() const { return
editor_default_base_; }
+
private:
//! The image used in the minimap
std::string minimap_image_;
@@ -104,6 +106,7 @@
bool village_, castle_, keep_;
bool overlay_, combined_;
+ t_translation::t_terrain editor_default_base_;
};
void create_terrain_maps(const std::vector<config*>& cfgs,
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits