Ensure that the map-editor still works
This makes the map-editor aware of the draw-layering. Since it's a subclass of the display-class, but relies on the buttons being re-created in the superclass I've moved that code into the subclass instead. This way there won't be any infinite loops with a full redraw triggering another full redraw. I have also introduced a small workaround in the GUI1 button widget, where it would sometimes add the postfix to overlay image names that already contained the postfix. If the image name ends in the postfix, the postfix is removed from the name before re-added. This ensures that the files are successfully found.
This commit is contained in:
parent
c0f7fb6be2
commit
b576e1ae90
6 changed files with 19 additions and 3 deletions
|
@ -266,7 +266,7 @@
|
|||
id=minimap-button-3
|
||||
items=minimap-draw-units
|
||||
type=checkbox
|
||||
overlay=icons/action/editor-tool-unit
|
||||
overlay=icons/action/editor-tool-unit_25
|
||||
image=button_square/button_square_25
|
||||
auto_tooltip=yes
|
||||
rect="+1,=,+25,+25"
|
||||
|
@ -276,7 +276,7 @@
|
|||
[action]
|
||||
id=minimap-button-4
|
||||
items=minimap-draw-villages
|
||||
overlay=icons/action/editor-tool-village
|
||||
overlay=icons/action/editor-tool-village_25
|
||||
type=checkbox
|
||||
image=button_square/button_square_25
|
||||
tooltip_name_prepend=yes
|
||||
|
|
|
@ -90,6 +90,7 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
|
|||
cursor::set(cursor::NORMAL);
|
||||
image::set_color_adjustment(preferences::editor::tod_r(), preferences::editor::tod_g(), preferences::editor::tod_b());
|
||||
|
||||
gui().create_buttons();
|
||||
gui().redraw_everything();
|
||||
events::raise_draw_event();
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ void context_manager::refresh_all()
|
|||
{
|
||||
gui_.rebuild_all();
|
||||
get_map_context().set_needs_terrain_rebuild(false);
|
||||
gui_.create_buttons();
|
||||
gui_.redraw_everything();
|
||||
get_map_context().clear_changed_locations();
|
||||
gui_.recalculate_minimap();
|
||||
|
|
|
@ -248,7 +248,9 @@ void editor_palette<Item>::adjust_size(const SDL_Rect& target)
|
|||
static_cast<unsigned> (space_for_items / item_space_) *
|
||||
item_width_;
|
||||
nitems_ = std::min<int>(items_fitting, nmax_items_);
|
||||
buttons_.resize(nitems_, gui::tristate_button(gui_.video(), this));
|
||||
if (buttons_.size() != nitems_) {
|
||||
buttons_.resize(nitems_, gui::tristate_button(gui_.video(), this));
|
||||
}
|
||||
set_location(target);
|
||||
set_dirty(true);
|
||||
gui_.video().clear_help_string(help_handle_);
|
||||
|
|
|
@ -2543,6 +2543,9 @@ std::vector<std::string> menu_handler::get_commands_list()
|
|||
|
||||
void console_handler::do_refresh() {
|
||||
image::flush_cache();
|
||||
|
||||
menu_handler_.gui_->create_buttons();
|
||||
|
||||
menu_handler_.gui_->redraw_everything();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#include "text.hpp"
|
||||
#include "wml_separators.hpp"
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
static lg::log_domain log_display("display");
|
||||
#define ERR_DP LOG_STREAM(err, log_display)
|
||||
|
||||
|
@ -104,6 +106,7 @@ void button::load_images() {
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef SDL_GPU
|
||||
sdl::timage button_image(image::get_texture(button_image_name_ + ".png" + button_image_path_suffix_));
|
||||
sdl::timage pressed_image(image::get_texture(button_image_name_ + "-pressed.png"+ button_image_path_suffix_));
|
||||
|
@ -193,6 +196,12 @@ void button::load_images() {
|
|||
surface pressed_disabled_image, pressed_active_image, touched_image;
|
||||
|
||||
if (!button_overlay_image_name_.empty()) {
|
||||
|
||||
if (button_overlay_image_name_.length() > size_postfix.length() &&
|
||||
boost::algorithm::ends_with(button_overlay_image_name_, size_postfix)) {
|
||||
button_overlay_image_name_.resize(button_overlay_image_name_.length() - size_postfix.length());
|
||||
}
|
||||
|
||||
overlayImage_.assign(image::get_image(button_overlay_image_name_ + size_postfix + ".png"+ button_image_path_suffix_));
|
||||
overlayPressedImage_.assign(image::get_image(button_overlay_image_name_ + size_postfix + "-pressed.png"+ button_image_path_suffix_));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue