15 #define GETTEXT_DOMAIN "wesnoth-editor"
71 if (e.button == SDL_BUTTON_LEFT) {
74 if (e.button == SDL_BUTTON_RIGHT) {
92 case SDL_MOUSEBUTTONUP:
102 if (!(start_state ==
state_))
109 bool is_number = std::find_if(
id.begin(),
id.
end(), [](
char c) {
return !std::isdigit(c); }) ==
id.
end();
140 virtual void mouse_up(
const SDL_MouseButtonEvent&
e)
override
158 , item_space_(20 + 3)
164 , active_mouse_action_(active_mouse_action)
172 for (
int i = 1;
i < 10; ++
i) {
173 items_.push_back(std::to_string(
i));
191 widget::hide(hidden);
226 bool scrolled =
false;
242 const int button_height = 30;
243 int bottom = target.y + target.h;
265 const int space_for_items = bottom - target.y;
266 const int items_fitting = space_for_items /
item_space_;
271 buttons_.resize(items_fitting, &lpi);
306 (*active_mouse_action_)->set_mouse_overlay(
gui_);
313 upscroll_button->enable(starting != 0);
315 if (downscroll_button)
316 downscroll_button->enable(ending !=
num_items());
340 std::stringstream tooltip_text;
364 std::vector<std::string>
res;
366 res.push_back(
"editor-remove-location");
std::shared_ptr< gui::button > find_action_button(const std::string &id)
Retrieves a pointer to a theme UI button.
friend bool operator==(tstate r, tstate l)
std::vector< events::sdl_handler * > sdl_handler_vector
virtual bool scroll_up()
Scroll the editor-palette up one step if possible.
location_palette_item(CVideo &video, editor::location_palette &parent)
boost::ptr_vector< location_palette_item > buttons_
virtual bool is_selected_item(const std::string &id)
GLint GLint GLint GLint GLint GLint y
virtual std::vector< std::string > action_pressed() const override
virtual void draw_contents()
const SDL_Color NORMAL_COLOR
mouse_action ** active_mouse_action_
editor::location_palette & parent_
std::unique_ptr< location_palette_button > button_goto_
GLdouble GLdouble GLdouble b
static UNUSEDNOWARN std::string _(const char *str)
static bool execute(const std::string &title, const std::string &label, std::string &text, CVideo &video)
Executes the dialog.
std::map< std::string, t_string > string_map
location_palette(editor_display &gui, const config &, mouse_action **active_mouse_action)
void draw_solid_tinted_rectangle(int x, int y, int w, int h, int r, int g, int b, double alpha, surface target)
Fills a specified rectangle area of a surface with a given color and opacity.
void adjust_size(const SDL_Rect &target)
Update the size of this widget.
virtual sdl_handler_vector handler_members()
GLubyte GLubyte GLubyte GLubyte w
virtual std::string get_help_string()
Manage the empty-palette in the editor.
int num_visible_items()
Return the maximum number of items shown at the same time.
void set_item_id(const std::string &id)
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
void set_selected(bool selected)
Encapsulates the map of the game.
std::string selected_item_
SDL_Rect draw_text(surface &dst, const SDL_Rect &area, int size, const SDL_Color &color, const std::string &txt, int x, int y, bool use_tooltips, int style)
Function to draw text on a surface.
map_location special_location(const std::string &id) const
std::map< std::string, tfilter >::iterator itor
void add_item(const std::string &id)
void scroll_to_tile(const map_location &loc, SCROLL_TYPE scroll_type=ONSCREEN, bool check_fogged=true, bool force=true)
Scroll such that location loc is on-screen.
virtual bool can_scroll_down()
GLfloat GLfloat GLfloat GLfloat h
GLint GLint GLint GLint GLint x
GLdouble GLdouble GLdouble r
std::unique_ptr< location_palette_button > button_add_
int set_help_string(const std::string &str)
std::unique_ptr< location_palette_button > button_delete_
const gamemap & get_map() const
bool find(E event, F functor)
Tests whether an event handler is available.
CVideo & video()
Gets the underlying screen object.
void draw_contents() override
bool hit(int x, int y) const
virtual bool scroll_down()
Scroll the editor-palette down one step if possible.
virtual void select_item(const std::string &item_id)
A mouse action receives events from the controller, and responds to them by creating an appropriate e...
A config object defines a single node in a WML file, with access to child nodes.
int num_items()
Return the number of items in the palette.
void mouse_up(SDL_MouseButtonEvent const &e)
void update_rect(const SDL_Rect &)
GLsizei const GLcharARB ** string
void hide(bool hidden) override
void draw_rectangle(int x, int y, int w, int h, Uint32 color, surface target)
Draw a colored rectangle on a surface.
void handle_event(const SDL_Event &e) override
virtual bool can_scroll_up()
std::vector< std::string > items_
void clear_help_string(int handle)