mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-12 02:28:11 +02:00
townselector
This commit is contained in:
parent
78b8c2c71c
commit
7c96ffa8ff
@ -44,6 +44,7 @@
|
|||||||
|
|
||||||
#include "../../lib/CGeneralTextHandler.h"
|
#include "../../lib/CGeneralTextHandler.h"
|
||||||
#include "../../lib/CHeroHandler.h"
|
#include "../../lib/CHeroHandler.h"
|
||||||
|
#include "../../lib/CTownHandler.h"
|
||||||
#include "../../lib/CRandomGenerator.h"
|
#include "../../lib/CRandomGenerator.h"
|
||||||
#include "../../lib/CThreadHelper.h"
|
#include "../../lib/CThreadHelper.h"
|
||||||
#include "../../lib/MetaString.h"
|
#include "../../lib/MetaString.h"
|
||||||
@ -402,21 +403,23 @@ PvPBox::PvPBox(const Rect & rect)
|
|||||||
backgroundTexture->playerColored(PlayerColor(1));
|
backgroundTexture->playerColored(PlayerColor(1));
|
||||||
backgroundBorder = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, rect.w, rect.h), ColorRGBA(0, 0, 0, 64), ColorRGBA(96, 96, 96, 255), 1);
|
backgroundBorder = std::make_shared<TransparentFilledRectangle>(Rect(0, 0, rect.w, rect.h), ColorRGBA(0, 0, 0, 64), ColorRGBA(96, 96, 96, 255), 1);
|
||||||
|
|
||||||
buttonFlipCoin = std::make_shared<CButton>(Point(17, 10), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){
|
factionselector = std::make_shared<FactionSelector>(Point(5, 3));
|
||||||
|
|
||||||
|
buttonFlipCoin = std::make_shared<CButton>(Point(203, 6), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("flip coin"), [](){
|
||||||
LobbyPvPAction lpa;
|
LobbyPvPAction lpa;
|
||||||
lpa.action = LobbyPvPAction::COIN;
|
lpa.action = LobbyPvPAction::COIN;
|
||||||
CSH->sendLobbyPack(lpa);
|
CSH->sendLobbyPack(lpa);
|
||||||
}, EShortcut::NONE);
|
}, EShortcut::NONE);
|
||||||
buttonFlipCoin->setTextOverlay("Flip coin2", EFonts::FONT_SMALL, Colors::WHITE);
|
buttonFlipCoin->setTextOverlay("Flip coin2", EFonts::FONT_SMALL, Colors::WHITE);
|
||||||
|
|
||||||
buttonRandomTown = std::make_shared<CButton>(Point(17, 30), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town"), [](){
|
buttonRandomTown = std::make_shared<CButton>(Point(203, 31), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town"), [](){
|
||||||
LobbyPvPAction lpa;
|
LobbyPvPAction lpa;
|
||||||
lpa.action = LobbyPvPAction::RANDOM_TOWN;
|
lpa.action = LobbyPvPAction::RANDOM_TOWN;
|
||||||
CSH->sendLobbyPack(lpa);
|
CSH->sendLobbyPack(lpa);
|
||||||
}, EShortcut::NONE);
|
}, EShortcut::NONE);
|
||||||
buttonRandomTown->setTextOverlay("random town", EFonts::FONT_SMALL, Colors::WHITE);
|
buttonRandomTown->setTextOverlay("random town", EFonts::FONT_SMALL, Colors::WHITE);
|
||||||
|
|
||||||
buttonRandomTownVs = std::make_shared<CButton>(Point(17, 50), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town vs"), [](){
|
buttonRandomTownVs = std::make_shared<CButton>(Point(203, 56), AnimationPath::builtin("GSPBUT2.DEF"), CButton::tooltip("random town vs"), [](){
|
||||||
LobbyPvPAction lpa;
|
LobbyPvPAction lpa;
|
||||||
lpa.action = LobbyPvPAction::RANDOM_TOWN_VS;
|
lpa.action = LobbyPvPAction::RANDOM_TOWN_VS;
|
||||||
CSH->sendLobbyPack(lpa);
|
CSH->sendLobbyPack(lpa);
|
||||||
@ -424,6 +427,37 @@ PvPBox::PvPBox(const Rect & rect)
|
|||||||
buttonRandomTownVs->setTextOverlay("random town vs", EFonts::FONT_SMALL, Colors::WHITE);
|
buttonRandomTownVs->setTextOverlay("random town vs", EFonts::FONT_SMALL, Colors::WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FactionSelector::FactionSelector(const Point & loc)
|
||||||
|
{
|
||||||
|
OBJ_CONSTRUCTION;
|
||||||
|
pos += loc;
|
||||||
|
setRedrawParent(true);
|
||||||
|
|
||||||
|
int x = 0, y = 0;
|
||||||
|
CGI->factions()->forEach([this, &x, &y](const Faction *entity, bool &stop){
|
||||||
|
if(!entity->hasTown())
|
||||||
|
return;
|
||||||
|
|
||||||
|
FactionID factionID = entity->getFaction();
|
||||||
|
auto getImageIndex = [](FactionID factionID, bool enabled){ return (*CGI->townh)[factionID]->town->clientInfo.icons[true][!enabled] + 2; };
|
||||||
|
towns[factionID] = std::make_shared<CAnimImage>(AnimationPath::builtin("ITPA"), getImageIndex(factionID, true), 0, 48 * x, 32 * y);
|
||||||
|
townsArea[factionID] = std::make_shared<LRClickableArea>(Rect(48 * x, 32 * y, 48, 32), [this, getImageIndex, factionID](){
|
||||||
|
townsEnabled[factionID] = !townsEnabled[factionID];
|
||||||
|
towns[factionID]->setFrame(getImageIndex(factionID, townsEnabled[factionID]));
|
||||||
|
redraw();
|
||||||
|
});
|
||||||
|
townsEnabled[factionID] = true;
|
||||||
|
|
||||||
|
if (x < 2)
|
||||||
|
x++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
CFlagBox::CFlagBox(const Rect & rect)
|
CFlagBox::CFlagBox(const Rect & rect)
|
||||||
: CIntObject(SHOW_POPUP)
|
: CIntObject(SHOW_POPUP)
|
||||||
{
|
{
|
||||||
|
@ -32,11 +32,14 @@ class SelectionTab;
|
|||||||
class InfoCard;
|
class InfoCard;
|
||||||
class CChatBox;
|
class CChatBox;
|
||||||
class PvPBox;
|
class PvPBox;
|
||||||
|
class FactionSelector;
|
||||||
class CLabel;
|
class CLabel;
|
||||||
|
class CSlider;
|
||||||
class CFlagBox;
|
class CFlagBox;
|
||||||
class CLabelGroup;
|
class CLabelGroup;
|
||||||
class TransparentFilledRectangle;
|
class TransparentFilledRectangle;
|
||||||
class FilledTexturePlayerColored;
|
class FilledTexturePlayerColored;
|
||||||
|
class LRClickableArea;
|
||||||
|
|
||||||
class ISelectionScreenInfo
|
class ISelectionScreenInfo
|
||||||
{
|
{
|
||||||
@ -145,6 +148,8 @@ class PvPBox : public CIntObject
|
|||||||
std::shared_ptr<FilledTexturePlayerColored> backgroundTexture;
|
std::shared_ptr<FilledTexturePlayerColored> backgroundTexture;
|
||||||
std::shared_ptr<TransparentFilledRectangle> backgroundBorder;
|
std::shared_ptr<TransparentFilledRectangle> backgroundBorder;
|
||||||
|
|
||||||
|
std::shared_ptr<FactionSelector> factionselector;
|
||||||
|
|
||||||
std::shared_ptr<CButton> buttonFlipCoin;
|
std::shared_ptr<CButton> buttonFlipCoin;
|
||||||
std::shared_ptr<CButton> buttonRandomTown;
|
std::shared_ptr<CButton> buttonRandomTown;
|
||||||
std::shared_ptr<CButton> buttonRandomTownVs;
|
std::shared_ptr<CButton> buttonRandomTownVs;
|
||||||
@ -152,6 +157,17 @@ public:
|
|||||||
PvPBox(const Rect & rect);
|
PvPBox(const Rect & rect);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class FactionSelector : public CIntObject
|
||||||
|
{
|
||||||
|
std::map<FactionID, std::shared_ptr<CAnimImage>> towns;
|
||||||
|
std::map<FactionID, std::shared_ptr<LRClickableArea>> townsArea;
|
||||||
|
std::map<FactionID, bool> townsEnabled;
|
||||||
|
std::shared_ptr<CSlider> slider;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FactionSelector(const Point & loc);
|
||||||
|
};
|
||||||
|
|
||||||
class CFlagBox : public CIntObject
|
class CFlagBox : public CIntObject
|
||||||
{
|
{
|
||||||
std::shared_ptr<CAnimation> iconsTeamFlags;
|
std::shared_ptr<CAnimation> iconsTeamFlags;
|
||||||
|
Loading…
Reference in New Issue
Block a user