diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/economy.cpp | 6 | ||||
-rw-r--r-- | src/industry_gui.cpp | 100 | ||||
-rw-r--r-- | src/lang/english.txt | 3 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 2 |
4 files changed, 86 insertions, 25 deletions
diff --git a/src/economy.cpp b/src/economy.cpp index 3eb8bdabc..46f3c14d6 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -1242,7 +1242,11 @@ static void DeliverGoodsToIndustry(TileIndex xy, CargoID cargo_type, int num_pie if (HASBIT(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HASBIT(callback, CBM_IND_PRODUCTION_256_TICKS)) { best->incoming_cargo_waiting[accepted_cargo_index] = min(num_pieces + best->incoming_cargo_waiting[accepted_cargo_index], 0xFFFF); - if (HASBIT(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) IndustryProductionCallback(ind, 0); + if (HASBIT(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL)) { + IndustryProductionCallback(best, 0); + } else { + InvalidateWindow(WC_INDUSTRY_VIEW, best->index); + } } else { best->produced_cargo_waiting[0] = min(best->produced_cargo_waiting[0] + (num_pieces * indspec->input_cargo_multiplier[accepted_cargo_index][0] / 256), 0xFFFF); best->produced_cargo_waiting[1] = min(best->produced_cargo_waiting[1] + (num_pieces * indspec->input_cargo_multiplier[accepted_cargo_index][1] / 256), 0xFFFF); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index fb1481145..9da1fb78f 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -20,6 +20,10 @@ #include "variables.h" #include "helpers.hpp" #include "cargotype.h" +#include "newgrf.h" +#include "newgrf_callbacks.h" +#include "newgrf_industries.h" +#include "newgrf_text.h" /* industries per climate, according to the different construction windows */ const byte _build_industry_types[4][12] = { @@ -299,14 +303,57 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) * WP(w,vp2_d).data_3 is for the click pos (left or right) */ switch (e->event) { + case WE_CREATE: { + /* Count the number of lines that we need to resize the GUI with */ + const IndustrySpec *ind = GetIndustrySpec(GetIndustry(w->window_number)->type); + int lines = -3; + + if (HASBIT(ind->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HASBIT(ind->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) { + for (uint j = 0; j < 3 && ind->accepts_cargo[j] != CT_INVALID; j++) { + if (j == 0) lines++; + lines++; + } + } else if (ind->accepts_cargo[0] != CT_INVALID) { + lines++; + } + + for (uint j = 0; j < 2 && ind->produced_cargo[j] != CT_INVALID; j++) { + if (j == 0) { + if (ind->accepts_cargo[0] != CT_INVALID) lines++; + lines++; + } + lines++; + } + + if (HASBIT(ind->callback_flags, CBM_IND_WINDOW_MORE_TEXT)) lines += 2; + + for (uint j = 5; j <= 7; j++) { + if (j != 5) w->widget[j].top += lines * 10; + w->widget[j].bottom += lines * 10; + } + w->height += lines * 10; + } break; + case WE_PAINT: { - const Industry *i = GetIndustry(w->window_number); + Industry *i = GetIndustry(w->window_number); const IndustrySpec *ind = GetIndustrySpec(i->type); + int y = 111; SetDParam(0, w->window_number); DrawWindowWidgets(w); - if (ind->accepts_cargo[0] != CT_INVALID) { + if (HASBIT(ind->callback_flags, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HASBIT(ind->callback_flags, CBM_IND_PRODUCTION_256_TICKS)) { + for (uint j = 0; j < 3 && ind->accepts_cargo[j] != CT_INVALID; j++) { + if (j == 0) { + DrawString(2, y, STR_INDUSTRY_WINDOW_WAITING_FOR_PROCESSING, 0); + y += 10; + } + SetDParam(0, ind->accepts_cargo[j]); + SetDParam(1, i->incoming_cargo_waiting[j]); + DrawString(4, y, STR_INDUSTRY_WINDOW_WAITING_STOCKPILE_CARGO, 0); + y += 10; + } + } else if (ind->accepts_cargo[0] != CT_INVALID) { StringID str; SetDParam(0, GetCargo(ind->accepts_cargo[0])->name); @@ -319,39 +366,44 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) str = STR_4829_REQUIRES; } } - DrawString(2, 107, str, 0); + DrawString(2, y, str, 0); + y += 10; } - if (ind->produced_cargo[0] != CT_INVALID) { - DrawString(2, 117, STR_482A_PRODUCTION_LAST_MONTH, 0); + for (uint j = 0; j < 2 && ind->produced_cargo[j] != CT_INVALID; j++) { + if (j == 0) { + if (ind->accepts_cargo[0] != CT_INVALID) y += 10; + DrawString(2, y, STR_482A_PRODUCTION_LAST_MONTH, 0); + y += 10; + } - SetDParam(0, ind->produced_cargo[0]); - SetDParam(1, i->last_month_production[0]); + SetDParam(0, ind->produced_cargo[j]); + SetDParam(1, i->last_month_production[j]); - SetDParam(2, i->last_month_pct_transported[0] * 100 >> 8); - DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 127, STR_482B_TRANSPORTED, 0); + SetDParam(2, i->last_month_pct_transported[j] * 100 >> 8); + DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), y, STR_482B_TRANSPORTED, 0); /* Let's put out those buttons.. */ if (IsProductionAlterable(i)) { - DrawArrowButtons(5, 127, 3, (WP(w, vp2_d).data_2 == 1) ? WP(w, vp2_d).data_3 : 0, - !isProductionMinimum(i, 0), !isProductionMaximum(i, 0)); + DrawArrowButtons(5, y, 3, (WP(w, vp2_d).data_2 == j + 1) ? WP(w, vp2_d).data_3 : 0, + !isProductionMinimum(i, j), !isProductionMaximum(i, j)); } + y += 10; + } - if (ind->produced_cargo[1] != CT_INVALID) { - SetDParam(0, ind->produced_cargo[1]); - SetDParam(1, i->last_month_production[1]); - SetDParam(2, i->last_month_pct_transported[1] * 100 >> 8); - DrawString(4 + (IsProductionAlterable(i) ? 30 : 0), 137, STR_482B_TRANSPORTED, 0); - /* Let's put out those buttons.. */ - if (IsProductionAlterable(i)) { - DrawArrowButtons(5, 137, 3, (WP(w, vp2_d).data_2 == 2) ? WP(w, vp2_d).data_3 : 0, - !isProductionMinimum(i, 1), !isProductionMaximum(i, 1)); + /* Get the extra message for the GUI */ + if (HASBIT(ind->callback_flags, CBM_IND_WINDOW_MORE_TEXT)) { + uint16 callback_res = GetIndustryCallback(CBID_INDUSTRY_WINDOW_MORE_TEXT, 0, 0, i, i->type, i->xy); + if (callback_res != CALLBACK_FAILED) { + StringID message = GetGRFStringID(ind->grf_prop.grffile->grfid, 0xD000 + callback_res); + if (message != STR_NULL && message != STR_UNDEFINED) { + y += 10; + DrawString(2, y, message, 0); } } } DrawWindowViewport(w); - } - break; + } break; case WE_CLICK: { Industry *i; @@ -366,8 +418,8 @@ static void IndustryViewWndProc(Window *w, WindowEvent *e) if (!IsProductionAlterable(i)) return; x = e->we.click.pt.x; - line = (e->we.click.pt.y - 127) / 10; - if (e->we.click.pt.y >= 127 && IS_INT_INSIDE(line, 0, 2) && + line = (e->we.click.pt.y - 121) / 10; + if (e->we.click.pt.y >= 121 && IS_INT_INSIDE(line, 0, 2) && GetIndustrySpec(i->type)->produced_cargo[line] != CT_INVALID) { if (IS_INT_INSIDE(x, 5, 25) ) { /* Clicked buttons, decrease or increase production */ diff --git a/src/lang/english.txt b/src/lang/english.txt index 16f51ca43..d60aa428c 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1980,6 +1980,9 @@ STR_4828_REQUIRES :{BLACK}Requires STR_4829_REQUIRES :{BLACK}Requires: {YELLOW}{STRING}, {STRING}, {STRING} ############ range for requires ends +STR_INDUSTRY_WINDOW_WAITING_FOR_PROCESSING :{BLACK}Cargo waiting to be processed: +STR_INDUSTRY_WINDOW_WAITING_STOCKPILE_CARGO :{YELLOW}{CARGO}{BLACK} + STR_482A_PRODUCTION_LAST_MONTH :{BLACK}Production last month: STR_482B_TRANSPORTED :{YELLOW}{CARGO}{BLACK} ({COMMA}% transported) STR_482C_CENTER_THE_MAIN_VIEW_ON :{BLACK}Centre the main view on industry location diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 6eb97ebee..6e43322fb 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -295,4 +295,6 @@ void IndustryProductionCallback(Industry *ind, int reason) SB(object.callback_param2, 24, 8, again); } + + InvalidateWindow(WC_INDUSTRY_VIEW, ind->index); } |