Working on assets
This commit is contained in:
62
src/dawnpokergame/ui/PokerPlayerDisplay.cpp
Normal file
62
src/dawnpokergame/ui/PokerPlayerDisplay.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2022 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "PokerPlayerDisplay.hpp"
|
||||
#include "game/DawnGame.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
void PokerPlayerDisplay::updatePositions() {
|
||||
UIEmpty::updatePositions();
|
||||
|
||||
this->labelChips.setTransform(
|
||||
UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START,
|
||||
glm::vec4(0, this->labelName.getHeight(), 0, 0),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
PokerPlayerDisplay::PokerPlayerDisplay(UICanvas *canvas) :
|
||||
UIEmpty(canvas),
|
||||
labelName(canvas),
|
||||
labelChips(canvas)
|
||||
{
|
||||
this->font = canvas->getGame()->assetManager.get<TrueTypeAsset>("truetype_ark");
|
||||
|
||||
this->addChild(&this->labelName);
|
||||
this->labelName.setFont(&this->font->font);
|
||||
this->labelName.setFontSize(40);
|
||||
this->labelName.setTransform(
|
||||
UI_COMPONENT_ALIGN_START, UI_COMPONENT_ALIGN_START,
|
||||
glm::vec4(0, 0, 0, 0),
|
||||
0.0f
|
||||
);
|
||||
|
||||
this->addChild(&this->labelChips);
|
||||
this->labelChips.setFont(&this->font->font);
|
||||
this->labelChips.setFontSize(40);
|
||||
|
||||
this->font->eventLoaded.addListener(this, &PokerPlayerDisplay::onFontLoaded);
|
||||
}
|
||||
|
||||
void PokerPlayerDisplay::setPlayer(PokerPlayer *player) {
|
||||
assertNull(this->player);
|
||||
this->player = player;
|
||||
|
||||
this->labelName.setText("Player");
|
||||
this->labelChips.setText("Chips");
|
||||
this->updatePositions();
|
||||
}
|
||||
|
||||
void PokerPlayerDisplay::onFontLoaded() {
|
||||
this->labelName.setFont(&this->font->font);
|
||||
this->labelChips.setFont(&this->font->font);
|
||||
|
||||
this->updatePositions();
|
||||
}
|
||||
|
||||
PokerPlayerDisplay::~PokerPlayerDisplay() {
|
||||
this->font->eventLoaded.removeListener(this, &PokerPlayerDisplay::onFontLoaded);
|
||||
}
|
Reference in New Issue
Block a user