fix: Make portraits hilight fill identical to border fill

This commit is contained in:
Vsevolod Kremianskii 2021-01-30 23:29:48 +07:00
parent 53fbfe49fc
commit 2c35ea149f
5 changed files with 29 additions and 0 deletions

View file

@ -126,9 +126,11 @@ void AbilitiesMenu::refreshPortraits() {
Control &btnChange1 = getControl("BTN_CHANGE1");
btnChange1.setBorderFill(partyMember1 ? partyMember1->portrait() : nullptr);
btnChange1.setHilightFill(partyMember1 ? partyMember1->portrait() : nullptr);
Control &btnChange2 = getControl("BTN_CHANGE2");
btnChange2.setBorderFill(partyMember2 ? partyMember2->portrait() : nullptr);
btnChange2.setHilightFill(partyMember2 ? partyMember2->portrait() : nullptr);
}
void AbilitiesMenu::onClick(const string &control) {

View file

@ -131,9 +131,11 @@ void CharacterMenu::refreshPortraits() {
Control &btnChange1 = getControl("BTN_CHANGE1");
btnChange1.setBorderFill(partyMember1 ? partyMember1->portrait() : nullptr);
btnChange1.setHilightFill(partyMember1 ? partyMember1->portrait() : nullptr);
Control &btnChange2 = getControl("BTN_CHANGE2");
btnChange2.setBorderFill(partyMember2 ? partyMember2->portrait() : nullptr);
btnChange2.setHilightFill(partyMember2 ? partyMember2->portrait() : nullptr);
}
void CharacterMenu::onClick(const string &control) {

View file

@ -70,9 +70,11 @@ void InventoryMenu::refreshPortraits() {
Control &btnChange1 = getControl("BTN_CHANGE1");
btnChange1.setBorderFill(partyMember1 ? partyMember1->portrait() : nullptr);
btnChange1.setHilightFill(partyMember1 ? partyMember1->portrait() : nullptr);
Control &btnChange2 = getControl("BTN_CHANGE2");
btnChange2.setBorderFill(partyMember2 ? partyMember2->portrait() : nullptr);
btnChange2.setHilightFill(partyMember2 ? partyMember2->portrait() : nullptr);
}
void InventoryMenu::onClick(const string &control) {

View file

@ -604,6 +604,27 @@ void Control::setHilightColor(const glm::vec3 &color) {
_hilight->color = color;
}
void Control::setHilightFill(const string &resRef) {
shared_ptr<Texture> texture;
if (!resRef.empty()) {
texture = Textures::instance().get(resRef, TextureType::GUI);
}
setHilightFill(texture);
}
void Control::setHilightFill(const shared_ptr<Texture> &texture) {
if (!texture && _hilight) {
_hilight->fill.reset();
return;
}
if (texture) {
if (!_hilight) {
_hilight = make_shared<Border>();
}
_hilight->fill = texture;
}
}
void Control::setText(const Text &text) {
_text = text;
updateTextLines();

View file

@ -137,6 +137,8 @@ public:
void setHeight(int height);
void setHilight(const Border &hilight);
void setHilightColor(const glm::vec3 &color);
void setHilightFill(const std::string &resRef);
void setHilightFill(const std::shared_ptr<render::Texture> &texture);
void setPadding(int padding);
void setScene3D(std::unique_ptr<Scene3D> scene);
void setText(const Text &text);