Add isKotOR() util method

Signed-off-by: William Brawner <me@wbrawner.com>
This commit is contained in:
William Brawner 2021-06-09 18:30:37 -06:00 committed by seedhartha
parent bd0698eb0d
commit 077b2bba70
4 changed files with 12 additions and 6 deletions

View file

@ -37,6 +37,10 @@ GameID determineGameID(const fs::path &gameDir) {
return GameID::TSL;
}
bool isKotOR(GameID gameId) {
return gameId == GameID::KotOR;
}
bool isTSL(GameID gameId) {
switch (gameId) {
case GameID::TSL:

View file

@ -30,6 +30,8 @@ namespace game {
*/
GameID determineGameID(const boost::filesystem::path &gameDir);
bool isKotOR(GameID gameId);
bool isTSL(GameID gameId);
} // namespace game

View file

@ -52,7 +52,7 @@ void CharacterMenu::load() {
bindControls();
_binding.btnAuto->setDisabled(true);
if (!isTSL(_game->gameId())) {
if (isKotOR(_game->gameId())) {
_binding.btnCharLeft->setVisible(false);
_binding.btnCharRight->setVisible(false);
@ -110,7 +110,7 @@ void CharacterMenu::bindControls() {
_binding.btnExit = getControlPtr<Button>("BTN_EXIT");
_binding.btnAuto = getControlPtr<Button>("BTN_AUTO");
_binding.btnLevelup = getControlPtr<Button>("BTN_LEVELUP");
if (!isTSL(_game->gameId())) {
if (isKotOR(_game->gameId())) {
_binding.lblAdorn = getControlPtr<Label>("LBL_ADORN");
_binding.btnScripts = getControlPtr<Button>("BTN_SCRIPTS");
_binding.lblClass = getControlPtr<Label>("LBL_CLASS");
@ -161,7 +161,7 @@ void CharacterMenu::refreshControls() {
shared_ptr<Creature> partyLeader(_game->services().party().getLeader());
CreatureAttributes &attributes = partyLeader->attributes();
if (!isTSL(_game->gameId())) {
if (isKotOR(_game->gameId())) {
_binding.lblClass1->setTextMessage(describeClass(attributes.getClassByPosition(1)));
_binding.lblClass2->setTextMessage(describeClass(attributes.getClassByPosition(2)));
_binding.lblLevel1->setTextMessage(toStringOrEmptyIfZero(attributes.getLevelByPosition(1)));

View file

@ -82,7 +82,7 @@ Equipment::Equipment(Game *game, InGameMenu &inGameMenu) : GameGUI(game), _inGam
void Equipment::bindControls() {
_binding.lblCantEquip = getControlPtr<Label>("LBL_CANTEQUIP");
if (!isTSL(_game->gameId())) {
if (isKotOR(_game->gameId())) {
_binding.lblAttackInfo = getControlPtr<Label>("LBL_ATTACK_INFO");
_binding.lblPortBord = getControlPtr<Label>("LBL_PORT_BORD");
_binding.lblPortrait = getControlPtr<Label>("LBL_PORTRAIT");
@ -114,7 +114,7 @@ void Equipment::bindControls() {
_binding.lblToHitR = getControlPtr<Label>("LBL_TOHITR");
_binding.lbItems = getControlPtr<ListBox>("LB_ITEMS");
for (auto &slotName : g_slotNames) {
if ((slotName.first == Slot::WeapL2 || slotName.first == Slot::WeapR2) && !isTSL(_game->gameId())) continue;
if ((slotName.first == Slot::WeapL2 || slotName.first == Slot::WeapR2) && isKotOR(_game->gameId())) continue;
_binding.lblInv[slotName.first] = getControlPtr<Label>("LBL_INV_" + slotName.second);
_binding.btnInv[slotName.first] = getControlPtr<Button>("BTN_INV_" + slotName.second);
}
@ -249,7 +249,7 @@ void Equipment::update() {
auto partyLeader(_game->services().party().getLeader());
if (!isTSL(_game->gameId())) {
if (isKotOR(_game->gameId())) {
string vitalityString(str(boost::format("%d/\n%d") % partyLeader->currentHitPoints() % partyLeader->hitPoints()));
_binding.lblVitality->setTextMessage(vitalityString);
}