Load portraits by PortraitId first, Appearance_Type second

This commit is contained in:
Vsevolod Kremianskii 2021-04-07 11:51:44 +07:00
parent 1c91fc707f
commit 1aa8e1f50d
4 changed files with 15 additions and 12 deletions

View file

@ -101,9 +101,16 @@ void PartySelection::prepare(const Context &ctx) {
if (party.isMemberAvailable(i)) {
string blueprintResRef(party.getAvailableMember(i));
shared_ptr<GffStruct> utc(Resources::instance().getGFF(blueprintResRef, ResourceType::Utc));
int appearance = utc->getInt("Appearance_Type");
shared_ptr<Texture> portrait;
int portraitId = utc->getInt("PortraitId", 0);
if (portraitId > 0) {
portrait = Portraits::instance().getTextureByIndex(portraitId);
} else {
int appearance = utc->getInt("Appearance_Type");
portrait = Portraits::instance().getTextureByAppearance(appearance);
}
btnNpc.setDisabled(false);
lblChar.setBorderFill(Portraits::instance().getTextureByAppearance(appearance));
lblChar.setBorderFill(move(portrait));
lblNa.setVisible(false);
} else {
btnNpc.setDisabled(true);

View file

@ -85,7 +85,11 @@ void Creature::loadAppearance() {
_walkSpeed = appearances->getFloat(_appearance, "walkdist", 0.0f);
_runSpeed = appearances->getFloat(_appearance, "rundist", 0.0f);
_portrait = Portraits::instance().getTextureByAppearance(_appearance);
if (_portraitId > 0) {
_portrait = Portraits::instance().getTextureByIndex(_portraitId);
} else {
_portrait = Portraits::instance().getTextureByAppearance(_appearance);
}
updateModel();
}

View file

@ -302,7 +302,6 @@ private:
void loadNameFromUTC(const resource::GffStruct &utc);
void loadAttributesFromUTC(const resource::GffStruct &utc);
void loadPortraitFromUTC(const resource::GffStruct &utc);
void loadPerceptionRangeFromUTC(const resource::GffStruct &utc);
void loadSoundSetFromUTC(const resource::GffStruct &utc);
void loadScriptsFromUTC(const resource::GffStruct &utc);

View file

@ -48,13 +48,13 @@ void Creature::loadUTC(const GffStruct &utc) {
_hitPoints = utc.getInt("HitPoints");
_maxHitPoints = utc.getInt("MaxHitPoints");
_minOneHP = utc.getBool("Min1HP");
_portraitId = utc.getInt("PortraitId");
_racialType = static_cast<RacialType>(utc.getInt("Race"));
_subrace = static_cast<Subrace>(utc.getInt("SubraceIndex"));
_tag = boost::to_lower_copy(utc.getString("Tag"));
loadNameFromUTC(utc);
loadAttributesFromUTC(utc);
loadPortraitFromUTC(utc);
loadPerceptionRangeFromUTC(utc);
loadSoundSetFromUTC(utc);
loadScriptsFromUTC(utc);
@ -109,13 +109,6 @@ void Creature::loadAttributesFromUTC(const GffStruct &utc) {
}
}
void Creature::loadPortraitFromUTC(const GffStruct &utc) {
int portraitId = utc.getInt("PortraitId", -1);
if (portraitId != -1) {
_portrait = Portraits::instance().getTextureByIndex(portraitId);
}
}
void Creature::loadPerceptionRangeFromUTC(const GffStruct &utc) {
int rangeIdx = utc.getInt("PerceptionRange");
shared_ptr<TwoDA> ranges(Resources::instance().get2DA("ranges"));