From 16a948a463feb420d0a1fee654b54a4a7acf165e Mon Sep 17 00:00:00 2001 From: maedhros Date: Wed, 18 Apr 2007 14:23:30 +0000 Subject: (svn r9667) -Feature: Add the concept of cities. A (configurable) proportion of towns can start off larger, and will grow twice as quickly as other towns. They can also be placed specifically in the scenario editor. Thanks to TheJosh for the initial patch and the idea. --- src/main_gui.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/main_gui.cpp') diff --git a/src/main_gui.cpp b/src/main_gui.cpp index 807591171..7c65218a5 100644 --- a/src/main_gui.cpp +++ b/src/main_gui.cpp @@ -51,7 +51,7 @@ static int _rename_what = -1; static byte _terraform_size = 1; RailType _last_built_railtype; -static int _scengen_town_size = 2; // depress medium-sized towns per default +static int _scengen_town_size = 1; // depress medium-sized towns per default extern void GenerateIndustries(); extern bool GenerateTowns(); @@ -1406,7 +1406,9 @@ void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2) static void PlaceProc_Town(TileIndex tile) { - DoCommandP(tile, _scengen_town_size, 0, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); + uint32 size = min(_scengen_town_size, (int)TSM_CITY); + uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED; + DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); } @@ -1414,13 +1416,14 @@ static const Widget _scen_edit_town_gen_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, { WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, -{ WWT_PANEL, RESIZE_NONE, 7, 0, 159, 14, 81, 0x0, STR_NULL}, +{ WWT_PANEL, RESIZE_NONE, 7, 0, 159, 14, 94, 0x0, STR_NULL}, { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 16, 27, STR_0234_NEW_TOWN, STR_0235_CONSTRUCT_NEW_TOWN}, { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 29, 40, STR_023D_RANDOM_TOWN, STR_023E_BUILD_TOWN_IN_RANDOM_LOCATION}, { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 42, 53, STR_MANY_RANDOM_TOWNS, STR_RANDOM_TOWNS_TIP}, { WWT_TEXTBTN, RESIZE_NONE, 14, 2, 53, 68, 79, STR_02A1_SMALL, STR_02A4_SELECT_TOWN_SIZE}, { WWT_TEXTBTN, RESIZE_NONE, 14, 54, 105, 68, 79, STR_02A2_MEDIUM, STR_02A4_SELECT_TOWN_SIZE}, { WWT_TEXTBTN, RESIZE_NONE, 14, 106, 157, 68, 79, STR_02A3_LARGE, STR_02A4_SELECT_TOWN_SIZE}, +{ WWT_TEXTBTN, RESIZE_NONE, 14, 2, 157, 81, 92, STR_SCENARIO_EDITOR_CITY, STR_02A4_SELECT_TOWN_SIZE}, { WWT_LABEL, RESIZE_NONE, 7, 0, 147, 54, 67, STR_02A5_TOWN_SIZE, STR_NULL}, { WIDGETS_END}, }; @@ -1433,7 +1436,7 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) break; case WE_CREATE: - LowerWindowWidget(w, (_scengen_town_size - 1)+ 7); + LowerWindowWidget(w, _scengen_town_size + 7); break; case WE_CLICK: @@ -1443,10 +1446,12 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) break; case 5: {// random town Town *t; + uint size = min(_scengen_town_size, (int)TSM_CITY); + TownSizeMode mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED; HandleButtonClick(w, 5); _generating_world = true; - t = CreateRandomTown(20, _scengen_town_size); + t = CreateRandomTown(20, mode, size); _generating_world = false; if (t == NULL) { @@ -1466,10 +1471,10 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) break; } - case 7: case 8: case 9: - RaiseWindowWidget(w, (_scengen_town_size - 1) + 7); - _scengen_town_size = (e->we.click.widget - 7) + 1; - LowerWindowWidget(w, (_scengen_town_size - 1) + 7); + case 7: case 8: case 9: case 10: + RaiseWindowWidget(w, _scengen_town_size + 7); + _scengen_town_size = e->we.click.widget - 7; + LowerWindowWidget(w, _scengen_town_size + 7); SetWindowDirty(w); break; } @@ -1485,14 +1490,14 @@ static void ScenEditTownGenWndProc(Window *w, WindowEvent *e) break; case WE_ABORT_PLACE_OBJ: RaiseWindowButtons(w); - LowerWindowWidget(w, (_scengen_town_size - 1) + 7); + LowerWindowWidget(w, _scengen_town_size + 7); SetWindowDirty(w); break; } } static const WindowDesc _scen_edit_town_gen_desc = { - WDP_AUTO, WDP_AUTO, 160, 82, + WDP_AUTO, WDP_AUTO, 160, 95, WC_SCEN_TOWN_GEN, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, _scen_edit_town_gen_widgets, -- cgit v1.2.3-54-g00ecf