mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Reorder and properly declare DrawSpriteIgnorePadding().
Parameters have been rearranged to be closer to those of the standard DrawSprite() function, and PaletteID can now be set.pull/10180/head
parent
c81c242c5a
commit
9bf24ec56f
|
@ -92,6 +92,7 @@ Dimension GetSpriteSize(SpriteID sprid, Point *offset = nullptr, ZoomLevel zoom
|
|||
Dimension GetScaledSpriteSize(SpriteID sprid); /* widget.cpp */
|
||||
void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr);
|
||||
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub = nullptr, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool clicked, StringAlignment align); /* widget.cpp */
|
||||
std::unique_ptr<uint32[]> DrawSpriteToRgbaBuffer(SpriteID spriteId, ZoomLevel zoom = ZOOM_LVL_GUI);
|
||||
|
||||
int DrawString(int left, int right, int top, const char *str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL);
|
||||
|
|
|
@ -2532,8 +2532,6 @@ void ShowGameSettings()
|
|||
*/
|
||||
void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clickable_left, bool clickable_right)
|
||||
{
|
||||
extern void DrawSpriteIgnorePadding(const Rect &r, SpriteID img, bool clicked, StringAlignment align);
|
||||
|
||||
int colour = _colour_gradient[button_colour][2];
|
||||
Dimension dim = NWidgetScrollbar::GetHorizontalDimension();
|
||||
|
||||
|
@ -2542,8 +2540,8 @@ void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clic
|
|||
|
||||
DrawFrameRect(lr, button_colour, (state == 1) ? FR_LOWERED : FR_NONE);
|
||||
DrawFrameRect(rr, button_colour, (state == 2) ? FR_LOWERED : FR_NONE);
|
||||
DrawSpriteIgnorePadding(lr, SPR_ARROW_LEFT, (state == 1), SA_CENTER);
|
||||
DrawSpriteIgnorePadding(rr, SPR_ARROW_RIGHT, (state == 2), SA_CENTER);
|
||||
DrawSpriteIgnorePadding(SPR_ARROW_LEFT, PAL_NONE, lr, (state == 1), SA_CENTER);
|
||||
DrawSpriteIgnorePadding(SPR_ARROW_RIGHT, PAL_NONE, rr, (state == 2), SA_CENTER);
|
||||
|
||||
/* Grey out the buttons that aren't clickable */
|
||||
bool rtl = _current_text_dir == TD_RTL;
|
||||
|
@ -2565,14 +2563,12 @@ void DrawArrowButtons(int x, int y, Colours button_colour, byte state, bool clic
|
|||
*/
|
||||
void DrawDropDownButton(int x, int y, Colours button_colour, bool state, bool clickable)
|
||||
{
|
||||
extern void DrawSpriteIgnorePadding(const Rect &r, SpriteID img, bool clicked, StringAlignment align);
|
||||
|
||||
int colour = _colour_gradient[button_colour][2];
|
||||
|
||||
Rect r = {x, y, x + SETTING_BUTTON_WIDTH - 1, y + SETTING_BUTTON_HEIGHT - 1};
|
||||
|
||||
DrawFrameRect(r, button_colour, state ? FR_LOWERED : FR_NONE);
|
||||
DrawSpriteIgnorePadding(r, SPR_ARROW_DOWN, state, SA_CENTER);
|
||||
DrawSpriteIgnorePadding(SPR_ARROW_DOWN, PAL_NONE, r, state, SA_CENTER);
|
||||
|
||||
if (!clickable) {
|
||||
GfxFillRect(r.Shrink(WidgetDimensions::scaled.bevel), colour, FILLRECT_CHECKER);
|
||||
|
|
|
@ -447,7 +447,7 @@ void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, Fra
|
|||
}
|
||||
}
|
||||
|
||||
void DrawSpriteIgnorePadding(const Rect &r, SpriteID img, bool clicked, StringAlignment align)
|
||||
void DrawSpriteIgnorePadding(SpriteID img, PaletteID pal, const Rect &r, bool clicked, StringAlignment align)
|
||||
{
|
||||
Point offset;
|
||||
Dimension d = GetSpriteSize(img, &offset);
|
||||
|
@ -456,7 +456,7 @@ void DrawSpriteIgnorePadding(const Rect &r, SpriteID img, bool clicked, StringAl
|
|||
|
||||
Point p = GetAlignedPosition(r, d, align);
|
||||
int o = clicked ? WidgetDimensions::scaled.pressed : 0;
|
||||
DrawSprite(img, PAL_NONE, p.x + o - offset.x, p.y + o - offset.y);
|
||||
DrawSprite(img, pal, p.x + o - offset.x, p.y + o - offset.y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -474,7 +474,7 @@ static inline void DrawImageButtons(const Rect &r, WidgetType type, Colours colo
|
|||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
|
||||
if ((type & WWT_MASK) == WWT_IMGBTN_2 && clicked) img++; // Show different image when clicked for #WWT_IMGBTN_2.
|
||||
DrawSpriteIgnorePadding(r, img, clicked, align);
|
||||
DrawSpriteIgnorePadding(img, PAL_NONE, r, clicked, align);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -773,7 +773,7 @@ static inline void DrawDebugBox(const Rect &r, Colours colour, bool clicked)
|
|||
static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bool clicked)
|
||||
{
|
||||
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, (clicked) ? FR_LOWERED : FR_NONE);
|
||||
DrawSpriteIgnorePadding(r.Shrink(ScaleGUITrad(2)), at_left ? SPR_WINDOW_RESIZE_LEFT : SPR_WINDOW_RESIZE_RIGHT, clicked, at_left ? (SA_LEFT | SA_BOTTOM | SA_FORCE) : (SA_RIGHT | SA_BOTTOM | SA_FORCE));
|
||||
DrawSpriteIgnorePadding(at_left ? SPR_WINDOW_RESIZE_LEFT : SPR_WINDOW_RESIZE_RIGHT, PAL_NONE, r.Shrink(ScaleGUITrad(2)), clicked, at_left ? (SA_LEFT | SA_BOTTOM | SA_FORCE) : (SA_RIGHT | SA_BOTTOM | SA_FORCE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -897,7 +897,7 @@ void Window::DrawSortButtonState(int widget, SortButtonState state) const
|
|||
/* Sort button uses the same sprites as vertical scrollbar */
|
||||
Dimension dim = NWidgetScrollbar::GetVerticalDimension();
|
||||
|
||||
DrawSpriteIgnorePadding(r.WithWidth(dim.width, _current_text_dir == TD_LTR), state == SBS_DOWN ? SPR_ARROW_DOWN : SPR_ARROW_UP, this->IsWidgetLowered(widget), SA_CENTER);
|
||||
DrawSpriteIgnorePadding(state == SBS_DOWN ? SPR_ARROW_DOWN : SPR_ARROW_UP, PAL_NONE, r.WithWidth(dim.width, _current_text_dir == TD_LTR), this->IsWidgetLowered(widget), SA_CENTER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue