summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2014-09-25 19:27:07 +0000
committerpeter1138 <peter1138@openttd.org>2014-09-25 19:27:07 +0000
commitd9179d518ebd0c82c914e67a9c23f522124a1a6c (patch)
treeb001f3135031ac39f36a3db0f677a0ef43efe44e /src
parent4018795080b2ef8f86421307684efee85e2fb51e (diff)
downloadopenttd-d9179d518ebd0c82c914e67a9c23f522124a1a6c.tar.xz
(svn r26921) -Codechange: Adjust content window listing to fit icon size.
Diffstat (limited to 'src')
-rw-r--r--src/network/network_content_gui.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index 332cf1a53..1b4b7e030 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -297,6 +297,7 @@ class NetworkContentListWindow : public Window, ContentCallback {
bool auto_select; ///< Automatically select all content when the meta-data becomes available
StringFilter string_filter; ///< Filter for content list
QueryString filter_editbox; ///< Filter editbox;
+ Dimension checkbox_size; ///< Size of checkbox/"blot" sprite
const ContentInfo *selected; ///< The selected content info
int list_pos; ///< Our position in the list
@@ -481,6 +482,8 @@ public:
selected(NULL),
list_pos(0)
{
+ this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
+
this->CreateNestedTree();
this->vscroll = this->GetScrollbar(WID_NCL_SCROLLBAR);
this->FinishInitNested(WN_NETWORK_WINDOW_CONTENT_LIST);
@@ -516,6 +519,10 @@ public:
*size = maxdim(*size, GetStringBoundingBox(STR_CONTENT_FILTER_TITLE));
break;
+ case WID_NCL_CHECKBOX:
+ size->width = this->checkbox_size.width + WD_MATRIX_RIGHT + WD_MATRIX_LEFT;
+ break;
+
case WID_NCL_TYPE: {
Dimension d = *size;
for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
@@ -526,7 +533,7 @@ public:
}
case WID_NCL_MATRIX:
- resize->height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
+ resize->height = max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
size->height = 10 * resize->height;
break;
}
@@ -577,9 +584,11 @@ public:
const NWidgetBase *nwi_name = this->GetWidget<NWidgetBase>(WID_NCL_NAME);
const NWidgetBase *nwi_type = this->GetWidget<NWidgetBase>(WID_NCL_TYPE);
+ int line_height = max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL);
/* Fill the matrix with the information */
- int sprite_y_offset = WD_MATRIX_TOP + (FONT_HEIGHT_NORMAL - 10) / 2;
+ int sprite_y_offset = WD_MATRIX_TOP + (line_height - this->checkbox_size.height) / 2 - 1;
+ int text_y_offset = WD_MATRIX_TOP + (line_height - FONT_HEIGHT_NORMAL) / 2;
uint y = r.top;
int cnt = 0;
for (ConstContentIterator iter = this->content.Get(this->vscroll->GetPosition()); iter != this->content.End() && cnt < this->vscroll->GetCapacity(); iter++, cnt++) {
@@ -600,9 +609,9 @@ public:
DrawSprite(sprite, pal, nwi_checkbox->pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS;
- DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + WD_MATRIX_TOP, str, TC_BLACK, SA_HOR_CENTER);
+ DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK, SA_HOR_CENTER);
- DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + WD_MATRIX_TOP, ci->name, TC_BLACK);
+ DrawString(nwi_name->pos_x + WD_FRAMERECT_LEFT, nwi_name->pos_x + nwi_name->current_x - WD_FRAMERECT_RIGHT, y + text_y_offset, ci->name, TC_BLACK);
y += this->resize.step_height;
}
}