Setting code formatting standard to allman.

This commit is contained in:
emb
2015-01-01 14:08:42 -06:00
parent 174ea4f4f9
commit 6410139f87
76 changed files with 5352 additions and 5314 deletions

View File

@@ -8,96 +8,96 @@
#include <sstream>
Text::Text(std::string text, Font *font, SDL_Color fontColor, float scaleX, float scaleY)
: TextData(text)
, FontInst(font)
, FontColor(fontColor)
, ScaleX(scaleX)
, ScaleY(scaleY)
: TextData(text)
, FontInst(font)
, FontColor(fontColor)
, ScaleX(scaleX)
, ScaleY(scaleY)
{
AllocateGraphicsMemory();
AllocateGraphicsMemory();
}
Text::~Text()
{
FreeGraphicsMemory();
FreeGraphicsMemory();
}
void Text::FreeGraphicsMemory()
{
Component::FreeGraphicsMemory();
Component::FreeGraphicsMemory();
}
void Text::AllocateGraphicsMemory()
{
//todo: make the font blend color a parameter that is passed in
Component::AllocateGraphicsMemory();
//todo: make the font blend color a parameter that is passed in
Component::AllocateGraphicsMemory();
}
void Text::Draw()
{
SDL_Texture *t = FontInst->GetTexture();
SDL_Texture *t = FontInst->GetTexture();
ViewInfo *info = GetBaseViewInfo();
float imageHeight = 0;
float imageWidth = 0;
ViewInfo *info = GetBaseViewInfo();
float imageHeight = 0;
float imageWidth = 0;
// determine image width
for(unsigned int i = 0; i < TextData.size(); ++i)
{
Font::GlyphInfo glyph;
if(FontInst->GetRect(TextData[i], glyph))
{
imageWidth += glyph.Advance;
imageHeight = (imageHeight >= glyph.Rect.h) ? imageHeight : glyph.Rect.h;
}
}
// determine image width
for(unsigned int i = 0; i < TextData.size(); ++i)
{
Font::GlyphInfo glyph;
if(FontInst->GetRect(TextData[i], glyph))
{
imageWidth += glyph.Advance;
imageHeight = (imageHeight >= glyph.Rect.h) ? imageHeight : glyph.Rect.h;
}
}
float scale = (float)info->GetFontSize() / (float)imageHeight;
float scale = (float)info->GetFontSize() / (float)imageHeight;
float width = info->GetRawWidth();
float height = info->GetRawHeight();
float width = info->GetRawWidth();
float height = info->GetRawHeight();
info->SetWidth(imageWidth*scale);
info->SetHeight(imageHeight*scale);
info->SetWidth(imageWidth*scale);
info->SetHeight(imageHeight*scale);
float xOrigin = info->GetXRelativeToOrigin();
float yOrigin = info->GetYRelativeToOrigin();
float xOrigin = info->GetXRelativeToOrigin();
float yOrigin = info->GetYRelativeToOrigin();
info->SetWidth(width);
info->SetHeight(height);
info->SetWidth(width);
info->SetHeight(height);
SDL_Rect rect;
rect.x = static_cast<int>(xOrigin);
SDL_Rect rect;
rect.x = static_cast<int>(xOrigin);
for(unsigned int i = 0; i < TextData.size(); ++i)
{
Font::GlyphInfo glyph;
for(unsigned int i = 0; i < TextData.size(); ++i)
{
Font::GlyphInfo glyph;
if(FontInst->GetRect(TextData[i], glyph) && glyph.Rect.h > 0)
{
SDL_Rect charRect = glyph.Rect;
float h = static_cast<float>(charRect.h * scale);
float w = static_cast<float>(charRect.w * scale);
rect.h = static_cast<int>(h);
rect.w = static_cast<int>(w);
rect.y = static_cast<int>(yOrigin);
/*
std::stringstream ss;
ss << " cx:" << charRect.x << " cy:" << charRect.y << " cw:" << charRect.w << " ch:" << charRect.h;
ss << " x:" << rect.x << " y:" << rect.y << " w:" << rect.w << " h:" << rect.h;
Logger::Write(Logger::ZONE_DEBUG, "Text", ss.str());
*/
if(FontInst->GetRect(TextData[i], glyph) && glyph.Rect.h > 0)
{
SDL_Rect charRect = glyph.Rect;
float h = static_cast<float>(charRect.h * scale);
float w = static_cast<float>(charRect.w * scale);
rect.h = static_cast<int>(h);
rect.w = static_cast<int>(w);
rect.y = static_cast<int>(yOrigin);
/*
std::stringstream ss;
ss << " cx:" << charRect.x << " cy:" << charRect.y << " cw:" << charRect.w << " ch:" << charRect.h;
ss << " x:" << rect.x << " y:" << rect.y << " w:" << rect.w << " h:" << rect.h;
Logger::Write(Logger::ZONE_DEBUG, "Text", ss.str());
*/
SDL_LockMutex(SDL::GetMutex());
SDL_SetTextureColorMod(t, FontColor.r, FontColor.g, FontColor.b);
SDL_UnlockMutex(SDL::GetMutex());
SDL_LockMutex(SDL::GetMutex());
SDL_SetTextureColorMod(t, FontColor.r, FontColor.g, FontColor.b);
SDL_UnlockMutex(SDL::GetMutex());
SDL::RenderCopy(t, static_cast<char>(info->GetTransparency() * 255), &charRect, &rect, info->GetAngle());
rect.x += static_cast<int>(glyph.Advance * scale);
}
}
SDL::RenderCopy(t, static_cast<char>(info->GetTransparency() * 255), &charRect, &rect, info->GetAngle());
rect.x += static_cast<int>(glyph.Advance * scale);
}
}
}