Ignore:
Timestamp:
2010-05-28 07:39:52 (2 years ago)
Author:
kpoole
Message:

Episode 5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Classes/mouse_events.cpp

    r17 r26  
    2929#include "wml_separators.hpp" 
    3030 
     31extern bool gIsDragging; 
     32extern bool gRedraw; 
    3133 
    3234namespace events{ 
     
    336338} 
    337339 
    338 bool mouse_handler::right_click_show_menu(int /*x*/, int /*y*/, const bool browse) 
     340bool mouse_handler::right_click_show_menu(int x, int y, const bool browse) 
    339341{ 
    340342    // The first right-click cancel the selection if any, 
    341343    // the second open the context menu 
    342344    if (selected_hex_.valid() && find_unit(selected_hex_) != units_.end()) { 
    343         select_hex(map_location(), browse); 
     345        //select_hex(map_location(), browse); 
     346         
     347        // KP: if we double tap on the selected unit, then always display the context menu 
     348        map_location new_hex = gui().hex_clicked_on(x,y); 
     349        if (selected_hex_ == new_hex) 
     350        { 
     351            select_hex(map_location(), browse); 
     352            return true; 
     353        } 
     354         
     355        // KP: now, we just send another tap if a unit is already selected, the user probably tapped too fast... 
     356        left_mouse_up(x, y, browse); 
     357        // note: we just need one, because the first one was already sent... 
    344358        return false; 
    345359    } else { 
     360        const SDL_Rect map_area = gui().map_area(); 
     361        if (x > map_area.w || y < map_area.y) 
     362            return false;   // tap on a panel, not the map 
    346363        return true; 
    347364    } 
     
    352369    if (mouse_handler_base::left_click(x, y, browse))  
    353370        return false; 
     371     
     372    // check for a click on the selected unit's description image 
     373    const SDL_Rect uia = gui().unit_image_area(); 
     374    if (x > uia.x && y > uia.y && x < uia.x+uia.w && y < uia.y+uia.h) 
     375    { 
     376        const unit_map::const_iterator i = find_unit(gui().displayedUnitHex_); 
     377        if (i != units_.end()) 
     378            dialogs::show_unit_description(gui(), i->second); 
     379        return true; 
     380    } 
    354381     
    355382    return false; 
     
    516543    { 
    517544        didDrag_ = false; 
     545        gIsDragging = false; 
     546        gRedraw = true; 
    518547        return; 
    519548    } 
     
    814843    gui().draw(true,true); 
    815844 
    816 //  attack_prediction_displayer ap_displayer(gui(), bc_vector, map_, teams_, units_, status_, attacker_loc, defender_loc); 
     845    //attack_prediction_displayer ap_displayer(gui(), bc_vector, map_, teams_, units_, status_, attacker_loc, defender_loc); 
    817846    std::vector<gui::dialog_button_info> buttons; 
    818 //  buttons.push_back(gui::dialog_button_info(&ap_displayer, _("Damage Calculations"))); 
     847    //buttons.push_back(gui::dialog_button_info(&ap_displayer, _("Damage Calculations"))); 
    819848 
    820849    int res = 0; 
Note: See TracChangeset for help on using the changeset viewer.