diff options
author | rubidium <rubidium@openttd.org> | 2013-02-17 14:50:54 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2013-02-17 14:50:54 +0000 |
commit | 446d50f6580d6d71ac30d6d64b72cb3e5c4c3aaa (patch) | |
tree | 93495ae2a17ce8b5dcc66ae264f9aef50e09cbf0 /src | |
parent | d6e2a8aa56337af68f2960cf404edf0ac03f405b (diff) | |
download | openttd-446d50f6580d6d71ac30d6d64b72cb3e5c4c3aaa.tar.xz |
(svn r25011) -Codechange: allow vehicle transfer and profit text effects to be shown at the same time (fonsinchen)
Diffstat (limited to 'src')
-rw-r--r-- | src/economy.cpp | 22 | ||||
-rw-r--r-- | src/economy_base.h | 7 | ||||
-rw-r--r-- | src/lang/english.txt | 4 | ||||
-rw-r--r-- | src/misc_gui.cpp | 25 | ||||
-rw-r--r-- | src/saveload/economy_sl.cpp | 10 | ||||
-rw-r--r-- | src/texteff.cpp | 5 | ||||
-rw-r--r-- | src/texteff.hpp | 2 |
7 files changed, 48 insertions, 27 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 7d055227e..c3745df33 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -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 } diff --git a/src/economy_base.h b/src/economy_base.h index 742d01878..60b0964a9 100644 --- a/src/economy_base.h +++ b/src/economy_base.h @@ -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 diff --git a/src/lang/english.txt b/src/lang/english.txt index f2f28f794..718ab9af4 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -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} diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 979b41813..bd390c7bf 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -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); + } } /** diff --git a/src/saveload/economy_sl.cpp b/src/saveload/economy_sl.cpp index 9bdad61a9..86605bdfb 100644 --- a/src/saveload/economy_sl.cpp +++ b/src/saveload/economy_sl.cpp @@ -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() diff --git a/src/texteff.cpp b/src/texteff.cpp index 981453c10..fd2001716 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -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); } } } diff --git a/src/texteff.hpp b/src/texteff.hpp index b9762c3fe..9ef74c171 100644 --- a/src/texteff.hpp +++ b/src/texteff.hpp @@ -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 */ |