Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Expand all towns in the scenario editor #10215

Merged
merged 1 commit into from
Dec 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lang/english.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2851,6 +2851,8 @@ STR_FOUND_TOWN_RANDOM_TOWN_BUTTON :{BLACK}Random T
STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP :{BLACK}Found town in random location
STR_FOUND_TOWN_MANY_RANDOM_TOWNS :{BLACK}Many random towns
STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP :{BLACK}Cover the map with randomly placed towns
STR_FOUND_TOWN_EXPAND_ALL_TOWNS :{BLACK}Expand all towns
STR_FOUND_TOWN_EXPAND_ALL_TOWNS_TOOLTIP :{BLACK}Make all towns grow slightly

STR_FOUND_TOWN_NAME_TITLE :{YELLOW}Town name:
STR_FOUND_TOWN_NAME_EDITOR_TITLE :{BLACK}Enter town name
Expand Down
12 changes: 10 additions & 2 deletions src/town_gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,9 @@ static const NWidgetPart _nested_found_town_widgets[] = {
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_RANDOM_TOWN), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_RANDOM_TOWN_BUTTON, STR_FOUND_TOWN_RANDOM_TOWN_TOOLTIP), SetPadding(0, 2, 1, 2),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_MANY_RANDOM_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
SetDataTip(STR_FOUND_TOWN_MANY_RANDOM_TOWNS, STR_FOUND_TOWN_RANDOM_TOWNS_TOOLTIP), SetPadding(0, 2, 1, 2),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_TF_EXPAND_ALL_TOWNS), SetMinimalSize(156, 12), SetFill(1, 0),
SetDataTip(STR_FOUND_TOWN_EXPAND_ALL_TOWNS, STR_FOUND_TOWN_EXPAND_ALL_TOWNS_TOOLTIP), SetPadding(0, 2, 0, 2),
/* Town name selection. */
NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(156, 14), SetPadding(0, 2, 0, 2), SetDataTip(STR_FOUND_TOWN_NAME_TITLE, STR_NULL),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_TF_TOWN_NAME_EDITBOX), SetMinimalSize(156, 12), SetPadding(0, 2, 3, 2),
Expand Down Expand Up @@ -1155,7 +1157,7 @@ struct FoundTownWindow : Window {
void UpdateButtons(bool check_availability)
{
if (check_availability && _game_mode != GM_EDITOR) {
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
this->SetWidgetsDisabledState(true, WID_TF_RANDOM_TOWN, WID_TF_MANY_RANDOM_TOWNS, WID_TF_EXPAND_ALL_TOWNS, WID_TF_SIZE_LARGE, WIDGET_LIST_END);
this->SetWidgetsDisabledState(_settings_game.economy.found_town != TF_CUSTOM_LAYOUT,
WID_TF_LAYOUT_ORIGINAL, WID_TF_LAYOUT_BETTER, WID_TF_LAYOUT_GRID2, WID_TF_LAYOUT_GRID3, WID_TF_LAYOUT_RANDOM, WIDGET_LIST_END);
if (_settings_game.economy.found_town != TF_CUSTOM_LAYOUT) town_layout = _settings_game.economy.town_layout;
Expand Down Expand Up @@ -1222,6 +1224,12 @@ struct FoundTownWindow : Window {
break;
}

case WID_TF_EXPAND_ALL_TOWNS:
for (Town *t : Town::Iterate()) {
Command<CMD_EXPAND_TOWN>::Do(DC_EXEC, t->index, 0);
}
break;

case WID_TF_SIZE_SMALL: case WID_TF_SIZE_MEDIUM: case WID_TF_SIZE_LARGE: case WID_TF_SIZE_RANDOM:
this->town_size = (TownSize)(widget - WID_TF_SIZE_SMALL);
this->UpdateButtons(false);
Expand Down
1 change: 1 addition & 0 deletions src/widgets/town_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ enum TownFoundingWidgets {
WID_TF_NEW_TOWN, ///< Create a new town.
WID_TF_RANDOM_TOWN, ///< Randomly place a town.
WID_TF_MANY_RANDOM_TOWNS, ///< Randomly place many towns.
WID_TF_EXPAND_ALL_TOWNS, ///< Make all towns grow slightly.
WID_TF_TOWN_NAME_EDITBOX, ///< Editor for the town name.
WID_TF_TOWN_NAME_RANDOM, ///< Generate a random town name.
WID_TF_SIZE_SMALL, ///< Selection for a small town.
Expand Down