Fix warnings, layout, and return value.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3871 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2011-07-01 22:57:55 +00:00
parent 009a6bfc92
commit 8cb3aebfd0
3 changed files with 264 additions and 255 deletions

View File

@ -72,7 +72,7 @@ class ScalableFont : public gui::IGUIFontBitmap
u32 i = (u32)xml->getAttributeValueAsInt(L"index");
float scale=1.0f;
if(xml->getAttributeValue(L"scale"))
if (xml->getAttributeValue(L"scale"))
scale = xml->getAttributeValueAsFloat(L"scale");
//std::cout << "scale = " << scale << std::endl;
@ -226,8 +226,10 @@ public:
//! destructor
virtual ~ScalableFont()
{
if (Driver) Driver->drop();
if (SpriteBank) SpriteBank->drop();
if (Driver)
Driver->drop();
if (SpriteBank)
SpriteBank->drop();
}
//! loads a font from an XML file
@ -246,11 +248,12 @@ public:
for(wchar_t c='0'; c<='9'; c++)
{
SFontArea a = getAreaFromCharacter(c, NULL);
if(a.overhang > m_max_digit_area.overhang ) m_max_digit_area.overhang = a.overhang;
if(a.underhang > m_max_digit_area.underhang) m_max_digit_area.underhang = a.underhang;
if(a.width > m_max_digit_area.width ) m_max_digit_area.width = a.width;
if (a.overhang > m_max_digit_area.overhang ) m_max_digit_area.overhang = a.overhang;
if (a.underhang > m_max_digit_area.underhang) m_max_digit_area.underhang = a.underhang;
if (a.width > m_max_digit_area.width) m_max_digit_area.width = a.width;
}
m_max_digit_area.overhang = 0;m_max_digit_area.underhang=0;
m_max_digit_area.overhang = 0;
m_max_digit_area.underhang=0;
return true;
}
//! draws an text and clips it to the specified rectangle if wanted
@ -284,9 +287,10 @@ public:
}
if (c == L'\r' || // Windows breaks
c == L'\n' ) // Unix breaks
c == L'\n') // Unix breaks
{
if(c==L'\r' && text[i+1]==L'\n') c = text[++i];
if (c==L'\r' && text[i+1]==L'\n')
c = text[++i];
offset.Y += (int)(MaxHeight*m_scale);
offset.X = position.UpperLeftCorner.X;
if (hcenter)
@ -301,8 +305,8 @@ public:
offsets.push_back(offset);
// Invisible character. add something to the array anyway so that
// indices from the various arrays remain in sync
indices.push_back( Invisible.findFirst(c) < 0 ? area.spriteno
: -1 );
indices.push_back((Invisible.findFirst(c) < 0) ? (int)area.spriteno
: -1);
offset.X += getCharWidth(area, fallback[i]);
} // for i<text_size
@ -312,7 +316,7 @@ public:
core::array< core::rect<s32> >& positions = SpriteBank->getPositions();
core::array< gui::SGUISprite >* fallback_sprites;
core::array< core::rect<s32> >* fallback_positions;
if(m_fallback_font!=NULL)
if (m_fallback_font!=NULL)
{
fallback_sprites = &m_fallback_font->SpriteBank->getSprites();
fallback_positions = &m_fallback_font->SpriteBank->getPositions();
@ -328,8 +332,10 @@ public:
for (int n=0; n<indiceAmount; n++)
{
const int spriteID = indices[n];
if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount)) continue;
if (indices[n] == -1) continue;
if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount))
continue;
if (indices[n] == -1)
continue;
//assert(sprites[spriteID].Frames.size() > 0);
@ -343,8 +349,7 @@ public:
const TextureInfo& info = (fallback[n] ?
(*(m_fallback_font->m_texture_files.find(texID))).second :
(*(m_texture_files.find(texID))).second
);
(*(m_texture_files.find(texID))).second);
float char_scale = info.m_scale;
core::dimension2d<s32> size = source.getSize();
@ -440,7 +445,7 @@ public:
for (const wchar_t* p = text; *p; ++p)
{
if (*p == L'\r' || // Windows breaks
*p == L'\n' ) // Unix breaks
*p == L'\n') // Unix breaks
{
if (*p==L'\r' && p[1] == L'\n') // Windows breaks
++p;
@ -566,21 +571,23 @@ private:
const TextureInfo& info = (fallback ?
(*(m_fallback_font->m_texture_files.find(texID))).second :
(*(m_texture_files.find(texID))).second
);
(*(m_texture_files.find(texID))).second);
const float char_scale = info.m_scale;
//std::cout << "area.spriteno=" << area.spriteno << ", char_scale=" << char_scale << std::endl;
if (fallback) return (int)(((area.width + area.overhang)*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale);
else return (int)((area.width + area.overhang + GlobalKerningWidth) * m_scale * char_scale);
if (fallback)
return (int)(((area.width + area.overhang)*m_fallback_font_scale + m_fallback_kerning_width) * m_scale * char_scale);
else
return (int)((area.width + area.overhang + GlobalKerningWidth) * m_scale * char_scale);
}
s32 getAreaIDFromCharacter(const wchar_t c, bool* fallback_font) const
{
std::map<wchar_t, s32>::const_iterator n = CharacterMap.find(c);
if (n != CharacterMap.end())
{
if (fallback_font != NULL) *fallback_font = false;
if (fallback_font != NULL)
*fallback_font = false;
return (*n).second;
}
else if (m_fallback_font != NULL && fallback_font != NULL)
@ -591,7 +598,8 @@ private:
else
{
// std::cout << "The font does not have this character : <" << (int)c << ">" << std::endl;
if (fallback_font != NULL) *fallback_font = false;
if (fallback_font != NULL)
*fallback_font = false;
return WrongCharacter;
}
}

View File

@ -41,7 +41,7 @@ bool testShots(video::E_DRIVER_TYPE type)
smgr->drawAll();
driver->endScene();
for (u32 i=0; i<video::ECF_UNKNOWN; ++i)
for (s32 i=0; i<video::ECF_UNKNOWN; ++i)
{
video::IImage* img = driver->createScreenShot((video::ECOLOR_FORMAT)i);
logTestString("Color Format %d %ssupported\n", i, (img && img->getColorFormat() == i)?"":"un");

View File

@ -114,7 +114,7 @@ bool terrainGaps()
device->closeDevice();
device->run();
device->drop();
return true;
return result;
}
}
@ -125,3 +125,4 @@ bool terrainSceneNode()
result &= terrainGaps();
return result;
}