and makes the pallette 3-wide in stead of 2-wide (see also patch #4144)
This commit is contained in:
Bram Ridder 2005-07-05 10:14:50 +00:00
parent 56a5f38f89
commit 8726ea7e61
5 changed files with 39 additions and 40 deletions

View file

@ -240,36 +240,36 @@ height=600
# The toolbar.
[menu]
title=_"Draw"
image=lite_small
image=button
items=editdraw
rect=900,250,955,271
rect=900,230,1007,253
xanchor=right
yanchor=fixed
[/menu]
[menu]
title=_"Flood"
image=lite_small
image=button
items=editfloodfill
rect=960,250,1015,271
rect=900,255,1007,278
xanchor=right
yanchor=fixed
[/menu]
[menu]
title=_"Start P"
image=lite_small
image=button
items=editsetstartpos
rect=900,275,955,296
rect=900,280,1007,303
xanchor=right
yanchor=fixed
[/menu]
[menu]
title=_"Paste"
image=lite_small
image=button
items=editpaste
rect=960,275,1015,296
rect=900,305,1007,328
xanchor=right
yanchor=fixed
[/menu]
@ -326,14 +326,15 @@ height=600
[edit_left_button_function]
font_size=12
rect=900,300,1024,320
rect=900,330,1024,345
xanchor=right
yanchor=fixed
[/edit_left_button_function]
[selected_terrain]
font_size=12
rect=900,730,1024,20
#rect=900,730,1024,20
rect=880,730,1024,40
xanchor=right
yanchor=bottom
[/selected_terrain]

View file

@ -29,7 +29,7 @@ msgstr "Flood"
#: data/themes/editor.cfg:260
msgid "Start P"
msgstr "Start P"
msgstr "Start Position"
#: data/themes/editor.cfg:269
msgid "Paste"

View file

@ -17,6 +17,7 @@
namespace {
const size_t default_terrain_size = 35;
const size_t default_palette_width = 3;
}
namespace map_editor {
@ -24,6 +25,7 @@ size_specs::size_specs() {
terrain_size = default_terrain_size;
terrain_padding = 2;
terrain_space = terrain_size + terrain_padding;
terrain_width = default_palette_width;
brush_x = 0;
brush_y = 0;
palette_x = 0;
@ -35,9 +37,9 @@ size_specs::size_specs() {
void adjust_sizes(const display &disp, size_specs &sizes) {
sizes.brush_x = disp.mapx() + 33;
sizes.brush_y = 190;
sizes.palette_x = disp.mapx() + 40;
sizes.palette_x = disp.mapx() + 15;
sizes.palette_y = sizes.brush_y + 160 + 10;
sizes.palette_w = sizes.terrain_space * 2;
sizes.palette_w = sizes.terrain_space * default_palette_width;
sizes.palette_h = disp.y() - sizes.palette_y - 60;
}

View file

@ -26,6 +26,7 @@ struct size_specs {
size_t terrain_size;
size_t terrain_padding;
size_t terrain_space;
size_t terrain_width;
size_t palette_x;
size_t palette_y;
size_t palette_h;

View file

@ -23,8 +23,6 @@
#include "../video.hpp"
#include "../wassert.hpp"
namespace map_editor {
bool is_invalid_terrain(char c) {
@ -51,25 +49,25 @@ terrain_palette::terrain_palette(display &gui, const size_specs &sizes,
}
void terrain_palette::adjust_size() {
scroll_top();
const size_t button_height = 24;
const size_t button_palette_padding = 8;
SDL_Rect rect = { size_specs_.palette_x, size_specs_.palette_y, size_specs_.palette_w, size_specs_.palette_h };
set_location(rect);
top_button_y_ = size_specs_.palette_y;
button_x_ = size_specs_.palette_x + size_specs_.palette_w/2 - button_height/2;
terrain_start_ = top_button_y_ + button_height + button_palette_padding;
const size_t space_for_terrains = size_specs_.palette_h -
(button_height + button_palette_padding) * 2;
const size_t space_for_terrains = size_specs_.palette_h - (button_height + button_palette_padding) * 2;
rect.y = terrain_start_;
rect.h = space_for_terrains;
bg_register(rect);
const unsigned terrains_fitting =
(unsigned)(space_for_terrains / size_specs_.terrain_space) * 2;
const unsigned terrains_fitting = (unsigned)(space_for_terrains / size_specs_.terrain_space) * size_specs_.terrain_width;
const unsigned total_terrains = num_terrains();
nterrains_ = minimum<int>(terrains_fitting, total_terrains);
bot_button_y_ = size_specs_.palette_y + (nterrains_ / 2) * size_specs_.terrain_space +
button_palette_padding * 2 + button_height;
bot_button_y_ = size_specs_.palette_y + (nterrains_ / size_specs_.terrain_width) * size_specs_.terrain_space + \
button_palette_padding * size_specs_.terrain_width + button_height;
top_button_.set_location(button_x_, top_button_y_);
bot_button_.set_location(button_x_, bot_button_y_);
top_button_.set_dirty();
@ -86,23 +84,22 @@ void terrain_palette::set_dirty(bool dirty) {
}
void terrain_palette::scroll_down() {
if(tstart_ + nterrains_ + 2 <= num_terrains()) {
tstart_ += 2;
if(tstart_ + nterrains_ + size_specs_.terrain_width <= num_terrains()) {
tstart_ += size_specs_.terrain_width;
bg_restore();
set_dirty();
}
else if (tstart_ + nterrains_ + 1 <= num_terrains()) {
tstart_ += 1;
else if (tstart_ + nterrains_ + (num_terrains() % size_specs_.terrain_width) <= num_terrains()) {
tstart_ += num_terrains() % size_specs_.terrain_width;
bg_restore();
set_dirty();
}
}
void terrain_palette::scroll_up() {
unsigned int decrement = 2;
if (tstart_ + nterrains_ == num_terrains()
&& num_terrains() % 2 != 0) {
decrement = 1;
unsigned int decrement = size_specs_.terrain_width;
if (tstart_ + nterrains_ == num_terrains() && num_terrains() % size_specs_.terrain_width != 0) {
decrement = num_terrains() % size_specs_.terrain_width;
}
if(tstart_ >= decrement) {
bg_restore();
@ -235,6 +232,7 @@ void terrain_palette::handle_event(const SDL_Event& event) {
}
void terrain_palette::draw(bool force) {
if (top_button_.pressed()) {
scroll_up();
}
@ -254,22 +252,20 @@ void terrain_palette::draw(bool force) {
int y = terrain_start_;
for(unsigned int counter = starting; counter < ending; counter++){
const gamemap::TERRAIN terrain = terrains_[counter];
const std::string filename = "terrain/" +
map_.get_terrain_info(terrain).symbol_image() + ".png";
const std::string filename = "terrain/" + map_.get_terrain_info(terrain).symbol_image() + ".png";
surface image(image::get_image(filename, image::UNSCALED));
if(image == NULL) {
std::cerr << "image for terrain " << counter << ": '" << filename << "' not found\n";
return;
}
if((unsigned)image->w != size_specs_.terrain_size
|| (unsigned)image->h != size_specs_.terrain_size) {
image.assign(scale_surface(image, size_specs_.terrain_size,
size_specs_.terrain_size));
if((unsigned)image->w != size_specs_.terrain_size || (unsigned)image->h != size_specs_.terrain_size) {
image.assign(scale_surface(image, size_specs_.terrain_size, size_specs_.terrain_size));
}
const int counter_from_zero = counter - starting;
SDL_Rect dstrect;
dstrect.x = loc.x + (counter_from_zero % 2 != 0 ? size_specs_.terrain_space : 0);
dstrect.x = loc.x + (counter_from_zero % size_specs_.terrain_width) * size_specs_.terrain_space;
dstrect.y = y;
dstrect.w = image->w;
dstrect.h = image->h;
@ -290,7 +286,7 @@ void terrain_palette::draw(bool force) {
color = SDL_MapRGB(screen->format,0x00,0x00,0x00);
}
draw_rectangle(dstrect.x, dstrect.y, image->w, image->h, color, screen);
if (counter_from_zero % 2 != 0)
if (counter_from_zero % size_specs_.terrain_width == size_specs_.terrain_width - 1)
y += size_specs_.terrain_space;
}
update_rect(loc);
@ -299,9 +295,8 @@ void terrain_palette::draw(bool force) {
int terrain_palette::tile_selected(const int x, const int y) const {
for(unsigned int i = 0; i != nterrains_; i++) {
const int px = size_specs_.palette_x +
(i % 2 != 0 ? size_specs_.terrain_space : 0);
const int py = terrain_start_ + (i / 2) * size_specs_.terrain_space;
const int px = size_specs_.palette_x + (i % size_specs_.terrain_width) * size_specs_.terrain_space;
const int py = terrain_start_ + (i / size_specs_.terrain_width) * size_specs_.terrain_space;
const int pw = size_specs_.terrain_space;
const int ph = size_specs_.terrain_space;