Skip to content

Commit

Permalink
KOTOR2: Add portrait string creation to chargeninfo class
Browse files Browse the repository at this point in the history
  • Loading branch information
Nostritius committed May 9, 2018
1 parent bb15b5e commit b692cb2
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/engines/kotor2/gui/chargen/charactergeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ CharacterGeneration::CharacterGeneration(Module *module, CharacterGenerationInfo

getLabel("LBL_NAME")->setText("");
getLabel("LBL_LEVEL_VAL")->setText("");

getLabel("PORTRAIT_LBL")->setFill(_chargenInfo->getPortrait());
}

} // End of namespace KotOR2
Expand Down
95 changes: 95 additions & 0 deletions src/engines/kotor2/gui/chargen/chargeninfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,101 @@ Class CharacterGenerationInfo::getClass() const {
return _class;
}

Common::UString CharacterGenerationInfo::getPortrait() const {
Common::UString portrait;
portrait += "po_p";

switch (_gender) {
case kGenderMale:
portrait += "m";
break;
case kGenderFemale:
portrait += "f";
break;
default:
throw Common::Exception("Gender unknown for creating portrait string");
}

portrait += "h";

switch (_skin) {
case kSkinA:
switch (_face) {
case 0:
portrait += "a01";
break;
case 1:
portrait += "a03";
break;
case 2:
if (_gender == kGenderFemale)
portrait += "a04";
else if (_gender == kGenderMale)
portrait += "a05";
break;
case 3:
if (_gender == kGenderFemale)
portrait += "a05";
else if (_gender == kGenderMale)
portrait += "a06";
break;
case 4:
if (_gender == kGenderFemale)
portrait += "a06";
else if (_gender == kGenderMale)
portrait += "a07";
break;
default:
throw Common::Exception("invalid face id");
}
break;
case kSkinB:
portrait += "b";
if (_gender == kGenderFemale)
portrait += ("0" + Common::composeString(_face + 1));
else
if (_face + 6 >= 10)
portrait += Common::composeString(_face + 6);
else
portrait += ("0" + Common::composeString(_face + 6));
break;
case kSkinC:
switch (_face) {
case 0:
portrait += "c01";
break;
case 1:
if (_gender == kGenderFemale)
portrait += "c02";
else if (_gender == kGenderMale)
portrait += "c03";
break;
case 2:
if (_gender == kGenderFemale)
portrait += "c05";
else if (_gender == kGenderMale)
portrait += "c04";
break;
case 3:
portrait += "c06";
break;
case 4:
portrait += "c07";
break;
default:
throw Common::Exception("invalid face id");
}
break;
case kSkinH:
portrait += ("h0" + Common::composeString(_face + 1));
break;
default:
throw Common::Exception("invalid skin id");
}

return portrait;
}

} // End of namespace KotOR2

} // End of namespace Engines
2 changes: 2 additions & 0 deletions src/engines/kotor2/gui/chargen/chargeninfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class CharacterGenerationInfo {

Class getClass() const;

Common::UString getPortrait() const;

private:
Gender _gender;
Class _class;
Expand Down

0 comments on commit b692cb2

Please sign in to comment.