summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/misc_gui.cpp21
-rw-r--r--src/settings_gui.cpp36
-rw-r--r--src/widget.cpp16
-rw-r--r--src/window_gui.h8
4 files changed, 42 insertions, 39 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index d8c983d46..048f8fb8c 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -326,7 +326,8 @@ enum AboutWidgets {
AW_BACKGROUND, ///< Background to draw on
AW_ABOUT_ORIG_COPYRIGHT, ///< Text with original copyright info
AW_ABOUT_VERSION, ///< OpenTTD version string
- AW_FRAME, ///< The scrolling frame with goodies
+ AW_FRAME, ///< The frame with the scrolling text
+ AW_SCROLLING_TEXT, ///< The actually scrolling text
AW_WEBSITE, ///< URL of OpenTTD website
AW_ABOUT_COPYRIGHT, ///< OpenTTD copyright info
};
@@ -339,7 +340,9 @@ static const NWidgetPart _nested_about_widgets[] = {
NWidget(WWT_PANEL, COLOUR_GREY, AW_BACKGROUND), SetPIP(4, 2, 4),
NWidget(WWT_TEXT, COLOUR_GREY, AW_ABOUT_ORIG_COPYRIGHT), SetDataTip(STR_ABOUT_ORIGINAL_COPYRIGHT, STR_NULL),
NWidget(WWT_TEXT, COLOUR_GREY, AW_ABOUT_VERSION), SetDataTip(STR_ABOUT_VERSION, STR_NULL),
- NWidget(WWT_FRAME, COLOUR_GREY, AW_FRAME), SetPadding(0, 5, 1, 5), EndContainer(),
+ NWidget(WWT_FRAME, COLOUR_GREY, AW_FRAME), SetPadding(0, 5, 1, 5),
+ NWidget(WWT_EMPTY, INVALID_COLOUR, AW_SCROLLING_TEXT),
+ EndContainer(),
NWidget(WWT_TEXT, COLOUR_GREY, AW_WEBSITE), SetDataTip(STR_BLACK_RAW_STRING, STR_NULL),
NWidget(WWT_TEXT, COLOUR_GREY, AW_ABOUT_COPYRIGHT), SetDataTip(STR_ABOUT_COPYRIGHT_OPENTTD, STR_NULL),
EndContainer(),
@@ -421,7 +424,7 @@ struct AboutWindow : public Window {
this->InitNested(&_about_desc);
this->counter = 5;
- this->text_position = this->GetWidget<NWidgetBase>(AW_FRAME)->pos_y + this->GetWidget<NWidgetBase>(AW_FRAME)->current_y;
+ this->text_position = this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->current_y;
}
virtual void SetStringParameters(int widget) const
@@ -431,7 +434,7 @@ struct AboutWindow : public Window {
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *resize)
{
- if (widget != AW_FRAME) return;
+ if (widget != AW_SCROLLING_TEXT) return;
this->line_height = FONT_HEIGHT_NORMAL;
@@ -442,8 +445,6 @@ struct AboutWindow : public Window {
for (uint i = 0; i < lengthof(_credits); i++) {
d.width = max(d.width, GetStringBoundingBox(_credits[i]).width);
}
- d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT;
-
*size = maxdim(*size, d);
}
@@ -454,14 +455,14 @@ struct AboutWindow : public Window {
virtual void DrawWidget(const Rect &r, int widget) const
{
- if (widget != AW_FRAME) return;
+ if (widget != AW_SCROLLING_TEXT) return;
int y = this->text_position;
/* Show all scrolling _credits */
for (uint i = 0; i < lengthof(_credits); i++) {
if (y >= r.top + 7 && y < r.bottom - this->line_height) {
- DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, _credits[i], TC_BLACK, SA_LEFT | SA_FORCE);
+ DrawString(r.left, r.right, y, _credits[i], TC_BLACK, SA_LEFT | SA_FORCE);
}
y += this->line_height;
}
@@ -473,8 +474,8 @@ struct AboutWindow : public Window {
this->counter = 5;
this->text_position--;
/* If the last text has scrolled start a new from the start */
- if (this->text_position < (int)(this->GetWidget<NWidgetBase>(AW_FRAME)->pos_y - lengthof(_credits) * this->line_height)) {
- this->text_position = this->GetWidget<NWidgetBase>(AW_FRAME)->pos_y + this->GetWidget<NWidgetBase>(AW_FRAME)->current_y;
+ if (this->text_position < (int)(this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->pos_y - lengthof(_credits) * this->line_height)) {
+ this->text_position = this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->pos_y + this->GetWidget<NWidgetBase>(AW_SCROLLING_TEXT)->current_y;
}
this->SetDirty();
}
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 1f9606e2a..b2b63b743 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -436,54 +436,54 @@ static const NWidgetPart _nested_game_options_widgets[] = {
NWidget(NWID_HORIZONTAL), SetPIP(10, 10, 10),
NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_CURRENCY_FRAME), SetDataTip(STR_GAME_OPTIONS_CURRENCY_UNITS_FRAME, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_CURRENCY_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_CURRENCY_UNITS_DROPDOWN_TOOLTIP), SetFill(true, false),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_ROADSIDE_FRAME), SetDataTip(STR_GAME_OPTIONS_ROAD_VEHICLES_FRAME, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_ROADSIDE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_ROADSIDE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_ROAD_VEHICLES_DROPDOWN_TOOLTIP), SetFill(true, false),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_AUTOSAVE_FRAME), SetDataTip(STR_GAME_OPTIONS_AUTOSAVE_FRAME, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_AUTOSAVE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_AUTOSAVE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_AUTOSAVE_DROPDOWN_TOOLTIP), SetFill(true, false),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_RESOLUTION_FRAME), SetDataTip(STR_GAME_OPTIONS_RESOLUTION, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_RESOLUTION_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP), SetPadding(14, 10, 3, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_RESOLUTION_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_RESOLUTION_TOOLTIP), SetFill(true, false), SetPadding(0, 0, 3, 0),
NWidget(NWID_HORIZONTAL),
- NWidget(WWT_TEXT, COLOUR_GREY, GOW_FULLSCREEN_LABEL), SetMinimalSize(0, 12), SetFill(true, false), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL), SetPadding(0, 2, 4, 10),
- NWidget(WWT_TEXTBTN, COLOUR_GREY, GOW_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP), SetPadding(0, 10, 4, 0),
+ NWidget(WWT_TEXT, COLOUR_GREY, GOW_FULLSCREEN_LABEL), SetMinimalSize(0, 12), SetFill(true, false), SetDataTip(STR_GAME_OPTIONS_FULLSCREEN, STR_NULL),
+ NWidget(WWT_TEXTBTN, COLOUR_GREY, GOW_FULLSCREEN_BUTTON), SetMinimalSize(21, 9), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_FULLSCREEN_TOOLTIP),
EndContainer(),
EndContainer(),
EndContainer(),
NWidget(NWID_VERTICAL), SetPIP(0, 6, 0),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_DISTANCE_FRAME), SetDataTip(STR_GAME_OPTIONS_MEASURING_UNITS_FRAME, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_DISTANCE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_MEASURING_UNITS_DROPDOWN_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_DISTANCE_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_MEASURING_UNITS_DROPDOWN_TOOLTIP), SetFill(true, false),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_TOWNNAME_FRAME), SetDataTip(STR_GAME_OPTIONS_TOWN_NAMES_FRAME, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_TOWNNAME_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_TOWNNAME_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_TOWN_NAMES_DROPDOWN_TOOLTIP), SetFill(true, false),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_LANG_FRAME), SetDataTip(STR_GAME_OPTIONS_LANGUAGE, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_LANG_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_LANGUAGE_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_LANG_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_LANGUAGE_TOOLTIP), SetFill(true, false),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_SCREENSHOT_FRAME), SetDataTip(STR_GAME_OPTIONS_SCREENSHOT_FORMAT, STR_NULL),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_SCREENSHOT_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_SCREENSHOT_FORMAT_TOOLTIP), SetPadding(14, 10, 10, 10), SetFill(true, false),
- NWidget(NWID_SPACER), SetMinimalSize(0, 9),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_SCREENSHOT_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_STRING, STR_GAME_OPTIONS_SCREENSHOT_FORMAT_TOOLTIP), SetFill(true, false),
EndContainer(),
+ NWidget(NWID_SPACER), SetMinimalSize(0, 0), SetFill(false, true),
EndContainer(),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_BASE_GRF_FRAME), SetDataTip(STR_GAME_OPTIONS_BASE_GRF, STR_NULL), SetPadding(0, 10, 0, 10),
- NWidget(NWID_HORIZONTAL), SetPIP(10, 30, 10),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP), SetPadding(14, 0, 0, 0),
- NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetPadding(14, 0, 0, 0), SetFill(true, false),
+ NWidget(NWID_HORIZONTAL), SetPIP(00, 30, 0),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_GRF_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_GRF_TOOLTIP),
+ NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_GRF_STATUS), SetMinimalSize(150, 12), SetDataTip(STR_EMPTY, STR_NULL), SetFill(true, false),
EndContainer(),
- NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_GRF_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetPadding(6, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_GRF_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_GRF_DESCRIPTION_TOOLTIP), SetFill(true, false), SetPadding(6, 0, 0, 0),
EndContainer(),
NWidget(WWT_FRAME, COLOUR_GREY, GOW_BASE_SFX_FRAME), SetDataTip(STR_GAME_OPTIONS_BASE_SFX, STR_NULL), SetPadding(0, 10, 0, 10),
- NWidget(NWID_HORIZONTAL), SetPIP(10, 30, 10),
- NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP), SetPadding(14, 0, 0, 0),
+ NWidget(NWID_HORIZONTAL), SetPIP(0, 30, 0),
+ NWidget(WWT_DROPDOWN, COLOUR_GREY, GOW_BASE_SFX_DROPDOWN), SetMinimalSize(150, 12), SetDataTip(STR_BLACK_RAW_STRING, STR_GAME_OPTIONS_BASE_SFX_TOOLTIP),
NWidget(NWID_SPACER), SetFill(true, false),
EndContainer(),
- NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_SFX_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetPadding(6, 10, 10, 10), SetFill(true, false),
+ NWidget(WWT_TEXT, COLOUR_GREY, GOW_BASE_SFX_DESCRIPTION), SetMinimalSize(330, 0), SetDataTip(STR_EMPTY, STR_GAME_OPTIONS_BASE_SFX_DESCRIPTION_TOOLTIP), SetFill(true, false), SetPadding(6, 0, 0, 0),
EndContainer(),
EndContainer(),
};
diff --git a/src/widget.cpp b/src/widget.cpp
index 82fecbfea..fe13d0bd5 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -1461,16 +1461,16 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
/* Account for the size of the frame's text if that exists */
if (w != NULL && this->type == WWT_FRAME) {
+ this->child->padding_left = WD_FRAMETEXT_LEFT;
+ this->child->padding_right = WD_FRAMETEXT_RIGHT;
+ this->child->padding_top = max((int)WD_FRAMETEXT_TOP, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP / 2 : 0);
+ this->child->padding_bottom = WD_FRAMETEXT_BOTTOM;
+
+ this->smallest_x += this->child->padding_left + this->child->padding_right;
+ this->smallest_y += this->child->padding_top + this->child->padding_bottom;
+
if (this->index >= 0) w->SetStringParameters(this->index);
this->smallest_x = max(this->smallest_x, GetStringBoundingBox(this->widget_data).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
- if (this->widget_data != STR_NULL) {
- /* Adjust child's padding to fit text. We assume that the
- * original padding is designed around the 10 pixel high
- * sprite font. */
- int y = FONT_HEIGHT_NORMAL - 10;
- this->child->padding_top += y;
- this->smallest_y += y;
- }
}
} else {
Dimension d = {this->min_x, this->min_y};
diff --git a/src/window_gui.h b/src/window_gui.h
index 2ff13c5da..d0e0f48a2 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -60,11 +60,13 @@ enum WidgetDrawDistances {
/* Extra space at top/bottom of text panels */
WD_TEXTPANEL_TOP = 6, ///< Offset at top to draw above the text
- WD_TEXTPANEL_BOTTOM = 6, ///< Offset at bottom to draw below the text
+ WD_TEXTPANEL_BOTTOM = 6, ///< Offset at bottom to draw below the text
/* WWT_FRAME */
- WD_FRAMETEXT_LEFT = 6, ///< Left offset of the text of the frame.
- WD_FRAMETEXT_RIGHT = 6, ///< Right offset of the text of the frame.
+ WD_FRAMETEXT_LEFT = 6, ///< Left offset of the text of the frame.
+ WD_FRAMETEXT_RIGHT = 6, ///< Right offset of the text of the frame.
+ WD_FRAMETEXT_TOP = 6, ///< Top offset of the text of the frame
+ WD_FRAMETEXT_BOTTOM = 6, ///< Bottom offset of the text of the frame
/* WWT_MATRIX */
WD_MATRIX_LEFT = 2, ///< Offset at left of a matrix cell.