summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-06-22 18:28:44 +0000
committertruelight <truelight@openttd.org>2007-06-22 18:28:44 +0000
commit80bcbce62bf0510a7fd6c21e0ea30068907459e5 (patch)
tree20623f97dba17284a729f18f337f9277809b8527
parentdb097a94dbfe808d35f9de08fc32438f83407802 (diff)
downloadopenttd-80bcbce62bf0510a7fd6c21e0ea30068907459e5.tar.xz
(svn r10270) -Add: prefixed the loading indicator with an arrow, up meaning vehicle is loading, down meaning vehicle is unloading
-rw-r--r--src/economy.cpp7
-rw-r--r--src/lang/english.txt8
-rw-r--r--src/misc_gui.cpp12
-rw-r--r--src/texteff.hpp4
-rw-r--r--src/vehicle.cpp15
-rw-r--r--src/vehicle.h2
6 files changed, 35 insertions, 13 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index b2091057d..2f12a070e 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1669,11 +1669,12 @@ static void LoadUnloadVehicle(Vehicle *v, int *cargo_left)
/* Calculate the loading indicator fill percent and display */
if (_patches.loading_indicators && _game_mode != GM_MENU && v->owner == _local_player) {
- int percent = CalcPercentVehicleFilled(v);
+ StringID percent_up_down = STR_NULL;
+ int percent = CalcPercentVehicleFilled(v, &percent_up_down);
if (v->fill_percent_te_id == INVALID_TE_ID) {
- v->fill_percent_te_id = ShowFillingPercent(v->x_pos, v->y_pos, v->z_pos + 20, percent);
+ v->fill_percent_te_id = ShowFillingPercent(v->x_pos, v->y_pos, v->z_pos + 20, percent, percent_up_down);
} else {
- UpdateFillingPercent(v->fill_percent_te_id, percent);
+ UpdateFillingPercent(v->fill_percent_te_id, percent, percent_up_down);
}
}
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 1a0892164..a176c5125 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3292,8 +3292,12 @@ STR_TRANSPARENT_BRIDGES_DESC :{BLACK}Toggle t
STR_TRANSPARENT_STRUCTURES_DESC :{BLACK}Toggle transparency for structures like lighthouses and antennas, maybe in future for eyecandy
STR_TRANSPARENT_LOADING_DESC :{BLACK}Toggle transparency for loading indicators
-STR_PERCENT_FULL_SMALL :{TINYFONT}{WHITE}{NUM}%
-STR_PERCENT_FULL :{WHITE}{NUM}%
+STR_PERCENT_UP_SMALL :{TINYFONT}{WHITE}{NUM}%{UPARROW}
+STR_PERCENT_UP :{WHITE}{NUM}%{UPARROW}
+STR_PERCENT_DOWN_SMALL :{TINYFONT}{WHITE}{NUM}%{DOWNARROW}
+STR_PERCENT_DOWN :{WHITE}{NUM}%{DOWNARROW}
+STR_PERCENT_UP_DOWN_SMALL :{TINYFONT}{WHITE}{NUM}%{UPARROW}{DOWNARROW}
+STR_PERCENT_UP_DOWN :{WHITE}{NUM}%{UPARROW}{DOWNARROW}
##### Mass Order
STR_GROUP_NAME_FORMAT :Group {COMMA}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index ffd8d84b7..22ccfabfe 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -644,18 +644,22 @@ void ShowFeederIncomeAnimation(int x, int y, int z, Money cost)
AddTextEffect(STR_FEEDER, pt.x, pt.y, 0x250, TE_RISING);
}
-TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent)
+TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID string)
{
Point pt = RemapCoords(x, y, z);
+ assert(string != STR_NULL);
+
SetDParam(0, percent);
- return AddTextEffect(STR_PERCENT_FULL, pt.x, pt.y, 0xFFFF, TE_STATIC);
+ return AddTextEffect(string, pt.x, pt.y, 0xFFFF, TE_STATIC);
}
-void UpdateFillingPercent(TextEffectID te_id, uint8 percent)
+void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
{
+ assert(string != STR_NULL);
+
SetDParam(0, percent);
- UpdateTextEffect(te_id, STR_PERCENT_FULL);
+ UpdateTextEffect(te_id, string);
}
void HideFillingPercent(TextEffectID te_id)
diff --git a/src/texteff.hpp b/src/texteff.hpp
index 96971d8ef..2ce1aebb0 100644
--- a/src/texteff.hpp
+++ b/src/texteff.hpp
@@ -28,8 +28,8 @@ void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...
void UndrawTextMessage();
/* misc_gui.cpp */
-TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent);
-void UpdateFillingPercent(TextEffectID te_id, uint8 percent);
+TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID color);
+void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID color);
void HideFillingPercent(TextEffectID te_id);
#endif /* TEXTEFF_HPP */
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index f04a1a3ea..b4c3daf92 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2271,19 +2271,32 @@ bool IsVehicleInDepot(const Vehicle *v)
/**
* Calculates how full a vehicle is.
* @param v The Vehicle to check. For trains, use the first engine.
+ * @param color The string to show depending on if we are unloading or loading
* @return A percentage of how full the Vehicle is.
*/
-uint8 CalcPercentVehicleFilled(Vehicle *v)
+uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color)
{
int count = 0;
int max = 0;
+ int cars = 0;
+ int unloading = 0;
+
+ assert(color != NULL);
/* Count up max and used */
for (; v != NULL; v = v->next) {
count += v->cargo.Count();
max += v->cargo_cap;
+ if (v->cargo_cap != 0) {
+ unloading += HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) ? 1 : 0;
+ cars++;
+ }
}
+ if (unloading == 0) *color = STR_PERCENT_UP;
+ else if (cars == unloading) *color = STR_PERCENT_DOWN;
+ else *color = STR_PERCENT_UP_DOWN;
+
/* Train without capacity */
if (max == 0) return 100;
diff --git a/src/vehicle.h b/src/vehicle.h
index 5efb14a7a..d8f039de1 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -505,7 +505,7 @@ void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
void *VehicleFromPosXY(int x, int y, void *data, VehicleFromPosProc *proc);
void CallVehicleTicks();
Vehicle *FindVehicleOnTileZ(TileIndex tile, byte z);
-uint8 CalcPercentVehicleFilled(Vehicle *v);
+uint8 CalcPercentVehicleFilled(Vehicle *v, StringID *color);
void InitializeTrains();
byte VehicleRandomBits();