1
0
Fork 0

(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
rubidium 2013-11-13 21:53:40 +00:00
parent 33ab06a9da
commit 04fc4595cf
15 changed files with 59 additions and 22 deletions

View File

@ -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)
*

View File

@ -24,7 +24,7 @@ public:
};
/* 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"; }

View File

@ -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);
}
Sprite *Blitter_32bppSimple::Encode(SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)
{
Blitter_32bppSimple::Pixel *dst;
Sprite *dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width * sizeof(*dst));

View File

@ -28,7 +28,7 @@ class Blitter_32bppSimple : public Blitter_32bppBase {
public:
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
/* 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"; }
};

View File

@ -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 */
uint memory = sizeof(SpriteData);

View File

@ -25,7 +25,7 @@ public:
};
/* 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"; }
};

View File

@ -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;
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite) + sprite->height * sprite->width);

View File

@ -19,7 +19,7 @@
class Blitter_8bppSimple FINAL : public Blitter_8bppBase {
public:
/* 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"; }
};

View File

@ -77,7 +77,7 @@ public:
/**
* 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

View File

@ -15,7 +15,7 @@
/** Instantiation of the null blitter factory. */
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;
dest_sprite = (Sprite *)allocator(sizeof(*dest_sprite));

View File

@ -20,7 +20,7 @@ public:
/* virtual */ uint8 GetScreenDepth() { return 0; }
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom) {};
/* 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 SetPixel(void *video, int x, int y, uint8 colour) {};
/* virtual */ void DrawRect(void *video, int width, int height, uint8 colour) {};

View File

@ -75,7 +75,7 @@ public:
virtual SpriteID GetUnicodeGlyph(WChar key);
virtual void SetUnicodeGlyph(WChar key, SpriteID sprite);
virtual void InitializeUnicodeGlyphMap();
virtual void ClearFontCache() {}
virtual void ClearFontCache();
virtual const Sprite *GetGlyph(GlyphID key);
virtual uint GetGlyphWidth(GlyphID key);
virtual bool GetDrawGlyphShadow();
@ -162,6 +162,11 @@ void SpriteFontCache::ClearGlyphToSpriteMap()
this->glyph_to_spriteid_map = NULL;
}
void SpriteFontCache::ClearFontCache()
{
Layouter::ResetFontCache(this->fs);
}
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
{
SpriteID sprite = this->GetUnicodeGlyph(key);
@ -392,6 +397,8 @@ void FreeTypeFontCache::ClearFontCache()
free(this->glyph_to_sprite);
this->glyph_to_sprite = NULL;
Layouter::ResetFontCache(this->fs);
}
FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key)
@ -458,9 +465,34 @@ const Sprite *FreeTypeFontCache::GetGlyph(GlyphID key)
if (key == 0) {
GlyphID question_glyph = this->MapCharToGlyph('?');
if (question_glyph == 0) {
/* The font misses the '?' character. Use sprite font. */
SpriteID sprite = this->GetUnicodeGlyph(key);
Sprite *spr = (Sprite*)GetRawSprite(sprite, ST_FONT, AllocateFont);
/* The font misses the '?' character. Use built-in sprite.
* Note: We cannot use the baseset as this also has to work in the bootstrap GUI. */
#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);
new_glyph.sprite = spr;
new_glyph.width = spr->width + (this->fs != FS_NORMAL);

View File

@ -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++) {
FontCache::Get(fs)->ClearFontCache();
}

View File

@ -481,6 +481,7 @@ struct OrdersWindow : public Window {
private:
/** Under what reason are we using the PlaceObject functionality? */
enum OrderPlaceObjectState {
OPOS_NONE,
OPOS_GOTO,
OPOS_CONDITIONAL,
OPOS_SHARE,
@ -631,7 +632,6 @@ private:
*/
void OrderClick_Conditional(int i)
{
this->LowerWidget(WID_O_GOTO);
this->SetWidgetDirty(WID_O_GOTO);
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_NONE, this);
this->goto_type = OPOS_CONDITIONAL;
@ -643,7 +643,6 @@ private:
*/
void OrderClick_Share(int i)
{
this->LowerWidget(WID_O_GOTO);
this->SetWidgetDirty(WID_O_GOTO);
SetObjectToPlaceWnd(ANIMCURSOR_PICKSTATION, PAL_NONE, HT_VEHICLE, this);
this->goto_type = OPOS_SHARE;
@ -810,6 +809,7 @@ public:
this->selected_order = -1;
this->order_over = INVALID_VEH_ORDER_ID;
this->goto_type = OPOS_NONE;
this->owner = v->owner;
this->UpdateAutoRefitState();
@ -1101,7 +1101,11 @@ public:
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();
}
@ -1189,7 +1193,6 @@ public:
switch (widget) {
case WID_O_ORDER_LIST: {
if (this->goto_type == OPOS_CONDITIONAL) {
this->goto_type = OPOS_GOTO;
VehicleOrderID order_id = this->GetOrderFromPt(_cursor.pos.y - this->top);
if (order_id != INVALID_VEH_ORDER_ID) {
Order order;
@ -1477,7 +1480,7 @@ public:
virtual void OnPlaceObjectAbort()
{
this->RaiseWidget(WID_O_GOTO);
this->goto_type = OPOS_NONE;
this->SetWidgetDirty(WID_O_GOTO);
/* Remove drag highlighting if it exists. */

View File

@ -118,9 +118,10 @@ bool SkipSpriteData(byte type, uint16 num)
/* Check if the given Sprite ID exists */
bool SpriteExists(SpriteID id)
{
if (id >= _spritecache_items) return false;
/* Special case for Sprite ID zero -- its position is also 0... */
if (id == 0) return true;
if (id >= _spritecache_items) return false;
return !(GetSpriteCache(id)->file_pos == 0 && GetSpriteCache(id)->file_slot == 0);
}