mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
Merge pull request #2829 from Laserlicht/level_up_easy
This commit is contained in:
commit
1f3f3ed603
@ -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);
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,7 @@ CSelWindow::CSelWindow(const std::string &Text, PlayerColor player, int charperl
|
||||
addChild(comps[i].get());
|
||||
components.push_back(comps[i]);
|
||||
comps[i]->onSelect = std::bind(&CSelWindow::selectionChange,this,i);
|
||||
comps[i]->onChoose = std::bind(&CSelWindow::madeChoiceAndClose,this);
|
||||
if(i<8)
|
||||
comps[i]->assignedKey = vstd::next(EShortcut::SELECT_INDEX_1,i);
|
||||
}
|
||||
@ -127,6 +128,12 @@ void CSelWindow::madeChoice()
|
||||
LOCPLINT->cb->selectionMade(ret+1,ID);
|
||||
}
|
||||
|
||||
void CSelWindow::madeChoiceAndClose()
|
||||
{
|
||||
madeChoice();
|
||||
close();
|
||||
}
|
||||
|
||||
CInfoWindow::CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo & comps, const TButtonsInfo & Buttons)
|
||||
{
|
||||
OBJECT_CONSTRUCTION_CAPTURING(255-DISPOSE);
|
||||
|
@ -130,6 +130,7 @@ class CSelWindow : public CInfoWindow
|
||||
public:
|
||||
void selectionChange(unsigned to);
|
||||
void madeChoice(); //looks for selected component and calls callback
|
||||
void madeChoiceAndClose();
|
||||
CSelWindow(const std::string & text, PlayerColor player, int charperline, const std::vector<std::shared_ptr<CSelectableComponent>> & comps, const std::vector<std::pair<AnimationPath,CFunctionList<void()> > > &Buttons, QueryID askID);
|
||||
|
||||
//notification - this class inherits important destructor from CInfoWindow
|
||||
|
Loading…
Reference in New Issue
Block a user