Skip to content

Commit

Permalink
SetupErrorScreen()
Browse files Browse the repository at this point in the history
  • Loading branch information
kphoenix137 committed Sep 20, 2024
1 parent 4f8819a commit a326a2f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 28 deletions.
51 changes: 26 additions & 25 deletions Source/stores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,29 +316,32 @@ bool StoreSession::GiveItemToPlayer(Item &item, bool persistItem)
return AutoPlaceItemInInventory(*MyPlayer, item, persistItem, true);
}

void StoreSession::SetupCannotAffordScreen()
void StoreSession::SetupErrorScreen(TalkID talkId)
{
StartStore(oldActiveStore);
hasScrollbar = false;
isTextFullSize = true;
renderGold = true;
ClearSText(5, 23);
SetLineText(0, 14, _("You do not have enough gold"), UiFlags::ColorWhite | UiFlags::AlignCenter, true);
}
std::string_view text;

void StoreSession::SetupNoRoomScreen()
{
StartStore(oldActiveStore);
hasScrollbar = false;
ClearSText(5, 23);
SetLineText(0, 14, _("You do not have enough room in inventory"), UiFlags::ColorWhite | UiFlags::AlignCenter, true);
switch (talkId) {
case TalkID::NoMoney:
isTextFullSize = true;
renderGold = true;
text = _("You do not have enough gold");
break;
case TalkID::NoRoom:
text = _("You do not have enough room in inventory");
break;
}

ClearTextLines(5, 23);
SetLineText(0, 14, text, UiFlags::ColorWhite | UiFlags::AlignCenter, true);
}

void StoreSession::SetupConfirmScreen(Item &item)
{
StartStore(oldActiveStore);
hasScrollbar = false;
ClearSText(5, 23);
ClearTextLines(5, 23);

UiFlags itemColor = item.getTextColorWithStatCheck();
SetLineText(20, 8, item.getName(), itemColor, false);
Expand Down Expand Up @@ -510,7 +513,7 @@ void StoreSession::SetupTownerMenuScreen()

void StoreSession::SetupItemList(TalkID talkId, Item *itemData, int storeLimit, int idx, bool selling /*= true*/)
{
ClearSText(5, 21);
ClearTextLines(5, 21);
previousScrollPos = 5;

if (talkId == TalkID::BoyBuy) {
Expand Down Expand Up @@ -1101,7 +1104,7 @@ void StoreSession::SetupTownerIdentifyResultScreen(Item &item)
{
StartStore(oldActiveStore);
hasScrollbar = false;
ClearSText(5, 23);
ClearTextLines(5, 23);

UiFlags itemColor = item.getTextColorWithStatCheck();

Expand Down Expand Up @@ -1900,7 +1903,7 @@ void StoreSession::DrawSelector(const Surface &out, const Rectangle &rect, std::

void StoreSession::InitStores()
{
ClearSText(0, NumStoreLines);
ClearTextLines(0, NumStoreLines);
activeStore = TalkID::None;
isTextFullSize = false;
hasScrollbar = false;
Expand Down Expand Up @@ -2024,9 +2027,9 @@ void StoreSession::DrawSTextHelp()
isTextFullSize = true;
}

void StoreSession::ClearSText(int s, int e)
void StoreSession::ClearTextLines(int start, int end)
{
for (int i = s; i < e; i++) {
for (int i = start; i < end; i++) {
textLine[i]._sx = 0;
textLine[i]._syoff = 0;
textLine[i].text.clear();
Expand All @@ -2050,7 +2053,7 @@ void StoreSession::StartStore(TalkID s)
renderGold = false;
QuestLogIsOpen = false;
CloseGoldDrop();
ClearSText(0, NumStoreLines);
ClearTextLines(0, NumStoreLines);
ReleaseStoreButton();
switch (s) {
case TalkID::Smith:
Expand Down Expand Up @@ -2084,8 +2087,7 @@ void StoreSession::StartStore(TalkID s)
SetupTownerMenuScreen();
break;
case TalkID::WitchBuy:
if (currentItemIndex > 0)
SetupTownerBuyScreen(s);
SetupTownerBuyScreen(s);
break;
case TalkID::WitchSell:
SetupTownerSellScreen(s);
Expand All @@ -2094,10 +2096,10 @@ void StoreSession::StartStore(TalkID s)
SetupTownerRechargeScreen();
break;
case TalkID::NoMoney:
SetupCannotAffordScreen();
SetupErrorScreen(s);
break;
case TalkID::NoRoom:
SetupNoRoomScreen();
SetupErrorScreen(s);
break;
case TalkID::Confirm:
SetupConfirmScreen(tempItem);
Expand All @@ -2118,8 +2120,7 @@ void StoreSession::StartStore(TalkID s)
SetupTownerMenuScreen();
break;
case TalkID::HealerBuy:
if (currentItemIndex > 0)
SetupTownerBuyScreen(s);
SetupTownerBuyScreen(s);
break;
case TalkID::StorytellerIdentify:
SetupTownerIdentifyScreen();
Expand Down
5 changes: 2 additions & 3 deletions Source/stores.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ class StoreSession {

/* General */

void SetupCannotAffordScreen();
void SetupNoRoomScreen();
void SetupErrorScreen(TalkID talkId);
void SetupConfirmScreen(Item &item);
void SetupItemList(TalkID talkId, Item *itemData, int storeLimit, int idx, bool selling = true);
void SetupTownerItemList(TalkID talkId, int idx, bool selling = true);
Expand Down Expand Up @@ -272,7 +271,7 @@ class StoreSession {
void PrintSString(const Surface &out, int margin, int line, std::string_view text, UiFlags flags, int price = 0, int cursId = -1, bool cursIndent = false);
void DrawSLine(const Surface &out, int sy);
void DrawSTextHelp();
void ClearSText(int s, int e);
void ClearTextLines(int start, int end);
void StartStore(TalkID s);
void DrawSText(const Surface &out);
void StoreESC();
Expand Down

0 comments on commit a326a2f

Please sign in to comment.