Added a "Draw Number of Bitmaps" option to the editor
This is similar to "Draw Hex Coordinates" and "Draw Terrain Codes", and displays the number of terrain graphics surfaces draw for each hex. It is useful for spotting mistakes such as overlay images having non-transparent pixels in adjacent hexes where they shouldn't, or for comparing the efficiency of different kinds of terrain graphics rules.
This commit is contained in:
parent
ac1d8c886c
commit
5d347bb61b
16 changed files with 89 additions and 11 deletions
|
@ -53,6 +53,8 @@ Version 1.13.5+dev:
|
|||
* When using the --wconsole option, the game now prints a prompt in the event
|
||||
of a fatal error to avoid closing the console before the error can be seen.
|
||||
* Restored GUI2 textbox selection highlight lost in version 1.13.3.
|
||||
* Added a "Draw Number of Bitmaps" option to the map editor, for terrain
|
||||
graphics diagnostics.
|
||||
* WML Engine:
|
||||
* Added ignore_special_locations=yes|no, default no, to [terrain_mask] to
|
||||
ignore the special locations given in the mask, leaving all those on the
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
id=menu-editor-map
|
||||
title= _ "Map"
|
||||
image=button_menu/menu_button_copper_H20
|
||||
items=editor-map-resize,editor-map-rotate,editor-map-generate, editor-map-apply-mask,editor-map-create-mask-to,menu-editor-transitions,editor-refresh,editor-refresh-image-cache,togglegrid,editor-draw-coordinates,editor-draw-terrain-codes
|
||||
items=editor-map-resize,editor-map-rotate,editor-map-generate, editor-map-apply-mask,editor-map-create-mask-to,menu-editor-transitions,editor-refresh,editor-refresh-image-cache,togglegrid,editor-draw-coordinates,editor-draw-terrain-codes,editor-draw-num-of-bitmaps
|
||||
rect="+0,=,+100,+20"
|
||||
xanchor=fixed
|
||||
yanchor=fixed
|
||||
|
@ -440,6 +440,16 @@
|
|||
xanchor=right
|
||||
yanchor=fixed
|
||||
[/action]
|
||||
[action]
|
||||
id=toggle_num_of_bitmaps_button_editor
|
||||
items=editor-draw-num-of-bitmaps
|
||||
type=checkbox
|
||||
image=button_square/button_square_30
|
||||
tooltip_name_prepend=yes
|
||||
rect="=-31,=,+30,+30"
|
||||
xanchor=right
|
||||
yanchor=fixed
|
||||
[/action]
|
||||
[panel]
|
||||
id=top_separator4
|
||||
rect="=-11,=,+10,+27"
|
||||
|
|
BIN
images/icons/action/editor-draw-num-of-bitmaps_25-active.png
Normal file
BIN
images/icons/action/editor-draw-num-of-bitmaps_25-active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 160 B |
BIN
images/icons/action/editor-draw-num-of-bitmaps_25-pressed.png
Normal file
BIN
images/icons/action/editor-draw-num-of-bitmaps_25-pressed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 161 B |
BIN
images/icons/action/editor-draw-num-of-bitmaps_25.png
Normal file
BIN
images/icons/action/editor-draw-num-of-bitmaps_25.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
BIN
images/icons/action/editor-draw-num-of-bitmaps_30-active.png
Normal file
BIN
images/icons/action/editor-draw-num-of-bitmaps_30-active.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 320 B |
BIN
images/icons/action/editor-draw-num-of-bitmaps_30-pressed.png
Normal file
BIN
images/icons/action/editor-draw-num-of-bitmaps_30-pressed.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 320 B |
BIN
images/icons/action/editor-draw-num-of-bitmaps_30.png
Normal file
BIN
images/icons/action/editor-draw-num-of-bitmaps_30.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 314 B |
|
@ -2554,13 +2554,21 @@ void display::draw_hex(const map_location& loc) {
|
|||
const bool on_map = get_map().on_board(loc);
|
||||
const bool off_map_tile = (get_map().get_terrain(loc) == t_translation::OFF_MAP_USER);
|
||||
const time_of_day& tod = get_time_of_day(loc);
|
||||
if(!shrouded(loc)) {
|
||||
// unshrouded terrain (the normal case)
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos,
|
||||
get_terrain_images(loc,tod.id, image_type, BACKGROUND));
|
||||
|
||||
drawing_buffer_add(LAYER_TERRAIN_FG, loc, xpos, ypos,
|
||||
get_terrain_images(loc,tod.id,image_type, FOREGROUND));
|
||||
int num_images_fg = 0;
|
||||
int num_images_bg = 0;
|
||||
|
||||
if(!shrouded(loc)) {
|
||||
std::vector<surface> images_fg = get_terrain_images(loc,tod.id, image_type, FOREGROUND);
|
||||
std::vector<surface> images_bg = get_terrain_images(loc,tod.id, image_type, BACKGROUND);
|
||||
|
||||
num_images_fg = images_fg.size();
|
||||
num_images_bg = images_bg.size();
|
||||
|
||||
// unshrouded terrain (the normal case)
|
||||
drawing_buffer_add(LAYER_TERRAIN_BG, loc, xpos, ypos, images_bg);
|
||||
|
||||
drawing_buffer_add(LAYER_TERRAIN_FG, loc, xpos, ypos, images_fg);
|
||||
|
||||
// Draw the grid, if that's been enabled
|
||||
if(grid_ && on_map && !off_map_tile) {
|
||||
|
@ -2660,9 +2668,11 @@ void display::draw_hex(const map_location& loc) {
|
|||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
off_y -= text->h / 2;
|
||||
if (draw_terrain_codes_) {
|
||||
off_y -= text->h;
|
||||
} else {
|
||||
off_y -= text->h / 2;
|
||||
}
|
||||
if (draw_num_of_bitmaps_) {
|
||||
off_y -= text->h / 2;
|
||||
}
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, bg);
|
||||
|
@ -2676,12 +2686,33 @@ void display::draw_hex(const map_location& loc) {
|
|||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
if (!draw_coordinates_) {
|
||||
off_y -= text->h / 2;
|
||||
if (draw_coordinates_ && !draw_num_of_bitmaps_) {
|
||||
off_y += text->h / 2;
|
||||
} else if (draw_num_of_bitmaps_ && !draw_coordinates_) {
|
||||
off_y -= text->h / 2;
|
||||
}
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, bg);
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, text);
|
||||
}
|
||||
if (draw_num_of_bitmaps_) {
|
||||
int off_x = xpos + hex_size()/2;
|
||||
int off_y = ypos + hex_size()/2;
|
||||
surface text = font::get_rendered_text(lexical_cast<std::string>(num_images_bg + num_images_fg), font::SIZE_SMALL, font::NORMAL_COLOR);
|
||||
surface bg = create_neutral_surface(text->w, text->h);
|
||||
SDL_Rect bg_rect = sdl::create_rect(0, 0, text->w, text->h);
|
||||
sdl::fill_rect(bg, &bg_rect, 0xaa000000);
|
||||
off_x -= text->w / 2;
|
||||
off_y -= text->h / 2;
|
||||
if (draw_coordinates_) {
|
||||
off_y += text->h / 2;
|
||||
}
|
||||
if (draw_terrain_codes_) {
|
||||
off_y += text->h / 2;
|
||||
}
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, bg);
|
||||
drawing_buffer_add(LAYER_FOG_SHROUD, loc, off_x, off_y, text);
|
||||
}
|
||||
}
|
||||
|
||||
if(debug_foreground) {
|
||||
|
|
|
@ -368,6 +368,11 @@ public:
|
|||
/** Setter for the terrain code debug overlay on tiles */
|
||||
void set_draw_terrain_codes(bool value) { draw_terrain_codes_ = value; }
|
||||
|
||||
/** Getter for the number of bitmaps debug overlay on tiles */
|
||||
bool get_draw_num_of_bitmaps() const { return draw_num_of_bitmaps_; }
|
||||
/** Setter for the terrain code debug overlay on tiles */
|
||||
void set_draw_num_of_bitmaps(bool value) { draw_num_of_bitmaps_ = value; }
|
||||
|
||||
/** Save a (map-)screenshot and return whether the operation succeeded. */
|
||||
bool screenshot(const std::string& filename, bool map_screenshot = false);
|
||||
|
||||
|
@ -1061,6 +1066,8 @@ private:
|
|||
bool draw_coordinates_;
|
||||
/** Debug flag - overlay terrain codes on tiles */
|
||||
bool draw_terrain_codes_;
|
||||
/** Debug flag - overlay number of bitmaps on tiles */
|
||||
bool draw_num_of_bitmaps_;
|
||||
|
||||
typedef std::list<arrow*> arrows_list_t;
|
||||
typedef std::map<map_location, arrows_list_t > arrows_map_t;
|
||||
|
|
|
@ -446,6 +446,7 @@ bool editor_controller::can_execute_command(const hotkey::hotkey_command& cmd, i
|
|||
return false; //not implemented
|
||||
case HOTKEY_EDITOR_DRAW_COORDINATES:
|
||||
case HOTKEY_EDITOR_DRAW_TERRAIN_CODES:
|
||||
case HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -518,6 +519,8 @@ hotkey::ACTION_STATE editor_controller::get_action_state(hotkey::HOTKEY_COMMAND
|
|||
return gui_->get_draw_coordinates() ? ACTION_ON : ACTION_OFF;
|
||||
case HOTKEY_EDITOR_DRAW_TERRAIN_CODES:
|
||||
return gui_->get_draw_terrain_codes() ? ACTION_ON : ACTION_OFF;
|
||||
case HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS:
|
||||
return gui_->get_draw_num_of_bitmaps() ? ACTION_ON : ACTION_OFF;
|
||||
|
||||
case HOTKEY_MINIMAP_DRAW_VILLAGES:
|
||||
return (preferences::minimap_draw_villages()) ? hotkey::ACTION_ON : hotkey::ACTION_OFF;
|
||||
|
@ -981,6 +984,11 @@ bool editor_controller::execute_command(const hotkey::hotkey_command& cmd, int i
|
|||
preferences::editor::set_draw_terrain_codes(gui().get_draw_terrain_codes());
|
||||
gui().invalidate_all();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS:
|
||||
gui().set_draw_num_of_bitmaps(!gui().get_draw_num_of_bitmaps());
|
||||
preferences::editor::set_draw_num_of_bitmaps(gui().get_draw_num_of_bitmaps());
|
||||
gui().invalidate_all();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_REMOVE_LOCATION: {
|
||||
location_palette* lp = dynamic_cast<location_palette*>(&toolkit_->get_palette_manager()->active_palette());
|
||||
if (lp) {
|
||||
|
|
|
@ -50,6 +50,14 @@ namespace editor {
|
|||
preferences::set("editor_draw_hex_coordinates", value);
|
||||
}
|
||||
|
||||
bool draw_num_of_bitmaps() {
|
||||
return preferences::get("editor_draw_num_of_bitmaps", false);
|
||||
}
|
||||
|
||||
void set_draw_num_of_bitmaps(bool value) {
|
||||
preferences::set("editor_draw_num_of_bitmaps", value);
|
||||
}
|
||||
|
||||
namespace {
|
||||
size_t editor_mru_limit()
|
||||
{
|
||||
|
|
|
@ -42,6 +42,9 @@ namespace editor {
|
|||
bool draw_hex_coordinates();
|
||||
void set_draw_hex_coordinates(bool value);
|
||||
|
||||
bool draw_num_of_bitmaps();
|
||||
void set_draw_num_of_bitmaps(bool value);
|
||||
|
||||
/** Retrieves the list of recently opened files. */
|
||||
std::vector<std::string> recent_files();
|
||||
/** Adds an entry to the recent files list. */
|
||||
|
|
|
@ -226,6 +226,7 @@ hotkey_command_temp hotkey_list_[] = {
|
|||
{ HOTKEY_EDITOR_REFRESH_IMAGE_CACHE, "editor-refresh-image-cache", N_("Refresh Image Cache"), false, scope_editor, HKCAT_GENERAL, "" },
|
||||
{ HOTKEY_EDITOR_DRAW_COORDINATES, "editor-draw-coordinates", N_("Draw Hex Coordinates"), false, scope_editor, HKCAT_MAP, "" },
|
||||
{ HOTKEY_EDITOR_DRAW_TERRAIN_CODES, "editor-draw-terrain-codes", N_("Draw Terrain Codes"), false, scope_editor, HKCAT_MAP, "" },
|
||||
{ HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS, "editor-draw-num-of-bitmaps", N_("Draw Number of Bitmaps"), false, scope_editor, HKCAT_MAP, "" },
|
||||
|
||||
{ HOTKEY_EDITOR_AREA_SAVE, "editor-save-area", N_("Save Selection to Area"), false, scope_editor, HKCAT_SCENARIO, "" },
|
||||
{ HOTKEY_EDITOR_AREA_RENAME, "editor-rename-area", N_("Rename Selected Area"), false, scope_editor, HKCAT_SCENARIO, "" },
|
||||
|
|
|
@ -166,7 +166,7 @@ enum HOTKEY_COMMAND {
|
|||
HOTKEY_EDITOR_REFRESH_IMAGE_CACHE,
|
||||
|
||||
// Draw
|
||||
HOTKEY_EDITOR_DRAW_COORDINATES, HOTKEY_EDITOR_DRAW_TERRAIN_CODES,
|
||||
HOTKEY_EDITOR_DRAW_COORDINATES, HOTKEY_EDITOR_DRAW_TERRAIN_CODES, HOTKEY_EDITOR_DRAW_NUM_OF_BITMAPS,
|
||||
|
||||
// Side
|
||||
HOTKEY_EDITOR_SIDE_NEW,
|
||||
|
|
|
@ -1055,6 +1055,7 @@ class console_handler : public map_command_handler<console_handler>, private cha
|
|||
void do_event();
|
||||
void do_toggle_draw_coordinates();
|
||||
void do_toggle_draw_terrain_codes();
|
||||
void do_toggle_draw_num_of_bitmaps();
|
||||
void do_toggle_whiteboard();
|
||||
void do_whiteboard_options();
|
||||
|
||||
|
@ -1185,6 +1186,9 @@ class console_handler : public map_command_handler<console_handler>, private cha
|
|||
register_command("show_terrain_codes", &console_handler::do_toggle_draw_terrain_codes,
|
||||
_("Toggle overlaying of terrain codes on hexes."));
|
||||
register_alias("show_terrain_codes", "tc");
|
||||
register_command("show_num_of_bitmaps", &console_handler::do_toggle_draw_num_of_bitmaps,
|
||||
_("Toggle overlaying of number of bitmaps on hexes."));
|
||||
register_alias("show_num_of_bitmaps", "bn");
|
||||
register_command("whiteboard", &console_handler::do_toggle_whiteboard,
|
||||
_("Toggle planning mode."));
|
||||
register_alias("whiteboard", "wb");
|
||||
|
@ -1870,6 +1874,10 @@ void console_handler::do_toggle_draw_terrain_codes() {
|
|||
menu_handler_.gui_->set_draw_terrain_codes(!menu_handler_.gui_->get_draw_terrain_codes());
|
||||
menu_handler_.gui_->invalidate_all();
|
||||
}
|
||||
void console_handler::do_toggle_draw_num_of_bitmaps() {
|
||||
menu_handler_.gui_->set_draw_num_of_bitmaps(!menu_handler_.gui_->get_draw_num_of_bitmaps());
|
||||
menu_handler_.gui_->invalidate_all();
|
||||
}
|
||||
|
||||
void console_handler::do_toggle_whiteboard() {
|
||||
if (const std::shared_ptr<wb::manager> & whiteb = menu_handler_.pc_.get_whiteboard()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue