30 #define ERR_DP LOG_STREAM(err, log_display)
34 : game_config_(game_config)
40 , scroll_right_(false)
61 if(event.key.keysym.sym == SDLK_ESCAPE) {
77 case SDL_JOYBUTTONDOWN:
81 case SDL_JOYHATMOTION:
88 if(SDL_PeepEvents(&new_event,1,SDL_GETEVENT,
90 while(SDL_PeepEvents(&new_event,1,SDL_GETEVENT,
97 case SDL_MOUSEBUTTONDOWN:
105 case SDL_MOUSEBUTTONUP:
146 scroll_threshold = 0;
157 if (mouse_in_window) {
158 if (mousey < scroll_threshold) {
164 if (mousex < scroll_threshold) {
182 const double speed = 0.04 * sqrt(static_cast<double>(scroll_speed));
183 const double snap_dist = 16;
184 const double x_diff = (mousex - original_loc.
x);
185 const double y_diff = (mousey - original_loc.
y);
187 if (fabs(x_diff) > snap_dist || fabs(y_diff) <= snap_dist) dx += speed * x_diff;
188 if (fabs(y_diff) > snap_dist || fabs(x_diff) <= snap_dist) dy += speed * y_diff;
235 if (!str_vec.empty()) {
243 const double joystickx = values.first;
244 const double joysticky = values.second;
247 Uint8 mouse_flags = SDL_GetMouseState(&mousex, &mousey);
298 std::vector<std::string>
items = items_arg;
300 while(i != items.end()) {
311 cmd_exec->
show_menu(items, xloc, yloc, context_menu, disp);
321 std::vector<std::string>
items;
326 items.push_back(item);
348 ERR_DP <<
"Theme '" << theme_name <<
"' not found. Trying the default theme." << std::endl;
353 ERR_DP <<
"Default theme not found." << std::endl;
static const config & get_theme(const config &game_config, std::string theme_name)
const map_location get_scroll_start()
joystick_manager joystick_manager_
virtual plugins_context * get_plugins_context()
Get (optionally) a plugins context a derived class uses.
virtual bool is_browsing() const
void set_scroll_up(bool on)
void set_scroll_down(bool on)
virtual void show_menu(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &disp)
void set_scroll_start(int x, int y)
Called when the middle click scrolling.
int mouse_scroll_threshold()
Gets the threshold for when to scroll.
static lg::log_domain log_display("display")
virtual void process_focus_keydown_event(const SDL_Event &event)
Process keydown (only when the general map display does not have focus).
const std::vector< std::string > & items() const
bool update_highlighted_hex(map_location &highlighted_hex)
Used for absolute movement of the cursor.
Stores all information related to functions that can be bound to hotkeys.
const std::vector< menu > & menus() const
void play_slice(bool is_delay_enabled=true)
void mbutton_event(const SDL_Event &event, command_executor *executor)
virtual display & get_display()=0
Get a reference to a display member a derived class uses.
const std::vector< std::string > items
virtual void mouse_motion(int x, int y, const bool browse, bool update=false, map_location new_loc=map_location::null_location())=0
Called when a mouse motion event takes place.
virtual void draw()
Draws invalidated items.
void mouse_motion_event(const SDL_MouseMotionEvent &event, const bool browse)
controller_base framework: controller_base is roughly analogous to a "dialog" class in a GUI toolkit ...
virtual void process_keydown_event(const SDL_Event &event)
Process keydown (always).
virtual bool have_keyboard_focus()
Derived classes should override this to return false when arrow keys should not scroll the map...
int round_double(double d)
std::pair< double, double > get_scroll_axis_pair()
SDL_Rect & location(const SDL_Rect &screen) const
virtual bool can_execute_command(const hotkey_command &command, int index=-1) const =0
GLboolean GLenum GLenum GLvoid * values
virtual std::vector< std::string > additional_actions_pressed()
const theme::action * action_pressed()
virtual void mouse_press(const SDL_MouseButtonEvent &event, const bool browse)
virtual soundsource::manager * get_soundsource_man()
Get (optionally) a soundsources manager a derived class uses.
std::string get(const std::string &key)
void execute_command(const hotkey_command &command, command_executor *executor, int index, bool press)
const map_location & mouseover_hex() const
void jbutton_event(const SDL_Event &event, command_executor *executor)
const theme::menu * menu_pressed()
GLboolean GLboolean GLboolean GLboolean a
int w() const
the dimensions of the display.
bool handle_scroll(int mousex, int mousey, int mouse_flags, double joystickx, double joysticky)
Handle scrolling by keyboard, joystick and moving mouse near map edges.
map_display and display: classes which take care of displaying the map and game-data on the screen...
virtual ~controller_base()
void jhat_event(const SDL_Event &event, command_executor *executor)
virtual events::mouse_handler_base & get_mouse_handler_base()=0
Get a reference to a mouse handler member a derived class uses.
bool point_in_rect(int x, int y, const SDL_Rect &rect)
Tests whether a point is inside a rectangle.
virtual void execute_action(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu)
Encapsulates the map of the game.
#define SDL_APPMOUSEFOCUS
The app has mouse coverage.
void raise_process_event()
#define SDL_APPACTIVE
The application is active.
controller_base(const config &game_config, CVideo &video)
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.
Game configuration data as global variables.
bool middle_click_scrolls()
void execute_action(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
void set_scroll_right(bool on)
virtual void mouse_wheel(int xscroll, int yscroll, bool browse)
Called when scrolling with the mouse wheel.
void key_event(const SDL_Event &event, command_executor *executor)
bool on_board(const map_location &loc) const
Tell if a location is on the map.
#define SDL_EVENTMASK(EVENT)
virtual hotkey::command_executor * get_hotkey_command_executor()
Get (optionally) a command executor to handle context menu events.
bool mouse_scroll_enabled()
void set_scroll_left(bool on)
virtual void process_keyup_event(const SDL_Event &event)
Process keyup (always).
const gamemap & get_map() const
const hotkey::HOTKEY_COMMAND id
the names are strange: the "hotkey::HOTKEY_COMMAND" is named id, and the string to identify the objec...
virtual void show_menu(const std::vector< std::string > &items_arg, int xloc, int yloc, bool context_menu, display &gui)
config & find_child(const std::string &key, const std::string &name, const std::string &value)
Returns the first child of tag key with a name attribute containing value.
Standard logging facilities (interface).
const SDL_Rect & map_outside_area() const
Returns the available area for a map, this may differ from the above.
static void delay(unsigned int milliseconds)
void handle_event(const SDL_Event &event)
Process mouse- and keypress-events from SDL.
A config object defines a single node in a WML file, with access to child nodes.
Class that keeps track of all the keys on the keyboard.
const hotkey_command & get_hotkey_command(const std::string &command)
returns the hotkey_command with the given name
void mouse_update(const bool browse, map_location loc)
update the mouse with a fake mouse motion
bool scroll(int xmov, int ymov, bool force=false)
Scrolls the display by xmov,ymov pixels.
GLsizei const GLcharARB ** string
virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const
static const hotkey_command & get_command_by_command(HOTKEY_COMMAND command)
the execute_command argument was changed from HOTKEY_COMMAND to hotkey_command, to be able to call it...