Browse Source

Refactor enums

pull/5761/head
KPhoenix 3 years ago committed by Anders Jenbo
parent
commit
8955700e67
  1. 88
      Source/stores.cpp
  2. 10
      Source/stores.h
  3. 2
      Source/towners.cpp

88
Source/stores.cpp

@ -468,7 +468,7 @@ bool StartSmithPremiumBuy()
storenumh++; storenumh++;
} }
if (storenumh == 0) { if (storenumh == 0) {
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 14; stextsel = 14;
return false; return false;
} }
@ -987,11 +987,11 @@ void StoreConfirm(Item &item)
if (stextshold == TalkID::StorytellerIdentify) if (stextshold == TalkID::StorytellerIdentify)
idprint = false; idprint = false;
if (item._iMagical != ITEM_QUALITY_NORMAL && !item._iIdentified) { if (item._iMagical != ITEM_QUALITY_NORMAL && !item._iIdentified) {
if (stextshold == TalkID::BlacksmithSell) if (stextshold == TalkID::SmithSell)
idprint = false; idprint = false;
if (stextshold == TalkID::WitchSell) if (stextshold == TalkID::WitchSell)
idprint = false; idprint = false;
if (stextshold == TalkID::BlacksmithRepair) if (stextshold == TalkID::SmithRepair)
idprint = false; idprint = false;
if (stextshold == TalkID::WitchRecharge) if (stextshold == TalkID::WitchRecharge)
idprint = false; idprint = false;
@ -1016,17 +1016,17 @@ void StoreConfirm(Item &item)
case TalkID::HealerBuy: case TalkID::HealerBuy:
case TalkID::SmithPremiumBuy: case TalkID::SmithPremiumBuy:
case TalkID::WitchBuy: case TalkID::WitchBuy:
case TalkID::BlacksmithBuy: case TalkID::SmithBuy:
prompt = _("Are you sure you want to buy this item?"); prompt = _("Are you sure you want to buy this item?");
break; break;
case TalkID::WitchRecharge: case TalkID::WitchRecharge:
prompt = _("Are you sure you want to recharge this item?"); prompt = _("Are you sure you want to recharge this item?");
break; break;
case TalkID::BlacksmithSell: case TalkID::SmithSell:
case TalkID::WitchSell: case TalkID::WitchSell:
prompt = _("Are you sure you want to sell this item?"); prompt = _("Are you sure you want to sell this item?");
break; break;
case TalkID::BlacksmithRepair: case TalkID::SmithRepair:
prompt = _("Are you sure you want to repair this item?"); prompt = _("Are you sure you want to repair this item?");
break; break;
default: default:
@ -1380,22 +1380,22 @@ void SmithEnter()
case 10: case 10:
talker = TOWN_SMITH; talker = TOWN_SMITH;
stextlhold = 10; stextlhold = 10;
stextshold = TalkID::Blacksmith; stextshold = TalkID::Smith;
gossipstart = TEXT_GRISWOLD2; gossipstart = TEXT_GRISWOLD2;
gossipend = TEXT_GRISWOLD13; gossipend = TEXT_GRISWOLD13;
StartStore(TalkID::Gossip); StartStore(TalkID::Gossip);
break; break;
case 12: case 12:
StartStore(TalkID::BlacksmithBuy); StartStore(TalkID::SmithBuy);
break; break;
case 14: case 14:
StartStore(TalkID::SmithPremiumBuy); StartStore(TalkID::SmithPremiumBuy);
break; break;
case 16: case 16:
StartStore(TalkID::BlacksmithSell); StartStore(TalkID::SmithSell);
break; break;
case 18: case 18:
StartStore(TalkID::BlacksmithRepair); StartStore(TalkID::SmithRepair);
break; break;
case 20: case 20:
stextflag = TalkID::None; stextflag = TalkID::None;
@ -1427,14 +1427,14 @@ void SmithBuyItem(Item &item)
void SmithBuyEnter() void SmithBuyEnter()
{ {
if (stextsel == BackButtonLine()) { if (stextsel == BackButtonLine()) {
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 12; stextsel = 12;
return; return;
} }
stextlhold = stextsel; stextlhold = stextsel;
stextvhold = stextsval; stextvhold = stextsval;
stextshold = TalkID::BlacksmithBuy; stextshold = TalkID::SmithBuy;
int idx = stextsval + ((stextsel - stextup) / 4); int idx = stextsval + ((stextsel - stextup) / 4);
if (!PlayerCanAfford(smithitem[idx]._iIvalue)) { if (!PlayerCanAfford(smithitem[idx]._iIvalue)) {
@ -1478,7 +1478,7 @@ void SmithBuyPItem(Item &item)
void SmithPremiumBuyEnter() void SmithPremiumBuyEnter()
{ {
if (stextsel == BackButtonLine()) { if (stextsel == BackButtonLine()) {
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 14; stextsel = 14;
return; return;
} }
@ -1555,13 +1555,13 @@ void StoreSellItem()
void SmithSellEnter() void SmithSellEnter()
{ {
if (stextsel == BackButtonLine()) { if (stextsel == BackButtonLine()) {
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 16; stextsel = 16;
return; return;
} }
stextlhold = stextsel; stextlhold = stextsel;
stextshold = TalkID::BlacksmithSell; stextshold = TalkID::SmithSell;
stextvhold = stextsval; stextvhold = stextsval;
int idx = stextsval + ((stextsel - stextup) / 4); int idx = stextsval + ((stextsel - stextup) / 4);
@ -1607,12 +1607,12 @@ void SmithRepairItem(int price)
void SmithRepairEnter() void SmithRepairEnter()
{ {
if (stextsel == BackButtonLine()) { if (stextsel == BackButtonLine()) {
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 18; stextsel = 18;
return; return;
} }
stextshold = TalkID::BlacksmithRepair; stextshold = TalkID::SmithRepair;
stextlhold = stextsel; stextlhold = stextsel;
stextvhold = stextsval; stextvhold = stextsval;
@ -1914,14 +1914,14 @@ void ConfirmEnter(Item &item)
{ {
if (stextsel == 18) { if (stextsel == 18) {
switch (stextshold) { switch (stextshold) {
case TalkID::BlacksmithBuy: case TalkID::SmithBuy:
SmithBuyItem(item); SmithBuyItem(item);
break; break;
case TalkID::BlacksmithSell: case TalkID::SmithSell:
case TalkID::WitchSell: case TalkID::WitchSell:
StoreSellItem(); StoreSellItem();
break; break;
case TalkID::BlacksmithRepair: case TalkID::SmithRepair:
SmithRepairItem(item._iIvalue); SmithRepairItem(item._iIvalue);
break; break;
case TalkID::WitchBuy: case TalkID::WitchBuy:
@ -1938,7 +1938,7 @@ void ConfirmEnter(Item &item)
break; break;
case TalkID::StorytellerIdentify: case TalkID::StorytellerIdentify:
StorytellerIdentifyItem(item); StorytellerIdentifyItem(item);
StartStore(TalkID::StorytellerShow); StartStore(TalkID::StorytellerIdentifyShow);
return; return;
case TalkID::SmithPremiumBuy: case TalkID::SmithPremiumBuy:
SmithBuyPItem(item); SmithBuyPItem(item);
@ -2372,10 +2372,10 @@ void StartStore(TalkID s)
ClearSText(0, STORE_LINES); ClearSText(0, STORE_LINES);
ReleaseStoreBtn(); ReleaseStoreBtn();
switch (s) { switch (s) {
case TalkID::Blacksmith: case TalkID::Smith:
StartSmith(); StartSmith();
break; break;
case TalkID::BlacksmithBuy: { case TalkID::SmithBuy: {
bool hasAnyItems = false; bool hasAnyItems = false;
for (int i = 0; !smithitem[i].isEmpty(); i++) { for (int i = 0; !smithitem[i].isEmpty(); i++) {
hasAnyItems = true; hasAnyItems = true;
@ -2384,17 +2384,17 @@ void StartStore(TalkID s)
if (hasAnyItems) if (hasAnyItems)
StartSmithBuy(); StartSmithBuy();
else { else {
stextflag = TalkID::BlacksmithBuy; stextflag = TalkID::SmithBuy;
stextlhold = 12; stextlhold = 12;
StoreESC(); StoreESC();
return; return;
} }
break; break;
} }
case TalkID::BlacksmithSell: case TalkID::SmithSell:
StartSmithSell(); StartSmithSell();
break; break;
case TalkID::BlacksmithRepair: case TalkID::SmithRepair:
StartSmithRepair(); StartSmithRepair();
break; break;
case TalkID::Witch: case TalkID::Witch:
@ -2445,7 +2445,7 @@ void StartStore(TalkID s)
case TalkID::Gossip: case TalkID::Gossip:
StartTalk(); StartTalk();
break; break;
case TalkID::StorytellerShow: case TalkID::StorytellerIdentifyShow:
StartStorytellerIdentifyShow(StoreItem); StartStorytellerIdentifyShow(StoreItem);
break; break;
case TalkID::Tavern: case TalkID::Tavern:
@ -2481,11 +2481,11 @@ void DrawSText(const Surface &out)
if (stextscrl) { if (stextscrl) {
switch (stextflag) { switch (stextflag) {
case TalkID::BlacksmithBuy: case TalkID::SmithBuy:
ScrollSmithBuy(stextsval); ScrollSmithBuy(stextsval);
break; break;
case TalkID::BlacksmithSell: case TalkID::SmithSell:
case TalkID::BlacksmithRepair: case TalkID::SmithRepair:
case TalkID::WitchSell: case TalkID::WitchSell:
case TalkID::WitchRecharge: case TalkID::WitchRecharge:
case TalkID::StorytellerIdentify: case TalkID::StorytellerIdentify:
@ -2532,7 +2532,7 @@ void StoreESC()
} }
switch (stextflag) { switch (stextflag) {
case TalkID::Blacksmith: case TalkID::Smith:
case TalkID::Witch: case TalkID::Witch:
case TalkID::Boy: case TalkID::Boy:
case TalkID::BoyBuy: case TalkID::BoyBuy:
@ -2547,20 +2547,20 @@ void StoreESC()
StartStore(stextshold); StartStore(stextshold);
stextsel = stextlhold; stextsel = stextlhold;
break; break;
case TalkID::BlacksmithBuy: case TalkID::SmithBuy:
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 12; stextsel = 12;
break; break;
case TalkID::SmithPremiumBuy: case TalkID::SmithPremiumBuy:
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 14; stextsel = 14;
break; break;
case TalkID::BlacksmithSell: case TalkID::SmithSell:
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 16; stextsel = 16;
break; break;
case TalkID::BlacksmithRepair: case TalkID::SmithRepair:
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
stextsel = 18; stextsel = 18;
break; break;
case TalkID::WitchBuy: case TalkID::WitchBuy:
@ -2583,7 +2583,7 @@ void StoreESC()
StartStore(TalkID::Storyteller); StartStore(TalkID::Storyteller);
stextsel = 14; stextsel = 14;
break; break;
case TalkID::StorytellerShow: case TalkID::StorytellerIdentifyShow:
StartStore(TalkID::StorytellerIdentify); StartStore(TalkID::StorytellerIdentify);
break; break;
case TalkID::NoMoney: case TalkID::NoMoney:
@ -2726,19 +2726,19 @@ void StoreEnter()
PlaySFX(IS_TITLSLCT); PlaySFX(IS_TITLSLCT);
switch (stextflag) { switch (stextflag) {
case TalkID::Blacksmith: case TalkID::Smith:
SmithEnter(); SmithEnter();
break; break;
case TalkID::SmithPremiumBuy: case TalkID::SmithPremiumBuy:
SmithPremiumBuyEnter(); SmithPremiumBuyEnter();
break; break;
case TalkID::BlacksmithBuy: case TalkID::SmithBuy:
SmithBuyEnter(); SmithBuyEnter();
break; break;
case TalkID::BlacksmithSell: case TalkID::SmithSell:
SmithSellEnter(); SmithSellEnter();
break; break;
case TalkID::BlacksmithRepair: case TalkID::SmithRepair:
SmithRepairEnter(); SmithRepairEnter();
break; break;
case TalkID::Witch: case TalkID::Witch:
@ -2783,7 +2783,7 @@ void StoreEnter()
case TalkID::Gossip: case TalkID::Gossip:
TalkEnter(); TalkEnter();
break; break;
case TalkID::StorytellerShow: case TalkID::StorytellerIdentifyShow:
StartStore(TalkID::StorytellerIdentify); StartStore(TalkID::StorytellerIdentify);
break; break;
case TalkID::Drunk: case TalkID::Drunk:

10
Source/stores.h

@ -21,10 +21,10 @@ namespace devilution {
enum class TalkID : uint8_t { enum class TalkID : uint8_t {
None, None,
Blacksmith, Smith,
BlacksmithBuy, SmithBuy,
BlacksmithSell, SmithSell,
BlacksmithRepair, SmithRepair,
Witch, Witch,
WitchBuy, WitchBuy,
WitchSell, WitchSell,
@ -40,7 +40,7 @@ enum class TalkID : uint8_t {
StorytellerIdentify, StorytellerIdentify,
SmithPremiumBuy, SmithPremiumBuy,
Gossip, Gossip,
StorytellerShow, StorytellerIdentifyShow,
Tavern, Tavern,
Drunk, Drunk,
Barmaid, Barmaid,

2
Source/towners.cpp

@ -411,7 +411,7 @@ void TalkToBlackSmith(Player &player, Towner &blackSmith)
} }
TownerTalk(TEXT_GRISWOLD1); TownerTalk(TEXT_GRISWOLD1);
StartStore(TalkID::Blacksmith); StartStore(TalkID::Smith);
} }
void TalkToWitch(Player &player, Towner & /*witch*/) void TalkToWitch(Player &player, Towner & /*witch*/)

Loading…
Cancel
Save