Fix warnings, layout, and return value.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3871 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
009a6bfc92
commit
8cb3aebfd0
|
@ -72,7 +72,7 @@ class ScalableFont : public gui::IGUIFontBitmap
|
||||||
u32 i = (u32)xml->getAttributeValueAsInt(L"index");
|
u32 i = (u32)xml->getAttributeValueAsInt(L"index");
|
||||||
|
|
||||||
float scale=1.0f;
|
float scale=1.0f;
|
||||||
if(xml->getAttributeValue(L"scale"))
|
if (xml->getAttributeValue(L"scale"))
|
||||||
scale = xml->getAttributeValueAsFloat(L"scale");
|
scale = xml->getAttributeValueAsFloat(L"scale");
|
||||||
//std::cout << "scale = " << scale << std::endl;
|
//std::cout << "scale = " << scale << std::endl;
|
||||||
|
|
||||||
|
@ -226,8 +226,10 @@ public:
|
||||||
//! destructor
|
//! destructor
|
||||||
virtual ~ScalableFont()
|
virtual ~ScalableFont()
|
||||||
{
|
{
|
||||||
if (Driver) Driver->drop();
|
if (Driver)
|
||||||
if (SpriteBank) SpriteBank->drop();
|
Driver->drop();
|
||||||
|
if (SpriteBank)
|
||||||
|
SpriteBank->drop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! loads a font from an XML file
|
//! loads a font from an XML file
|
||||||
|
@ -246,11 +248,12 @@ public:
|
||||||
for(wchar_t c='0'; c<='9'; c++)
|
for(wchar_t c='0'; c<='9'; c++)
|
||||||
{
|
{
|
||||||
SFontArea a = getAreaFromCharacter(c, NULL);
|
SFontArea a = getAreaFromCharacter(c, NULL);
|
||||||
if(a.overhang > m_max_digit_area.overhang ) m_max_digit_area.overhang = a.overhang;
|
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.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.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;
|
return true;
|
||||||
}
|
}
|
||||||
//! draws an text and clips it to the specified rectangle if wanted
|
//! draws an text and clips it to the specified rectangle if wanted
|
||||||
|
@ -284,9 +287,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == L'\r' || // Windows breaks
|
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.Y += (int)(MaxHeight*m_scale);
|
||||||
offset.X = position.UpperLeftCorner.X;
|
offset.X = position.UpperLeftCorner.X;
|
||||||
if (hcenter)
|
if (hcenter)
|
||||||
|
@ -301,8 +305,8 @@ public:
|
||||||
offsets.push_back(offset);
|
offsets.push_back(offset);
|
||||||
// Invisible character. add something to the array anyway so that
|
// Invisible character. add something to the array anyway so that
|
||||||
// indices from the various arrays remain in sync
|
// indices from the various arrays remain in sync
|
||||||
indices.push_back( Invisible.findFirst(c) < 0 ? area.spriteno
|
indices.push_back((Invisible.findFirst(c) < 0) ? (int)area.spriteno
|
||||||
: -1 );
|
: -1);
|
||||||
offset.X += getCharWidth(area, fallback[i]);
|
offset.X += getCharWidth(area, fallback[i]);
|
||||||
} // for i<text_size
|
} // for i<text_size
|
||||||
|
|
||||||
|
@ -312,7 +316,7 @@ public:
|
||||||
core::array< core::rect<s32> >& positions = SpriteBank->getPositions();
|
core::array< core::rect<s32> >& positions = SpriteBank->getPositions();
|
||||||
core::array< gui::SGUISprite >* fallback_sprites;
|
core::array< gui::SGUISprite >* fallback_sprites;
|
||||||
core::array< core::rect<s32> >* fallback_positions;
|
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_sprites = &m_fallback_font->SpriteBank->getSprites();
|
||||||
fallback_positions = &m_fallback_font->SpriteBank->getPositions();
|
fallback_positions = &m_fallback_font->SpriteBank->getPositions();
|
||||||
|
@ -328,8 +332,10 @@ public:
|
||||||
for (int n=0; n<indiceAmount; n++)
|
for (int n=0; n<indiceAmount; n++)
|
||||||
{
|
{
|
||||||
const int spriteID = indices[n];
|
const int spriteID = indices[n];
|
||||||
if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount)) continue;
|
if (!fallback[n] && (spriteID < 0 || spriteID >= spriteAmount))
|
||||||
if (indices[n] == -1) continue;
|
continue;
|
||||||
|
if (indices[n] == -1)
|
||||||
|
continue;
|
||||||
|
|
||||||
//assert(sprites[spriteID].Frames.size() > 0);
|
//assert(sprites[spriteID].Frames.size() > 0);
|
||||||
|
|
||||||
|
@ -343,8 +349,7 @@ public:
|
||||||
|
|
||||||
const TextureInfo& info = (fallback[n] ?
|
const TextureInfo& info = (fallback[n] ?
|
||||||
(*(m_fallback_font->m_texture_files.find(texID))).second :
|
(*(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;
|
float char_scale = info.m_scale;
|
||||||
|
|
||||||
core::dimension2d<s32> size = source.getSize();
|
core::dimension2d<s32> size = source.getSize();
|
||||||
|
@ -440,7 +445,7 @@ public:
|
||||||
for (const wchar_t* p = text; *p; ++p)
|
for (const wchar_t* p = text; *p; ++p)
|
||||||
{
|
{
|
||||||
if (*p == L'\r' || // Windows breaks
|
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
|
if (*p==L'\r' && p[1] == L'\n') // Windows breaks
|
||||||
++p;
|
++p;
|
||||||
|
@ -566,21 +571,23 @@ private:
|
||||||
|
|
||||||
const TextureInfo& info = (fallback ?
|
const TextureInfo& info = (fallback ?
|
||||||
(*(m_fallback_font->m_texture_files.find(texID))).second :
|
(*(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;
|
const float char_scale = info.m_scale;
|
||||||
|
|
||||||
//std::cout << "area.spriteno=" << area.spriteno << ", char_scale=" << char_scale << std::endl;
|
//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);
|
if (fallback)
|
||||||
else return (int)((area.width + area.overhang + GlobalKerningWidth) * m_scale * char_scale);
|
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
|
s32 getAreaIDFromCharacter(const wchar_t c, bool* fallback_font) const
|
||||||
{
|
{
|
||||||
std::map<wchar_t, s32>::const_iterator n = CharacterMap.find(c);
|
std::map<wchar_t, s32>::const_iterator n = CharacterMap.find(c);
|
||||||
if (n != CharacterMap.end())
|
if (n != CharacterMap.end())
|
||||||
{
|
{
|
||||||
if (fallback_font != NULL) *fallback_font = false;
|
if (fallback_font != NULL)
|
||||||
|
*fallback_font = false;
|
||||||
return (*n).second;
|
return (*n).second;
|
||||||
}
|
}
|
||||||
else if (m_fallback_font != NULL && fallback_font != NULL)
|
else if (m_fallback_font != NULL && fallback_font != NULL)
|
||||||
|
@ -591,7 +598,8 @@ private:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// std::cout << "The font does not have this character : <" << (int)c << ">" << std::endl;
|
// 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;
|
return WrongCharacter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ bool testShots(video::E_DRIVER_TYPE type)
|
||||||
smgr->drawAll();
|
smgr->drawAll();
|
||||||
driver->endScene();
|
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);
|
video::IImage* img = driver->createScreenShot((video::ECOLOR_FORMAT)i);
|
||||||
logTestString("Color Format %d %ssupported\n", i, (img && img->getColorFormat() == i)?"":"un");
|
logTestString("Color Format %d %ssupported\n", i, (img && img->getColorFormat() == i)?"":"un");
|
||||||
|
|
|
@ -114,7 +114,7 @@ bool terrainGaps()
|
||||||
device->closeDevice();
|
device->closeDevice();
|
||||||
device->run();
|
device->run();
|
||||||
device->drop();
|
device->drop();
|
||||||
return true;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -125,3 +125,4 @@ bool terrainSceneNode()
|
||||||
result &= terrainGaps();
|
result &= terrainGaps();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue