mirror of https://github.com/OpenTTD/OpenTTD
(svn r25987) [1.3] -Backport from trunk:
- Fix: When clearing font cache, also clear layout cache [FS#5737] (r25860) - Fix: Goto button in order window was not always lowered when it should [FS#5783] (r25858, 25857) - Fix: Searching for a suitable font failed, if one of the fonts had no '?' glyph, and no baseset is installed [FS#5704] (r25822, r25820) - Fix: Sprite 0 was considered available, even if no baseset was loaded (r25821)release/1.3
parent
33ab06a9da
commit
04fc4595cf
|
@ -207,7 +207,7 @@ void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite *Blitter_32bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
Sprite *Blitter_32bppOptimized::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
||||||
{
|
{
|
||||||
/* streams of pixels (a, r, g, b channels)
|
/* streams of pixels (a, r, g, b channels)
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,7 +24,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
||||||
/* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
||||||
|
|
||||||
/* virtual */ const char *GetName() { return "32bpp-optimized"; }
|
/* virtual */ const char *GetName() { return "32bpp-optimized"; }
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,7 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
|
||||||
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
|
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite *Blitter_32bppSimple::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
||||||
{
|
{
|
||||||
Blitter_32bppSimple::Pixel *dst;
|
Blitter_32bppSimple::Pixel *dst;
|
||||||
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width * sizeof(*dst));
|
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width * sizeof(*dst));
|
||||||
|
|
|
@ -28,7 +28,7 @@ class Blitter_32bppSimple : public Blitter_32bppBase {
|
||||||
public:
|
public:
|
||||||
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
||||||
/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
|
/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
|
||||||
/* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
||||||
|
|
||||||
/* virtual */ const char *GetName() { return "32bpp-simple"; }
|
/* virtual */ const char *GetName() { return "32bpp-simple"; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -112,7 +112,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite *Blitter_8bppOptimized::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
Sprite *Blitter_8bppOptimized::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
||||||
{
|
{
|
||||||
/* Make memory for all zoom-levels */
|
/* Make memory for all zoom-levels */
|
||||||
uint memory = sizeof(SpriteData);
|
uint memory = sizeof(SpriteData);
|
||||||
|
|
|
@ -25,7 +25,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
||||||
/* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
||||||
|
|
||||||
/* virtual */ const char *GetName() { return "8bpp-optimized"; }
|
/* virtual */ const char *GetName() { return "8bpp-optimized"; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -55,7 +55,7 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sprite *Blitter_8bppSimple::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
Sprite *Blitter_8bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
||||||
{
|
{
|
||||||
Sprite *dest_sprite;
|
Sprite *dest_sprite;
|
||||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);
|
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
class Blitter_8bppSimple FINAL : public Blitter_8bppBase {
|
class Blitter_8bppSimple FINAL : public Blitter_8bppBase {
|
||||||
public:
|
public:
|
||||||
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
|
||||||
/* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
||||||
|
|
||||||
/* virtual */ const char *GetName() { return "8bpp-simple"; }
|
/* virtual */ const char *GetName() { return "8bpp-simple"; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Convert a sprite from the loader to our own format.
|
* Convert a sprite from the loader to our own format.
|
||||||
*/
|
*/
|
||||||
virtual Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator) = 0;
|
virtual Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the destination pointer the requested amount x and y, keeping in mind
|
* Move the destination pointer the requested amount x and y, keeping in mind
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
/** Instantiation of the null blitter factory. */
|
/** Instantiation of the null blitter factory. */
|
||||||
static FBlitter_Null iFBlitter_Null;
|
static FBlitter_Null iFBlitter_Null;
|
||||||
|
|
||||||
Sprite *Blitter_Null::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
Sprite *Blitter_Null::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
|
||||||
{
|
{
|
||||||
Sprite *dest_sprite;
|
Sprite *dest_sprite;
|
||||||
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite));
|
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite));
|
||||||
|
|
|
@ -20,7 +20,7 @@ public:
|
||||||
/* virtual */ uint8 GetScreenDepth() { return 0; }
|
/* virtual */ uint8 GetScreenDepth() { return 0; }
|
||||||
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) {};
|
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) {};
|
||||||
/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) {};
|
/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal) {};
|
||||||
/* virtual */ Sprite *Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
|
||||||
/* virtual */ void *MoveTo(void *video, int x, int y) { return NULL; };
|
/* virtual */ void *MoveTo(void *video, int x, int y) { return NULL; };
|
||||||
/* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {};
|
/* virtual */ void SetPixel(void *video, int x, int y, uint8 colour) {};
|
||||||
/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {};
|
/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {};
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
virtual SpriteID GetUnicodeGlyph(WChar key);
|
virtual SpriteID GetUnicodeGlyph(WChar key);
|
||||||
virtual void SetUnicodeGlyph(WChar key, SpriteID sprite);
|
virtual void SetUnicodeGlyph(WChar key, SpriteID sprite);
|
||||||
virtual void InitializeUnicodeGlyphMap();
|
virtual void InitializeUnicodeGlyphMap();
|
||||||
virtual void ClearFontCache() {}
|
virtual void ClearFontCache();
|
||||||
virtual const Sprite *GetGlyph(GlyphID key);
|
virtual const Sprite *GetGlyph(GlyphID key);
|
||||||
virtual uint GetGlyphWidth(GlyphID key);
|
virtual uint GetGlyphWidth(GlyphID key);
|
||||||
virtual bool GetDrawGlyphShadow();
|
virtual bool GetDrawGlyphShadow();
|
||||||
|
@ -162,6 +162,11 @@ void SpriteFontCache::ClearGlyphToSpriteMap()
|
||||||
this->glyph_to_spriteid_map = NULL;
|
this->glyph_to_spriteid_map = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SpriteFontCache::ClearFontCache()
|
||||||
|
{
|
||||||
|
Layouter::ResetFontCache(this->fs);
|
||||||
|
}
|
||||||
|
|
||||||
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
SpriteID sprite = this->GetUnicodeGlyph(key);
|
||||||
|
@ -392,6 +397,8 @@ void FreeTypeFontCache::ClearFontCache()
|
||||||
|
|
||||||
free(this->glyph_to_sprite);
|
free(this->glyph_to_sprite);
|
||||||
this->glyph_to_sprite = NULL;
|
this->glyph_to_sprite = NULL;
|
||||||
|
|
||||||
|
Layouter::ResetFontCache(this->fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
|
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
|
||||||
|
@ -458,9 +465,34 @@ const Sprite *FreeTypeFontCache::GetGlyph(GlyphID key)
|
||||||
if (key == 0) {
|
if (key == 0) {
|
||||||
GlyphID question_glyph = this->MapCharToGlyph('?');
|
GlyphID question_glyph = this->MapCharToGlyph('?');
|
||||||
if (question_glyph == 0) {
|
if (question_glyph == 0) {
|
||||||
/* The font misses the '?' character. Use sprite font. */
|
/* The font misses the '?' character. Use built-in sprite.
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
* Note: We cannot use the baseset as this also has to work in the bootstrap GUI. */
|
||||||
Sprite *spr = (Sprite*)GetRawSprite(sprite, ST_FONT, AllocateFont);
|
#define CPSET { 0, 0, 0, 0, 1 }
|
||||||
|
#define CP___ { 0, 0, 0, 0, 0 }
|
||||||
|
static SpriteLoader::CommonPixel builtin_questionmark_data[10 * 8] = {
|
||||||
|
CP___, CP___, CPSET, CPSET, CPSET, CPSET, CP___, CP___,
|
||||||
|
CP___, CPSET, CPSET, CP___, CP___, CPSET, CPSET, CP___,
|
||||||
|
CP___, CP___, CP___, CP___, CP___, CPSET, CPSET, CP___,
|
||||||
|
CP___, CP___, CP___, CP___, CPSET, CPSET, CP___, CP___,
|
||||||
|
CP___, CP___, CP___, CPSET, CPSET, CP___, CP___, CP___,
|
||||||
|
CP___, CP___, CP___, CPSET, CPSET, CP___, CP___, CP___,
|
||||||
|
CP___, CP___, CP___, CPSET, CPSET, CP___, CP___, CP___,
|
||||||
|
CP___, CP___, CP___, CP___, CP___, CP___, CP___, CP___,
|
||||||
|
CP___, CP___, CP___, CPSET, CPSET, CP___, CP___, CP___,
|
||||||
|
CP___, CP___, CP___, CPSET, CPSET, CP___, CP___, CP___,
|
||||||
|
};
|
||||||
|
#undef CPSET
|
||||||
|
#undef CP___
|
||||||
|
static const SpriteLoader::Sprite builtin_questionmark = {
|
||||||
|
10, // height
|
||||||
|
8, // width
|
||||||
|
0, // x_offs
|
||||||
|
0, // y_offs
|
||||||
|
ST_FONT,
|
||||||
|
builtin_questionmark_data
|
||||||
|
};
|
||||||
|
|
||||||
|
Sprite *spr = BlitterFactoryBase::GetCurrentBlitter()->Encode(&builtin_questionmark, AllocateFont);
|
||||||
assert(spr != NULL);
|
assert(spr != NULL);
|
||||||
new_glyph.sprite = spr;
|
new_glyph.sprite = spr;
|
||||||
new_glyph.width = spr->width + (this->fs != FS_NORMAL);
|
new_glyph.width = spr->width + (this->fs != FS_NORMAL);
|
||||||
|
|
|
@ -159,7 +159,8 @@ static inline void InitializeUnicodeGlyphMap()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ClearFontCache() {
|
static inline void ClearFontCache()
|
||||||
|
{
|
||||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
||||||
FontCache::Get(fs)->ClearFontCache();
|
FontCache::Get(fs)->ClearFontCache();
|
||||||
}
|
}
|
||||||
|
|
|
@ -481,6 +481,7 @@ struct OrdersWindow : public Window {
|
||||||
private:
|
private:
|
||||||
/** Under what reason are we using the PlaceObject functionality? */
|
/** Under what reason are we using the PlaceObject functionality? */
|
||||||
enum OrderPlaceObjectState {
|
enum OrderPlaceObjectState {
|
||||||
|
OPOS_NONE,
|
||||||
OPOS_GOTO,
|
OPOS_GOTO,
|
||||||
OPOS_CONDITIONAL,
|
OPOS_CONDITIONAL,
|
||||||
OPOS_SHARE,
|
OPOS_SHARE,
|
||||||
|
@ -631,7 +632,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void OrderClick_Conditional(int i)
|
void OrderClick_Conditional(int i)
|
||||||
{
|
{
|
||||||
this->LowerWidget(WID_O_GOTO);
|
|
||||||
this->SetWidgetDirty(WID_O_GOTO);
|
this->SetWidgetDirty(WID_O_GOTO);
|
||||||
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_NONE, this);
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_NONE, this);
|
||||||
this->goto_type = OPOS_CONDITIONAL;
|
this->goto_type = OPOS_CONDITIONAL;
|
||||||
|
@ -643,7 +643,6 @@ private:
|
||||||
*/
|
*/
|
||||||
void OrderClick_Share(int i)
|
void OrderClick_Share(int i)
|
||||||
{
|
{
|
||||||
this->LowerWidget(WID_O_GOTO);
|
|
||||||
this->SetWidgetDirty(WID_O_GOTO);
|
this->SetWidgetDirty(WID_O_GOTO);
|
||||||
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_VEHICLE, this);
|
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_VEHICLE, this);
|
||||||
this->goto_type = OPOS_SHARE;
|
this->goto_type = OPOS_SHARE;
|
||||||
|
@ -810,6 +809,7 @@ public:
|
||||||
|
|
||||||
this->selected_order = -1;
|
this->selected_order = -1;
|
||||||
this->order_over = INVALID_VEH_ORDER_ID;
|
this->order_over = INVALID_VEH_ORDER_ID;
|
||||||
|
this->goto_type = OPOS_NONE;
|
||||||
this->owner = v->owner;
|
this->owner = v->owner;
|
||||||
|
|
||||||
this->UpdateAutoRefitState();
|
this->UpdateAutoRefitState();
|
||||||
|
@ -1101,7 +1101,11 @@ public:
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
if (this->vehicle->owner != _local_company) this->selected_order = -1; // Disable selection any selected row at a competitor order window.
|
if (this->vehicle->owner != _local_company) {
|
||||||
|
this->selected_order = -1; // Disable selection any selected row at a competitor order window.
|
||||||
|
} else {
|
||||||
|
this->SetWidgetLoweredState(WID_O_GOTO, this->goto_type != OPOS_NONE);
|
||||||
|
}
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1189,7 +1193,6 @@ public:
|
||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_O_ORDER_LIST: {
|
case WID_O_ORDER_LIST: {
|
||||||
if (this->goto_type == OPOS_CONDITIONAL) {
|
if (this->goto_type == OPOS_CONDITIONAL) {
|
||||||
this->goto_type = OPOS_GOTO;
|
|
||||||
VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
|
VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
|
||||||
if (order_id != INVALID_VEH_ORDER_ID) {
|
if (order_id != INVALID_VEH_ORDER_ID) {
|
||||||
Order order;
|
Order order;
|
||||||
|
@ -1477,7 +1480,7 @@ public:
|
||||||
|
|
||||||
virtual void OnPlaceObjectAbort()
|
virtual void OnPlaceObjectAbort()
|
||||||
{
|
{
|
||||||
this->RaiseWidget(WID_O_GOTO);
|
this->goto_type = OPOS_NONE;
|
||||||
this->SetWidgetDirty(WID_O_GOTO);
|
this->SetWidgetDirty(WID_O_GOTO);
|
||||||
|
|
||||||
/* Remove drag highlighting if it exists. */
|
/* Remove drag highlighting if it exists. */
|
||||||
|
|
|
@ -118,9 +118,10 @@ bool SkipSpriteData(byte type, uint16 num)
|
||||||
/* Check if the given Sprite ID exists */
|
/* Check if the given Sprite ID exists */
|
||||||
bool SpriteExists(SpriteID id)
|
bool SpriteExists(SpriteID id)
|
||||||
{
|
{
|
||||||
|
if (id >= _spritecache_items) return false;
|
||||||
|
|
||||||
/* Special case for Sprite ID zero -- its position is also 0... */
|
/* Special case for Sprite ID zero -- its position is also 0... */
|
||||||
if (id == 0) return true;
|
if (id == 0) return true;
|
||||||
if (id >= _spritecache_items) return false;
|
|
||||||
return !(GetSpriteCache(id)->file_pos == 0 && GetSpriteCache(id)->file_slot == 0);
|
return !(GetSpriteCache(id)->file_pos == 0 && GetSpriteCache(id)->file_slot == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue