-
Notifications
You must be signed in to change notification settings - Fork 94
feat(display): Implement player money per minute #1481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,40 @@ | |
static const Real placementOpacity = 0.45f; | ||
static const RGBColor illegalBuildColor = { 1.0, 0.0, 0.0 }; | ||
|
||
// ------------------------------------------------------------------------------------------------ | ||
static UnicodeString formatMoneyValue(UnsignedInt amount) | ||
{ | ||
UnicodeString result; | ||
if (amount >= 100000) | ||
{ | ||
result.format(L"%dk", amount / 1000); | ||
} | ||
else | ||
{ | ||
result.format(L"%d", amount); | ||
} | ||
return result; | ||
} | ||
|
||
static UnicodeString formatIncomeValue(UnsignedInt cashPerMin) | ||
{ | ||
UnicodeString result; | ||
if (cashPerMin >= 10000) | ||
{ | ||
result.format(L"%dk", cashPerMin / 1000); | ||
} | ||
else if (cashPerMin >= 1000) | ||
{ | ||
UnsignedInt k = cashPerMin / 100; | ||
result.format(L"%d.%dk", k / 10, k % 10); | ||
} | ||
else | ||
{ | ||
result.format(L"%d", cashPerMin); | ||
} | ||
return result; | ||
} | ||
|
||
//------------------------------------------------------------------------------------------------- | ||
/// The InGameUI singleton instance. | ||
InGameUI *TheInGameUI = NULL; | ||
|
@@ -1837,6 +1871,7 @@ void InGameUI::update( void ) | |
// update the player money window if the money amount has changed | ||
// this seems like as good a place as any to do the power hide/show | ||
static Int lastMoney = -1; | ||
static Int lastIncome = -1; | ||
static NameKeyType moneyWindowKey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:MoneyDisplay" ); | ||
static NameKeyType powerWindowKey = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:PowerWindow" ); | ||
|
||
|
@@ -1852,16 +1887,39 @@ void InGameUI::update( void ) | |
Player* moneyPlayer = TheControlBar->getCurrentlyViewedPlayer(); | ||
if( moneyPlayer) | ||
{ | ||
Int currentMoney = moneyPlayer->getMoney()->countMoney(); | ||
if( lastMoney != currentMoney ) | ||
Money *money = moneyPlayer->getMoney(); | ||
Bool showIncome = TheGlobalData->m_showMoneyPerMinute; | ||
if (!showIncome) | ||
{ | ||
UnicodeString buffer; | ||
Int currentMoney = money->countMoney(); | ||
if( lastMoney != currentMoney ) | ||
{ | ||
UnicodeString buffer; | ||
|
||
buffer.format( TheGameText->fetch( "GUI:ControlBarMoneyDisplay" ), currentMoney ); | ||
GadgetStaticTextSetText( moneyWin, buffer ); | ||
lastMoney = currentMoney; | ||
buffer.format(TheGameText->fetch( "GUI:ControlBarMoneyDisplay" ), currentMoney ); | ||
GadgetStaticTextSetText( moneyWin, buffer ); | ||
lastMoney = currentMoney; | ||
|
||
} // end if | ||
} // end if | ||
} | ||
else | ||
{ | ||
// TheSuperHackers @feature L3-M 21/08/2025 player money per minute | ||
money->updateIncomeBucket(); | ||
UnsignedInt currentMoney = money->countMoney(); | ||
UnsignedInt cashPerMin = money->getCashPerMinute(); | ||
if (lastMoney != (Int)currentMoney || lastIncome != (Int)cashPerMin) | ||
{ | ||
UnicodeString buffer; | ||
UnicodeString moneyStr = formatMoneyValue(currentMoney); | ||
UnicodeString incomeStr = formatIncomeValue(cashPerMin); | ||
|
||
buffer.format(TheGameText->FETCH_OR_SUBSTITUTE_FORMAT("GUI:ControlBarMoneyDisplayIncome", L"%ls (%ls)", moneyStr.str(), incomeStr.str())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the Money symbol? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The limitation here would be the ControlBarPro money texture. It has much less space compared to the original game's ControlBar, hence I removed it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you show image for it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You tested Control Bar Pro correctly in 16:9. The Original Control Bar always needs to be tested in 4:3. That is because its elements are stretched wide in 16:9 and beyond. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
GadgetStaticTextSetText(moneyWin, buffer); | ||
lastMoney = currentMoney; | ||
lastIncome = cashPerMin; | ||
} | ||
} | ||
moneyWin->winHide(FALSE); | ||
powerWin->winHide(FALSE); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this value not be derived from
m_currentBucket
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so,
m_lastBucketFrame
records the exact frame of the last updateThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But do we care for this frame number? We only care for bucket position, no? I would expect that this logic can be simplified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.