summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/industry_gui.cpp85
-rw-r--r--src/lang/english.txt8
-rw-r--r--src/widgets/industry_widget.h13
3 files changed, 81 insertions, 25 deletions
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 58f4a6097..f3d61ec6d 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -37,6 +37,7 @@
#include "smallmap_gui.h"
#include "widgets/dropdown_type.h"
#include "widgets/industry_widget.h"
+#include "clear_map.h"
#include "table/strings.h"
@@ -244,6 +245,14 @@ static const NWidgetPart _nested_build_industry_widgets[] = {
NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
EndContainer(),
+ NWidget(NWID_SELECTION, COLOUR_DARK_GREEN, WID_DPI_SCENARIO_EDITOR_PANE),
+ NWidget(NWID_VERTICAL),
+ NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET), SetMinimalSize(0, 12), SetFill(1, 0), SetResize(1, 0),
+ SetDataTip(STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP),
+ NWidget(WWT_TEXTBTN, COLOUR_DARK_GREEN, WID_DPI_REMOVE_ALL_INDUSTRIES_WIDGET), SetMinimalSize(0, 12), SetFill(1, 0), SetResize(1, 0),
+ SetDataTip(STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES, STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_TOOLTIP),
+ EndContainer(),
+ EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_MATRIX, COLOUR_DARK_GREEN, WID_DPI_MATRIX_WIDGET), SetMatrixDataTip(1, 0, STR_FUND_INDUSTRY_SELECTION_TOOLTIP), SetFill(1, 0), SetResize(1, 1), SetScrollbar(WID_DPI_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_DPI_SCROLLBAR),
@@ -289,11 +298,6 @@ class BuildIndustryWindow : public Window {
this->enabled[i] = false;
}
- if (_game_mode == GM_EDITOR) { // give room for the Many Random "button"
- this->index[this->count] = INVALID_INDUSTRYTYPE;
- this->enabled[this->count] = true;
- this->count++;
- }
/* Fill the arrays with industries.
* The tests performed after the enabled allow to load the industries
* In the same way they are inserted by grf (if any)
@@ -392,6 +396,13 @@ public:
this->FinishInitNested(0);
this->SetButtons();
+
+ /* Show scenario editor tools in editor. */
+ if (_game_mode != GM_EDITOR) {
+ auto *se_tools = this->GetWidget<NWidgetStacked>(WID_DPI_SCENARIO_EDITOR_PANE);
+ se_tools->SetDisplayedPlane(SZSP_HORIZONTAL);
+ this->ReInit();
+ }
}
void OnInit() override
@@ -578,9 +589,53 @@ public:
}
}
+ static void AskManyRandomIndustriesCallback(Window *w, bool confirmed)
+ {
+ if (!confirmed) return;
+
+ if (Town::GetNumItems() == 0) {
+ ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO);
+ } else {
+ extern void GenerateIndustries();
+ _generating_world = true;
+ GenerateIndustries();
+ _generating_world = false;
+ }
+ }
+
+ static void AskRemoveAllIndustriesCallback(Window *w, bool confirmed)
+ {
+ if (!confirmed) return;
+
+ for (Industry* industry : Industry::Iterate()) delete industry;
+
+ /* Clear farmland. */
+ for (TileIndex tile = 0; tile < MapSize(); tile++) {
+ if (IsTileType(tile, MP_CLEAR) && GetRawClearGround(tile) == CLEAR_FIELDS) {
+ MakeClear(tile, CLEAR_GRASS, 3);
+ }
+ }
+
+ MarkWholeScreenDirty();
+ }
+
void OnClick(Point pt, int widget, int click_count) override
{
switch (widget) {
+ case WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET: {
+ assert(_game_mode == GM_EDITOR);
+ this->HandleButtonClick(WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET);
+ ShowQuery(STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_CAPTION, STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_QUERY, nullptr, AskManyRandomIndustriesCallback);
+ break;
+ }
+
+ case WID_DPI_REMOVE_ALL_INDUSTRIES_WIDGET: {
+ assert(_game_mode == GM_EDITOR);
+ this->HandleButtonClick(WID_DPI_REMOVE_ALL_INDUSTRIES_WIDGET);
+ ShowQuery(STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_CAPTION, STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_QUERY, nullptr, AskRemoveAllIndustriesCallback);
+ break;
+ }
+
case WID_DPI_MATRIX_WIDGET: {
int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_DPI_MATRIX_WIDGET);
if (y < this->count) { // Is it within the boundaries of available data?
@@ -610,22 +665,14 @@ public:
break;
case WID_DPI_FUND_WIDGET: {
- if (this->selected_type == INVALID_INDUSTRYTYPE) {
- this->HandleButtonClick(WID_DPI_FUND_WIDGET);
-
- if (Town::GetNumItems() == 0) {
- ShowErrorMessage(STR_ERROR_CAN_T_GENERATE_INDUSTRIES, STR_ERROR_MUST_FOUND_TOWN_FIRST, WL_INFO);
+ if (this->selected_type != INVALID_INDUSTRYTYPE)
+ {
+ if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
+ DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY));
+ this->HandleButtonClick(WID_DPI_FUND_WIDGET);
} else {
- extern void GenerateIndustries();
- _generating_world = true;
- GenerateIndustries();
- _generating_world = false;
+ HandlePlacePushButton(this, WID_DPI_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT);
}
- } else if (_game_mode != GM_EDITOR && _settings_game.construction.raw_industry_construction == 2 && GetIndustrySpec(this->selected_type)->IsRawIndustry()) {
- DoCommandP(0, this->selected_type, InteractiveRandom(), CMD_BUILD_INDUSTRY | CMD_MSG(STR_ERROR_CAN_T_CONSTRUCT_THIS_INDUSTRY));
- this->HandleButtonClick(WID_DPI_FUND_WIDGET);
- } else {
- HandlePlacePushButton(this, WID_DPI_FUND_WIDGET, SPR_CURSOR_INDUSTRY, HT_RECT);
}
break;
}
diff --git a/src/lang/english.txt b/src/lang/english.txt
index dc184aa31..567d23820 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2605,12 +2605,18 @@ STR_FOUND_TOWN_SELECT_LAYOUT_RANDOM :{BLACK}Random
# Fund new industry window
STR_FUND_INDUSTRY_CAPTION :{WHITE}Fund new industry
STR_FUND_INDUSTRY_SELECTION_TOOLTIP :{BLACK}Choose the appropriate industry from this list
-STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES :Many random industries
+STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES :{BLACK}Create random industries
STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_TOOLTIP :{BLACK}Cover the map with randomly placed industries
+STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_CAPTION :{WHITE}Create random industries
+STR_FUND_INDUSTRY_MANY_RANDOM_INDUSTRIES_QUERY :{YELLOW}Are you sure you want to create many random industries?
STR_FUND_INDUSTRY_INDUSTRY_BUILD_COST :{BLACK}Cost: {YELLOW}{CURRENCY_LONG}
STR_FUND_INDUSTRY_PROSPECT_NEW_INDUSTRY :{BLACK}Prospect
STR_FUND_INDUSTRY_BUILD_NEW_INDUSTRY :{BLACK}Build
STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY :{BLACK}Fund
+STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES :{BLACK}Remove all industries
+STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_TOOLTIP :{BLACK}Remove all industries currently present on the map
+STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_CAPTION :{WHITE}Remove all industries
+STR_FUND_INDUSTRY_REMOVE_ALL_INDUSTRIES_QUERY :{YELLOW}Are you sure you want to remove all industries?
# Industry cargoes window
STR_INDUSTRY_CARGOES_INDUSTRY_CAPTION :{WHITE}Industry chain for {STRING} industry
diff --git a/src/widgets/industry_widget.h b/src/widgets/industry_widget.h
index e9fb2b114..5e3a656c1 100644
--- a/src/widgets/industry_widget.h
+++ b/src/widgets/industry_widget.h
@@ -12,11 +12,14 @@
/** Widgets of the #BuildIndustryWindow class. */
enum DynamicPlaceIndustriesWidgets {
- WID_DPI_MATRIX_WIDGET, ///< Matrix of the industries.
- WID_DPI_SCROLLBAR, ///< Scrollbar of the matrix.
- WID_DPI_INFOPANEL, ///< Info panel about the industry.
- WID_DPI_DISPLAY_WIDGET, ///< Display chain button.
- WID_DPI_FUND_WIDGET, ///< Fund button.
+ WID_DPI_SCENARIO_EDITOR_PANE, ///< Pane containing SE-only widgets.
+ WID_DPI_REMOVE_ALL_INDUSTRIES_WIDGET, ///< Remove all industries button.
+ WID_DPI_CREATE_RANDOM_INDUSTRIES_WIDGET, ///< Create random industries button.
+ WID_DPI_MATRIX_WIDGET, ///< Matrix of the industries.
+ WID_DPI_SCROLLBAR, ///< Scrollbar of the matrix.
+ WID_DPI_INFOPANEL, ///< Info panel about the industry.
+ WID_DPI_DISPLAY_WIDGET, ///< Display chain button.
+ WID_DPI_FUND_WIDGET, ///< Fund button.
};
/** Widgets of the #IndustryViewWindow class. */