mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-12 01:24:54 +00:00
(svn r25011) -Codechange: allow vehicle transfer and profit text effects to be shown at the same time (fonsinchen)
This commit is contained in:
parent
d6e2a8aa56
commit
446d50f658
@ -1140,21 +1140,23 @@ CargoPayment::~CargoPayment()
|
||||
|
||||
this->front->cargo_payment = NULL;
|
||||
|
||||
if (this->visual_profit == 0) return;
|
||||
if (this->visual_profit == 0 && this->visual_transfer == 0) return;
|
||||
|
||||
Backup<CompanyByte> cur_company(_current_company, this->front->owner, FILE_LINE);
|
||||
|
||||
SubtractMoneyFromCompany(CommandCost(this->front->GetExpenseType(true), -this->route_profit));
|
||||
this->front->profit_this_year += this->visual_profit << 8;
|
||||
this->front->profit_this_year += (this->visual_profit + this->visual_transfer) << 8;
|
||||
|
||||
if (this->route_profit != 0) {
|
||||
if (IsLocalCompany() && !PlayVehicleSound(this->front, VSE_LOAD_UNLOAD)) {
|
||||
SndPlayVehicleFx(SND_14_CASHTILL, this->front);
|
||||
}
|
||||
if (this->route_profit != 0 && IsLocalCompany() && !PlayVehicleSound(this->front, VSE_LOAD_UNLOAD)) {
|
||||
SndPlayVehicleFx(SND_14_CASHTILL, this->front);
|
||||
}
|
||||
|
||||
ShowCostOrIncomeAnimation(this->front->x_pos, this->front->y_pos, this->front->z_pos, -this->visual_profit);
|
||||
} else {
|
||||
ShowFeederIncomeAnimation(this->front->x_pos, this->front->y_pos, this->front->z_pos, this->visual_profit);
|
||||
if (this->visual_transfer != 0) {
|
||||
ShowFeederIncomeAnimation(this->front->x_pos, this->front->y_pos,
|
||||
this->front->z_pos, this->visual_transfer, -this->visual_profit);
|
||||
} else if (this->visual_profit != 0) {
|
||||
ShowCostOrIncomeAnimation(this->front->x_pos, this->front->y_pos,
|
||||
this->front->z_pos, -this->visual_profit);
|
||||
}
|
||||
|
||||
cur_company.Restore();
|
||||
@ -1196,7 +1198,7 @@ Money CargoPayment::PayTransfer(const CargoPacket *cp, uint count)
|
||||
|
||||
profit = profit * _settings_game.economy.feeder_payment_share / 100;
|
||||
|
||||
this->visual_profit += profit; // accumulate transfer profits for whole vehicle
|
||||
this->visual_transfer += profit; // accumulate transfer profits for whole vehicle
|
||||
return profit; // account for the (virtual) profit already made for the cargo packet
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,10 @@ extern CargoPaymentPool _cargo_payment_pool;
|
||||
* Helper class to perform the cargo payment.
|
||||
*/
|
||||
struct CargoPayment : CargoPaymentPool::PoolItem<&_cargo_payment_pool> {
|
||||
Vehicle *front; ///< The front vehicle to do the payment of
|
||||
Money route_profit; ///< The amount of money to add/remove from the bank account
|
||||
Money visual_profit; ///< The visual profit to show
|
||||
Vehicle *front; ///< The front vehicle to do the payment of
|
||||
Money route_profit; ///< The amount of money to add/remove from the bank account
|
||||
Money visual_profit; ///< The visual profit to show
|
||||
Money visual_transfer; ///< The transfer credits to be shown
|
||||
|
||||
/* Unsaved variables */
|
||||
Company *owner; ///< The owner of the vehicle
|
||||
|
@ -3827,6 +3827,10 @@ STR_INCOME_FLOAT_INCOME_SMALL :{TINY_FONT}{GRE
|
||||
STR_INCOME_FLOAT_INCOME :{GREEN}Income: {CURRENCY_LONG}
|
||||
STR_FEEDER_TINY :{TINY_FONT}{YELLOW}Transfer: {CURRENCY_LONG}
|
||||
STR_FEEDER :{YELLOW}Transfer: {CURRENCY_LONG}
|
||||
STR_FEEDER_INCOME_TINY :{TINY_FONT}{YELLOW}Transfer: {CURRENCY_LONG}{WHITE} / {GREEN}Income: {CURRENCY_LONG}
|
||||
STR_FEEDER_INCOME :{YELLOW}Transfer: {CURRENCY_LONG}{WHITE} / {GREEN}Income: {CURRENCY_LONG}
|
||||
STR_FEEDER_COST_TINY :{TINY_FONT}{YELLOW}Transfer: {CURRENCY_LONG}{WHITE} / {RED}Cost: {CURRENCY_LONG}
|
||||
STR_FEEDER_COST :{YELLOW}Transfer: {CURRENCY_LONG}{WHITE} / {RED}Cost: {CURRENCY_LONG}
|
||||
STR_MESSAGE_ESTIMATED_COST :{WHITE}Estimated Cost: {CURRENCY_LONG}
|
||||
STR_MESSAGE_ESTIMATED_INCOME :{WHITE}Estimated Income: {CURRENCY_LONG}
|
||||
|
||||
|
@ -543,17 +543,28 @@ void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
|
||||
|
||||
/**
|
||||
* Display animated feeder income.
|
||||
* @param x World X position of the animation location.
|
||||
* @param y World Y position of the animation location.
|
||||
* @param z World Z position of the animation location.
|
||||
* @param cost Estimated feeder income.
|
||||
* @param x World X position of the animation location.
|
||||
* @param y World Y position of the animation location.
|
||||
* @param z World Z position of the animation location.
|
||||
* @param transfer Estimated feeder income.
|
||||
* @param income Real income from goods being delivered to their final destination.
|
||||
*/
|
||||
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
|
||||
void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income)
|
||||
{
|
||||
Point pt = RemapCoords(x, y, z);
|
||||
|
||||
SetDParam(0, cost);
|
||||
AddTextEffect(STR_FEEDER, pt.x, pt.y, DAY_TICKS, TE_RISING);
|
||||
SetDParam(0, transfer);
|
||||
if (income == 0) {
|
||||
AddTextEffect(STR_FEEDER, pt.x, pt.y, DAY_TICKS, TE_RISING);
|
||||
} else {
|
||||
StringID msg = STR_FEEDER_COST;
|
||||
if (income < 0) {
|
||||
income = -income;
|
||||
msg = STR_FEEDER_INCOME;
|
||||
}
|
||||
SetDParam(1, income);
|
||||
AddTextEffect(msg, pt.x, pt.y, DAY_TICKS, TE_RISING);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,11 +63,11 @@ static void Load_ECMY()
|
||||
}
|
||||
|
||||
static const SaveLoad _cargopayment_desc[] = {
|
||||
SLE_REF(CargoPayment, front, REF_VEHICLE),
|
||||
SLE_VAR(CargoPayment, route_profit, SLE_INT64),
|
||||
SLE_VAR(CargoPayment, visual_profit, SLE_INT64),
|
||||
|
||||
SLE_END()
|
||||
SLE_REF(CargoPayment, front, REF_VEHICLE),
|
||||
SLE_VAR(CargoPayment, route_profit, SLE_INT64),
|
||||
SLE_VAR(CargoPayment, visual_profit, SLE_INT64),
|
||||
SLE_CONDVAR(CargoPayment, visual_transfer, SLE_INT64, 181, SL_MAX_VERSION),
|
||||
SLE_END()
|
||||
};
|
||||
|
||||
static void Save_CAPY()
|
||||
|
@ -20,6 +20,7 @@
|
||||
/** Container for all information about a text effect */
|
||||
struct TextEffect : public ViewportSign {
|
||||
uint64 params_1; ///< DParam parameter
|
||||
uint64 params_2; ///< second DParam parameter
|
||||
StringID string_id; ///< String to draw for the text effect, if INVALID_STRING_ID then it's not valid
|
||||
uint8 duration; ///< How long the text effect should stay, in ticks (applies only when mode == TE_RISING)
|
||||
TextEffectMode mode; ///< Type of text effect
|
||||
@ -52,6 +53,7 @@ TextEffectID AddTextEffect(StringID msg, int center, int y, uint8 duration, Text
|
||||
te->string_id = msg;
|
||||
te->duration = duration;
|
||||
te->params_1 = GetDParam(0);
|
||||
te->params_2 = GetDParam(1);
|
||||
te->mode = mode;
|
||||
|
||||
/* Make sure we only dirty the new area */
|
||||
@ -68,6 +70,7 @@ void UpdateTextEffect(TextEffectID te_id, StringID msg)
|
||||
if (msg == te->string_id && GetDParam(0) == te->params_1) return;
|
||||
te->string_id = msg;
|
||||
te->params_1 = GetDParam(0);
|
||||
te->params_2 = GetDParam(1);
|
||||
|
||||
te->UpdatePosition(te->center, te->top, msg);
|
||||
}
|
||||
@ -109,7 +112,7 @@ void DrawTextEffects(DrawPixelInfo *dpi)
|
||||
for (TextEffect *te = _text_effects.Begin(); te != end; te++) {
|
||||
if (te->string_id == INVALID_STRING_ID) continue;
|
||||
if (te->mode == TE_RISING || (_settings_client.gui.loading_indicators && !IsTransparencySet(TO_LOADING))) {
|
||||
ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, 0, te->params_1);
|
||||
ViewportAddString(dpi, ZOOM_LVL_OUT_8X, te, te->string_id, te->string_id - 1, 0, te->params_1, te->params_2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,6 @@ void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID colour);
|
||||
void HideFillingPercent(TextEffectID *te_id);
|
||||
|
||||
void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost);
|
||||
void ShowFeederIncomeAnimation(int x, int y, int z, Money cost);
|
||||
void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income);
|
||||
|
||||
#endif /* TEXTEFF_HPP */
|
||||
|
Loading…
Reference in New Issue
Block a user