More type conversion warning cleanup; some minor refactoring in the phase bar while I was cleaning up the warnings.

This commit is contained in:
wrenczes
2010-10-28 06:57:34 +00:00
parent 98627d96ba
commit fadd36c0c4
6 changed files with 68 additions and 67 deletions

View File

@@ -23,12 +23,30 @@ static int colors[] =
};
*/
namespace
{
const float kWidth = 28;
const float kHeight = kWidth;
const unsigned kPhases = 12;
const float ICONSCALE = 1.5;
const float CENTER = SCREEN_HEIGHT_F / 2 + 10;
void DrawGlyph(JQuad* inQuad, int inGlyph, float inY, float inAngle, unsigned int inP, float inScale)
{
float xPos = static_cast<float>((inP + inGlyph * (int)(kWidth+1)) % (kPhases * (int)(kWidth+1)));
inQuad->SetTextureRect(xPos, 0, kWidth, kHeight);
JRenderer::GetInstance()->RenderQuad(inQuad, 0, inY, 0.0, inScale, inScale);
}
}
GuiPhaseBar::GuiPhaseBar() : phase(NULL), angle(0.0f)
{
JQuad * quad = NULL;
if ((quad = resources.GetQuad("phasebar")) != NULL){
quad->mHeight = Height;
quad->mWidth = Width;
quad->mHeight = kHeight;
quad->mWidth = kWidth;
}
else GameApp::systemError = "Error loading phasebar texture : " __FILE__;
}
@@ -44,51 +62,38 @@ void GuiPhaseBar::Update(float dt)
void GuiPhaseBar::Render()
{
static const float ICONSCALE = 1.5;
static const float CENTER = SCREEN_HEIGHT_F / 2 + 10;
JRenderer* renderer = JRenderer::GetInstance();
GameObserver * g = GameObserver::GetInstance();
JQuad * quad = resources.GetQuad("phasebar");
unsigned p = (phase->id + Phases - 4) * (Width+1);
float scale;
float start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
JRenderer::GetInstance()->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));
renderer->DrawLine(0, CENTER, SCREEN_WIDTH, CENTER, ARGB(255, 255, 255, 255));
unsigned int p = (phase->id + kPhases - 4) * (int)(kWidth+1);
float centerYPosition = CENTER + (kWidth / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * kWidth / 4;
float yPos = centerYPosition;
float scale = 0;
for (int glyph = 3; glyph < 6; ++glyph)
{
scale = ICONSCALE * sinf(angle + glyph * M_PI / 6) / 2;
DrawGlyph(quad, glyph, yPos, angle, p, scale);
yPos += kWidth * scale;
}
scale = ICONSCALE * sinf(angle + 3 * M_PI / 6) / 2;
quad->SetTextureRect((p + 3 * (Width+1)) % (Phases * (Width+1)), 0, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale;
scale = ICONSCALE * sinf(angle + 4 * M_PI / 6) / 2;
quad->SetTextureRect((p + 4 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale;
scale = ICONSCALE * sinf(angle + 5 * M_PI / 6) / 2;
quad->SetTextureRect((p + 5 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
start += Width * scale;
start = CENTER + (Width / 2) * angle * ICONSCALE / (M_PI / 6) - ICONSCALE * Width / 4;
scale = ICONSCALE * sinf(angle + 2 * M_PI / 6) / 2;
start -= Width * scale;
quad->SetTextureRect((p + 2 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
scale = ICONSCALE * sinf(angle + 1 * M_PI / 6) / 2;
start -= Width * scale;
quad->SetTextureRect((p + 1 * (Width+1)) % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
yPos = centerYPosition;
for (int glyph = 2; glyph > 0; --glyph)
{
scale = ICONSCALE * sinf(angle + glyph * M_PI / 6) / 2;
yPos -= kWidth * scale;
DrawGlyph(quad, glyph, yPos, angle, p, scale);
}
if (angle > 0)
{
scale = ICONSCALE * sinf(angle)/2;
start -= Width * scale;
quad->SetTextureRect(p % (Phases * (Width+1)), Height, Width, Height);
renderer->RenderQuad(quad, 0, start, 0.0, scale, scale);
}
{
scale = ICONSCALE * sinf(angle)/2;
yPos -= kWidth * scale;
float xPos = static_cast<float>(p % (kPhases * (int)(kWidth+1)));
quad->SetTextureRect(xPos, kHeight, kWidth, kHeight);
JRenderer::GetInstance()->RenderQuad(quad, 0, yPos, 0.0, scale, scale);
}
//print phase name
WFont * font = resources.GetWFont(Fonts::MAIN_FONT);