mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 18:16:31 +03:00
Added some important access to some data in fonts, changed how the font texture coordinates are saved ( so you'll need to regenerate them ).
Fixed some minor bugs.
This commit is contained in:
@@ -182,7 +182,7 @@ void cIsoMap::Draw() {
|
||||
for ( eeInt y = Ty; y < Ty2; y++ ) {
|
||||
for ( eeInt x = Tx; x < Tx2; x++ ) {
|
||||
T = &Tile( (eeUint)x, (eeUint)y );
|
||||
mFont->Draw( T->TilePosStr, mOffsetX + T->Q.V[1].x + ( T->Q.V[3].x - T->Q.V[1].x ) * 0.5f - T->TilePosStr.size() * mFont->GetFontSize() * 0.5f, mOffsetY + T->Q.V[0].y + ( T->Q.V[2].y - T->Q.V[0].y ) * 0.5f - mFont->GetFontHeight() * 0.5f );
|
||||
mFont->Draw( T->TilePosStr, mOffsetX + T->Q.V[1].x + ( T->Q.V[3].x - T->Q.V[1].x ) * 0.5f - T->TilePosStr.size() * mFont->GetFontHeight() * 0.5f, mOffsetY + T->Q.V[0].y + ( T->Q.V[2].y - T->Q.V[0].y ) * 0.5f - mFont->GetFontHeight() * 0.5f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,6 +216,7 @@ void cMapEditor::CreateShapeContainer( Int32 Width ) {
|
||||
FillGotyList();
|
||||
|
||||
mBtnGOTypeAdd = mTheme->CreatePushButton( mShapeCont, eeSize( 24, 21 ), eeVector2i( mGOTypeList->Pos().x + mGOTypeList->Size().Width() + 2, mGOTypeList->Pos().y ), UI_CONTROL_ALIGN_CENTER | UI_AUTO_SIZE | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP, mTheme->GetIconByName( "add" ) );
|
||||
mBtnGOTypeAdd->TooltipText( "Adds a new game object type\nunknown by the map editor." );
|
||||
mBtnGOTypeAdd->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::AddNewGOType ) );
|
||||
|
||||
if ( NULL == mBtnGOTypeAdd->Icon()->Shape() )
|
||||
@@ -240,10 +241,12 @@ void cMapEditor::CreateShapeContainer( Int32 Width ) {
|
||||
|
||||
mChkBlocked = mTheme->CreateCheckBox( mShapeCont, eeSize(), eeVector2i( mChkMirrored->Pos().x, mChkMirrored->Pos().y + mChkMirrored->Size().Height() + 4 ), ChkFlags );
|
||||
mChkBlocked->Text( "Blocked" );
|
||||
mChkBlocked->TooltipText( "Blocks the tile occupied by the sprite." );
|
||||
mChkBlocked->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickBlocked ) );
|
||||
|
||||
mChkAnim = mTheme->CreateCheckBox( mShapeCont, eeSize(), eeVector2i( mChkFliped->Pos().x, mChkFliped->Pos().y + mChkFliped->Size().Height() + 4 ), ChkFlags );
|
||||
mChkAnim->Text( "Animated" );
|
||||
mChkAnim->TooltipText( "Indicates if the Sprite is animated." );
|
||||
mChkAnim->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickAnimated ) );
|
||||
|
||||
mChkRot90 = mTheme->CreateCheckBox( mShapeCont, eeSize(), eeVector2i( mChkBlocked->Pos().x, mChkBlocked->Pos().y + mChkBlocked->Size().Height() + 4 ), ChkFlags );
|
||||
@@ -252,12 +255,14 @@ void cMapEditor::CreateShapeContainer( Int32 Width ) {
|
||||
|
||||
mChkAutoFix = mTheme->CreateCheckBox( mShapeCont, eeSize(), eeVector2i( mChkAnim->Pos().x, mChkAnim->Pos().y + mChkAnim->Size().Height() + 4 ), ChkFlags );
|
||||
mChkAutoFix->Text( "AutoFix TilePos" );
|
||||
mChkAutoFix->TooltipText( "In a tiled layer if the sprite is moved,\nit will update the current tile position automatically." );
|
||||
mChkAutoFix->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickAutoFix ) );
|
||||
|
||||
Txt = mTheme->CreateTextBox( "Game Object Data:", mShapeCont, eeSize( Width, 16 ), eeVector2i( 0, mChkRot90->Pos().y + mChkRot90->Size().Height() + 8 ), TxtFlags );
|
||||
|
||||
mChkDI = mTheme->CreateCheckBox( mShapeCont, eeSize(), eeVector2i( 0, Txt->Pos().y + Txt->Size().Height() + 4 ), ChkFlags );
|
||||
mChkDI->Text( "Add as DataId" );
|
||||
mChkDI->TooltipText( "If the resource it's not a sprite,\nyou can reference it with a data id" );
|
||||
mChkDI->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickDI ) );
|
||||
|
||||
cUIComplexControl::CreateParams SGParams;
|
||||
|
||||
@@ -64,7 +64,10 @@ void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUin
|
||||
|
||||
mFont = Font;
|
||||
|
||||
mFontSize = (eeFloat)mFont->GetFontSize();
|
||||
mFontSize = (eeFloat)( mFont->GetFontSize() * 1.25 );
|
||||
|
||||
if ( mFont->GetFontHeight() < mFontSize && ( mFont->GetFontHeight() != mFont->GetFontSize() || mFont->GetLineSkip() != (Int32)mFont->GetFontHeight() ) )
|
||||
mFontSize = mFont->GetFontHeight();
|
||||
|
||||
if ( TextureId > 0 )
|
||||
mTexId = TextureId;
|
||||
@@ -73,7 +76,6 @@ void cConsole::Create( cFont* Font, const bool& MakeDefaultCommands, const eeUin
|
||||
mMaxAlpha = (eeFloat)mConColor.A();
|
||||
|
||||
mEnabled = true;
|
||||
mFontSize *= 1.25f;
|
||||
|
||||
if ( MakeDefaultCommands )
|
||||
CreateDefaultCommands();
|
||||
@@ -150,7 +152,7 @@ void cConsole::Draw() {
|
||||
}
|
||||
}
|
||||
|
||||
CurY = mTempY + mY + mCurHeight - mFontSize;
|
||||
CurY = mTempY + mY + mCurHeight - mFontSize - 1;
|
||||
|
||||
mFont->Color( eeColorA ( mFontLineColor.R(), mFontLineColor.G(), mFontLineColor.B(), static_cast<Uint8>(mA) ) );
|
||||
mFont->SetText( "> " + mTBuf.Buffer() );
|
||||
|
||||
@@ -12,7 +12,10 @@ cFont::cFont( const Uint32& Type, const std::string& Name ) :
|
||||
mTexId(0),
|
||||
mCachedWidth(0.f),
|
||||
mHeight(0),
|
||||
mSize(0)
|
||||
mSize(0),
|
||||
mLineSkip(0),
|
||||
mAscent(0),
|
||||
mDescent(0)
|
||||
{
|
||||
this->Name( Name );
|
||||
cFontManager::instance()->Add( this );
|
||||
@@ -89,6 +92,18 @@ Uint32 cFont::GetFontHeight() const {
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
Int32 cFont::GetLineSkip() const {
|
||||
return mLineSkip;
|
||||
}
|
||||
|
||||
Int32 cFont::GetFontAscent() const {
|
||||
return mAscent;
|
||||
}
|
||||
|
||||
Int32 cFont::GetFontDescent() const {
|
||||
return mDescent;
|
||||
}
|
||||
|
||||
String cFont::GetText() {
|
||||
return mText;
|
||||
}
|
||||
@@ -102,7 +117,7 @@ const bool& cFont::CacheData() const {
|
||||
}
|
||||
|
||||
eeFloat cFont::GetTextHeight() {
|
||||
return (eeFloat)GetFontSize() * (eeFloat)GetNumLines();
|
||||
return (eeFloat)GetFontHeight() * (eeFloat)GetNumLines();
|
||||
}
|
||||
|
||||
const std::vector<eeFloat>& cFont::GetLinesWidth() const {
|
||||
@@ -213,7 +228,7 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con
|
||||
case '\n':
|
||||
{
|
||||
if (mVerticalDraw) {
|
||||
nX += (GetFontSize() * Scale);
|
||||
nX += (GetFontHeight() * Scale);
|
||||
nY = 0;
|
||||
} else {
|
||||
if ( i + 1 < TextCache.Text().size() ) {
|
||||
@@ -229,7 +244,7 @@ void cFont::Draw( cTextCache& TextCache, const eeFloat& X, const eeFloat& Y, con
|
||||
}
|
||||
}
|
||||
|
||||
nY += (GetFontSize() * Scale);
|
||||
nY += (GetFontHeight() * Scale);
|
||||
Line++;
|
||||
}
|
||||
|
||||
@@ -403,7 +418,7 @@ void cFont::SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, con
|
||||
break;
|
||||
case '\n':
|
||||
if (mVerticalDraw) {
|
||||
nX += (GetFontSize() * Scale);
|
||||
nX += (GetFontHeight() * Scale);
|
||||
nY = 0;
|
||||
} else {
|
||||
if ( i + 1 < Text.size() ) {
|
||||
@@ -419,7 +434,7 @@ void cFont::SubDraw( const String& Text, const eeFloat& X, const eeFloat& Y, con
|
||||
}
|
||||
}
|
||||
|
||||
nY += (GetFontSize() * Scale);
|
||||
nY += (GetFontHeight() * Scale);
|
||||
Line++;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,6 +52,15 @@ class EE_API cFont {
|
||||
/** @return The current font height */
|
||||
Uint32 GetFontHeight() const;
|
||||
|
||||
/** @return The recommended line spacing */
|
||||
Int32 GetLineSkip() const;
|
||||
|
||||
/** @return The font highest ascent (height above base) */
|
||||
Int32 GetFontAscent() const;
|
||||
|
||||
/** @return The font lowest descent (height below base) */
|
||||
Int32 GetFontDescent() const;
|
||||
|
||||
/** @return The current text */
|
||||
String GetText();
|
||||
|
||||
@@ -126,7 +135,7 @@ class EE_API cFont {
|
||||
std::string mFontName;
|
||||
Uint32 mFontHash;
|
||||
|
||||
String mText;
|
||||
String mText;
|
||||
bool mCacheData;
|
||||
eeColorA mColor;
|
||||
eeColorA mShadowColor;
|
||||
@@ -136,6 +145,9 @@ class EE_API cFont {
|
||||
eeFloat mCachedWidth;
|
||||
Uint32 mHeight;
|
||||
Uint32 mSize;
|
||||
Int32 mLineSkip;
|
||||
Int32 mAscent;
|
||||
Int32 mDescent;
|
||||
|
||||
std::vector<eeFloat> mLinesWidth;
|
||||
std::vector<eeGlyph> mGlyphs;
|
||||
|
||||
@@ -115,7 +115,7 @@ eeFloat cTextCache::GetTextWidth() {
|
||||
}
|
||||
|
||||
eeFloat cTextCache::GetTextHeight() {
|
||||
return (eeFloat)mFont->GetFontSize() * (eeFloat)mNumLines;
|
||||
return (eeFloat)mFont->GetFontHeight() * (eeFloat)mNumLines;
|
||||
}
|
||||
|
||||
const eeInt& cTextCache::GetNumLines() const {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "ctexturefont.hpp"
|
||||
#include "../system/ciostreamfile.hpp"
|
||||
#include "../system/ciostreammemory.hpp"
|
||||
|
||||
namespace EE { namespace Graphics {
|
||||
|
||||
@@ -19,19 +21,19 @@ bool cTextureFont::Load( const Uint32& TexId, const eeUint& StartChar, const eeU
|
||||
mTexId = TexId;
|
||||
|
||||
if ( NULL != Tex ) {
|
||||
mTexColumns = TexColumns;
|
||||
mTexRows = TexRows;
|
||||
mStartChar = StartChar;
|
||||
mNumChars = NumChars;
|
||||
mTexColumns = TexColumns;
|
||||
mTexRows = TexRows;
|
||||
mStartChar = StartChar;
|
||||
mNumChars = NumChars;
|
||||
|
||||
mtX = ( 1 / static_cast<eeFloat>( mTexColumns ) );
|
||||
mtY = ( 1 / static_cast<eeFloat>( mTexRows ) );
|
||||
mtX = ( 1 / static_cast<eeFloat>( mTexColumns ) );
|
||||
mtY = ( 1 / static_cast<eeFloat>( mTexRows ) );
|
||||
|
||||
mFWidth = (eeFloat)( Tex->Width() / mTexColumns );
|
||||
mFHeight = (eeFloat)( Tex->Height() / mTexRows );
|
||||
mHeight = mSize = (eeUint)mFHeight;
|
||||
mFWidth = (eeFloat)( Tex->Width() / mTexColumns );
|
||||
mFHeight = (eeFloat)( Tex->Height() / mTexRows );
|
||||
mHeight = mSize = mLineSkip = (eeUint)mFHeight;
|
||||
|
||||
mVerticalDraw = VerticalDraw;
|
||||
mVerticalDraw = VerticalDraw;
|
||||
|
||||
if ( Spacing == 0 )
|
||||
mSpacing = static_cast<eeUint>( mFWidth );
|
||||
@@ -85,7 +87,7 @@ void cTextureFont::BuildFont() {
|
||||
}
|
||||
}
|
||||
|
||||
void cTextureFont::BuildFontFromDat() {
|
||||
void cTextureFont::BuildFromGlyphs() {
|
||||
eeFloat Top, Bottom;
|
||||
eeRectf tR;
|
||||
|
||||
@@ -95,15 +97,19 @@ void cTextureFont::BuildFontFromDat() {
|
||||
|
||||
cTextureFactory::instance()->Bind( Tex );
|
||||
|
||||
eeGlyph tGlyph;
|
||||
|
||||
for (eeUint i = 0; i < mNumChars; i++) {
|
||||
tR.Left = (eeFloat)mGlyphs[i].CurX / Tex->Width();
|
||||
tR.Top = (eeFloat)mGlyphs[i].CurY / Tex->Height();
|
||||
tGlyph = mGlyphs[i];
|
||||
|
||||
tR.Right = (eeFloat)(mGlyphs[i].CurX + mGlyphs[i].CurW) / Tex->Width();
|
||||
tR.Bottom = (eeFloat)(mGlyphs[i].CurY + mGlyphs[i].CurH) / Tex->Height();
|
||||
tR.Left = (eeFloat)tGlyph.CurX / Tex->Width();
|
||||
tR.Top = (eeFloat)tGlyph.CurY / Tex->Height();
|
||||
|
||||
Top = mFHeight - mGlyphs[i].GlyphH - mGlyphs[i].MinY;
|
||||
Bottom = mFHeight + mGlyphs[i].GlyphH - mGlyphs[i].MaxY;
|
||||
tR.Right = (eeFloat)(tGlyph.CurX + tGlyph.CurW) / Tex->Width();
|
||||
tR.Bottom = (eeFloat)(tGlyph.CurY + tGlyph.CurH) / Tex->Height();
|
||||
|
||||
Top = mHeight + mDescent - tGlyph.GlyphH - tGlyph.MinY;
|
||||
Bottom = mHeight + mDescent + tGlyph.GlyphH - tGlyph.MaxY;
|
||||
|
||||
mTexCoords[i].TexCoords[0] = tR.Left;
|
||||
mTexCoords[i].TexCoords[1] = tR.Top;
|
||||
@@ -113,24 +119,22 @@ void cTextureFont::BuildFontFromDat() {
|
||||
mTexCoords[i].TexCoords[5] = tR.Bottom;
|
||||
mTexCoords[i].TexCoords[6] = tR.Right;
|
||||
mTexCoords[i].TexCoords[7] = tR.Top;
|
||||
mTexCoords[i].Vertex[0] = (eeFloat) mGlyphs[i].MinX;
|
||||
mTexCoords[i].Vertex[0] = (eeFloat) tGlyph.MinX;
|
||||
mTexCoords[i].Vertex[1] = Top;
|
||||
mTexCoords[i].Vertex[2] = (eeFloat) mGlyphs[i].MinX;
|
||||
mTexCoords[i].Vertex[2] = (eeFloat) tGlyph.MinX;
|
||||
mTexCoords[i].Vertex[3] = Bottom;
|
||||
mTexCoords[i].Vertex[4] = (eeFloat) mGlyphs[i].MaxX;
|
||||
mTexCoords[i].Vertex[4] = (eeFloat) tGlyph.MaxX;
|
||||
mTexCoords[i].Vertex[5] = Bottom;
|
||||
mTexCoords[i].Vertex[6] = (eeFloat) mGlyphs[i].MaxX;
|
||||
mTexCoords[i].Vertex[6] = (eeFloat) tGlyph.MaxX;
|
||||
mTexCoords[i].Vertex[7] = Top;
|
||||
}
|
||||
}
|
||||
|
||||
bool cTextureFont::Load( const Uint32& TexId, const std::string& CoordinatesDatPath, const bool& VerticalDraw ) {
|
||||
if ( FileExists( CoordinatesDatPath ) ) {
|
||||
SafeDataPointer PData;
|
||||
cIOStreamFile IOS( CoordinatesDatPath, std::ios::in | std::ios::binary );
|
||||
|
||||
FileGet( CoordinatesDatPath, PData );
|
||||
|
||||
return LoadFromMemory( TexId, reinterpret_cast<const Uint8*> ( PData.Data ), PData.DataSize, VerticalDraw );
|
||||
return LoadFromStream( TexId, IOS, VerticalDraw );
|
||||
} else if ( cPackManager::instance()->FallbackToPacks() ) {
|
||||
std::string tPath( CoordinatesDatPath );
|
||||
|
||||
@@ -145,38 +149,52 @@ bool cTextureFont::Load( const Uint32& TexId, const std::string& CoordinatesDatP
|
||||
}
|
||||
|
||||
bool cTextureFont::LoadFromPack( const Uint32& TexId, cPack* Pack, const std::string& FilePackPath, const bool& VerticalDraw ) {
|
||||
SafeDataPointer PData;
|
||||
if ( NULL != Pack && Pack->IsOpen() && -1 != Pack->Exists( FilePackPath ) ) {
|
||||
SafeDataPointer PData;
|
||||
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, PData ) ) {
|
||||
return LoadFromMemory( TexId, reinterpret_cast<const Uint8*> ( PData.Data ), PData.DataSize, VerticalDraw );
|
||||
Pack->ExtractFileToMemory( FilePackPath, PData );
|
||||
|
||||
return LoadFromMemory( TexId, reinterpret_cast<const char*> ( PData.Data ), PData.DataSize, VerticalDraw );
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cTextureFont::LoadFromMemory( const Uint32& TexId, const Uint8* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw ) {
|
||||
bool cTextureFont::LoadFromMemory( const Uint32& TexId, const char* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw ) {
|
||||
cIOStreamMemory IOS( CoordData, CoordDataSize );
|
||||
|
||||
return LoadFromStream( TexId, IOS, VerticalDraw );
|
||||
}
|
||||
|
||||
bool cTextureFont::LoadFromStream( const Uint32& TexId, cIOStream& IOS, const bool& VerticalDraw ) {
|
||||
mTexId = TexId;
|
||||
|
||||
if ( mTexId > 0 ) {
|
||||
mVerticalDraw = VerticalDraw;
|
||||
|
||||
if ( CoordData != NULL ) {
|
||||
mNumChars = static_cast<Uint16> ( ( CoordDataSize - 2 ) / 32 );
|
||||
if ( IOS.IsOpen() ) {
|
||||
sFntHdr FntHdr;
|
||||
|
||||
IOS.Read( (char*)&FntHdr, sizeof(sFntHdr) );
|
||||
|
||||
if ( EE_TTF_FONT_MAGIC != FntHdr.Magic )
|
||||
return false;
|
||||
|
||||
mStartChar = FntHdr.FirstChar;
|
||||
mNumChars = FntHdr.NumChars;
|
||||
mSize = FntHdr.Size;
|
||||
mHeight = FntHdr.Height;
|
||||
mLineSkip = FntHdr.LineSkip;
|
||||
mAscent = FntHdr.Ascent;
|
||||
mDescent = FntHdr.Descent;
|
||||
|
||||
mGlyphs.resize( mNumChars );
|
||||
|
||||
// Read the number of the first char represented on the texture
|
||||
mStartChar = CoordData[0];
|
||||
// Read the glyphs
|
||||
IOS.Read( (char*)&mGlyphs[0], sizeof(eeGlyph) * mNumChars );
|
||||
|
||||
// Read the default size of every char
|
||||
mFWidth = CoordData[1];
|
||||
mFHeight = CoordData[1];
|
||||
mHeight = mSize = (Uint32)mFHeight;
|
||||
BuildFromGlyphs();
|
||||
|
||||
// Read every char coordinates
|
||||
memcpy( reinterpret_cast<void*> (&mGlyphs[0]), reinterpret_cast<const void*> (&CoordData[2]), sizeof(eeGlyph) * mNumChars );
|
||||
|
||||
BuildFontFromDat();
|
||||
mLoadedCoords = true;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -50,14 +50,17 @@ class EE_API cTextureFont : public cFont {
|
||||
* @param VerticalDraw If true render the string verticaly
|
||||
* @return True if success
|
||||
*/
|
||||
bool LoadFromMemory( const Uint32& TexId, const Uint8* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw = false );
|
||||
bool LoadFromMemory( const Uint32& TexId, const char* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw = false );
|
||||
|
||||
bool LoadFromStream( const Uint32& TexId, cIOStream& IOS, const bool& VerticalDraw );
|
||||
private:
|
||||
eeUint mBase, mStartChar, mTexColumns, mTexRows, mSpacing, mNumChars;
|
||||
eeFloat mtX, mtY, mFWidth, mFHeight;
|
||||
bool mLoadedCoords;
|
||||
|
||||
void BuildFont();
|
||||
void BuildFontFromDat();
|
||||
|
||||
void BuildFromGlyphs();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -44,7 +44,7 @@ cTextureFontLoader::cTextureFontLoader( const std::string FontName, cTextureLoad
|
||||
mTexLoader = TexLoader;
|
||||
}
|
||||
|
||||
cTextureFontLoader::cTextureFontLoader( const std::string FontName, cTextureLoader * TexLoader, const Uint8* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw ) :
|
||||
cTextureFontLoader::cTextureFontLoader( const std::string FontName, cTextureLoader * TexLoader, const char* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw ) :
|
||||
cObjectLoader( FontTexLoader ),
|
||||
mLoadType( TEF_LT_MEM ),
|
||||
mFontName( FontName ),
|
||||
|
||||
@@ -22,7 +22,7 @@ class EE_API cTextureFontLoader : public cObjectLoader {
|
||||
|
||||
cTextureFontLoader( const std::string FontName, cTextureLoader * TexLoader, cPack * Pack, const std::string& FilePackPath, const bool& VerticalDraw = false );
|
||||
|
||||
cTextureFontLoader( const std::string FontName, cTextureLoader * TexLoader, const Uint8* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw = false );
|
||||
cTextureFontLoader( const std::string FontName, cTextureLoader * TexLoader, const char* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw = false );
|
||||
|
||||
virtual ~cTextureFontLoader();
|
||||
|
||||
@@ -52,7 +52,7 @@ class EE_API cTextureFontLoader : public cObjectLoader {
|
||||
|
||||
cPack * mPack;
|
||||
|
||||
const Uint8 * mData;
|
||||
const char * mData;
|
||||
Uint32 mDataSize;
|
||||
|
||||
void Start();
|
||||
|
||||
@@ -86,6 +86,10 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve
|
||||
mVerticalDraw = VerticalDraw;
|
||||
mSize = Size;
|
||||
mHeight = mFont->Height() + OutlineTotal;
|
||||
mLineSkip = mFont->LineSkip();
|
||||
mAscent = mFont->Ascent();
|
||||
mDescent = mFont->Descent();
|
||||
|
||||
mNumChars = NumCharsToGen;
|
||||
mFontColor = FontColor;
|
||||
mOutlineColor = OutlineColor;
|
||||
@@ -99,12 +103,30 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve
|
||||
bool lastWasWidth = false;
|
||||
Uint32 ReqSize;
|
||||
|
||||
// Find the best size for the texture ( aprox )
|
||||
// Find the larger glyph
|
||||
/*
|
||||
int maxWidth = 0, maxHeight = 0;
|
||||
|
||||
mSize += PixelSep;
|
||||
for ( eeUint i = 0; i < mNumChars; i++) {
|
||||
TempGlyphSurface = mFont->GlyphRender( i, 0x00000000 );
|
||||
|
||||
maxWidth = eemax( mFont->Current()->Pixmap()->width, maxWidth );
|
||||
maxHeight = eemax( mFont->Current()->Pixmap()->rows, maxHeight );
|
||||
|
||||
hkSAFE_DELETE_ARRAY( TempGlyphSurface );
|
||||
}
|
||||
|
||||
//ReqSize = mNumChars * mHeight * mHeight;
|
||||
*/
|
||||
|
||||
// Find the best size for the texture ( aprox )
|
||||
// Totally wild guessing, but it's working
|
||||
Int32 tWildGuessW = ( mAscent + PixelSep + OutlineTotal );
|
||||
Int32 tWildGuessH = tWildGuessW; //( mHeight );
|
||||
|
||||
ReqSize = mNumChars * tWildGuessW * tWildGuessH;
|
||||
|
||||
do {
|
||||
ReqSize = mNumChars * mSize * mSize;
|
||||
TexSize = (Uint32)mTexWidth * (Uint32)mTexHeight;
|
||||
|
||||
if ( TexSize < ReqSize ) {
|
||||
@@ -117,10 +139,6 @@ bool cTTFFont::iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& Ve
|
||||
}
|
||||
} while ( TexSize < ReqSize );
|
||||
|
||||
mSize -= PixelSep;
|
||||
|
||||
TexSize = (Uint32)mTexWidth * (Uint32)mTexHeight;
|
||||
|
||||
mPixels = eeNewArray( eeColorA, TexSize );
|
||||
memset( mPixels, 0x00000000, TexSize * 4 );
|
||||
|
||||
@@ -288,15 +306,19 @@ void cTTFFont::RebuildFromGlyphs() {
|
||||
|
||||
cTextureFactory::instance()->Bind( Tex );
|
||||
|
||||
eeGlyph tGlyph;
|
||||
|
||||
for (eeUint i = 0; i < mNumChars; i++) {
|
||||
tR.Left = (eeFloat)mGlyphs[i].CurX / Tex->Width();
|
||||
tR.Top = (eeFloat)mGlyphs[i].CurY / Tex->Height();
|
||||
tGlyph = mGlyphs[i];
|
||||
|
||||
tR.Right = (eeFloat)(mGlyphs[i].CurX + mGlyphs[i].CurW) / Tex->Width();
|
||||
tR.Bottom = (eeFloat)(mGlyphs[i].CurY + mGlyphs[i].CurH) / Tex->Height();
|
||||
tR.Left = (eeFloat)tGlyph.CurX / Tex->Width();
|
||||
tR.Top = (eeFloat)tGlyph.CurY / Tex->Height();
|
||||
|
||||
Top = (eeFloat)mSize - mGlyphs[i].GlyphH - mGlyphs[i].MinY;
|
||||
Bottom = (eeFloat)mSize + mGlyphs[i].GlyphH - mGlyphs[i].MaxY;
|
||||
tR.Right = (eeFloat)(tGlyph.CurX + tGlyph.CurW) / Tex->Width();
|
||||
tR.Bottom = (eeFloat)(tGlyph.CurY + tGlyph.CurH) / Tex->Height();
|
||||
|
||||
Top = (eeFloat)mHeight + mDescent - tGlyph.GlyphH - tGlyph.MinY;
|
||||
Bottom = (eeFloat)mHeight + mDescent + tGlyph.GlyphH - tGlyph.MaxY;
|
||||
|
||||
mTexCoords[i].TexCoords[0] = tR.Left;
|
||||
mTexCoords[i].TexCoords[1] = tR.Top;
|
||||
@@ -306,13 +328,13 @@ void cTTFFont::RebuildFromGlyphs() {
|
||||
mTexCoords[i].TexCoords[5] = tR.Bottom;
|
||||
mTexCoords[i].TexCoords[6] = tR.Right;
|
||||
mTexCoords[i].TexCoords[7] = tR.Top;
|
||||
mTexCoords[i].Vertex[0] = (eeFloat) mGlyphs[i].MinX;
|
||||
mTexCoords[i].Vertex[0] = (eeFloat) tGlyph.MinX;
|
||||
mTexCoords[i].Vertex[1] = Top;
|
||||
mTexCoords[i].Vertex[2] = (eeFloat) mGlyphs[i].MinX;
|
||||
mTexCoords[i].Vertex[2] = (eeFloat) tGlyph.MinX;
|
||||
mTexCoords[i].Vertex[3] = Bottom;
|
||||
mTexCoords[i].Vertex[4] = (eeFloat) mGlyphs[i].MaxX;
|
||||
mTexCoords[i].Vertex[4] = (eeFloat) tGlyph.MaxX;
|
||||
mTexCoords[i].Vertex[5] = Bottom;
|
||||
mTexCoords[i].Vertex[6] = (eeFloat) mGlyphs[i].MaxX;
|
||||
mTexCoords[i].Vertex[6] = (eeFloat) tGlyph.MaxX;
|
||||
mTexCoords[i].Vertex[7] = Top;
|
||||
}
|
||||
}
|
||||
@@ -327,21 +349,25 @@ bool cTTFFont::SaveTexture( const std::string& Filepath, const EE_SAVE_TYPE& For
|
||||
}
|
||||
|
||||
bool cTTFFont::SaveCoordinates( const std::string& Filepath ) {
|
||||
Uint8 chars;
|
||||
|
||||
cIOStreamFile fs( Filepath, std::ios::out | std::ios::binary );
|
||||
|
||||
if ( fs.IsOpen() ) {
|
||||
// Write the number of the fist char represented on the texture
|
||||
chars = 0;
|
||||
fs.Write( reinterpret_cast<const char*> (&chars), sizeof(Uint8) );
|
||||
sFntHdr FntHdr;
|
||||
|
||||
// Write the default size of every char
|
||||
chars = static_cast<Uint8> ( mSize );
|
||||
fs.Write( reinterpret_cast<const char*> (&chars), sizeof(Uint8) );
|
||||
FntHdr.Magic = EE_TTF_FONT_MAGIC;
|
||||
FntHdr.FirstChar = 0;
|
||||
FntHdr.NumChars = mGlyphs.size();
|
||||
FntHdr.Size = mSize;
|
||||
FntHdr.Height = mHeight;
|
||||
FntHdr.LineSkip = mLineSkip;
|
||||
FntHdr.Ascent = mAscent;
|
||||
FntHdr.Descent = mDescent;
|
||||
|
||||
for (eeUint i = 0; i < mGlyphs.size(); i++)
|
||||
fs.Write( reinterpret_cast<const char*> (&mGlyphs[i]), sizeof(eeGlyph) );
|
||||
// Write the header
|
||||
fs.Write( reinterpret_cast<const char*>( &FntHdr ), sizeof(sFntHdr) );
|
||||
|
||||
// Write the glyphs
|
||||
fs.Write( reinterpret_cast<const char*> (&mGlyphs[0]), sizeof(eeGlyph) * mGlyphs.size() );
|
||||
|
||||
RebuildFromGlyphs();
|
||||
|
||||
@@ -381,4 +407,12 @@ void cTTFFont::MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h) {
|
||||
}
|
||||
}
|
||||
|
||||
bool cTTFFont::ThreadedLoading() const {
|
||||
return mThreadedLoading;
|
||||
}
|
||||
|
||||
void cTTFFont::ThreadedLoading( const bool& isThreaded ) {
|
||||
mThreadedLoading = isThreaded;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -70,32 +70,35 @@ class EE_API cTTFFont : public cFont {
|
||||
protected:
|
||||
friend class cTTFFontLoader;
|
||||
|
||||
bool ThreadedLoading() const { return mThreadedLoading; }
|
||||
hkFont * mFont;
|
||||
eeColorA * mPixels;
|
||||
|
||||
void ThreadedLoading( const bool& isThreaded ) { mThreadedLoading = isThreaded; }
|
||||
std::string mFilepath;
|
||||
Uint32 mNumChars;
|
||||
Uint8 mOutlineSize;
|
||||
|
||||
void UpdateLoading();
|
||||
private:
|
||||
hkFont * mFont;
|
||||
eeColorA * mPixels;
|
||||
eeColor mFontColor;
|
||||
eeColor mOutlineColor;
|
||||
|
||||
std::string mFilepath;
|
||||
Uint32 mBase;
|
||||
Uint32 mNumChars;
|
||||
Uint8 mOutlineSize;
|
||||
|
||||
eeColor mFontColor, mOutlineColor;
|
||||
EE_TTF_FONTSTYLE mStyle;
|
||||
|
||||
eeFloat mTexWidth, mTexHeight;
|
||||
eeFloat mTexWidth;
|
||||
eeFloat mTexHeight;
|
||||
|
||||
bool mLoadedFromMemory;
|
||||
bool mLoadedFromMemory;
|
||||
bool mThreadedLoading;
|
||||
bool mTexReady;
|
||||
|
||||
bool mThreadedLoading;
|
||||
bool mTexReady;
|
||||
bool ThreadedLoading() const;
|
||||
|
||||
void ThreadedLoading( const bool& isThreaded );
|
||||
|
||||
void UpdateLoading();
|
||||
|
||||
bool iLoad( const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, Uint8 OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator );
|
||||
|
||||
void MakeOutline( Uint8 *in, Uint8 *out, Int16 w, Int16 h);
|
||||
|
||||
void RebuildFromGlyphs();
|
||||
};
|
||||
|
||||
|
||||
@@ -44,6 +44,19 @@ struct eeTexCoords {
|
||||
eeFloat Vertex[8];
|
||||
};
|
||||
|
||||
typedef struct sFntHdrS {
|
||||
Uint32 Magic;
|
||||
Uint32 FirstChar;
|
||||
Uint32 NumChars;
|
||||
Uint32 Size;
|
||||
Uint32 Height;
|
||||
Int32 LineSkip;
|
||||
Int32 Ascent;
|
||||
Int32 Descent;
|
||||
} sFntHdr;
|
||||
|
||||
#define EE_TTF_FONT_MAGIC ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'F' << 16 ) | ( 'N' << 24 ) )
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,7 +24,7 @@ cLog::~cLog() {
|
||||
mFS->Write( mData.c_str(), mData.size() );
|
||||
}
|
||||
|
||||
eeSAFE_DELETE( mFS );
|
||||
closefs();
|
||||
}
|
||||
|
||||
void cLog::Save( const std::string& filepath ) {
|
||||
@@ -69,7 +69,7 @@ void cLog::Write( const std::string& Text, const bool& newLine ) {
|
||||
mFS->Write( "\n", 1 );
|
||||
}
|
||||
|
||||
eeSAFE_DELETE( mFS );
|
||||
closefs();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ void cLog::openfs() {
|
||||
mFilePath = GetProcessPath();
|
||||
}
|
||||
|
||||
eeSAFE_DELETE( mFS );
|
||||
closefs();
|
||||
|
||||
if ( NULL == mFS ) {
|
||||
std::string str = mFilePath + "log.log";
|
||||
@@ -87,6 +87,14 @@ void cLog::openfs() {
|
||||
}
|
||||
}
|
||||
|
||||
void cLog::closefs() {
|
||||
Lock();
|
||||
|
||||
eeSAFE_DELETE( mFS );
|
||||
|
||||
Unlock();
|
||||
}
|
||||
|
||||
void cLog::Writef( const char* format, ... ) {
|
||||
int n, size = 256;
|
||||
std::string tstr( size, '\0' );
|
||||
@@ -124,7 +132,7 @@ void cLog::Writef( const char* format, ... ) {
|
||||
|
||||
mFS->Write( tstr.c_str(), tstr.size() );
|
||||
|
||||
eeSAFE_DELETE( mFS );
|
||||
closefs();
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
#include "base.hpp"
|
||||
#include "tsingleton.hpp"
|
||||
#include "ciostreamfile.hpp"
|
||||
#include "cmutex.hpp"
|
||||
|
||||
namespace EE { namespace System {
|
||||
|
||||
class EE_API cLog {
|
||||
class EE_API cLog : protected cMutex {
|
||||
SINGLETON_DECLARE_HEADERS(cLog)
|
||||
|
||||
public:
|
||||
@@ -39,6 +40,8 @@ class EE_API cLog {
|
||||
cIOStreamFile * mFS;
|
||||
|
||||
void openfs();
|
||||
|
||||
void closefs();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -25,7 +25,7 @@ void cEETest::Init() {
|
||||
|
||||
mAxisX = 0;
|
||||
mAxisY = 0;
|
||||
mCurDemo = 0xFFFFFF;
|
||||
mCurDemo = eeINDEX_NOT_FOUND;
|
||||
mMapEditor = NULL;
|
||||
mETGEditor = NULL;
|
||||
Mus = NULL;
|
||||
@@ -181,6 +181,10 @@ void cEETest::LoadFonts() {
|
||||
mFontLoader.Add( eeNew( cTTFFontLoader, ( "arial", PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 256, eeColor(255,255,255) ) ) );
|
||||
mFontLoader.Add( eeNew( cTTFFontLoader, ( "arialb", PAK, "arial.ttf", 12, EE_TTF_STYLE_NORMAL, false, 256, eeColor(255,255,255), 1, eeColor(0,0,0), true ) ) );
|
||||
|
||||
//mFontLoader.Add( eeNew( cTextureFontLoader, ( "ProggySquareSZ", eeNew( cTextureLoader, ( MyPath + "data/ProggySquareSZ.png" ) ), MyPath + "data/ProggySquareSZ.fnt" ) ) );
|
||||
//mFontLoader.Add( eeNew( cTTFFontLoader, ( "ProggySquareSZ", MyPath + "data/ProggySquareSZ.ttf", 16, EE_TTF_STYLE_NORMAL, false, 256 ) ) );
|
||||
//mFontLoader.Add( eeNew( cTTFFontLoader, ( "DejaVuSansMono", MyPath + "fonts/DejaVuSansMono.ttf", 12, EE_TTF_STYLE_NORMAL, false, 512, eeColor(), 1, eeColor(0,0,0) ) ) );
|
||||
|
||||
mFontLoader.Load( cb::Make1( this, &cEETest::OnFontLoaded ) );
|
||||
}
|
||||
|
||||
@@ -190,6 +194,32 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) {
|
||||
TTF = cFontManager::instance()->GetByName( "arial" );
|
||||
TTFB = cFontManager::instance()->GetByName( "arialb" );
|
||||
|
||||
//cFont * FF3 = cFontManager::instance()->GetByName( "DejaVuSansMono" );
|
||||
|
||||
/*
|
||||
std::string MyFontPath = MyPath + "fonts" + GetOSlash();
|
||||
cTTFFont * TTFD, * TTFMon;
|
||||
TTFD = eeNew( cTTFFont, ( "DejaVuSans" ) );
|
||||
TTFMon = eeNew( cTTFFont, ( "DejaVuSansMono" ) );
|
||||
|
||||
TTFD->Load( MyFontPath + "DejaVuSans.ttf", 12, EE_TTF_STYLE_NORMAL, false, 512, eeColor(), 1, eeColor(0,0,0) );
|
||||
TTFMon->Load( MyFontPath + "DejaVuSansMono.ttf", 12, EE_TTF_STYLE_NORMAL, false, 512, eeColor(), 1, eeColor(0,0,0) );
|
||||
|
||||
TTFD->Save( MyFontPath + "DejaVuSans.png", MyFontPath + "DejaVuSans.dat", EE_SAVE_TYPE_PNG );
|
||||
TTFMon->Save( MyFontPath + "DejaVuSansMono.png", MyFontPath + "DejaVuSansMono.dat", EE_SAVE_TYPE_PNG );
|
||||
*/
|
||||
|
||||
/*
|
||||
cTTFFont * Fnt = reinterpret_cast<cTTFFont*> ( FF2 );
|
||||
Fnt->Save( MyPath + "data/ProggySquareSZ.png", MyPath + "data/ProggySquareSZ.fnt" );
|
||||
|
||||
Fnt = reinterpret_cast<cTTFFont*> ( TTF );
|
||||
Fnt->Save( MyPath + "data/arial.png", MyPath + "data/arial.fnt" );
|
||||
|
||||
Fnt = reinterpret_cast<cTTFFont*> ( TTFB );
|
||||
Fnt->Save( MyPath + "data/arialb.png", MyPath + "data/arialb.fnt" );
|
||||
*/
|
||||
|
||||
Log->Writef( "Fonts loading time: %f", mFTE.Elapsed() );
|
||||
|
||||
eeASSERT( TTF != NULL );
|
||||
@@ -454,9 +484,20 @@ void cEETest::CreateUI() {
|
||||
|
||||
mComboBox->ListBox()->AddListBoxItems( combostrs );
|
||||
mComboBox->ListBox()->SetSelected( 0 );
|
||||
|
||||
/*
|
||||
cUIPopUpMenu::CreateParams MenuParams;
|
||||
MenuParams.Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE | UI_AUTO_PADDING;
|
||||
MenuParams.RowHeight = 0;
|
||||
MenuParams.PaddingContainer = eeRecti();
|
||||
MenuParams.MinWidth = 100;
|
||||
MenuParams.MinSpaceForIcons = 24;
|
||||
MenuParams.MinRightMargin = 8;
|
||||
MenuParams.Font = FF2;
|
||||
Menu = eeNew( cUIPopUpMenu, ( MenuParams ) );
|
||||
*/
|
||||
Menu = mTheme->CreatePopUpMenu();
|
||||
Menu->Add( "New", mTheme->GetIconByName( "document-new" ) );
|
||||
|
||||
Menu->Add( "Open...", mTheme->GetIconByName( "document-open" ) );
|
||||
Menu->AddSeparator();
|
||||
Menu->Add( "Map Editor" );
|
||||
@@ -1206,7 +1247,7 @@ void cEETest::Render() {
|
||||
|
||||
PR.DrawRectangle(
|
||||
0.f,
|
||||
(eeFloat)mWindow->GetHeight() - (eeFloat)mEEText.GetNumLines() * (eeFloat)mEEText.Font()->GetFontSize(),
|
||||
(eeFloat)mWindow->GetHeight() - mEEText.GetTextHeight(),
|
||||
mEEText.GetTextWidth(),
|
||||
mEEText.GetTextHeight(),
|
||||
ColRR1, ColRR2, ColRR3, ColRR4
|
||||
@@ -1222,7 +1263,7 @@ void cEETest::Render() {
|
||||
FF2->Draw( "_", 6.f + FF2->GetTextWidth(), 180.f );
|
||||
} else {
|
||||
FF2->SetText( InBuf.Buffer().substr( NLPos, InBuf.CurPos() - NLPos ) );
|
||||
FF2->Draw( "_", 6.f + FF2->GetTextWidth(), 180.f + (eeFloat)LineNum * (eeFloat)FF2->GetFontSize() );
|
||||
FF2->Draw( "_", 6.f + FF2->GetTextWidth(), 180.f + (eeFloat)LineNum * (eeFloat)FF2->GetFontHeight() );
|
||||
}
|
||||
|
||||
FF2->SetText( "FPS: " + toStr( mWindow->FPS() ) );
|
||||
@@ -1704,7 +1745,7 @@ void cEETest::Demo2Destroy() {
|
||||
|
||||
void cEETest::ChangeDemo( Uint32 num ) {
|
||||
if ( num < mDemo.size() ) {
|
||||
if ( 0xFFFFFF != mCurDemo )
|
||||
if ( eeINDEX_NOT_FOUND != mCurDemo )
|
||||
mDemo[ mCurDemo ].destroy();
|
||||
|
||||
mCurDemo = num;
|
||||
|
||||
@@ -269,7 +269,7 @@ class cEETest : private cThread {
|
||||
};
|
||||
|
||||
std::vector<physicDemo> mDemo;
|
||||
Int32 mCurDemo;
|
||||
Uint32 mCurDemo;
|
||||
cSprite * mBoxSprite;
|
||||
cSprite * mCircleSprite;
|
||||
|
||||
|
||||
@@ -300,15 +300,15 @@ void cUIListBox::SetRowHeight() {
|
||||
Uint32 FontSize = 12;
|
||||
|
||||
if ( NULL != cUIThemeManager::instance()->DefaultFont() )
|
||||
FontSize = cUIThemeManager::instance()->DefaultFont()->GetFontSize();
|
||||
FontSize = cUIThemeManager::instance()->DefaultFont()->GetFontHeight();
|
||||
|
||||
if ( NULL != mSkinState && NULL != mSkinState->GetSkin() && NULL != mSkinState->GetSkin()->Theme() && NULL != mSkinState->GetSkin()->Theme()->Font() )
|
||||
FontSize = mSkinState->GetSkin()->Theme()->Font()->GetFontSize();
|
||||
FontSize = mSkinState->GetSkin()->Theme()->Font()->GetFontHeight();
|
||||
|
||||
if ( NULL != mFont )
|
||||
FontSize = mFont->GetFontSize();
|
||||
FontSize = mFont->GetFontHeight();
|
||||
|
||||
mRowHeight = (Uint32)( FontSize * 1.5f );
|
||||
mRowHeight = (Uint32)( FontSize + 4 );
|
||||
}
|
||||
|
||||
if ( tOldRowHeight != mRowHeight ) {
|
||||
|
||||
@@ -353,7 +353,7 @@ Uint32 cUIMenu::OnMessage( const cUIMessage * Msg ) {
|
||||
|
||||
void cUIMenu::OnSizeChange() {
|
||||
if ( NULL != mFont && ( ( mFlags & UI_AUTO_SIZE ) || 0 == mRowHeight ) ) {
|
||||
mRowHeight = mFont->GetFontSize() * 1.5f;
|
||||
mRowHeight = mFont->GetFontHeight() + 8;
|
||||
}
|
||||
|
||||
if ( 0 != mMinWidth && mSize.Width() < (Int32)mMinWidth ) {
|
||||
|
||||
@@ -348,7 +348,7 @@ void cUITextEdit::FixScrollToCursor() {
|
||||
mSkipValueChange = true;
|
||||
|
||||
eeFloat tW = mTextInput->GetTextCache()->Font()->GetTextWidth();
|
||||
eeFloat tH = (eeFloat)(LineNum + 1) * (eeFloat)mTextInput->GetTextCache()->Font()->GetFontSize();
|
||||
eeFloat tH = (eeFloat)(LineNum + 1) * (eeFloat)mTextInput->GetTextCache()->Font()->GetFontHeight();
|
||||
|
||||
if ( tW > Width ) {
|
||||
mTextInput->Pos( mPadding.Left + Width - tW, mTextInput->Pos().y );
|
||||
|
||||
@@ -145,7 +145,7 @@ void cUITextInput::AlignFix() {
|
||||
eeFloat tX = mAlignOffset.x + tW;
|
||||
|
||||
mCurPos.x = tW;
|
||||
mCurPos.y = (eeFloat)LineNum * (eeFloat)mTextCache->Font()->GetFontSize();
|
||||
mCurPos.y = (eeFloat)LineNum * (eeFloat)mTextCache->Font()->GetFontHeight();
|
||||
|
||||
if ( !mTextBuffer.SupportNewLine() ) {
|
||||
if ( tX < 0.f )
|
||||
|
||||
@@ -24,7 +24,7 @@ cUITooltip::cUITooltip( cUITooltip::CreateParams& Params, cUIControl * TooltipOf
|
||||
eePRINT( "cUITooltip::cUITextBox : Created a UI TextBox without a defined font.\n" );
|
||||
}
|
||||
|
||||
AutoAlign();
|
||||
AutoPadding();
|
||||
|
||||
if ( Params.ParentCtrl != cUIManager::instance()->MainControl() )
|
||||
Parent( cUIManager::instance()->MainControl() );
|
||||
@@ -161,7 +161,7 @@ void cUITooltip::AutoSize() {
|
||||
|
||||
void cUITooltip::AutoAlign() {
|
||||
Uint32 Width = mSize.Width() - mPadding.Left - mPadding.Right;
|
||||
Uint32 Height = mSize.Height() - mPadding.Top - mPadding.Right;
|
||||
Uint32 Height = mSize.Height() - mPadding.Top - mPadding.Bottom;
|
||||
|
||||
switch ( FontHAlignGet( Flags() ) ) {
|
||||
case UI_HALIGN_CENTER:
|
||||
|
||||
Reference in New Issue
Block a user