29 #include "table/strings.h" |
29 #include "table/strings.h" |
30 |
30 |
31 extern bool GenerateTowns(); |
31 extern bool GenerateTowns(); |
32 static int _scengen_town_size = 1; // depress medium-sized towns per default |
32 static int _scengen_town_size = 1; // depress medium-sized towns per default |
33 |
33 |
34 enum TownAuthorityWidget { |
|
35 TWA_CLOSEBOX = 0, |
|
36 TWA_CAPTION, |
|
37 TWA_RATING_INFO, |
|
38 TWA_COMMAND_LIST, |
|
39 TWA_SCROLLBAR, |
|
40 TWA_ACTION_INFO, |
|
41 TWA_EXECUTE, |
|
42 }; |
|
43 |
|
44 static const Widget _town_authority_widgets[] = { |
34 static const Widget _town_authority_widgets[] = { |
45 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TWA_CLOSEBOX |
35 { WWT_CLOSEBOX, RESIZE_NONE, 13, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, // TWA_CLOSEBOX |
46 { WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TWA_CAPTION |
36 { WWT_CAPTION, RESIZE_NONE, 13, 11, 316, 0, 13, STR_2022_LOCAL_AUTHORITY, STR_018C_WINDOW_TITLE_DRAG_THIS}, // TWA_CAPTION |
47 { WWT_PANEL, RESIZE_NONE, 13, 0, 316, 14, 105, 0x0, STR_NULL}, // TWA_RATING_INFO |
37 { WWT_PANEL, RESIZE_NONE, 13, 0, 316, 14, 105, 0x0, STR_NULL}, // TWA_RATING_INFO |
48 { WWT_PANEL, RESIZE_NONE, 13, 0, 304, 106, 157, 0x0, STR_2043_LIST_OF_THINGS_TO_DO_AT}, // TWA_COMMAND_LIST |
38 { WWT_PANEL, RESIZE_NONE, 13, 0, 304, 106, 157, 0x0, STR_2043_LIST_OF_THINGS_TO_DO_AT}, // TWA_COMMAND_LIST |
140 } |
130 } |
141 return -1; |
131 return -1; |
142 } |
132 } |
143 |
133 |
144 struct TownAuthorityWindow : Window { |
134 struct TownAuthorityWindow : Window { |
|
135 private: |
145 int sel_index; |
136 int sel_index; |
146 |
137 |
|
138 enum TownAuthorityWidget { |
|
139 TWA_CLOSEBOX = 0, |
|
140 TWA_CAPTION, |
|
141 TWA_RATING_INFO, |
|
142 TWA_COMMAND_LIST, |
|
143 TWA_SCROLLBAR, |
|
144 TWA_ACTION_INFO, |
|
145 TWA_EXECUTE, |
|
146 }; |
|
147 |
|
148 public: |
147 TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) : |
149 TownAuthorityWindow(const WindowDesc *desc, WindowNumber window_number) : |
148 Window(desc, window_number), sel_index(-1) |
150 Window(desc, window_number), sel_index(-1) |
149 { |
151 { |
150 this->vscroll.cap = 5; |
152 this->vscroll.cap = 5; |
151 |
153 |
269 static void ShowTownAuthorityWindow(uint town) |
271 static void ShowTownAuthorityWindow(uint town) |
270 { |
272 { |
271 AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc, town); |
273 AllocateWindowDescFront<TownAuthorityWindow>(&_town_authority_desc, town); |
272 } |
274 } |
273 |
275 |
274 |
|
275 enum TownViewWidget { |
|
276 TVW_CAPTION = 1, |
|
277 TVW_STICKY, |
|
278 TVW_CENTERVIEW = 6, |
|
279 TVW_SHOWAUTORITY, |
|
280 TVW_CHANGENAME, |
|
281 TVW_EXPAND, |
|
282 TVW_DELETE, |
|
283 }; |
|
284 |
|
285 struct TownViewWindow : Window { |
276 struct TownViewWindow : Window { |
|
277 private: |
|
278 |
|
279 enum TownViewWidget { |
|
280 TVW_CAPTION = 1, |
|
281 TVW_STICKY, |
|
282 TVW_CENTERVIEW = 6, |
|
283 TVW_SHOWAUTORITY, |
|
284 TVW_CHANGENAME, |
|
285 TVW_EXPAND, |
|
286 TVW_DELETE, |
|
287 }; |
|
288 |
|
289 public: |
286 TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
290 TownViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
287 { |
291 { |
288 const Town *t = GetTown(this->window_number); |
292 const Town *t = GetTown(this->window_number); |
289 |
293 |
290 this->flags4 |= WF_DISABLE_VP_SCROLL; |
294 this->flags4 |= WF_DISABLE_VP_SCROLL; |
474 DEBUG(misc, 3, "Resorting towns list"); |
478 DEBUG(misc, 3, "Resorting towns list"); |
475 } |
479 } |
476 |
480 |
477 |
481 |
478 struct TownDirectoryWindow : public Window { |
482 struct TownDirectoryWindow : public Window { |
|
483 private: |
479 enum TownDirectoryWidget { |
484 enum TownDirectoryWidget { |
480 TDW_SORTNAME = 3, |
485 TDW_SORTNAME = 3, |
481 TDW_SORTPOPULATION, |
486 TDW_SORTPOPULATION, |
482 TDW_CENTERTOWN, |
487 TDW_CENTERTOWN, |
483 }; |
488 }; |
484 |
489 |
|
490 public: |
485 TownDirectoryWindow(const WindowDesc *desc) : Window(desc, 0) |
491 TownDirectoryWindow(const WindowDesc *desc) : Window(desc, 0) |
486 { |
492 { |
487 this->vscroll.cap = 16; |
493 this->vscroll.cap = 16; |
488 this->resize.step_height = 10; |
494 this->resize.step_height = 10; |
489 this->resize.height = this->height - 10 * 6; // minimum of 10 items in the list, each item 10 high |
495 this->resize.height = this->height - 10 * 6; // minimum of 10 items in the list, each item 10 high |
600 { |
606 { |
601 uint32 size = min(_scengen_town_size, (int)TSM_CITY); |
607 uint32 size = min(_scengen_town_size, (int)TSM_CITY); |
602 uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED; |
608 uint32 mode = _scengen_town_size > TSM_CITY ? TSM_CITY : TSM_FIXED; |
603 DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); |
609 DoCommandP(tile, size, mode, CcBuildTown, CMD_BUILD_TOWN | CMD_MSG(STR_0236_CAN_T_BUILD_TOWN_HERE)); |
604 } |
610 } |
605 |
|
606 enum TownScenarioEditorWidget { |
|
607 TSEW_NEWTOWN = 4, |
|
608 TSEW_RANDOMTOWN, |
|
609 TSEW_MANYRANDOMTOWNS, |
|
610 TSEW_SMALLTOWN, |
|
611 TSEW_MEDIUMTOWN, |
|
612 TSEW_LARGETOWN, |
|
613 TSEW_CITY, |
|
614 }; |
|
615 |
611 |
616 static const Widget _scen_edit_town_gen_widgets[] = { |
612 static const Widget _scen_edit_town_gen_widgets[] = { |
617 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
613 { WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
618 { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
614 { WWT_CAPTION, RESIZE_NONE, 7, 11, 147, 0, 13, STR_0233_TOWN_GENERATION, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
619 { WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, |
615 { WWT_STICKYBOX, RESIZE_NONE, 7, 148, 159, 0, 13, 0x0, STR_STICKY_BUTTON}, |
629 { WIDGETS_END}, |
625 { WIDGETS_END}, |
630 }; |
626 }; |
631 |
627 |
632 struct ScenarioEditorTownGenerationWindow : Window |
628 struct ScenarioEditorTownGenerationWindow : Window |
633 { |
629 { |
|
630 private: |
|
631 enum TownScenarioEditorWidget { |
|
632 TSEW_NEWTOWN = 4, |
|
633 TSEW_RANDOMTOWN, |
|
634 TSEW_MANYRANDOMTOWNS, |
|
635 TSEW_SMALLTOWN, |
|
636 TSEW_MEDIUMTOWN, |
|
637 TSEW_LARGETOWN, |
|
638 TSEW_CITY, |
|
639 }; |
|
640 |
|
641 public: |
|
642 |
634 ScenarioEditorTownGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
643 ScenarioEditorTownGenerationWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) |
635 { |
644 { |
636 this->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN); |
645 this->LowerWidget(_scengen_town_size + TSEW_SMALLTOWN); |
637 } |
646 } |
638 |
647 |