mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-08 22:26:51 +02:00
add region blink #3601
This commit is contained in:
@@ -484,7 +484,7 @@ void CBonusSelection::decreaseDifficulty()
|
||||
}
|
||||
|
||||
CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc)
|
||||
: CIntObject(LCLICK | SHOW_POPUP), idOfMapAndRegion(id), accessible(accessible), selectable(selectable), labelOnly(labelOnly)
|
||||
: CIntObject(LCLICK | SHOW_POPUP | TIME), idOfMapAndRegion(id), accessible(accessible), selectable(selectable), labelOnly(labelOnly), blinkAnim({})
|
||||
{
|
||||
OBJECT_CONSTRUCTION;
|
||||
|
||||
@@ -509,12 +509,18 @@ CBonusSelection::CRegion::CRegion(CampaignScenarioID id, bool accessible, bool s
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusSelection::CRegion::updateState()
|
||||
void CBonusSelection::CRegion::updateState(bool disableAll)
|
||||
{
|
||||
if(labelOnly)
|
||||
return;
|
||||
|
||||
if(!accessible)
|
||||
if(disableAll)
|
||||
{
|
||||
graphicsNotSelected->disable();
|
||||
graphicsSelected->disable();
|
||||
graphicsStriped->disable();
|
||||
}
|
||||
else if(!accessible)
|
||||
{
|
||||
graphicsNotSelected->disable();
|
||||
graphicsSelected->disable();
|
||||
@@ -534,6 +540,23 @@ void CBonusSelection::CRegion::updateState()
|
||||
}
|
||||
}
|
||||
|
||||
void CBonusSelection::CRegion::tick(uint32_t msPassed)
|
||||
{
|
||||
blinkAnim.msPassed += msPassed;
|
||||
if(blinkAnim.msPassed >= 150)
|
||||
{
|
||||
blinkAnim.state = !blinkAnim.state;
|
||||
blinkAnim.msPassed -= 150;
|
||||
if(blinkAnim.state)
|
||||
blinkAnim.count++;
|
||||
else if(blinkAnim.count >= 3)
|
||||
removeUsedEvents(TIME);
|
||||
}
|
||||
updateState(blinkAnim.state);
|
||||
setRedrawParent(true);
|
||||
redraw();
|
||||
}
|
||||
|
||||
void CBonusSelection::CRegion::clickReleased(const Point & cursorPosition)
|
||||
{
|
||||
if(!labelOnly && selectable && !graphicsNotSelected->getSurface()->isTransparent(cursorPosition - pos.topLeft()))
|
||||
|
@@ -51,9 +51,16 @@ public:
|
||||
bool selectable; // true if region should be selectable
|
||||
bool labelOnly;
|
||||
std::shared_ptr<CLabel> label;
|
||||
struct BlinkAnim
|
||||
{
|
||||
uint32_t msPassed;
|
||||
uint32_t count;
|
||||
bool state;
|
||||
} blinkAnim;
|
||||
public:
|
||||
CRegion(CampaignScenarioID id, bool accessible, bool selectable, bool labelOnly, const CampaignRegions & campDsc);
|
||||
void updateState();
|
||||
void updateState(bool disableAll = false);
|
||||
void tick(uint32_t msPassed) override;
|
||||
void clickReleased(const Point & cursorPosition) override;
|
||||
void showPopupWindow(const Point & cursorPosition) override;
|
||||
};
|
||||
|
Reference in New Issue
Block a user