summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2005-07-28 09:17:32 +0000
committercelestar <celestar@openttd.org>2005-07-28 09:17:32 +0000
commit04f4d8237b879e3bb7c61a84cfbb5146cd408111 (patch)
treee279dbeda45e111fee0148b401cba8615f3adaec
parent139f0c95ca77b7c28510e92c3230495f88806cd9 (diff)
downloadopenttd-04f4d8237b879e3bb7c61a84cfbb5146cd408111.tar.xz
(svn r2736) -Codechange: De-mystified GfxDrawFillRect a bit, and used enums from table/sprites.h. You can now change the number of bits used for sprites and switches in the SpriteSetup enum and the rest should work automagically. Can be used to increase the number of active sprites to 2^19 in case there are no colortables (recolor sprites) in any newgrf. We should possibly move the the colortables to an own list, but how to detect them in a newgrf.
-rw-r--r--economy.c3
-rw-r--r--engine_gui.c9
-rw-r--r--gfx.c8
-rw-r--r--main_gui.c4
-rw-r--r--table/sprites.h8
-rw-r--r--texteff.c3
-rw-r--r--widget.c10
7 files changed, 28 insertions, 17 deletions
diff --git a/economy.c b/economy.c
index c71e3143a..396b9a8a6 100644
--- a/economy.c
+++ b/economy.c
@@ -5,6 +5,7 @@
#include "functions.h"
#include "strings.h" // XXX InjectDParam()
#include "table/strings.h"
+#include "table/sprites.h"
#include "map.h"
#include "news.h"
#include "player.h"
@@ -491,7 +492,7 @@ void DrawNewsBankrupcy(Window *w)
p = GetPlayer(WP(w,news_d).ni->string_id & 15);
DrawPlayerFace(p->face, p->player_color, 2, 23);
- GfxFillRect(3, 23, 3+91, 23+118, 0x4323);
+ GfxFillRect(3, 23, 3+91, 23+118, 0x323 | USE_COLORTABLE);
SetDParam(0, p->president_name_1);
SetDParam(1, p->president_name_2);
diff --git a/engine_gui.c b/engine_gui.c
index ad7159d32..c8b67486b 100644
--- a/engine_gui.c
+++ b/engine_gui.c
@@ -3,6 +3,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
+#include "table/sprites.h"
#include "functions.h"
#include "window.h"
#include "gui.h"
@@ -160,7 +161,7 @@ void DrawNewsNewTrainAvail(Window *w)
DrawStringMultiCenter(w->width >> 1, 57, STR_885A, w->width - 2);
DrawTrainEngine(w->width >> 1, 88, engine, 0);
- GfxFillRect(25, 56, w->width - 56, 112, 0x4323);
+ GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE);
DrawTrainEngineInfo(engine, w->width >> 1, 129, w->width - 52);
}
@@ -200,7 +201,7 @@ void DrawNewsNewAircraftAvail(Window *w)
DrawStringMultiCenter(w->width >> 1, 57, STR_A02D, w->width - 2);
DrawAircraftEngine(w->width >> 1, 93, engine, 0);
- GfxFillRect(25, 56, w->width - 56, 110, 0x4323);
+ GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE);
DrawAircraftEngineInfo(engine, w->width >> 1, 131, w->width - 52);
}
@@ -240,7 +241,7 @@ void DrawNewsNewRoadVehAvail(Window *w)
DrawStringMultiCenter(w->width >> 1, 57, STR_9029, w->width - 2);
DrawRoadVehEngine(w->width >> 1, 88, engine, 0);
- GfxFillRect(25, 56, w->width - 56, 112, 0x4323);
+ GfxFillRect(25, 56, w->width - 56, 112, 0x323 | USE_COLORTABLE);
DrawRoadVehEngineInfo(engine, w->width >> 1, 129, w->width - 52);
}
@@ -278,7 +279,7 @@ void DrawNewsNewShipAvail(Window *w)
DrawStringMultiCenter(w->width >> 1, 57, STR_982D, w->width - 2);
DrawShipEngine(w->width >> 1, 93, engine, 0);
- GfxFillRect(25, 56, w->width - 56, 110, 0x4323);
+ GfxFillRect(25, 56, w->width - 56, 110, 0x323 | USE_COLORTABLE);
DrawShipEngineInfo(engine, w->width >> 1, 131, w->width - 52);
}
diff --git a/gfx.c b/gfx.c
index c404c608a..5c0c9b7a3 100644
--- a/gfx.c
+++ b/gfx.c
@@ -139,15 +139,15 @@ void GfxFillRect(int left, int top, int right, int bottom, int color)
dst = dpi->dst_ptr + top * dpi->pitch + left;
- if (!(color & 0x8000)) {
- if (!(color & 0x4000)) {
+ if (!(color & PALETTE_MODIFIER_GREYOUT)) {
+ if (!(color & USE_COLORTABLE)) {
do {
memset(dst, color, right);
dst += dpi->pitch;
} while (--bottom);
} else {
/* use colortable mode */
- const byte* ctab = GetNonSprite(color & 0x3FFF) + 1;
+ const byte* ctab = GetNonSprite(color & COLORTABLE_MASK) + 1;
do {
int i;
@@ -567,7 +567,7 @@ void DrawFrameRect(int left, int top, int right, int bottom, int ctab, int flags
}
} else if (flags & 0x1) {
// transparency
- GfxFillRect(left, top, right, bottom, 0x4322);
+ GfxFillRect(left, top, right, bottom, 0x322 | USE_COLORTABLE);
} else {
GfxFillRect(left, top, right, bottom, color_interior);
}
diff --git a/main_gui.c b/main_gui.c
index 9875d5d06..252d6f492 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -1863,7 +1863,7 @@ static void MainToolbarWndProc(Window *w, WindowEvent *e)
// Draw brown-red toolbar bg.
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
- GfxFillRect(0, 0, w->width-1, w->height-1, 0x80B4);
+ GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT);
// if spectator, disable things
if (_current_player == OWNER_SPECTATOR){
@@ -2089,7 +2089,7 @@ static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
// Draw brown-red toolbar bg.
GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
- GfxFillRect(0, 0, w->width-1, w->height-1, 0x80B4);
+ GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | PALETTE_MODIFIER_GREYOUT);
DrawWindowWidgets(w);
diff --git a/table/sprites.h b/table/sprites.h
index 421ad74ce..82426efcb 100644
--- a/table/sprites.h
+++ b/table/sprites.h
@@ -984,6 +984,12 @@ enum Modifiers {
PALETTE_MODIFIER_TRANSPARENT = 1 << TRANSPARENT_BIT,
///this bit is set when a recoloring process is in action
PALETTE_MODIFIER_COLOR = 1 << RECOLOR_BIT,
+
+ //This is used for the GfxFillRect function
+ ///Used to draw a "grey out" rectangle. @see GfxFillRect
+ PALETTE_MODIFIER_GREYOUT = 1 << TRANSPARENT_BIT,
+ ///Set when a colortable mode is used. @see GfxFillRect
+ USE_COLORTABLE = 1 << RECOLOR_BIT,
};
/** Masks needed for sprite operations.
@@ -997,6 +1003,8 @@ enum SpriteMasks {
SPRITE_MASK = MAX_SPRITES,
///The mask for the auxiliary sprite (the one that takes care of recoloring)
PALETTE_SPRITE_MASK = ((1 << PALETTE_SPRITE_WIDTH) - 1) << PALETTE_SPRITE_START,
+ ///Mask for the auxiliary sprites if it is locate in the LSBs
+ COLORTABLE_MASK = (1 << PALETTE_SPRITE_WIDTH) - 1
};
assert_compile( (1 << TRANSPARENT_BIT & SPRITE_MASK) == 0 );
diff --git a/texteff.c b/texteff.c
index 5e5e7c41e..9121b29a2 100644
--- a/texteff.c
+++ b/texteff.c
@@ -11,6 +11,7 @@
#include "console.h"
#include "string.h"
#include "variables.h"
+#include "table/sprites.h"
#include <stdarg.h> /* va_list */
typedef struct TextEffect {
@@ -207,7 +208,7 @@ void DrawTextMessage(void)
continue;
j++;
- GfxFillRect(_textmessage_box_left, _screen.height-_textmessage_box_bottom-j*13-2, _textmessage_box_left+_textmessage_width - 1, _screen.height-_textmessage_box_bottom-j*13+10, /* black, but with some alpha */ 0x4322);
+ GfxFillRect(_textmessage_box_left, _screen.height-_textmessage_box_bottom-j*13-2, _textmessage_box_left+_textmessage_width - 1, _screen.height-_textmessage_box_bottom-j*13+10, /* black, but with some alpha */ 0x322 | USE_COLORTABLE);
DoDrawString(_text_message_list[i].message, _textmessage_box_left + 2, _screen.height - _textmessage_box_bottom - j * 13 - 1, 0x10);
DoDrawString(_text_message_list[i].message, _textmessage_box_left + 3, _screen.height - _textmessage_box_bottom - j * 13, _text_message_list[i].color);
diff --git a/widget.c b/widget.c
index 12ac2f32e..5465ce852 100644
--- a/widget.c
+++ b/widget.c
@@ -285,7 +285,7 @@ void DrawWindowWidgets(Window *w)
// draw "shaded" background
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
- GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | 0x8000);
+ GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT);
// draw shaded lines
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
@@ -317,7 +317,7 @@ void DrawWindowWidgets(Window *w)
// draw "shaded" background
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
- GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | 0x8000);
+ GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | PALETTE_MODIFIER_GREYOUT);
// draw shaded lines
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
@@ -350,7 +350,7 @@ void DrawWindowWidgets(Window *w)
// draw "shaded" background
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2);
- GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | 0x8000);
+ GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | PALETTE_MODIFIER_GREYOUT);
// draw shaded lines
GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1);
@@ -426,7 +426,7 @@ void DrawWindowWidgets(Window *w)
DrawStringCentered( (r.left+r.right+1)>>1, r.top+2, wi->unkA, 0x84);
draw_default:;
if (cur_disabled & 1) {
- GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | 0x8000);
+ GfxFillRect(r.left+1, r.top+1, r.right-1, r.bottom-1, _color_list[wi->color&0xF].unk2 | PALETTE_MODIFIER_GREYOUT);
}
}
}
@@ -503,7 +503,7 @@ static void DropdownMenuWndProc(Window *w, WindowEvent *e)
DrawString(x+2, y, _dropdown_items[i], sel==0 ? 12 : 16);
if (HASBIT(_dropdown_disabled, i) && !_dropdown_disabled_items) {
- GfxFillRect(x, y, x+w->width-3, y + 9, 0x8000 +
+ GfxFillRect(x, y, x+w->width-3, y + 9, PALETTE_MODIFIER_GREYOUT |
_color_list[_dropdown_menu_widgets[0].color].window_color_bga);
}
} else {