diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp --- a/src/intro_gui.cpp +++ b/src/intro_gui.cpp @@ -59,14 +59,19 @@ struct SelectGameWindow : public Window { this->InitNested(desc); this->LowerWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE); + this->SetLandscapeButtons(); } - virtual void OnPaint() + void SetLandscapeButtons() { this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC); this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC); this->SetWidgetLoweredState(SGI_TOYLAND_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TOYLAND); + } + + virtual void OnPaint() + { SetDParam(0, STR_DIFFICULTY_LEVEL_EASY + _settings_newgame.difficulty.diff_level); this->DrawWidgets(); } @@ -105,6 +110,7 @@ struct SelectGameWindow : public Window case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE: this->RaiseWidget(_settings_newgame.game_creation.landscape + SGI_TEMPERATE_LANDSCAPE); SetNewLandscapeType(widget - SGI_TEMPERATE_LANDSCAPE); + this->SetLandscapeButtons(); break; case SGI_OPTIONS: ShowGameOptions(); break; @@ -132,36 +138,30 @@ static const NWidgetPart _nested_select_ /* 'generate game' and 'load game' buttons */ NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_GENERATE_GAME), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), + SetDataTip(STR_INTRO_NEW_GAME, STR_INTRO_TOOLTIP_NEW_GAME), SetPadding(0, 0, 0, 10), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_LOAD_GAME), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), + SetDataTip(STR_INTRO_LOAD_GAME, STR_INTRO_TOOLTIP_LOAD_GAME), SetPadding(0, 10, 0, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 6), /* 'play scenario' and 'play heightmap' buttons */ NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_PLAY_SCENARIO), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), + SetDataTip(STR_INTRO_PLAY_SCENARIO, STR_INTRO_TOOLTIP_PLAY_SCENARIO), SetPadding(0, 0, 0, 10), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_PLAY_HEIGHTMAP), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_PLAY_HEIGHTMAP_TOOLTIP), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), + SetDataTip(STR_INTRO_PLAY_HEIGHTMAP, STR_INTRO_PLAY_HEIGHTMAP_TOOLTIP), SetPadding(0, 10, 0, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 6), /* 'edit scenario' and 'play multiplayer' buttons */ NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_EDIT_SCENARIO), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), + SetDataTip(STR_INTRO_SCENARIO_EDITOR, STR_INTRO_TOOLTIP_SCENARIO_EDITOR), SetPadding(0, 0, 0, 10), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_PLAY_NETWORK), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), + SetDataTip(STR_INTRO_MULTIPLAYER, STR_INTRO_TOOLTIP_MULTIPLAYER), SetPadding(0, 10, 0, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 7), @@ -186,36 +186,30 @@ static const NWidgetPart _nested_select_ /* 'game options' and 'difficulty options' buttons */ NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_OPTIONS), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), + SetDataTip(STR_INTRO_GAME_OPTIONS, STR_INTRO_TOOLTIP_GAME_OPTIONS), SetPadding(0, 0, 0, 10), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_DIFFICULTIES), SetMinimalSize(158, 12), - SetDataTip(STR_INTRO_DIFFICULTY, STR_INTRO_TOOLTIP_DIFFICULTY_OPTIONS), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), + SetDataTip(STR_INTRO_DIFFICULTY, STR_INTRO_TOOLTIP_DIFFICULTY_OPTIONS), SetPadding(0, 10, 0, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 6), /* 'advanced settings' and 'newgrf settings' buttons */ NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_SETTINGS_OPTIONS), SetMinimalSize(158, 12), - SetDataTip(STR_CONFIG_SETTING, STR_CONFIG_SETTING_TIP), + SetDataTip(STR_CONFIG_SETTING, STR_CONFIG_SETTING_TIP), SetPadding(0, 0, 0, 10), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_GRF_SETTINGS), SetMinimalSize(158, 12), - SetDataTip(STR_NEWGRF_SETTINGS_BUTTON, STR_NEWGRF_SETTINGS_BUTTON_TIP), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), + SetDataTip(STR_NEWGRF_SETTINGS_BUTTON, STR_NEWGRF_SETTINGS_BUTTON_TIP), SetPadding(0, 10, 0, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 6), /* 'online content' and 'ai settings' buttons */ NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_CONTENT_DOWNLOAD), SetMinimalSize(158, 12), - SetDataTip(STR_CONTENT_INTRO_BUTTON, STR_CONTENT_INTRO_BUTTON_TIP), + SetDataTip(STR_CONTENT_INTRO_BUTTON, STR_CONTENT_INTRO_BUTTON_TIP), SetPadding(0, 0, 0, 10), NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, SGI_AI_SETTINGS), SetMinimalSize(158, 12), - SetDataTip(STR_AI_SETTINGS_BUTTON, STR_AI_SETTINGS_BUTTON_TIP), - NWidget(NWID_SPACER), SetMinimalSize(10, 0), + SetDataTip(STR_AI_SETTINGS_BUTTON, STR_AI_SETTINGS_BUTTON_TIP), SetPadding(0, 10, 0, 0), EndContainer(), NWidget(NWID_SPACER), SetMinimalSize(0, 6), diff --git a/src/town_gui.cpp b/src/town_gui.cpp --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -524,11 +524,13 @@ static const NWidgetPart _nested_town_di EndContainer(), }; +/** Town directory window class. */ struct TownDirectoryWindow : public Window { private: /* Runtime saved values */ static Listing last_sorting; static const Town *last_town; + int townline_height; ///< Height of a single town line in the town directory window. /* Constants for sorting towns */ static GUITownList::SortFunction * const sorter_funcs[]; @@ -588,6 +590,7 @@ private: public: TownDirectoryWindow(const WindowDesc *desc) : Window() { + this->townline_height = FONT_HEIGHT_NORMAL; this->InitNested(desc, 0); this->vscroll.cap = this->nested_array[TDW_CENTERTOWN]->current_y / this->resize.step_height; @@ -615,7 +618,7 @@ public: { int n = 0; uint16 i = this->vscroll.pos; - int y = 28; + int y = this->nested_array[TDW_CENTERTOWN]->pos_y + 2; while (i < this->towns.Length()) { const Town *t = this->towns[i]; @@ -626,7 +629,7 @@ public: SetDParam(1, t->population); DrawString(2, this->width - 2, y, STR_TOWN_DIRECTORY_TOWN); - y += 10; + y += this->townline_height; i++; if (++n == this->vscroll.cap) break; // max number of towns in 1 window } @@ -658,7 +661,7 @@ public: break; case TDW_CENTERTOWN: { // Click on Town Matrix - uint16 id_v = (pt.y - 28) / 10; + uint16 id_v = (pt.y - this->nested_array[widget]->pos_y - 2) / this->townline_height; if (id_v >= this->vscroll.cap) return; // click out of bounds @@ -685,7 +688,7 @@ public: virtual void OnResize(Point delta) { - this->vscroll.cap += delta.y / 10; + this->vscroll.cap += delta.y / this->townline_height; } virtual void OnInvalidateData(int data) @@ -802,6 +805,7 @@ static const NWidgetPart _nested_found_t EndContainer(), }; +/** Found a town window class. */ struct FoundTownWindow : Window { private: