sovereignx/include/money.h
psf 522a8ba3f7
Allow users to increase MAX_MONEY (#4943)
* Added GetMaxNumMoneyDigits and GetMoneyBoxHorizontalPosition to header
Replaced use of PrintMoneyAmount

* Added define for MAX_MONEY_DIGITS
Removed GetMaxNumMoneyDigits
Converted uses of ConvertIntToDecimalStringN that called for 7 money digits to use MAX_MONEY_DIGITS
Replaced 6 money digits in PrintMoneyAmount with MAX_MONEY_DIGITS

* Use preproc and MAX_MONEY_DIGITS to increase the width of the sell item money box

* Added GetItemSoldMoneyHorizonalPosition and fixed ConvertInt in PrintMoneyAmount to use MAX_MONEY_DIGITS

* Added GetItemSoldMoneyHorizonalPosition and fixed ConvertInt in PrintMoneyAmount to use MAX_MONEY_DIGITS

* Removed width and tilemap changes

* Modified CountDigits to count digits greater than 1
Fixed PrintMoneyAmount to work with large digits

* Added an early return to PrependFontIdToFit

* First prototype working

* Updated GetMoneyBoxHorizontalPosition with amount

* Updated GetMoneyBoxHorizontalPosition with amount

* Got version working with one space before

* Got version working with one space before

* Got version working with all spacingOC

* cleaned up PrintMoneyAmount

* Created CalculateleadingSpacesForMoney

* Cleaned up for PR

* Changed tabs to spaces per https://github.com/rh-hideout/pokeemerald-expansion/pull/4943\#issuecomment-2223023365
2024-07-13 11:16:34 +02:00

33 lines
1.2 KiB
C

#ifndef GUARD_MONEY_H
#define GUARD_MONEY_H
#define MAX_MONEY 999999 // Can be increased to INT_MAX
#define MAX_MONEY_DIGITS ((MAX_MONEY > 999999999) ? 10 : \
(MAX_MONEY > 99999999) ? 9 : \
(MAX_MONEY > 9999999) ? 8 : \
(MAX_MONEY > 999999) ? 7 : \
(MAX_MONEY > 99999) ? 6 : \
(MAX_MONEY > 9999) ? 5 : \
(MAX_MONEY > 999) ? 4 : \
(MAX_MONEY > 99) ? 3 : \
(MAX_MONEY > 9) ? 2 : 1)
u32 GetMoney(u32 *moneyPtr);
void SetMoney(u32 *moneyPtr, u32 newValue);
bool8 IsEnoughMoney(u32 *moneyPtr, u32 cost);
void AddMoney(u32 *moneyPtr, u32 toAdd);
void RemoveMoney(u32 *moneyPtr, u32 toSub);
bool8 IsEnoughForCostInVar0x8005(void);
void SubtractMoneyFromVar0x8005(void);
void PrintMoneyAmountInMoneyBox(u8 windowId, int amount, u8 speed);
void PrintMoneyAmount(u8 windowId, u8 x, u8 y, int amount, u8 speed);
void PrintMoneyAmountInMoneyBoxWithBorder(u8 windowId, u16 tileStart, u8 pallete, int amount);
void ChangeAmountInMoneyBox(int amount);
void DrawMoneyBox(int amount, u8 x, u8 y);
void HideMoneyBox(void);
void AddMoneyLabelObject(u16 x, u16 y);
void RemoveMoneyLabelObject(void);
u32 CalculateMoneyTextHorizontalPosition(u32 amount);
#endif // GUARD_MONEY_H