fix: Fix loading party member portraits

This commit is contained in:
Vsevolod Kremianskii 2020-11-06 14:02:17 +07:00
parent f111c9d075
commit f9b285ef2d
7 changed files with 21 additions and 4 deletions

View file

@ -39,6 +39,7 @@ void CreatureBlueprint::load(const GffStruct &utc) {
} }
_appearance = utc.getInt("Appearance_Type"); _appearance = utc.getInt("Appearance_Type");
_portraitId = utc.getInt("PortraitId", -1);
_conversation = utc.getString("Conversation"); _conversation = utc.getString("Conversation");
loadAttributes(utc); loadAttributes(utc);
@ -89,6 +90,10 @@ int CreatureBlueprint::appearance() const {
return _appearance; return _appearance;
} }
int CreatureBlueprint::portraitId() const {
return _portraitId;
}
const string &CreatureBlueprint::conversation() const { const string &CreatureBlueprint::conversation() const {
return _conversation; return _conversation;
} }

View file

@ -38,6 +38,7 @@ public:
const std::string &tag() const; const std::string &tag() const;
const std::vector<std::string> &equipment() const; const std::vector<std::string> &equipment() const;
int appearance() const; int appearance() const;
int portraitId() const;
const std::string &conversation() const; const std::string &conversation() const;
const CreatureAttributes &attributes() const; const CreatureAttributes &attributes() const;
const std::string &onSpawn() const; const std::string &onSpawn() const;
@ -47,6 +48,7 @@ private:
std::string _tag; std::string _tag;
std::vector<std::string> _equipment; std::vector<std::string> _equipment;
int _appearance { 0 }; int _appearance { 0 };
int _portraitId { -1 };
std::string _conversation; std::string _conversation;
CreatureAttributes _attributes; CreatureAttributes _attributes;

View file

@ -208,7 +208,7 @@ void CharacterGeneration::loadCharacterModel() {
lblModel.setScene3D(move(scene)); lblModel.setScene3D(move(scene));
string portrait(findPortrait(_character.appearance)); string portrait(getPortraitByAppearance(_character.appearance));
if (!portrait.empty()) { if (!portrait.empty()) {
Control &lblPortrait = getControl("PORTRAIT_LBL"); Control &lblPortrait = getControl("PORTRAIT_LBL");
lblPortrait.setBorderFill(portrait); lblPortrait.setBorderFill(portrait);

View file

@ -111,7 +111,7 @@ void PartySelection::prepare(const Context &ctx) {
if (maybePortrait != g_portraitByAppearance.end()) { if (maybePortrait != g_portraitByAppearance.end()) {
portrait = maybePortrait->second; portrait = maybePortrait->second;
} else { } else {
portrait = findPortrait(blueprint->appearance()); portrait = getPortraitByAppearance(blueprint->appearance());
} }
btnNpc.setDisabled(false); btnNpc.setDisabled(false);
lblChar.setBorderFill(Textures::instance().get(portrait, TextureType::GUI)); lblChar.setBorderFill(Textures::instance().get(portrait, TextureType::GUI));

View file

@ -30,6 +30,7 @@
#include "../../system/streamutil.h" #include "../../system/streamutil.h"
#include "../blueprint/blueprints.h" #include "../blueprint/blueprints.h"
#include "../portraits.h"
#include "../script/util.h" #include "../script/util.h"
#include "objectfactory.h" #include "objectfactory.h"
@ -94,6 +95,9 @@ void Creature::load(const shared_ptr<CreatureBlueprint> &blueprint) {
shared_ptr<TwoDaTable> appearance(Resources::instance().get2DA("appearance")); shared_ptr<TwoDaTable> appearance(Resources::instance().get2DA("appearance"));
loadAppearance(*appearance, _blueprint->appearance()); loadAppearance(*appearance, _blueprint->appearance());
string portrait(getPortrait(_blueprint->portraitId()));
_portrait = Textures::instance().get(portrait, TextureType::GUI);
_attributes = blueprint->attributes(); _attributes = blueprint->attributes();
_onSpawn = blueprint->onSpawn(); _onSpawn = blueprint->onSpawn();
_onUserDefined = blueprint->onUserDefined(); _onUserDefined = blueprint->onUserDefined();

View file

@ -27,7 +27,12 @@ namespace reone {
namespace game { namespace game {
string findPortrait(int appearance) { string getPortrait(int id) {
shared_ptr<TwoDaTable> table(Resources::instance().get2DA("portraits"));
return table->getString(id, "baseresref");
}
string getPortraitByAppearance(int appearance) {
shared_ptr<TwoDaTable> table(Resources::instance().get2DA("portraits")); shared_ptr<TwoDaTable> table(Resources::instance().get2DA("portraits"));
const TwoDaRow *row = table->findRow([&appearance](const TwoDaRow &row) { const TwoDaRow *row = table->findRow([&appearance](const TwoDaRow &row) {

View file

@ -23,7 +23,8 @@ namespace reone {
namespace game { namespace game {
std::string findPortrait(int appearance); std::string getPortrait(int id);
std::string getPortraitByAppearance(int appearance);
} // namespace game } // namespace game