Changeset - r20053:1f0b373e9dce
[Not reviewed]
master
0 7 0
rubidium - 12 years ago 2013-02-17 14:50:54
rubidium@openttd.org
(svn r25011) -Codechange: allow vehicle transfer and profit text effects to be shown at the same time (fonsinchen)
7 files changed with 35 insertions and 14 deletions:
0 comments (0 inline, 0 general)
src/economy.cpp
Show inline comments
 
@@ -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)) {
 
	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 Ca
 

	
 
	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
 
}
 

	
src/economy_base.h
Show inline comments
 
@@ -27,6 +27,7 @@ struct CargoPayment : CargoPaymentPool::
 
	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
src/lang/english.txt
Show inline comments
 
@@ -3827,6 +3827,10 @@ STR_INCOME_FLOAT_INCOME_SMALL           
 
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}
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -546,14 +546,25 @@ void ShowCostOrIncomeAnimation(int x, in
 
 * @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 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);
 
	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);
 
	}
 
}
 

	
 
/**
src/saveload/economy_sl.cpp
Show inline comments
 
@@ -66,7 +66,7 @@ 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_CONDVAR(CargoPayment, visual_transfer, SLE_INT64, 181, SL_MAX_VERSION),
 
	SLE_END()
 
};
 

	
src/texteff.cpp
Show inline comments
 
@@ -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,
 
	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
 
	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);
 
		}
 
	}
 
}
src/texteff.hpp
Show inline comments
 
@@ -41,6 +41,6 @@ void UpdateFillingPercent(TextEffectID t
 
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 */
0 comments (0 inline, 0 general)