mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-16 10:20:30 +00:00
Use custom cursors when dragging.
This commit is contained in:
parent
60b1e51b9f
commit
447af1ce11
@ -85,13 +85,13 @@ SDL_Cursor* create_cursor(surface surf)
|
||||
return SDL_CreateCursor(&data[0],&mask[0],cursor_width,nsurf->h,0,0);
|
||||
}
|
||||
|
||||
SDL_Cursor* cache[cursor::NUM_CURSORS] = { NULL, NULL, NULL, NULL };
|
||||
SDL_Cursor* cache[cursor::NUM_CURSORS] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
//this array must have members corresponding to cursor::CURSOR_TYPE enum members
|
||||
#ifdef __APPLE__
|
||||
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait-alt.png", "move.png", "attack.png", "select.png" };
|
||||
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait-alt.png", "move.png", "attack.png", "select.png", "move_drag.png" , "attack_drag.png" };
|
||||
#else
|
||||
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait.png", "move.png", "attack.png", "select.png" };
|
||||
const std::string images[cursor::NUM_CURSORS] = { "normal.png", "wait.png", "move.png", "attack.png", "select.png", "move_drag.png", "attack_drag.png" };
|
||||
#endif
|
||||
|
||||
cursor::CURSOR_TYPE current_cursor = cursor::NUM_CURSORS;
|
||||
|
@ -26,7 +26,7 @@ struct manager
|
||||
~manager();
|
||||
};
|
||||
|
||||
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, NUM_CURSORS };
|
||||
enum CURSOR_TYPE { NORMAL, WAIT, MOVE, ATTACK, HYPERLINK, MOVE_DRAG, ATTACK_DRAG, NUM_CURSORS };
|
||||
|
||||
void use_colour(bool value);
|
||||
|
||||
|
@ -671,6 +671,7 @@ gui_(gui), teams_(teams), units_(units), map_(map), status_(status), gameinfo_(g
|
||||
undo_stack_(undo_stack), redo_stack_(redo_stack)
|
||||
{
|
||||
minimap_scrolling_ = false;
|
||||
dragging_ = false;
|
||||
last_nearest_ = gamemap::location::NORTH;
|
||||
last_second_nearest_ = gamemap::location::NORTH;
|
||||
enemy_paths_ = false;
|
||||
@ -740,9 +741,9 @@ void mouse_handler::mouse_motion(int x, int y, const bool browse)
|
||||
if(selected_unit != units_.end() && (current_paths_.routes.count(new_hex) ||
|
||||
attack_from.valid())) {
|
||||
if(mouseover_unit == units_.end()) {
|
||||
cursor::set(cursor::MOVE);
|
||||
dragging_ ? cursor::set(cursor::MOVE_DRAG) : cursor::set(cursor::MOVE);
|
||||
} else if(viewing_team().is_enemy(mouseover_unit->second.side()) && !mouseover_unit->second.incapacitated()) {
|
||||
cursor::set(cursor::ATTACK);
|
||||
dragging_ ? cursor::set(cursor::ATTACK_DRAG) : cursor::set(cursor::ATTACK) ;
|
||||
} else {
|
||||
cursor::set(cursor::NORMAL);
|
||||
}
|
||||
@ -908,10 +909,12 @@ void mouse_handler::mouse_press(const SDL_MouseButtonEvent& event, const bool br
|
||||
|
||||
if(is_left_click(event) && event.state == SDL_RELEASED) {
|
||||
minimap_scrolling_ = false;
|
||||
dragging_ = false;
|
||||
left_click(event, browse);
|
||||
} else if(is_middle_click(event) && event.state == SDL_RELEASED) {
|
||||
minimap_scrolling_ = false;
|
||||
} else if(is_left_click(event) && event.state == SDL_PRESSED) {
|
||||
dragging_ = true;
|
||||
left_click(event, browse);
|
||||
} else if(is_right_click(event) && event.state == SDL_PRESSED) {
|
||||
// FIXME: when it's not our turn, movement gets highlighted
|
||||
|
@ -91,6 +91,7 @@ private:
|
||||
undo_list& redo_stack_;
|
||||
|
||||
bool minimap_scrolling_;
|
||||
bool dragging_;
|
||||
gamemap::location last_hex_;
|
||||
gamemap::location selected_hex_;
|
||||
gamemap::location::DIRECTION last_nearest_, last_second_nearest_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user