Merge branch 'master' into jgrpp
# Conflicts: # src/lang/korean.txt # src/misc_gui.cpp
This commit is contained in:
@@ -45,8 +45,8 @@ class BuildObjectWindow : public Window {
|
||||
typedef GUIList<ObjectClassID, StringFilter &> GUIObjectClassList; ///< Type definition for the list to hold available object classes.
|
||||
|
||||
static const uint EDITBOX_MAX_SIZE = 16; ///< The maximum number of characters for the filter edit box.
|
||||
static const int OBJECT_MARGIN = 4; ///< The margin (in pixels) around an object.
|
||||
|
||||
int object_margin; ///< The margin (in pixels) around an object.
|
||||
int line_height; ///< The height of a single line.
|
||||
int info_height; ///< The height of the info box.
|
||||
Scrollbar *vscroll; ///< The scrollbar.
|
||||
@@ -226,6 +226,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void OnInit() override
|
||||
{
|
||||
this->object_margin = ScaleGUITrad(4);
|
||||
}
|
||||
|
||||
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
|
||||
{
|
||||
switch (widget) {
|
||||
@@ -263,7 +268,7 @@ public:
|
||||
|
||||
case WID_BO_OBJECT_SPRITE: {
|
||||
bool two_wide = false; // Whether there will be two widgets next to each other in the matrix or not.
|
||||
int height[2] = {0, 0}; // The height for the different views; in this case views 1/2 and 4.
|
||||
uint height[2] = {0, 0}; // The height for the different views; in this case views 1/2 and 4.
|
||||
|
||||
/* Get the height and view information. */
|
||||
for (int i = 0; i < NUM_OBJECTS; i++) {
|
||||
@@ -276,26 +281,28 @@ public:
|
||||
/* Determine the pixel heights. */
|
||||
for (size_t i = 0; i < lengthof(height); i++) {
|
||||
height[i] *= ScaleGUITrad(TILE_HEIGHT);
|
||||
height[i] += ScaleGUITrad(TILE_PIXELS) + 2 * OBJECT_MARGIN;
|
||||
height[i] += ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
|
||||
}
|
||||
|
||||
/* Now determine the size of the minimum widgets. When there are two columns, then
|
||||
* we want these columns to be slightly less wide. When there are two rows, then
|
||||
* determine the size of the widgets based on the maximum size for a single row
|
||||
* of widgets, or just the twice the widget height of the two row ones. */
|
||||
size->height = std::max(height[0], height[1] * 2 + 2);
|
||||
size->height = std::max(height[0], height[1] * 2);
|
||||
if (two_wide) {
|
||||
size->width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * OBJECT_MARGIN) * 2 + 2;
|
||||
size->width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2;
|
||||
} else {
|
||||
size->width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * OBJECT_MARGIN;
|
||||
size->width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
|
||||
}
|
||||
|
||||
/* Get the right size for the single widget based on the current spec. */
|
||||
ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
|
||||
const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
|
||||
if (spec != nullptr) {
|
||||
if (spec->views >= 2) size->width = size->width / 2 - 1;
|
||||
if (spec->views >= 4) size->height = size->height / 2 - 1;
|
||||
if (spec->views <= 1) size->width += WidgetDimensions::scaled.hsep_normal;
|
||||
if (spec->views <= 2) size->height += WidgetDimensions::scaled.vsep_normal;
|
||||
if (spec->views >= 2) size->width /= 2;
|
||||
if (spec->views >= 4) size->height /= 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -357,9 +364,9 @@ public:
|
||||
if (spec->grf_prop.grffile == nullptr) {
|
||||
extern const DrawTileSprites _objects[];
|
||||
const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
|
||||
DrawOrigTileSeqInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
|
||||
DrawOrigTileSeqInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
|
||||
} else {
|
||||
DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16));
|
||||
DrawNewObjectTileInGUI(r.Width() / 2 - 1, (r.Height() + matrix_height / 2) / 2 - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec, GB(widget, 16, 16));
|
||||
}
|
||||
_cur_dpi = old_dpi;
|
||||
}
|
||||
@@ -384,9 +391,9 @@ public:
|
||||
if (spec->grf_prop.grffile == nullptr) {
|
||||
extern const DrawTileSprites _objects[];
|
||||
const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
|
||||
DrawOrigTileSeqInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
|
||||
DrawOrigTileSeqInGUI(r.Width() / 2 - 1, r.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), dts, PAL_NONE);
|
||||
} else {
|
||||
DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - OBJECT_MARGIN - ScaleSpriteTrad(TILE_PIXELS), spec,
|
||||
DrawNewObjectTileInGUI(r.Width() / 2 - 1, r.Height() - this->object_margin - ScaleSpriteTrad(TILE_PIXELS), spec,
|
||||
std::min<int>(_selected_object_view, spec->views - 1));
|
||||
}
|
||||
_cur_dpi = old_dpi;
|
||||
@@ -412,11 +419,11 @@ public:
|
||||
/* Use all the available space left from where we stand up to the
|
||||
* end of the window. We ALSO enlarge the window if needed, so we
|
||||
* can 'go' wild with the bottom of the window. */
|
||||
int y = DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, message, TC_ORANGE) - r.top;
|
||||
int y = DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, message, TC_ORANGE) - r.top - 1;
|
||||
StopTextRefStackUsage();
|
||||
if (y > this->info_height) {
|
||||
BuildObjectWindow *bow = const_cast<BuildObjectWindow *>(this);
|
||||
bow->info_height = y + 2;
|
||||
bow->info_height = y;
|
||||
bow->ReInit();
|
||||
}
|
||||
}
|
||||
@@ -727,7 +734,7 @@ static const NWidgetPart _nested_build_object_widgets[] = {
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BO_INFO), SetPadding(0, 5, 0, 1), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BO_INFO), SetPadding(0, 5, 2, 2), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
|
||||
|
Reference in New Issue
Block a user