mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-04 23:17:41 +02:00
Easy choosing for a secondary skill in Level Up Dialog by double clicking it
This commit is contained in:
parent
f8541d0ae4
commit
03316c62bf
@ -269,6 +269,12 @@ void CSelectableComponent::clickPressed(const Point & cursorPosition)
|
||||
onSelect();
|
||||
}
|
||||
|
||||
void CSelectableComponent::clickDouble(const Point & cursorPosition)
|
||||
{
|
||||
if(onChoose)
|
||||
onChoose();
|
||||
}
|
||||
|
||||
void CSelectableComponent::init()
|
||||
{
|
||||
selected = false;
|
||||
@ -278,7 +284,7 @@ CSelectableComponent::CSelectableComponent(const Component &c, std::function<voi
|
||||
CComponent(c),onSelect(OnSelect)
|
||||
{
|
||||
setRedrawParent(true);
|
||||
addUsedEvents(LCLICK | KEYBOARD);
|
||||
addUsedEvents(LCLICK | DOUBLECLICK | KEYBOARD);
|
||||
init();
|
||||
}
|
||||
|
||||
@ -286,7 +292,7 @@ CSelectableComponent::CSelectableComponent(Etype Type, int Sub, int Val, ESize i
|
||||
CComponent(Type,Sub,Val, imageSize),onSelect(OnSelect)
|
||||
{
|
||||
setRedrawParent(true);
|
||||
addUsedEvents(LCLICK | KEYBOARD);
|
||||
addUsedEvents(LCLICK | DOUBLECLICK | KEYBOARD);
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -77,11 +77,13 @@ class CSelectableComponent : public CComponent, public CKeyShortcut
|
||||
public:
|
||||
bool selected; //if true, this component is selected
|
||||
std::function<void()> onSelect; //function called on selection change
|
||||
std::function<void()> onChoose; //function called on doubleclick
|
||||
|
||||
void showAll(Canvas & to) override;
|
||||
void select(bool on);
|
||||
|
||||
void clickPressed(const Point & cursorPosition) override; //call-in
|
||||
void clickDouble(const Point & cursorPosition) override; //call-in
|
||||
CSelectableComponent(Etype Type, int Sub, int Val, ESize imageSize=large, std::function<void()> OnSelect = nullptr);
|
||||
CSelectableComponent(const Component & c, std::function<void()> OnSelect = nullptr);
|
||||
};
|
||||
|
@ -415,6 +415,7 @@ CLevelWindow::CLevelWindow(const CGHeroInstance * hero, PrimarySkill pskill, std
|
||||
for(auto & skill : skills)
|
||||
{
|
||||
auto comp = std::make_shared<CSelectableComponent>(CComponent::secskill, skill, hero->getSecSkillLevel(SecondarySkill(skill))+1, CComponent::medium);
|
||||
comp->onChoose = std::bind(&CLevelWindow::close, this);
|
||||
comps.push_back(comp);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user