diff --git a/changelog b/changelog index 7539576593e..ee9a54f0c37 100644 --- a/changelog +++ b/changelog @@ -5,6 +5,8 @@ Version 1.5.4+svn: (hardcoded) list of time_of_days. Can change the settings and see the effects without having to close the settings dialog. The preferences are shared with the old editor. + * Added a feature to draw hex coordinates and/or terrain code on every hex + * Auto update transitions option is stored in the preferences * Graphics: * New or updated unit frames: Walking Corpse swimmer, Soulless swimmer * Language and i18n: diff --git a/data/core/editor2-hotkeys.cfg b/data/core/editor2-hotkeys.cfg index 407de668e9e..1c07fe5b1c7 100644 --- a/data/core/editor2-hotkeys.cfg +++ b/data/core/editor2-hotkeys.cfg @@ -137,4 +137,18 @@ key="t" [/hotkey] +[hotkey] + command="editor-update-transitions" + key="t" +[/hotkey] + +[hotkey] + command="editor-draw-coordinates" + key="o" +[/hotkey] + +[hotkey] + command="editor-draw-terrain-codes" + key="i" +[/hotkey] #undef IF_APPLE_CMD_ELSE_CTRL diff --git a/data/themes/editor2.cfg b/data/themes/editor2.cfg index e7293ca5959..cb8c4e7c5a3 100644 --- a/data/themes/editor2.cfg +++ b/data/themes/editor2.cfg @@ -140,7 +140,7 @@ id=menu-editor-map title= _ "Map" image=lite - items=editor-map-resize,editor-map-rotate,editor-map-flip-x,editor-map-flip-y,editor-map-generate,editor-refresh,editor-update-transitions,editor-auto-update-transitions,editor-refresh-image-cache + items=editor-map-resize,editor-map-rotate,editor-map-flip-x,editor-map-flip-y,editor-map-generate,editor-refresh,editor-update-transitions,editor-auto-update-transitions,editor-refresh-image-cache,editor-draw-coordinates,editor-draw-terrain-codes rect="+2,=,+100,=" xanchor=fixed yanchor=fixed diff --git a/players_changelog b/players_changelog index b32c6de1e10..4b1a88a6e56 100644 --- a/players_changelog +++ b/players_changelog @@ -6,6 +6,7 @@ Version 1.5.4+svn: * Editor2 * Allow changing the display time of day from a preset list or to custom values via sliders, available in the new editor settings dialog. + * Added a feature to draw hex coordinates and/or terrain code on every hex * Language and translations * updated translations: Finnish, German, Lithuanian, Slovak, Valencian. diff --git a/src/editor2/editor_controller.cpp b/src/editor2/editor_controller.cpp index bbec313dbe0..d3a85b3022c 100644 --- a/src/editor2/editor_controller.cpp +++ b/src/editor2/editor_controller.cpp @@ -593,6 +593,9 @@ bool editor_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int return true; case HOTKEY_EDITOR_MAP_ROTATE: return false; //not implemented + case HOTKEY_EDITOR_DRAW_COORDINATES: + case HOTKEY_EDITOR_DRAW_TERRAIN_CODES: + return true; default: return false; } @@ -608,6 +611,10 @@ hotkey::ACTION_STATE editor_controller::get_action_state(hotkey::HOTKEY_COMMAND return is_mouse_action_set(command) ? ACTION_ON : ACTION_OFF; case HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS: return auto_update_transitions_ ? ACTION_ON : ACTION_OFF; + case HOTKEY_EDITOR_DRAW_COORDINATES: + 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; default: return command_executor::get_action_state(command); } @@ -727,6 +734,14 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde case HOTKEY_EDITOR_REFRESH_IMAGE_CACHE: refresh_image_cache(); return true; + case HOTKEY_EDITOR_DRAW_COORDINATES: + gui().set_draw_coordinates(!gui().get_draw_coordinates()); + gui().invalidate_all(); + return true; + case HOTKEY_EDITOR_DRAW_TERRAIN_CODES: + gui().set_draw_terrain_codes(!gui().get_draw_terrain_codes()); + gui().invalidate_all(); + return true; default: return controller_base::execute_command(command, index); } diff --git a/src/editor2/editor_display.cpp b/src/editor2/editor_display.cpp index ee33befc4b0..42c664d5a89 100644 --- a/src/editor2/editor_display.cpp +++ b/src/editor2/editor_display.cpp @@ -26,6 +26,8 @@ editor_display::editor_display(CVideo& video, const editor_map& map, : display(video, map, theme_cfg, cfg, level) , brush_locations_() , toolbar_hint_() + , draw_coordinates_(false) + , draw_terrain_codes_(false) { clear_screen(); } @@ -84,9 +86,43 @@ void editor_display::draw_hex(const gamemap::location& loc) int drawing_order = gamemap::get_drawing_order(loc); tblit blit(xpos, ypos); display::draw_hex(loc); - if (map().on_board_with_border(loc) && map().in_selection(loc)) { - drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(xpos, ypos, - image::get_image("editor/selection-overlay.png", image::SCALED_TO_HEX))); + if (map().on_board_with_border(loc)) { + if (map().in_selection(loc)) { + drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(xpos, ypos, + image::get_image("editor/selection-overlay.png", image::SCALED_TO_HEX))); + } + } + if (map().on_board(loc)) { + if (draw_coordinates_) { + int off_x = xpos + hex_size()/2; + int off_y = ypos + hex_size()/2; + surface text = font::get_rendered_text(lexical_cast(loc), font::SIZE_SMALL, font::NORMAL_COLOUR); + surface bg = create_neutral_surface(text->w, text->h); + SDL_Rect bg_rect = {0, 0, text->w, text->h}; + SDL_FillRect(bg, &bg_rect, 0xff000000); + off_x -= text->w / 2; + if (draw_terrain_codes_) { + off_y -= text->h; + } else { + off_y -= text->h / 2; + } + drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(off_x, off_y, bg)); + drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(off_x, off_y, text)); + } + if (draw_terrain_codes_) { + int off_x = xpos + hex_size()/2; + int off_y = ypos + hex_size()/2; + surface text = font::get_rendered_text(lexical_cast(map().get_terrain(loc)), font::SIZE_SMALL, font::NORMAL_COLOUR); + surface bg = create_neutral_surface(text->w, text->h); + SDL_Rect bg_rect = {0, 0, text->w, text->h}; + SDL_FillRect(bg, &bg_rect, 0xff000000); + off_x -= text->w / 2; + if (!draw_coordinates_) { + off_y -= text->h / 2; + } + drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(off_x, off_y, bg)); + drawing_buffer_add(LAYER_FOG_SHROUD, drawing_order, tblit(off_x, off_y, text)); + } } } diff --git a/src/editor2/editor_display.hpp b/src/editor2/editor_display.hpp index de6a97c4bbc..3a3c8836a6d 100644 --- a/src/editor2/editor_display.hpp +++ b/src/editor2/editor_display.hpp @@ -34,6 +34,10 @@ public: const editor_map& map() const { return static_cast(map_); } void rebuild_terrain(const gamemap::location &loc); void set_toolbar_hint(const std::string value) { toolbar_hint_ = value; } + bool get_draw_coordinates() { return draw_coordinates_; } + void set_draw_coordinates(bool value) { draw_coordinates_ = value; } + bool get_draw_terrain_codes() { return draw_terrain_codes_; } + void set_draw_terrain_codes(bool value) { draw_terrain_codes_ = value; } protected: void pre_draw(); /** @@ -48,6 +52,9 @@ protected: std::set brush_locations_; std::string toolbar_hint_; + + bool draw_coordinates_; + bool draw_terrain_codes_; }; } //end namespace editor2 diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index e42054d78f5..feb5d8d3cce 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -186,11 +186,16 @@ const struct { { hotkey::HOTKEY_EDITOR_REFRESH, "editor-refresh", N_("Refresh Display"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_UPDATE_TRANSITIONS, "editor-update-transitions", - N_("Update Terrain Tranistions"), false, hotkey::SCOPE_EDITOR }, + N_("Update Terrain Transitions"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS, "editor-auto-update-transitions", - N_("Auto-update Terrain Transitions"), false, hotkey::SCOPE_EDITOR }, + N_("Auto-update Terrain Transitions"), false, hotkey::SCOPE_EDITOR }, { hotkey::HOTKEY_EDITOR_REFRESH_IMAGE_CACHE, "editor-refresh-image-cache", - N_("Refresh Image Cache"), false, hotkey::SCOPE_EDITOR }, + N_("Refresh Image Cache"), false, hotkey::SCOPE_EDITOR }, + { hotkey::HOTKEY_EDITOR_DRAW_COORDINATES, "editor-draw-coordinates", + N_("Draw Hex Coordinates"), false, hotkey::SCOPE_EDITOR }, + { hotkey::HOTKEY_EDITOR_DRAW_TERRAIN_CODES, "editor-draw-terrain-codes", + N_("Draw Terrain Codes"), false, hotkey::SCOPE_EDITOR }, + #endif diff --git a/src/hotkeys.hpp b/src/hotkeys.hpp index d72c741f526..d58812dce97 100644 --- a/src/hotkeys.hpp +++ b/src/hotkeys.hpp @@ -93,6 +93,7 @@ enum HOTKEY_COMMAND { HOTKEY_EDITOR_REFRESH, HOTKEY_EDITOR_UPDATE_TRANSITIONS, HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS, HOTKEY_EDITOR_REFRESH_IMAGE_CACHE, + HOTKEY_EDITOR_DRAW_COORDINATES, HOTKEY_EDITOR_DRAW_TERRAIN_CODES, #endif //misc.