summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2017-02-26 15:34:15 +0000
committeralberth <alberth@openttd.org>2017-02-26 15:34:15 +0000
commitdcc240f826ef6ffe88f88054e17db07c33117180 (patch)
tree2c4a41973e2fdc1dd184d252ff28e1c17fff2676
parent325a46e8ed8b93692ca8fb78e14b4d296511523b (diff)
downloadopenttd-dcc240f826ef6ffe88f88054e17db07c33117180.tar.xz
(svn r27751) -Feature: Display cargo suffix of accepted cargoes in industry view based on cb37 result type.
Industry-sets that have no stockpiling get better control over the displayed accepted cargo information. - result 0401 only prints the accepted cargo - results 0800-0BFF prints the accepted cargo and a string (but not the amount)
-rw-r--r--src/industry_gui.cpp66
-rw-r--r--src/lang/english.txt8
2 files changed, 46 insertions, 28 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 8a8918333..b9077b9d7 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -766,35 +766,49 @@ public:
CargoSuffix cargo_suffix[3];
GetAllCargoSuffixes(0, CST_VIEW, i, i->type, ind, i->accepts_cargo, cargo_suffix);
- if (HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS)) {
- for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
- if (i->accepts_cargo[j] == CT_INVALID) continue;
- has_accept = true;
- if (first) {
- DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_WAITING_FOR_PROCESSING);
- y += FONT_HEIGHT_NORMAL;
- first = false;
- }
- SetDParam(0, i->accepts_cargo[j]);
- SetDParam(1, i->incoming_cargo_waiting[j]);
- SetDParamStr(2, cargo_suffix[j].text);
- DrawString(left + WD_FRAMETEXT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO);
+ bool stockpiling = HasBit(ind->callback_mask, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(ind->callback_mask, CBM_IND_PRODUCTION_256_TICKS);
+
+ uint left_side = left + WD_FRAMERECT_LEFT * 4; // Indent accepted cargoes.
+ for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
+ if (i->accepts_cargo[j] == CT_INVALID) continue;
+ has_accept = true;
+ if (first) {
+ DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_REQUIRES);
y += FONT_HEIGHT_NORMAL;
+ first = false;
}
- } else {
- StringID str = STR_INDUSTRY_VIEW_REQUIRES_CARGO;
- byte p = 0;
- for (byte j = 0; j < lengthof(i->accepts_cargo); j++) {
- if (i->accepts_cargo[j] == CT_INVALID) continue;
- has_accept = true;
- if (p > 0) str++;
- SetDParam(p++, CargoSpec::Get(i->accepts_cargo[j])->name);
- SetDParamStr(p++, cargo_suffix[j].text);
- }
- if (has_accept) {
- DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, str);
- y += FONT_HEIGHT_NORMAL;
+ switch (cargo_suffix[j].display) {
+ case CSD_CARGO_AMOUNT:
+ if (stockpiling) {
+ SetDParam(0, i->accepts_cargo[j]);
+ SetDParam(1, i->incoming_cargo_waiting[j]);
+ DrawString(left_side, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_ACCEPT_CARGO_AMOUNT);
+ break;
+ }
+ /* FALL THROUGH */
+
+ case CSD_CARGO:
+ SetDParam(0, CargoSpec::Get(i->accepts_cargo[j])->name);
+ DrawString(left_side, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_ACCEPT_CARGO);
+ break;
+
+ case CSD_CARGO_TEXT:
+ SetDParam(0, CargoSpec::Get(i->accepts_cargo[j])->name);
+ SetDParamStr(1, cargo_suffix[j].text);
+ DrawString(left_side, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_ACCEPT_CARGO_TEXT);
+ break;
+
+ case CSD_CARGO_AMOUNT_TEXT:
+ SetDParam(0, i->accepts_cargo[j]);
+ SetDParam(1, i->incoming_cargo_waiting[j]);
+ SetDParamStr(2, cargo_suffix[j].text);
+ DrawString(left_side, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_ACCEPT_CARGO_AMOUNT_TEXT);
+ break;
+
+ default:
+ NOT_REACHED();
}
+ y += FONT_HEIGHT_NORMAL;
}
GetAllCargoSuffixes(3, CST_VIEW, i, i->type, ind, i->produced_cargo, cargo_suffix);
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 83b6591f6..8d931307a 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3294,9 +3294,13 @@ STR_INDUSTRY_VIEW_REQUIRES_CARGO_CARGO :{BLACK}Requires
STR_INDUSTRY_VIEW_REQUIRES_CARGO_CARGO_CARGO :{BLACK}Requires: {YELLOW}{STRING}{RAW_STRING}, {STRING}{RAW_STRING}, {STRING}{RAW_STRING}
############ range for requires ends
+STR_INDUSTRY_VIEW_REQUIRES :{BLACK}Requires
+STR_INDUSTRY_VIEW_ACCEPT_CARGO :{YELLOW}{STRING}
+STR_INDUSTRY_VIEW_ACCEPT_CARGO_AMOUNT :{YELLOW}{CARGO_LONG} {BLACK}waiting
+STR_INDUSTRY_VIEW_ACCEPT_CARGO_TEXT :{YELLOW}{STRING}{RAW_STRING}
+STR_INDUSTRY_VIEW_ACCEPT_CARGO_AMOUNT_TEXT :{YELLOW}{CARGO_LONG}{RAW_STRING}
+
############ range for produces starts
-STR_INDUSTRY_VIEW_WAITING_FOR_PROCESSING :{BLACK}Cargo waiting to be processed:
-STR_INDUSTRY_VIEW_WAITING_STOCKPILE_CARGO :{YELLOW}{CARGO_LONG}{RAW_STRING}{BLACK}
STR_INDUSTRY_VIEW_PRODUCES_CARGO :{BLACK}Produces: {YELLOW}{STRING}{RAW_STRING}
STR_INDUSTRY_VIEW_PRODUCES_CARGO_CARGO :{BLACK}Produces: {YELLOW}{STRING}{RAW_STRING}, {STRING}{RAW_STRING}
############ range for produces ends