mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Optimize button responsiveness during pregame options
This commit is contained in:
parent
ec536e613c
commit
c428e326b9
@ -173,34 +173,47 @@ InfoCard::InfoCard()
|
|||||||
|
|
||||||
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE);
|
labelGroupPlayersAssigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE);
|
||||||
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE);
|
labelGroupPlayersUnassigned = std::make_shared<CLabelGroup>(FONT_SMALL, TOPLEFT, Colors::WHITE);
|
||||||
|
disableLabelRedraws();
|
||||||
}
|
}
|
||||||
setChat(false);
|
setChat(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InfoCard::disableLabelRedraws()
|
||||||
|
{
|
||||||
|
labelSaveDate->setAutoRedraw(false);
|
||||||
|
mapName->setAutoRedraw(false);
|
||||||
|
mapDescription->label->setAutoRedraw(false);
|
||||||
|
labelVictoryConditionText->setAutoRedraw(false);
|
||||||
|
labelLossConditionText->setAutoRedraw(false);
|
||||||
|
labelDifficulty->setAutoRedraw(false);
|
||||||
|
labelDifficultyPercent->setAutoRedraw(false);
|
||||||
|
}
|
||||||
|
|
||||||
void InfoCard::changeSelection()
|
void InfoCard::changeSelection()
|
||||||
{
|
{
|
||||||
if(!SEL->getMapInfo())
|
auto mapInfo = SEL->getMapInfo();
|
||||||
|
if(!mapInfo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
labelSaveDate->setText(SEL->getMapInfo()->date);
|
labelSaveDate->setText(mapInfo->date);
|
||||||
mapName->setText(SEL->getMapInfo()->getName());
|
mapName->setText(mapInfo->getName());
|
||||||
mapDescription->setText(SEL->getMapInfo()->getDescription());
|
mapDescription->setText(mapInfo->getDescription());
|
||||||
|
|
||||||
mapDescription->label->scrollTextTo(0);
|
mapDescription->label->scrollTextTo(0, false);
|
||||||
if(mapDescription->slider)
|
if(mapDescription->slider)
|
||||||
mapDescription->slider->moveToMin();
|
mapDescription->slider->moveToMin();
|
||||||
|
|
||||||
if(SEL->screenType == ESelectionScreen::campaignList)
|
if(SEL->screenType == ESelectionScreen::campaignList)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
iconsMapSizes->setFrame(SEL->getMapInfo()->getMapSizeIconId());
|
iconsMapSizes->setFrame(mapInfo->getMapSizeIconId());
|
||||||
const CMapHeader * header = SEL->getMapInfo()->mapHeader.get();
|
const CMapHeader * header = mapInfo->mapHeader.get();
|
||||||
iconsVictoryCondition->setFrame(header->victoryIconIndex);
|
iconsVictoryCondition->setFrame(header->victoryIconIndex);
|
||||||
labelVictoryConditionText->setText(header->victoryMessage);
|
labelVictoryConditionText->setText(header->victoryMessage);
|
||||||
iconsLossCondition->setFrame(header->defeatIconIndex);
|
iconsLossCondition->setFrame(header->defeatIconIndex);
|
||||||
labelLossConditionText->setText(header->defeatMessage);
|
labelLossConditionText->setText(header->defeatMessage);
|
||||||
flagbox->recreate();
|
flagbox->recreate();
|
||||||
labelDifficulty->setText(CGI->generaltexth->arraytxt[142 + SEL->getMapInfo()->mapHeader->difficulty]);
|
labelDifficulty->setText(CGI->generaltexth->arraytxt[142 + mapInfo->mapHeader->difficulty]);
|
||||||
iconDifficulty->setSelected(SEL->getCurrentDifficulty());
|
iconDifficulty->setSelected(SEL->getCurrentDifficulty());
|
||||||
const std::array<std::string, 5> difficultyPercent = {"80%", "100%", "130%", "160%", "200%"};
|
const std::array<std::string, 5> difficultyPercent = {"80%", "100%", "130%", "160%", "200%"};
|
||||||
labelDifficultyPercent->setText(difficultyPercent[SEL->getCurrentDifficulty()]);
|
labelDifficultyPercent->setText(difficultyPercent[SEL->getCurrentDifficulty()]);
|
||||||
|
@ -101,6 +101,7 @@ public:
|
|||||||
std::shared_ptr<CToggleGroup> iconDifficulty;
|
std::shared_ptr<CToggleGroup> iconDifficulty;
|
||||||
|
|
||||||
InfoCard();
|
InfoCard();
|
||||||
|
void disableLabelRedraws();
|
||||||
void changeSelection();
|
void changeSelection();
|
||||||
void toggleChat();
|
void toggleChat();
|
||||||
void setChat(bool activateChat);
|
void setChat(bool activateChat);
|
||||||
|
@ -102,13 +102,14 @@ CMultiLineLabel::CMultiLineLabel(Rect position, EFonts Font, EAlignment Align, c
|
|||||||
{
|
{
|
||||||
pos.w = position.w;
|
pos.w = position.w;
|
||||||
pos.h = position.h;
|
pos.h = position.h;
|
||||||
splitText(Text);
|
splitText(Text, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiLineLabel::setVisibleSize(Rect visibleSize)
|
void CMultiLineLabel::setVisibleSize(Rect visibleSize, bool redrawElement)
|
||||||
{
|
{
|
||||||
this->visibleSize = visibleSize;
|
this->visibleSize = visibleSize;
|
||||||
redraw();
|
if(redrawElement)
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiLineLabel::scrollTextBy(int distance)
|
void CMultiLineLabel::scrollTextBy(int distance)
|
||||||
@ -116,16 +117,16 @@ void CMultiLineLabel::scrollTextBy(int distance)
|
|||||||
scrollTextTo(visibleSize.y + distance);
|
scrollTextTo(visibleSize.y + distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiLineLabel::scrollTextTo(int distance)
|
void CMultiLineLabel::scrollTextTo(int distance, bool redrawAfterScroll)
|
||||||
{
|
{
|
||||||
Rect size = visibleSize;
|
Rect size = visibleSize;
|
||||||
size.y = distance;
|
size.y = distance;
|
||||||
setVisibleSize(size);
|
setVisibleSize(size, redrawAfterScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiLineLabel::setText(const std::string &Txt)
|
void CMultiLineLabel::setText(const std::string &Txt)
|
||||||
{
|
{
|
||||||
splitText(Txt);
|
splitText(Txt, false); //setText used below can handle redraw
|
||||||
CLabel::setText(Txt);
|
CLabel::setText(Txt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +222,7 @@ void CMultiLineLabel::showAll(SDL_Surface * to)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMultiLineLabel::splitText(const std::string &Txt)
|
void CMultiLineLabel::splitText(const std::string &Txt, bool redrawAfter)
|
||||||
{
|
{
|
||||||
lines.clear();
|
lines.clear();
|
||||||
|
|
||||||
@ -234,7 +235,8 @@ void CMultiLineLabel::splitText(const std::string &Txt)
|
|||||||
textSize.x = 0;
|
textSize.x = 0;
|
||||||
for(const std::string &line : lines)
|
for(const std::string &line : lines)
|
||||||
vstd::amax( textSize.x, f->getStringWidth(line.c_str()));
|
vstd::amax( textSize.x, f->getStringWidth(line.c_str()));
|
||||||
redraw();
|
if(redrawAfter)
|
||||||
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect CMultiLineLabel::getTextLocation()
|
Rect CMultiLineLabel::getTextLocation()
|
||||||
|
@ -80,7 +80,7 @@ class CMultiLineLabel : public CLabel
|
|||||||
// area of text that actually will be printed, default is widget size
|
// area of text that actually will be printed, default is widget size
|
||||||
Rect visibleSize;
|
Rect visibleSize;
|
||||||
|
|
||||||
void splitText(const std::string &Txt);
|
void splitText(const std::string &Txt, bool redrawAfter);
|
||||||
Rect getTextLocation();
|
Rect getTextLocation();
|
||||||
public:
|
public:
|
||||||
// total size of text, x = longest line of text, y = total height of lines
|
// total size of text, x = longest line of text, y = total height of lines
|
||||||
@ -91,9 +91,9 @@ public:
|
|||||||
void setText(const std::string &Txt) override;
|
void setText(const std::string &Txt) override;
|
||||||
void showAll(SDL_Surface * to) override;
|
void showAll(SDL_Surface * to) override;
|
||||||
|
|
||||||
void setVisibleSize(Rect visibleSize);
|
void setVisibleSize(Rect visibleSize, bool redrawElement = true);
|
||||||
// scrolls text visible in widget. Positive value will move text up
|
// scrolls text visible in widget. Positive value will move text up
|
||||||
void scrollTextTo(int distance);
|
void scrollTextTo(int distance, bool redrawAfterScroll = true);
|
||||||
void scrollTextBy(int distance);
|
void scrollTextBy(int distance);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user