Merge branch 'master' into jgrpp
# Conflicts: # src/cheat_gui.cpp # src/main_gui.cpp # src/network/network_gui.cpp # src/saveload/saveload.h # src/smallmap_gui.cpp # src/station_cmd.cpp # src/timetable_cmd.cpp # src/toolbar_gui.cpp # src/widget.cpp # src/widget_type.h # src/widgets/dropdown_type.h
This commit is contained in:
@@ -35,6 +35,13 @@ DropDownListStringItem::DropDownListStringItem(StringID string, int result, bool
|
||||
{
|
||||
}
|
||||
|
||||
DropDownListStringItem::DropDownListStringItem(const std::string &string, int result, bool masked) : DropDownListItem(result, masked)
|
||||
{
|
||||
/* A raw string may contain parsable tokens, so it needs to be passed through GetString. */
|
||||
SetDParamStr(0, string);
|
||||
this->string = GetString(STR_JUST_RAW_STRING);
|
||||
}
|
||||
|
||||
uint DropDownListStringItem::Width() const
|
||||
{
|
||||
return GetStringBoundingBox(this->String()).width + WidgetDimensions::scaled.dropdowntext.Horizontal();
|
||||
@@ -66,7 +73,7 @@ DropDownListIconItem::DropDownListIconItem(SpriteID sprite, PaletteID pal, Strin
|
||||
this->sprite_y = dim.height;
|
||||
}
|
||||
|
||||
uint DropDownListIconItem::Height(uint) const
|
||||
uint DropDownListIconItem::Height() const
|
||||
{
|
||||
return std::max(this->dim.height, (uint)FONT_HEIGHT_NORMAL);
|
||||
}
|
||||
@@ -164,7 +171,7 @@ struct DropdownWindow : Window {
|
||||
/* Total length of list */
|
||||
int list_height = 0;
|
||||
for (const auto &item : this->list) {
|
||||
list_height += item->Height(items_width);
|
||||
list_height += item->Height();
|
||||
}
|
||||
|
||||
/* Capacity is the average number of items visible */
|
||||
@@ -214,14 +221,13 @@ struct DropdownWindow : Window {
|
||||
|
||||
const Rect &r = this->GetWidget<NWidgetBase>(WID_DM_ITEMS)->GetCurrentRect().Shrink(WidgetDimensions::scaled.fullbevel);
|
||||
int y = _cursor.pos.y - this->top - r.top - WidgetDimensions::scaled.fullbevel.top;
|
||||
int width = r.Width();
|
||||
int pos = this->vscroll->GetPosition();
|
||||
|
||||
for (const auto &item : this->list) {
|
||||
/* Skip items that are scrolled up */
|
||||
if (--pos >= 0) continue;
|
||||
|
||||
int item_height = item->Height(width);
|
||||
int item_height = item->Height();
|
||||
|
||||
if (y < item_height) {
|
||||
if (item->masked || !item->Selectable()) return false;
|
||||
@@ -245,7 +251,7 @@ struct DropdownWindow : Window {
|
||||
int y = ir.top;
|
||||
int pos = this->vscroll->GetPosition();
|
||||
for (const auto &item : this->list) {
|
||||
int item_height = item->Height(ir.Width());
|
||||
int item_height = item->Height();
|
||||
|
||||
/* Skip items that are scrolled up */
|
||||
if (--pos >= 0) continue;
|
||||
@@ -382,7 +388,7 @@ void ShowDropDownListAt(Window *w, DropDownList &&list, int selected, int button
|
||||
uint height = 0;
|
||||
|
||||
for (const auto &item : list) {
|
||||
height += item->Height(width);
|
||||
height += item->Height();
|
||||
max_item_width = std::max(max_item_width, item->Width());
|
||||
}
|
||||
|
||||
|
@@ -35,7 +35,7 @@ public:
|
||||
virtual ~DropDownListItem() = default;
|
||||
|
||||
virtual bool Selectable() const { return false; }
|
||||
virtual uint Height([[maybe_unused]] uint) const { return FONT_HEIGHT_NORMAL; }
|
||||
virtual uint Height() const { return FONT_HEIGHT_NORMAL; }
|
||||
virtual uint Width() const { return 0; }
|
||||
virtual void Draw(const Rect &r, bool sel, Colours bg_colour) const;
|
||||
};
|
||||
@@ -45,11 +45,11 @@ public:
|
||||
*/
|
||||
class DropDownListStringItem : public DropDownListItem {
|
||||
public:
|
||||
const std::string string; ///< String of item
|
||||
std::string string; ///< String of item
|
||||
TextColour colour_flags = TC_BEGIN;
|
||||
|
||||
DropDownListStringItem(StringID string, int result, bool masked);
|
||||
DropDownListStringItem(const std::string &string, int result, bool masked) : DropDownListItem(result, masked), string(string) {}
|
||||
DropDownListStringItem(const std::string &string, int result, bool masked);
|
||||
|
||||
bool Selectable() const override { return true; }
|
||||
uint Width() const override;
|
||||
@@ -71,7 +71,7 @@ class DropDownListIconItem : public DropDownListStringItem {
|
||||
public:
|
||||
DropDownListIconItem(SpriteID sprite, PaletteID pal, StringID string, int result, bool masked);
|
||||
|
||||
uint Height(uint width) const override;
|
||||
uint Height() const override;
|
||||
uint Width() const override;
|
||||
void Draw(const Rect &r, bool sel, Colours bg_colour) const override;
|
||||
void SetDimension(Dimension d);
|
||||
|
@@ -29,7 +29,6 @@ enum GoalQuestionWidgets {
|
||||
WID_GQ_BUTTON_1, ///< First button.
|
||||
WID_GQ_BUTTON_2, ///< Second button.
|
||||
WID_GQ_BUTTON_3, ///< Third button.
|
||||
WID_GQ_BUTTON_SPACER, ///< Selection to hide extra padding if there are no buttons
|
||||
};
|
||||
|
||||
#endif /* WIDGETS_GOAL_WIDGET_H */
|
||||
|
@@ -19,7 +19,6 @@ enum NetworkGameWidgets {
|
||||
WID_NG_FILTER_LABEL, ///< Label in front of the filter/search edit box.
|
||||
WID_NG_FILTER, ///< Panel with the edit box to enter the search text.
|
||||
|
||||
WID_NG_HEADER, ///< Header container of the matrix.
|
||||
WID_NG_NAME, ///< 'Name' button.
|
||||
WID_NG_CLIENTS, ///< 'Clients' button.
|
||||
WID_NG_MAPSIZE, ///< 'Map size' button.
|
||||
|
Reference in New Issue
Block a user