|
@@ -588,26 +588,32 @@ public:
|
|
|
}
|
|
|
|
|
|
virtual void OnTimeout()
|
|
|
{
|
|
|
this->RaiseButtons();
|
|
|
}
|
|
|
|
|
|
virtual void OnPlaceObjectAbort()
|
|
|
{
|
|
|
this->RaiseButtons();
|
|
|
}
|
|
|
|
|
|
virtual void OnInvalidateData(int data = 0)
|
|
|
/**
|
|
|
* Some data on this window has become invalid.
|
|
|
* @param data Information about the changed data.
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
*/
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
|
|
{
|
|
|
if (!gui_scope) return;
|
|
|
this->SetupArrays();
|
|
|
|
|
|
const IndustrySpec *indsp = (this->selected_type == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(this->selected_type);
|
|
|
if (indsp == NULL) this->enabled[this->selected_index] = _settings_game.difficulty.industry_density != ID_FUND_ONLY;
|
|
|
this->SetButtons();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
void ShowBuildIndustryWindow()
|
|
|
{
|
|
|
if (_game_mode != GM_EDITOR && !Company::IsValidID(_local_company)) return;
|
|
|
if (BringWindowToFrontById(WC_BUILD_INDUSTRY, 0)) return;
|
|
@@ -938,26 +944,32 @@ public:
|
|
|
case IL_MULTIPLIER:
|
|
|
i->prod_level = ClampU(RoundDivSU(value * PRODLEVEL_DEFAULT, 100), PRODLEVEL_MINIMUM, PRODLEVEL_MAXIMUM);
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
i->production_rate[this->editbox_line - IL_RATE1] = ClampU(RoundDivSU(value, 8), 0, 255);
|
|
|
break;
|
|
|
}
|
|
|
UpdateIndustryProduction(i);
|
|
|
this->SetDirty();
|
|
|
}
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
/**
|
|
|
* Some data on this window has become invalid.
|
|
|
* @param data Information about the changed data.
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
*/
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
|
|
{
|
|
|
if (!gui_scope) return;
|
|
|
const Industry *i = Industry::Get(this->window_number);
|
|
|
if (IsProductionAlterable(i)) {
|
|
|
const IndustrySpec *ind = GetIndustrySpec(i->type);
|
|
|
this->editable = ind->UsesSmoothEconomy() ? EA_RATE : EA_MULTIPLIER;
|
|
|
} else {
|
|
|
this->editable = EA_NONE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
virtual bool IsNewGRFInspectable() const
|
|
|
{
|
|
|
return ::IsNewGRFInspectable(GSF_INDUSTRIES, this->window_number);
|
|
@@ -1337,26 +1349,32 @@ public:
|
|
|
virtual void OnPaint()
|
|
|
{
|
|
|
if (this->industries.NeedRebuild()) this->BuildSortIndustriesList();
|
|
|
this->DrawWidgets();
|
|
|
}
|
|
|
|
|
|
virtual void OnHundredthTick()
|
|
|
{
|
|
|
this->industries.ForceResort();
|
|
|
this->BuildSortIndustriesList();
|
|
|
}
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
/**
|
|
|
* Some data on this window has become invalid.
|
|
|
* @param data Information about the changed data.
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
*/
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
|
|
{
|
|
|
if (!gui_scope) return;
|
|
|
/* We can only set the trigger for resorting/rebuilding.
|
|
|
* We cannot safely resort at this point, as there might be multiple scheduled invalidations,
|
|
|
* and a rebuild needs to be done first though it is scheduled later. */
|
|
|
if (data == 0) {
|
|
|
this->industries.ForceRebuild();
|
|
|
} else {
|
|
|
this->industries.ForceResort();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
|
|
|
Listing IndustryDirectoryWindow::last_sorting = {false, 0};
|
|
@@ -2385,31 +2403,33 @@ struct IndustryCargoesWindow : public Wi
|
|
|
this->PlaceIndustry(1 + cust_count * num_indrows / num_cust, 2, NUM_INDUSTRYTYPES);
|
|
|
cust_count++;
|
|
|
}
|
|
|
|
|
|
this->ShortenCargoColumn(1, 1, num_indrows);
|
|
|
const NWidgetBase *nwp = this->GetWidget<NWidgetBase>(ICW_PANEL);
|
|
|
this->vscroll->SetCount(CeilDiv(WD_FRAMETEXT_TOP + WD_FRAMETEXT_BOTTOM + CargoesField::small_height + num_indrows * CargoesField::normal_height, nwp->resize_y));
|
|
|
this->SetDirty();
|
|
|
this->NotifySmallmap();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Notify the window about external events.
|
|
|
* Some data on this window has become invalid.
|
|
|
* @param data Information about the changed data.
|
|
|
* - data = 0 .. NUM_INDUSTRYTYPES - 1: Display the chain around the given industry.
|
|
|
* - data = NUM_INDUSTRYTYPES: Stop sending updates to the smallmap window.
|
|
|
* @param data The event.
|
|
|
* @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
|
|
|
*/
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
|
|
|
{
|
|
|
if (!gui_scope) return;
|
|
|
if (data == NUM_INDUSTRYTYPES) {
|
|
|
if (this->IsWidgetLowered(ICW_NOTIFY)) {
|
|
|
this->RaiseWidget(ICW_NOTIFY);
|
|
|
this->SetWidgetDirty(ICW_NOTIFY);
|
|
|
}
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
assert(data >= 0 && data < NUM_INDUSTRYTYPES);
|
|
|
this->ComputeIndustryDisplay(data);
|
|
|
}
|
|
|
|