Skip to content

Commit

Permalink
Update stores.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Sep 21, 2024
1 parent e0e0f5e commit e62ad8a
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,6 @@ void StoreSession::SetupItemList(TalkID talkId, Item *itemData, int storeLimit,
ClearTextLines(5, 21);
previousScrollPos = 5;

// Handle special case for BoyBuy separately
if (talkId == TalkID::BoyBuy) {
const Item &item = itemData[idx];
UiFlags itemColor = item.getTextColorWithStatCheck();
Expand All @@ -573,50 +572,50 @@ void StoreSession::SetupItemList(TalkID talkId, Item *itemData, int storeLimit,
else
SetLineValue(10, item._iIvalue + (item._iIvalue / 2));
PrintStoreItem(item, 11, itemColor, true);
return;
}

int l = 5;
for (int i = 0; i < storeLimit && l < 20; ++i) {
const Item &item = itemData[i];
if (!item.isEmpty()) {
UiFlags itemColor = item.getTextColorWithStatCheck();
SetLineText(20, l, item.getName(), itemColor, true, item._iCurs, true);
SetLineValue(l, item._iIdentified ? item._iIvalue : item._ivalue);
PrintStoreItem(item, l + 1, itemColor, true);
nextScrollPos = l;
l += 4; // Move to the next line in the store UI
} else {
for (int l = 5; l < 20 && idx < storeLimit; l += 4) {
const Item &item = itemData[idx];
if (!item.isEmpty()) {
UiFlags itemColor = item.getTextColorWithStatCheck();
SetLineText(20, l, item.getName(), itemColor, true, item._iCurs, true);
SetLineValue(l, item._iIdentified ? item._iIvalue : item._ivalue);
PrintStoreItem(item, l + 1, itemColor, true);
nextScrollPos = l;
} else {
l -= 4;
}
idx++;
}
}

if (selling) {
if (currentTextLine != -1 && !textLine[currentTextLine].isSelectable() && currentTextLine != BackButtonLine())
currentTextLine = nextScrollPos;
} else {
numTextLines = std::max(storeLimit - BuyLineSpace, 0);
if (selling) {
if (currentTextLine != -1 && !textLine[currentTextLine].isSelectable() && currentTextLine != BackButtonLine())
currentTextLine = nextScrollPos;
} else {
numTextLines = std::max(storeLimit - BuyLineSpace, 0);
}
}
}

void StoreSession::SetupTownerItemList(TalkID talkId, int idx, bool selling /*= true*/)
{
Item *item = nullptr;
Item *items = nullptr;
size_t storeLimit = 0;

switch (talkId) {
case TalkID::SmithBuy:
item = smithItems.data();
items = smithItems.data();
storeLimit = smithItems.size();
break;
case TalkID::SmithPremiumBuy:
item = premiumItems.data();
items = premiumItems.data();
storeLimit = premiumItems.size();
break;
case TalkID::HealerBuy:
item = healerItems.data();
items = healerItems.data();
storeLimit = healerItems.size();
break;
case TalkID::WitchBuy:
item = witchItems.data();
items = witchItems.data();
storeLimit = witchItems.size();
break;
case TalkID::BoyBuy:
Expand All @@ -628,14 +627,14 @@ void StoreSession::SetupTownerItemList(TalkID talkId, int idx, bool selling /*=
case TalkID::WitchSell:
case TalkID::WitchRecharge:
case TalkID::StorytellerIdentify:
item = playerItems.data()->itemPtr;
storeLimit = playerItems.size();
SetupItemList(talkId, playerItems.data()->itemPtr, playerItems.size(), idx, selling);

Check warning on line 630 in Source/stores.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
return; // Exit early since we handle player items separately
default:
return; // Invalid TalkID, do nothing
}

if (item != nullptr) {
SetupItemList(talkId, item, storeLimit, idx, selling);
if (items != nullptr) {
SetupItemList(talkId, items, storeLimit, idx, selling);

Check warning on line 637 in Source/stores.cpp

View workflow job for this annotation

GitHub Actions / build

'argument': conversion from 'size_t' to 'int', possible loss of data
}
}

Expand Down

0 comments on commit e62ad8a

Please sign in to comment.