(svn r26965) -Codechange: Add palette bit to indicate that palette is actually a text colour remap, and draw closebox as a sprite, using said bit. Change news popup to use closebox widget for its closebox.

pull/155/head
peter1138 10 years ago
parent d3c614c3cf
commit ee266b9b9d

@ -797,7 +797,11 @@ void DrawSpriteViewport(SpriteID img, PaletteID pal, int x, int y, const SubSpri
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1; _colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite); GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite);
} else if (pal != PAL_NONE) { } else if (pal != PAL_NONE) {
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1; if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
} else {
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
}
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite); GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite);
} else { } else {
GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite); GfxMainBlitterViewport(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite);
@ -820,7 +824,11 @@ void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub,
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1; _colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite, zoom); GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_TRANSPARENT, sub, real_sprite, zoom);
} else if (pal != PAL_NONE) { } else if (pal != PAL_NONE) {
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1; if (HasBit(pal, PALETTE_TEXT_RECOLOUR)) {
SetColourRemap((TextColour)GB(pal, 0, PALETTE_WIDTH));
} else {
_colour_remap_ptr = GetNonSprite(GB(pal, 0, PALETTE_WIDTH), ST_RECOLOUR) + 1;
}
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite, zoom); GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, pal == PALETTE_CRASH ? BM_CRASH_REMAP : BM_COLOUR_REMAP, sub, real_sprite, zoom);
} else { } else {
GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite, zoom); GfxMainBlitter(GetSprite(real_sprite, ST_NORMAL), x, y, BM_NORMAL, sub, real_sprite, zoom);

@ -80,7 +80,7 @@ static TileIndex GetReferenceTile(NewsReferenceType reftype, uint32 ref)
static const NWidgetPart _nested_normal_news_widgets[] = { static const NWidgetPart _nested_normal_news_widgets[] = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1),
NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX), SetPadding(0, 0, 0, 1),
NWidget(NWID_SPACER), SetFill(1, 0), NWidget(NWID_SPACER), SetFill(1, 0),
NWidget(NWID_VERTICAL), NWidget(NWID_VERTICAL),
NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_DATE), SetDataTip(STR_DATE_LONG_SMALL, STR_NULL), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_DATE), SetDataTip(STR_DATE_LONG_SMALL, STR_NULL),
@ -103,7 +103,7 @@ static const NWidgetPart _nested_vehicle_news_widgets[] = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1),
NWidget(NWID_VERTICAL), NWidget(NWID_VERTICAL),
NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX), SetPadding(0, 0, 0, 1),
NWidget(NWID_SPACER), SetFill(0, 1), NWidget(NWID_SPACER), SetFill(0, 1),
EndContainer(), EndContainer(),
NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_VEH_TITLE), SetFill(1, 1), SetMinimalSize(419, 55), SetDataTip(STR_EMPTY, STR_NULL), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_VEH_TITLE), SetFill(1, 1), SetMinimalSize(419, 55), SetDataTip(STR_EMPTY, STR_NULL),
@ -130,7 +130,7 @@ static const NWidgetPart _nested_company_news_widgets[] = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1),
NWidget(NWID_VERTICAL), NWidget(NWID_VERTICAL),
NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX), SetPadding(0, 0, 0, 1),
NWidget(NWID_SPACER), SetFill(0, 1), NWidget(NWID_SPACER), SetFill(0, 1),
EndContainer(), EndContainer(),
NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_TITLE), SetFill(1, 1), SetMinimalSize(410, 20), SetDataTip(STR_EMPTY, STR_NULL), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_TITLE), SetFill(1, 1), SetMinimalSize(410, 20), SetDataTip(STR_EMPTY, STR_NULL),
@ -157,7 +157,7 @@ static WindowDesc _company_news_desc(
static const NWidgetPart _nested_thin_news_widgets[] = { static const NWidgetPart _nested_thin_news_widgets[] = {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL), NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1), NWidget(NWID_HORIZONTAL), SetPadding(1, 1, 0, 1),
NWidget(WWT_TEXT, COLOUR_WHITE, WID_N_CLOSEBOX), SetDataTip(STR_SILVER_CROSS, STR_NULL), SetPadding(0, 0, 0, 1), NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX), SetPadding(0, 0, 0, 1),
NWidget(NWID_SPACER), SetFill(1, 0), NWidget(NWID_SPACER), SetFill(1, 0),
NWidget(NWID_VERTICAL), NWidget(NWID_VERTICAL),
NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_DATE), SetDataTip(STR_DATE_LONG_SMALL, STR_NULL), NWidget(WWT_LABEL, COLOUR_WHITE, WID_N_DATE), SetDataTip(STR_DATE_LONG_SMALL, STR_NULL),

@ -85,6 +85,8 @@ static const SpriteID SPR_SHARED_ORDERS_ICON = SPR_OPENTTD_BASE + 50;
static const SpriteID SPR_PIN_UP = SPR_OPENTTD_BASE + 51; // pin icon static const SpriteID SPR_PIN_UP = SPR_OPENTTD_BASE + 51; // pin icon
static const SpriteID SPR_PIN_DOWN = SPR_OPENTTD_BASE + 52; static const SpriteID SPR_PIN_DOWN = SPR_OPENTTD_BASE + 52;
static const SpriteID SPR_CLOSEBOX = 143;
static const SpriteID SPR_CIRCLE_FOLDED = SPR_OPENTTD_BASE + 147; // (+) icon static const SpriteID SPR_CIRCLE_FOLDED = SPR_OPENTTD_BASE + 147; // (+) icon
static const SpriteID SPR_CIRCLE_UNFOLDED = SPR_OPENTTD_BASE + 148; // (-) icon static const SpriteID SPR_CIRCLE_UNFOLDED = SPR_OPENTTD_BASE + 148; // (-) icon
@ -1479,11 +1481,15 @@ static const CursorID ANIMCURSOR_BUILDSIGNALS = ANIMCURSOR_FLAG | 4; ///< 1292 -
* bits used for the recolouring process. For transparency, it must be 0x322.</li></ul> * bits used for the recolouring process. For transparency, it must be 0x322.</li></ul>
*/ */
enum SpriteSetup { enum SpriteSetup {
/* These bits are applied to sprite ID */
TRANSPARENT_BIT = 31, ///< toggles transparency in the sprite TRANSPARENT_BIT = 31, ///< toggles transparency in the sprite
RECOLOUR_BIT = 30, ///< toggles recolouring in the sprite RECOLOUR_BIT = 30, ///< toggles recolouring in the sprite
CUSTOM_BIT = 29, CUSTOM_BIT = 29,
OPAQUE_BIT = 28, OPAQUE_BIT = 28,
/* This bit is applied to palette ID */
PALETTE_TEXT_RECOLOUR = 31, ///< Set if palette is actually a magic text recolour
PALETTE_WIDTH = 24, ///< number of bits of the sprite containing the recolour palette PALETTE_WIDTH = 24, ///< number of bits of the sprite containing the recolour palette
SPRITE_WIDTH = 24, ///< number of bits for the sprite number SPRITE_WIDTH = 24, ///< number of bits for the sprite number
}; };

@ -522,13 +522,11 @@ static inline void DrawResizeBox(const Rect &r, Colours colour, bool at_left, bo
* Draw a close box. * Draw a close box.
* @param r Rectangle of the box. * @param r Rectangle of the box.
* @param colour Colour of the close box. * @param colour Colour of the close box.
* @param str Cross to draw (#STR_BLACK_CROSS or #STR_SILVER_CROSS).
*/ */
static inline void DrawCloseBox(const Rect &r, Colours colour, StringID str) static inline void DrawCloseBox(const Rect &r, Colours colour)
{ {
assert(str == STR_BLACK_CROSS || str == STR_SILVER_CROSS); // black or silver cross if (colour != COLOUR_WHITE) DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE);
DrawFrameRect(r.left, r.top, r.right, r.bottom, colour, FR_NONE); DrawSprite(SPR_CLOSEBOX, (colour != COLOUR_WHITE ? TC_BLACK : TC_SILVER) | (1 << PALETTE_TEXT_RECOLOUR), r.left + WD_CLOSEBOX_LEFT, r.top + WD_CLOSEBOX_TOP);
DrawString(r.left, r.right, r.top + WD_CLOSEBOX_TOP, str, TC_FROMSTRING, SA_HOR_CENTER);
} }
/** /**
@ -2182,7 +2180,7 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint16 data,
case WWT_CLOSEBOX: case WWT_CLOSEBOX:
this->SetFill(0, 0); this->SetFill(0, 0);
this->SetMinimalSize(WD_CLOSEBOX_WIDTH, WD_CAPTION_HEIGHT); this->SetMinimalSize(WD_CLOSEBOX_WIDTH, WD_CAPTION_HEIGHT);
this->SetDataTip(STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW); this->SetDataTip(STR_NULL, STR_TOOLTIP_CLOSE_WINDOW);
break; break;
case WWT_DROPDOWN: case WWT_DROPDOWN:
@ -2320,7 +2318,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array)
static const Dimension extra = {WD_CLOSEBOX_LEFT + WD_CLOSEBOX_RIGHT, WD_CLOSEBOX_TOP + WD_CLOSEBOX_BOTTOM}; static const Dimension extra = {WD_CLOSEBOX_LEFT + WD_CLOSEBOX_RIGHT, WD_CLOSEBOX_TOP + WD_CLOSEBOX_BOTTOM};
padding = &extra; padding = &extra;
if (NWidgetLeaf::closebox_dimension.width == 0) { if (NWidgetLeaf::closebox_dimension.width == 0) {
NWidgetLeaf::closebox_dimension = maxdim(GetStringBoundingBox(STR_BLACK_CROSS), GetStringBoundingBox(STR_SILVER_CROSS)); NWidgetLeaf::closebox_dimension = GetSpriteSize(SPR_CLOSEBOX);
NWidgetLeaf::closebox_dimension.width += extra.width; NWidgetLeaf::closebox_dimension.width += extra.width;
NWidgetLeaf::closebox_dimension.height += extra.height; NWidgetLeaf::closebox_dimension.height += extra.height;
} }
@ -2490,7 +2488,7 @@ void NWidgetLeaf::Draw(const Window *w)
break; break;
case WWT_CLOSEBOX: case WWT_CLOSEBOX:
DrawCloseBox(r, this->colour, this->widget_data); DrawCloseBox(r, this->colour);
break; break;
case WWT_DROPDOWN: case WWT_DROPDOWN:

Loading…
Cancel
Save