|
@@ -107,97 +107,97 @@ static void BuildDynamicIndustryWndProc(
|
|
|
w->resize.step_height = 13;
|
|
|
|
|
|
if (_game_mode == GM_EDITOR) { // give room for the Many Random "button"
|
|
|
_fund_gui.index[_fund_gui.count] = INVALID_INDUSTRYTYPE;
|
|
|
_fund_gui.count++;
|
|
|
WP(w, fnd_d).timer_enabled = false;
|
|
|
}
|
|
|
|
|
|
/* Fill the _fund_gui structure with industries.
|
|
|
* The tests performed after the enabled allow to load the industries
|
|
|
* In the same way they are inserted by grf (if any)
|
|
|
*/
|
|
|
for (ind = 0; ind < NUM_INDUSTRYTYPES; ind++) {
|
|
|
indsp = GetIndustrySpec(ind);
|
|
|
if (indsp->enabled){
|
|
|
/* Rule is that editor mode loads all industries.
|
|
|
* In game mode, all non raw industries are loaded too
|
|
|
* and raw ones are loaded only when setting allows it */
|
|
|
if (_game_mode != GM_EDITOR && indsp->IsRawIndustry() && _patches.raw_industry_construction == 0) continue;
|
|
|
_fund_gui.index[_fund_gui.count] = ind;
|
|
|
_fund_gui.enabled[_fund_gui.count] = (_game_mode == GM_EDITOR) || CheckIfCallBackAllowsAvailability(ind, IACT_USERCREATION);
|
|
|
_fund_gui.count++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* first indutry type is selected.
|
|
|
* I'll be damned if there are none available ;) */
|
|
|
WP(w, fnd_d).index = 0;
|
|
|
WP(w, fnd_d).select = _fund_gui.index[0];
|
|
|
WP(w, fnd_d).callback_timer = DAY_TICKS;
|
|
|
} break;
|
|
|
|
|
|
case WE_PAINT: {
|
|
|
const IndustrySpec *indsp = (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(WP(w, fnd_d).select);
|
|
|
int x_str = w->widget[DYNA_INDU_INFOPANEL].left + 3;
|
|
|
int y_str = w->widget[DYNA_INDU_INFOPANEL].top + 3;
|
|
|
const Widget *wi = &w->widget[DYNA_INDU_INFOPANEL];
|
|
|
int max_width = wi->right - wi->left - 4;
|
|
|
|
|
|
/* Raw industries might be prospected. Show this fact by changing the string
|
|
|
* In Editor, you just build, while ingame, or you fund or you prospect */
|
|
|
if (_game_mode == GM_EDITOR) {
|
|
|
/* We've chosen many random industries but no industries have been specified */
|
|
|
if (indsp == NULL) _fund_gui.enabled[WP(w, fnd_d).index] = _opt.diff.number_industries != 0;
|
|
|
w->widget[DYNA_INDU_FUND_WIDGET].data = STR_BUILD_NEW_INDUSTRY;
|
|
|
} else {
|
|
|
w->widget[DYNA_INDU_FUND_WIDGET].data = (_patches.raw_industry_construction == 2 && indsp->IsRawIndustry()) ? STR_PROSPECT_NEW_INDUSTRY : STR_FUND_NEW_INDUSTRY;
|
|
|
}
|
|
|
SetWindowWidgetDisabledState(w, DYNA_INDU_FUND_WIDGET, !_fund_gui.enabled[WP(w, fnd_d).index]);
|
|
|
w->SetWidgetDisabledState(DYNA_INDU_FUND_WIDGET, !_fund_gui.enabled[WP(w, fnd_d).index]);
|
|
|
|
|
|
SetVScrollCount(w, _fund_gui.count);
|
|
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
|
|
/* and now with the matrix painting */
|
|
|
for (byte i = 0; i < w->vscroll.cap && ((i + w->vscroll.pos) < _fund_gui.count); i++) {
|
|
|
int offset = i * 13;
|
|
|
int x = 3;
|
|
|
int y = 16;
|
|
|
bool selected = WP(w, fnd_d).index == i + w->vscroll.pos;
|
|
|
|
|
|
if (_fund_gui.index[i + w->vscroll.pos] == INVALID_INDUSTRYTYPE) {
|
|
|
DrawStringTruncated(20, y + offset, STR_MANY_RANDOM_INDUSTRIES, selected ? TC_WHITE : TC_ORANGE, max_width - 25);
|
|
|
continue;
|
|
|
}
|
|
|
const IndustrySpec *indsp = GetIndustrySpec(_fund_gui.index[i + w->vscroll.pos]);
|
|
|
|
|
|
/* Draw the name of the industry in white is selected, otherwise, in orange */
|
|
|
DrawStringTruncated(20, y + offset, indsp->name, selected ? TC_WHITE : TC_ORANGE, max_width - 25);
|
|
|
GfxFillRect(x, y + 1 + offset, x + 10, y + 7 + offset, selected ? 15 : 0);
|
|
|
GfxFillRect(x + 1, y + 2 + offset, x + 9, y + 6 + offset, indsp->map_colour);
|
|
|
}
|
|
|
|
|
|
if (WP(w, fnd_d).select == INVALID_INDUSTRYTYPE) {
|
|
|
DrawStringMultiLine(x_str, y_str, STR_RANDOM_INDUSTRIES_TIP, max_width, wi->bottom - wi->top - 40);
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if (_game_mode != GM_EDITOR) {
|
|
|
SetDParam(0, indsp->GetConstructionCost());
|
|
|
DrawStringTruncated(x_str, y_str, STR_482F_COST, TC_FROMSTRING, max_width);
|
|
|
y_str += 11;
|
|
|
}
|
|
|
|
|
|
/* Draw the accepted cargos, if any. Otherwhise, will print "Nothing" */
|
|
|
StringID str = STR_4827_REQUIRES;
|
|
|
byte p = 0;
|
|
|
SetDParam(0, STR_00D0_NOTHING);
|
|
|
for (byte j = 0; j < lengthof(indsp->accepts_cargo); j++) {
|
|
|
if (indsp->accepts_cargo[j] == CT_INVALID) continue;
|
|
|
if (p > 0) str++;
|
|
|
SetDParam(p++, GetCargo(indsp->accepts_cargo[j])->name);
|
|
|
}
|
|
|
DrawStringTruncated(x_str, y_str, str, TC_FROMSTRING, max_width);
|
|
|
y_str += 11;
|
|
|
|
|
|
/* Draw the produced cargos, if any. Otherwhise, will print "Nothing" */
|