Various small code cleanups.

Player changelog cleanup.

The resize option can now also use the surrounding tiles to expand the
map in a smart way, this is the default.

The map editor can now also shift the origin of the map when resizing.
This commit is contained in:
Mark de Wever 2007-08-15 09:50:45 +00:00
parent 543e372ce7
commit d4b651b4aa
8 changed files with 438 additions and 91 deletions

View file

@ -54,6 +54,9 @@ Version 1.3.6+svn:
* new or improved sounds: bat hit
* map editor:
* the grid is scaled properly again and no longer shown in the offmap area
* the resize option can now also use the surrounding tiles to expand the
map in a smart way, this is the default.
* the map editor can now also shift the origin of the map when resizing.
* user interface:
* Enable "Save Game" and "View Chat Log" menu entries in replay mode.
* Add an additional line below the minimap in the "Multiplayer->Create game"

View file

@ -5,13 +5,19 @@ changelog: http://svn.gna.org/viewcvs/*checkout*/wesnoth/trunk/changelog
Version 1.3.6+svn:
* Campaigns
* Son of the Black Eye
*Fixed bug in 'Saving Inarix' where no user_description is generated for Inarix
* Fixed bug in 'Saving Inarix' where no user_description is generated
for Inarix
* Northern Rebirth
* Colored portraits for Sister Theta and Ro'Arthian
* Fixed bug in Anita's death event where Tallin speaks instead of her.
* Fixed bug in 'Old Friend' where Rakshas' portrait doesn't appear.
* Balancing and text changes in 'Old Friend'
* Editor
* The resize option can now use the current tiles to expand the map
instead of the background tile.
* When resizing the map, the origin can also be modified.
* Sounds and music
* New or improved sounds: bat hit.
@ -138,9 +144,9 @@ Version 1.3.4:
dialog in the same scenario have all been fixed.
* Graphics
* Changed how the edges of the map are drawn, making small maps display
better on large resolutions. Not fully completed so it doesn't look
perfect yet.
* Changed how the edges of the map are drawn, making small maps display
better on large resolutions. Not fully completed so it doesn't look
perfect yet.
* Added a blur effect to most ingame dialogs.
* New animations: troll whelp idle, young ogre idle, elvish fighter idle,
skeleton idle, general idle, master at armscrossbow & defend, pikeman
@ -246,7 +252,7 @@ Version 1.3.3:
loaded.
* Fixed a crash when an invalid scenario was loaded (bug #9049).
* Fixed a bug which allowed undo after a recruit of a traitless unit
revealed fogged or shrouded map areas.
revealed fogged or shrouded map areas.
Version 1.3.2:
* Campaigns

View file

@ -701,16 +701,26 @@ void map_editor::edit_revert() {
}
void map_editor::edit_resize() {
const std::pair<unsigned, unsigned> new_size =
resize_dialog(gui_, map_.w(), map_.h());
if (new_size.first != 0) {
const std::string resized_map =
resize_map(map_, new_size.first, new_size.second, palette_.selected_bg_terrain());
if (resized_map != "") {
map_undo_action action;
action.set_map_data(map_.write(), resized_map);
save_undo_action(action);
throw new_map_exception(resized_map, filename_, from_scenario_);
unsigned width = map_.w(), height = map_.h();
int x_offset = 0, y_offset = 0;
bool do_expand = true;
if(resize_dialog(gui_, width, height, x_offset, y_offset, do_expand)) {
try {
const std::string resized_map =
resize_map(map_, width, height, x_offset, y_offset,
do_expand, palette_.selected_bg_terrain());
if (resized_map != "") {
map_undo_action action;
action.set_map_data(map_.write(), resized_map);
save_undo_action(action);
throw new_map_exception(resized_map, filename_, from_scenario_);
}
} catch (gamemap::incorrect_format_exception& e) {
std::cerr << "ERROR: " << e.msg_ << '\n';
gui::message_dialog(gui_, "", e.msg_).show();
}
}
}

View file

@ -16,6 +16,7 @@
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "../config.hpp"
#include "../construct_dialog.hpp"
#include "../display.hpp"
#include "../events.hpp"
#include "../filesystem.hpp"
@ -26,7 +27,6 @@
#include "../mapgen.hpp"
#include "../map_create.hpp"
#include "../marked-up_text.hpp"
#include "../construct_dialog.hpp"
#include "../util.hpp"
#include "../preferences_display.hpp"
#include "../video.hpp"
@ -34,7 +34,6 @@
#include "editor_dialogs.hpp"
namespace {
const int map_min_height = 1;
const int map_min_width = 1;
@ -354,126 +353,196 @@ void preferences_dialog(display &disp, config &prefs) {
}
}
std::pair<unsigned, unsigned>
resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h) {
bool resize_dialog(display &disp, unsigned& width, unsigned& height,
int& x_offset, int& y_offset, bool& do_expand)
{
const resize_lock prevent_resizing;
const events::event_context dialog_events_context;
const gui::dialog_manager dialog_mgr;
int map_width(curr_w), map_height(curr_h);
const int width = 600;
const int height = 200;
const int xpos = disp.w()/2 - width/2;
const int ypos = disp.h()/2 - height/2;
const int dlg_width = 600;
const int dlg_height = 350;
const int xpos = disp.w() / 2 - dlg_width / 2;
const int ypos = disp.h() / 2 - dlg_height / 2;
const int horz_margin = 5;
const int vertical_margin = 20;
const int button_padding = 20;
SDL_Rect dialog_rect = {xpos-10,ypos-10,width+20,height+20};
surface_restorer restorer(&disp.video(),dialog_rect);
SDL_Rect dialog_rect = {xpos - 10,
ypos - 10, dlg_width + 20, dlg_height + 20};
surface_restorer restorer(&disp.video(), dialog_rect);
gui::dialog_frame frame(disp.video());
frame.layout(xpos,ypos,width,height);
frame.layout(xpos,ypos,dlg_width, dlg_height);
frame.draw_background();
frame.draw_border();
SDL_Rect title_rect = font::draw_text(NULL,screen_area(),24,font::NORMAL_COLOUR,
_("Resize Map"),0,0);
SDL_Rect title_rect = font::draw_text(NULL, screen_area(), 24,
font::NORMAL_COLOUR, _("Resize Map"), 0, 0);
const std::string& width_label = _("Width:");
const std::string& height_label = _("Height:");
const std::string& x_offset_label = _("X offset:");
const std::string& y_offset_label = _("Y offset:");
SDL_Rect width_rect = font::draw_text(NULL, screen_area(), 14, font::NORMAL_COLOUR,
width_label, 0, 0);
SDL_Rect height_rect = font::draw_text(NULL, screen_area(), 14, font::NORMAL_COLOUR,
height_label, 0, 0);
SDL_Rect width_rect = font::draw_text(NULL, screen_area(), 14,
font::NORMAL_COLOUR, width_label, 0, 0);
SDL_Rect height_rect = font::draw_text(NULL, screen_area(), 14,
font::NORMAL_COLOUR, height_label, 0, 0);
SDL_Rect x_offset_rect = font::draw_text(NULL, screen_area(), 14,
font::NORMAL_COLOUR, x_offset_label, 0, 0);
SDL_Rect y_offset_rect = font::draw_text(NULL, screen_area(), 14,
font::NORMAL_COLOUR, y_offset_label, 0, 0);
// store the width of all labels in an array to determine the maximum
const int label_arr_size = 4;
int label_arr[label_arr_size] =
{ width_rect.w, height_rect.w, x_offset_rect.w, y_offset_rect.w };
// use the biggest label to deterimine the right side for the labels
const int text_right = xpos + horz_margin +
maximum<int>(width_rect.w,height_rect.w);
*std::max_element(label_arr, label_arr + label_arr_size);
width_rect.x = text_right - width_rect.w;
height_rect.x = text_right - height_rect.w;
x_offset_rect.x = text_right - x_offset_rect.w;
y_offset_rect.x = text_right - y_offset_rect.w;
width_rect.y = ypos + title_rect.h + vertical_margin*2;
width_rect.y = ypos + title_rect.h + vertical_margin * 2;
height_rect.y = width_rect.y + width_rect.h + vertical_margin;
x_offset_rect.y = height_rect.y + height_rect.h + vertical_margin * 2;
y_offset_rect.y = x_offset_rect.y + x_offset_rect.h + vertical_margin;
gui::button cancel_button(disp.video(), _("Cancel"));
gui::button ok_button(disp.video(), _("OK"));
cancel_button.set_location(xpos + width - cancel_button.width() - horz_margin,
ypos + height - cancel_button.height()-14);
cancel_button.set_location(
xpos + dlg_width - cancel_button.width() - horz_margin,
ypos + dlg_height - cancel_button.height() - 14);
ok_button.set_location(xpos + width - cancel_button.width() - horz_margin
- ok_button.width() - button_padding,
ypos + height - ok_button.height()-14);
ok_button.set_location(
xpos + dlg_width - cancel_button.width() - horz_margin - ok_button.width() - button_padding,
ypos + dlg_height - ok_button.height()-14);
const int right_space = 100;
const int slider_left = text_right + 10;
const int slider_right = xpos + width - horz_margin - right_space;
SDL_Rect slider_rect = { slider_left,width_rect.y,slider_right-slider_left,width_rect.h};
const int slider_right = xpos + dlg_width - horz_margin - right_space;
SDL_Rect slider_rect =
{ slider_left, width_rect.y, slider_right-slider_left, width_rect.h};
slider_rect.y = width_rect.y;
gui::slider width_slider(disp.video());
width_slider.set_location(slider_rect);
width_slider.set_min(map_min_width);
width_slider.set_max(map_max_width);
width_slider.set_value(map_width);
width_slider.set_value(width);
slider_rect.y = height_rect.y;
gui::slider height_slider(disp.video());
height_slider.set_location(slider_rect);
height_slider.set_min(map_min_height);
height_slider.set_max(map_max_height);
height_slider.set_value(map_height);
height_slider.set_value(height);
slider_rect.y = x_offset_rect.y;
gui::slider x_offset_slider(disp.video());
x_offset_slider.set_location(slider_rect);
x_offset_slider.set_min(-map_max_height);
x_offset_slider.set_max(map_max_height);
x_offset_slider.set_value(x_offset);
slider_rect.y = y_offset_rect.y;
gui::slider y_offset_slider(disp.video());
y_offset_slider.set_location(slider_rect);
y_offset_slider.set_min(-map_max_height);
y_offset_slider.set_max(map_max_height);
y_offset_slider.set_value(y_offset);
slider_rect.y += y_offset_rect.h + vertical_margin * 2;
gui::button do_expand_button(disp.video(), _("Smart expand"), gui::button::TYPE_CHECK);
// assume the width will be correct for this widget
do_expand_button.set_location(slider_rect);
do_expand_button.set_check(do_expand);
for(bool draw = true;; draw = false) {
if(cancel_button.pressed()) {
return std::make_pair((unsigned)0, (unsigned)0);
return false;
}
if (width_slider.value() != map_width
|| height_slider.value() != map_height) {
if (static_cast<unsigned>(width_slider.value()) != width
|| static_cast<unsigned>(height_slider.value()) != height
|| x_offset_slider.value() != x_offset
|| y_offset_slider.value() != y_offset
|| do_expand_button.checked() != do_expand) {
draw = true;
}
if (draw) {
map_width = width_slider.value();
map_height = height_slider.value();
width = width_slider.value();
height = height_slider.value();
x_offset = x_offset_slider.value();
y_offset = y_offset_slider.value();
do_expand = do_expand_button.checked();
frame.draw_background();
frame.draw_border();
title_rect = font::draw_text(&disp.video(),screen_area(),24,font::NORMAL_COLOUR,
_("Resize Map"),
xpos+(width-title_rect.w)/2,ypos+10);
title_rect = font::draw_text(&disp.video(), screen_area(), 24,
font::NORMAL_COLOUR, _("Resize Map"),
xpos + (dlg_width - title_rect.w) / 2, ypos + 10);
font::draw_text(&disp.video(), screen_area(), 14, font::NORMAL_COLOUR,
width_label, width_rect.x, width_rect.y);
font::draw_text(&disp.video(), screen_area(), 14, font::NORMAL_COLOUR,
height_label, height_rect.x, height_rect.y);
font::draw_text(&disp.video(), screen_area(), 14, font::NORMAL_COLOUR,
x_offset_label, x_offset_rect.x, x_offset_rect.y);
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,
width_label,width_rect.x,width_rect.y);
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,
height_label,height_rect.x,height_rect.y);
y_offset_label, y_offset_rect.x, y_offset_rect.y);
std::stringstream width_str;
width_str << map_width;
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,width_str.str(),
slider_right+horz_margin,width_rect.y);
font::draw_text(&disp.video(), screen_area(), 14,
font::NORMAL_COLOUR, lexical_cast<std::string>(width),
slider_right + horz_margin, width_rect.y);
std::stringstream height_str;
height_str << map_height;
font::draw_text(&disp.video(),screen_area(),14,font::NORMAL_COLOUR,height_str.str(),
slider_right+horz_margin,height_rect.y);
font::draw_text(&disp.video(), screen_area(), 14,
font::NORMAL_COLOUR, lexical_cast<std::string>(height),
slider_right + horz_margin, height_rect.y);
font::draw_text(&disp.video(), screen_area(), 14,
font::NORMAL_COLOUR, lexical_cast<std::string>(x_offset),
slider_right + horz_margin, x_offset_rect.y);
font::draw_text(&disp.video(), screen_area(), 14,
font::NORMAL_COLOUR, lexical_cast<std::string>(y_offset),
slider_right + horz_margin, y_offset_rect.y);
}
if (ok_button.pressed()) {
return std::make_pair((unsigned)map_width, (unsigned)map_height);
return true;
}
// make sure the all elements are redrawn
cancel_button.set_dirty();
ok_button.set_dirty();
width_slider.set_dirty();
height_slider.set_dirty();
x_offset_slider.set_dirty();
y_offset_slider.set_dirty();
do_expand_button.set_dirty();
events::raise_process_event();
events::raise_draw_event();
if (draw) {
update_rect(xpos,ypos,width,height);
update_rect(xpos, ypos, dlg_width, dlg_height);
}
disp.update_display();
SDL_Delay(20);
events::pump();

View file

@ -44,8 +44,8 @@ void preferences_dialog(display &disp, config &prefs);
/// Show a dialog asking for the new size of the map. Return the chosen
/// width and height. Checks are made to see that the desired values
/// will result in a feasible map.
std::pair<unsigned, unsigned>
resize_dialog(display &disp, const unsigned curr_w, const unsigned curr_h);
bool resize_dialog(display &disp, unsigned& width, unsigned& height,
int& x_offset, int& y_offset, bool& do_expand);
FLIP_AXIS flip_dialog(display &disp);

View file

@ -13,34 +13,68 @@
#include "map_manip.hpp"
#include "../gettext.hpp"
#include "../map.hpp"
#include "../config.hpp"
#include "../construct_dialog.hpp"
#include "../util.hpp"
#include "../wassert.hpp"
#include "serialization/string_utils.hpp"
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
std::string editormap::resize(const size_t width, const size_t height, const t_translation::t_letter filler)
std::string editormap::resize(const size_t width, const size_t height,
const int x_offset, const int y_offset,
const bool do_expand, t_translation::t_letter filler)
{
const unsigned old_w = static_cast<unsigned>(w());
const unsigned old_h = static_cast<unsigned>(h());
if(old_w == width && old_h == height) {
// no changes leave
if(old_w == width && old_h == height && x_offset == 0 && y_offset == 0 ) {
return "";
}
if (old_w != width) {
const t_translation::t_list one_row(old_h, filler);
tiles_.resize(width, one_row);
if(do_expand) {
filler = t_translation::NONE_TERRAIN;
}
if(height != old_h) {
for(size_t i = 0; i < tiles_.size(); ++i) {
tiles_[i].resize(height, filler);
}
// determine the amount of resizing is required
const int left_resize = -x_offset;
const int right_resize = (width - old_w) + x_offset;
const int top_resize = -y_offset;
const int bottom_resize = (height - old_h) + y_offset;
// std::cerr << "resize y " << left_resize << " x " << right_resize
// << " top " << top_resize << " bottom " << bottom_resize << '\n';
if(right_resize > 0) {
add_tiles_right(right_resize, filler);
} else if(right_resize < 0) {
remove_tiles_right(-right_resize);
}
if(bottom_resize > 0) {
add_tiles_bottom(bottom_resize, filler);
} else if(bottom_resize < 0) {
remove_tiles_bottom(-bottom_resize);
}
if(left_resize > 0) {
add_tiles_left(left_resize, filler);
} else if(left_resize < 0) {
remove_tiles_left(-left_resize);
}
if(top_resize > 0) {
add_tiles_top(top_resize, filler);
} else if(top_resize < 0) {
remove_tiles_top(-top_resize);
}
return write();
@ -100,7 +134,7 @@ void editormap::set_starting_position(const int pos, const location loc) {
}
void editormap::swap_starting_position(const size_t x1, const size_t y1,
const size_t x2, const size_t y2)
const size_t x2, const size_t y2)
{
const int pos1 = is_starting_position(location(x1, y1));
const int pos2 = is_starting_position(location(x2, y2));
@ -114,6 +148,151 @@ void editormap::swap_starting_position(const size_t x1, const size_t y1,
}
}
void editormap::add_tiles_right(
const unsigned count, const t_translation::t_letter& filler)
{
// std::cerr << "add right " << count << '\n';
for(size_t x = 1; x <= count; ++x) {
t_translation::t_list one_row(h());
for(size_t y = 0; y < tiles_[1].size(); ++y) {
one_row[y] =
filler != t_translation::NONE_TERRAIN ?
filler :
get_terrain(gamemap::location(x - 1, y));
wassert(one_row[y] != t_translation::NONE_TERRAIN);
}
tiles_.push_back(one_row);
}
}
void editormap::add_tiles_left(
const unsigned count, const t_translation::t_letter& filler)
{
// std::cerr << "add left " << count << '\n';
for(size_t i = 1; i <= count; ++i) {
t_translation::t_list one_row(h());
for(size_t y = 0; y < tiles_[1].size(); ++y) {
one_row[y] =
filler != t_translation::NONE_TERRAIN ?
filler :
get_terrain(gamemap::location(-1, y));
wassert(one_row[y] != t_translation::NONE_TERRAIN);
}
tiles_.insert(tiles_.begin(), 1, one_row);
clear_border_cache();
}
}
void editormap::remove_tiles_right(const unsigned count)
{
// std::cerr << "remove right " << count << '\n';
if(count > tiles_.size()) {
std::stringstream sstr;
sstr << _("Can't resize the map, the requested size is bigger "
"than the maximum, size=") << count << _(" maximum=")
<< tiles_.size();
throw incorrect_format_exception(sstr.str().c_str());
}
tiles_.resize(tiles_.size() - count);
}
void editormap::remove_tiles_left(const unsigned count)
{
// std::cerr << "remove left " << count << '\n';
if(count > tiles_.size()) {
std::stringstream sstr;
sstr << _("Can't resize the map, the requested size is bigger "
"than the maximum, size=") << count << _(" maximum=")
<< tiles_.size();
throw incorrect_format_exception(sstr.str().c_str());
}
tiles_.erase(tiles_.begin(), tiles_.begin() + count);
}
void editormap::add_tiles_top(
const unsigned count, const t_translation::t_letter& filler)
{
// std::cerr << "add top " << count << '\n';
for(size_t i = 1; i <= count; ++i) {
for(size_t y = 0; y < tiles_.size(); ++y) {
t_translation::t_letter terrain =
filler != t_translation::NONE_TERRAIN ?
filler :
get_terrain(gamemap::location(y, -1));
wassert(terrain != t_translation::NONE_TERRAIN);
tiles_[y].insert(tiles_[y].begin(), 1, terrain);
clear_border_cache();
}
}
}
void editormap::add_tiles_bottom(
const unsigned count, const t_translation::t_letter& filler)
{
// std::cerr << "add bottom " << count << '\n';
for(size_t i = 1; i <= count; ++i) {
for(size_t x = 0; x < tiles_.size(); ++x) {
t_translation::t_letter terrain =
filler != t_translation::NONE_TERRAIN ?
filler :
get_terrain(gamemap::location(x, i - 1));
wassert(terrain != t_translation::NONE_TERRAIN);
tiles_[x].push_back(terrain);
}
}
}
void editormap::remove_tiles_top(const unsigned count)
{
// std::cerr << "remove top " << count << '\n';
if(count > tiles_[0].size()) {
std::stringstream sstr;
sstr << _("Can't resize the map, the requested size is bigger "
"than the maximum, size=") << count << _(" maximum=")
<< tiles_[0].size();
throw incorrect_format_exception(sstr.str().c_str());
}
for(size_t x = 0; x < tiles_.size(); ++x) {
tiles_[x].erase(tiles_[x].begin(), tiles_[x].begin() + count);
}
}
void editormap::remove_tiles_bottom(const unsigned count)
{
// std::cerr << "remove bottom " << count << '\n';
if(count > tiles_[0].size()) {
std::stringstream sstr;
sstr << _("Can't resize the map, the requested size is bigger "
"than the maximum, size=") << count << _(" maximum=")
<< tiles_[0].size();
throw incorrect_format_exception(sstr.str().c_str());
}
for(size_t x = 0; x < tiles_.size(); ++x) {
tiles_[x].erase(tiles_[x].end() - count, tiles_[x].end());
}
}
namespace map_editor {
std::vector<gamemap::location> get_tiles(const gamemap &map,
@ -194,9 +373,10 @@ std::set<gamemap::location> get_component(const gamemap &map,
}
std::string resize_map(editormap &map, const unsigned new_w,
const unsigned new_h, const t_translation::t_letter fill_with)
const unsigned new_h, const int off_x, const int off_y,
const bool do_expand, const t_translation::t_letter fill_with)
{
return map.resize(new_w, new_h, fill_with);
return map.resize(new_w, new_h, off_x, off_y, do_expand, fill_with);
}

View file

@ -41,13 +41,19 @@ public:
*
* @param width the new width
* @param height the new height
* @param x_offset the offset in x direction (the x coordinate specified will be the new 0 location)
* @param y_offset the offset in y direction (the y coordinate specified will be the new 0 location)
* @param expand try to expand the map depending on the current tiles
* @param filler if the map is enlarged the new tiles are set to this terrain
* unless expand is set
*
* @return if there's been a modification to the map the new map data as string
* else an empty string
* @return if there's been a modification to the map the new map data as string
* else an empty string
*/
std::string resize(const size_t width, const size_t height, const t_translation::t_letter filler);
std::string resize(const size_t width, const size_t height,
const int x_offset, const int y_offset,
const bool do_expand, t_translation::t_letter filler);
/**
* Flips the map over an axis
*
@ -74,8 +80,77 @@ private:
* is moved to x1, y1. The function also works if both locations contain
* a starting position.
*/
void swap_starting_position(const size_t x1, const size_t y1,
const size_t x2, const size_t y2);
void swap_starting_position(
const size_t x1, const size_t y1,
const size_t x2, const size_t y2);
/**
* Adds column(s) at the right side
*
* @param count the number of columns to add
* @param filler the terrain to draw, if equal to NONE_TERRAIN
* the enigne will determine the terrain by itself
*/
void add_tiles_right(const unsigned count,
const t_translation::t_letter& filler);
/**
* Adds column(s) at the left side
*
* @param count the number of columns to add
* @param filler the terrain to draw, if equal to NONE_TERRAIN
* the enigne will determine the terrain by itself
*/
void add_tiles_left(const unsigned count,
const t_translation::t_letter& filler);
/**
* Removes column(s) at the right side
*
* @param count the number of columns to remove
*/
void remove_tiles_right(const unsigned count);
/**
* Removes column(s) at the left side
*
* @param count the number of columns to remove
*/
void remove_tiles_left(const unsigned count);
/**
* Adds row(s) at the top side
*
* @param count the number of rows to add
* @param filler the terrain to draw, if equal to NONE_TERRAIN
* the enigne will determine the terrain by itself
*/
void add_tiles_top(const unsigned count,
const t_translation::t_letter& filler);
/**
* Adds row(s) at the bottom side
*
* @param count the number of rows to add
* @param filler the terrain to draw, if equal to NONE_TERRAIN
* the enigne will determine the terrain by itself
*/
void add_tiles_bottom(const unsigned count,
const t_translation::t_letter& filler);
/**
* Removes row(s) at the top side
*
* @param count the number of rows to remove
*/
void remove_tiles_top(const unsigned count);
/**
* Removes row(s) at the bottom side
*
* @param count the number of rows to remove
*/
void remove_tiles_bottom(const unsigned count);
};
namespace map_editor {
@ -106,7 +181,8 @@ get_component(const gamemap &map, const gamemap::location &start_loc);
/// new map area appeard at the bottom and/or the right and is filled
/// with the terrain fill_with.
std::string resize_map(editormap &map, const unsigned new_w,
const unsigned new_h, const t_translation::t_letter fill_with);
const unsigned new_h, const int off_x, const int off_y,
const bool do_expand, const t_translation::t_letter fill_with);
/// Return the string representation of the map after it has been
/// flipped around the axis.

View file

@ -206,6 +206,10 @@ protected:
t_translation::t_map tiles_;
location startingPositions_[STARTING_POSITIONS];
/**
* Clears the border cache, needed for the editor
*/
void clear_border_cache() { borderCache_.clear(); }
private:
int num_starting_positions() const
{ return sizeof(startingPositions_)/sizeof(*startingPositions_); }
@ -217,8 +221,8 @@ private:
mutable std::map<location, t_translation::t_letter> borderCache_;
mutable std::map<t_translation::t_letter, size_t> terrainFrequencyCache_;
int w_;
int h_;
int w_;
int h_;
};
class viewpoint
@ -232,8 +236,7 @@ public:
//a utility function which parses ranges of locations
//into a vector of locations
std::vector<gamemap::location> parse_location_range(const std::string& xvals,
const std::string& yvals,
const gamemap *const map=NULL);
const std::string& yvals, const gamemap *const map=NULL);
//dump a position on a stream for debug purposes
std::ostream &operator<<(std::ostream &s, gamemap::location const &l);