More type conversion warning fixes, with some minor refactoring thrown in.

This commit is contained in:
wrenczes@gmail.com
2010-10-14 07:39:00 +00:00
parent 3ca5a7261d
commit f7361fb030
5 changed files with 93 additions and 83 deletions

View File

@@ -1,9 +1,9 @@
#ifndef _MTGDEFINITION_H_ #ifndef _MTGDEFINITION_H_
#define _MTGDEFINITION_H_ #define _MTGDEFINITION_H_
#define DEFAULT_MENU_FONT_SCALE 1.0 const float DEFAULT_MENU_FONT_SCALE = 1.0f;
#define DEFAULT_MAIN_FONT_SCALE 1.0 const float DEFAULT_MAIN_FONT_SCALE = 1.0f;
#define DEFAULT_TEXT_FONT_SCALE 1.0 const float DEFAULT_TEXT_FONT_SCALE = 1.0f;
class Constants class Constants
{ {

View File

@@ -34,7 +34,7 @@ class PlayGuiObject: public JGuiObject, public JGuiListener, public Pos{
PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus); PlayGuiObject(float desiredHeight, float x, float y, bool hasFocus);
PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus); PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus);
virtual void ButtonPressed(int controllerId, int controlId){}; virtual void ButtonPressed(int controllerId, int controlId){};
virtual bool getTopLeft(int& top, int& left) {top = actY; left = actX; return true;}; virtual bool getTopLeft(int& top, int& left) {top = static_cast<int>(actY); left = static_cast<int>(actX); return true;};
virtual ~PlayGuiObject(){}; virtual ~PlayGuiObject(){};
vector<Effect*> effects; vector<Effect*> effects;
}; };

View File

@@ -25,13 +25,11 @@ CardDisplay::CardDisplay(int id, GameObserver* game, int _x, int _y, JGuiListene
zone = NULL; zone = NULL;
} }
void CardDisplay::AddCard(MTGCardInstance * _card){ void CardDisplay::AddCard(MTGCardInstance * _card){
CardGui * card = NEW CardView(CardSelector::nullZone, _card, x + 20 + (mCount - start_item) * 30, y + 25); CardGui * card = NEW CardView(CardSelector::nullZone, _card, static_cast<float>(x + 20 + (mCount - start_item) * 30), static_cast<float>(y + 25));
Add(card); Add(card);
} }
void CardDisplay::init(MTGGameZone * zone){ void CardDisplay::init(MTGGameZone * zone){
resetObjects(); resetObjects();
if (!zone) return; if (!zone) return;
@@ -60,8 +58,6 @@ void CardDisplay::rotateRight(){
start_item ++; start_item ++;
} }
void CardDisplay::Update(float dt){ void CardDisplay::Update(float dt){
bool update = false; bool update = false;
@@ -195,22 +191,21 @@ bool CardDisplay::CheckUserInput(JButton key){
return false; return false;
} }
void CardDisplay::Render(){ void CardDisplay::Render(){
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
r->DrawRect(x,y,nb_displayed_items * 30 + 20, 50, ARGB(255,255,255,255)); r->DrawRect(static_cast<float>(x), static_cast<float>(y), static_cast<float>(nb_displayed_items * 30 + 20), 50, ARGB(255,255,255,255));
if (!mCount) return; if (!mCount) return;
for (int i = start_item; i< start_item + nb_displayed_items && i < mCount; i++){ for (int i = start_item; i< start_item + nb_displayed_items && i < mCount; i++){
if (mObjects[i]){ if (mObjects[i]){
mObjects[i]->Render(); mObjects[i]->Render();
if (tc){ if (tc){
CardGui * cardg = (CardGui *)mObjects[i]; CardGui * cardg = (CardGui *)mObjects[i];
if( tc->alreadyHasTarget(cardg->card)){ if( tc->alreadyHasTarget(cardg->card)){
r->DrawCircle(cardg->x + 5, cardg->y+5,5, ARGB(255,255,0,0)); r->DrawCircle(cardg->x + 5, cardg->y+5,5, ARGB(255,255,0,0));
}else if (!tc->canTarget(cardg->card)){ }else if (!tc->canTarget(cardg->card)){
r->FillRect(cardg->x,cardg->y,30,40,ARGB(200,0,0,0)); r->FillRect(cardg->x,cardg->y,30,40,ARGB(200,0,0,0));
} }
} }
} }
} }

View File

@@ -20,6 +20,21 @@ const float CardGui::Height = 40.0;
const float CardGui::BigWidth = 200.0; const float CardGui::BigWidth = 200.0;
const float CardGui::BigHeight = 285.0; const float CardGui::BigHeight = 285.0;
const float kWidthScaleFactor = 0.8f;
namespace
{
inline float SineHelperFunction(const float& value)
{
return sinf(2*M_PI*(value)/256.0f);
}
inline float CosineHelperFunction(const float& value)
{
return cosf(2*M_PI*(value-35)/256.0f);
}
}
CardGui::CardGui(MTGCardInstance* card, float x, float y) : PlayGuiObject(Height, x, y, false), card(card) {} CardGui::CardGui(MTGCardInstance* card, float x, float y) : PlayGuiObject(Height, x, y, false), card(card) {}
CardGui::CardGui(MTGCardInstance* card, const Pos& ref) : PlayGuiObject(Height, ref, false), card(card) {} CardGui::CardGui(MTGCardInstance* card, const Pos& ref) : PlayGuiObject(Height, ref, false), card(card) {}
@@ -83,7 +98,7 @@ void CardGui::Render()
if (alternate) { if (alternate) {
mFont->SetColor(ARGB(static_cast<unsigned char>(actA), 0, 0, 0)); mFont->SetColor(ARGB(static_cast<unsigned char>(actA), 0, 0, 0));
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5 * actZ); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE * 0.5f * actZ);
mFont->DrawString(_(card->getName()), actX - actZ * Width / 2 + 1, actY - actZ * Height / 2 + 1); mFont->DrawString(_(card->getName()), actX - actZ * Width / 2 + 1, actY - actZ * Height / 2 + 1);
mFont->SetScale(DEFAULT_MAIN_FONT_SCALE); mFont->SetScale(DEFAULT_MAIN_FONT_SCALE);
@@ -165,7 +180,7 @@ JQuad * CardGui::alternateThumbQuad(MTGCard * card){
} }
} }
if(q && q->mTex) if(q && q->mTex)
q->SetHotSpot(q->mTex->mWidth/2,q->mTex->mHeight/2); q->SetHotSpot(static_cast<float>(q->mTex->mWidth/2),static_cast<float>(q->mTex->mHeight/2));
return q; return q;
} }
@@ -192,7 +207,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
} }
} }
if(q && q->mTex){ if(q && q->mTex){
q->SetHotSpot(q->mTex->mWidth/2,q->mTex->mHeight/2); q->SetHotSpot(static_cast<float>(q->mTex->mWidth/2),static_cast<float>(q->mTex->mHeight/2));
float scale = pos.actZ * 250 / q->mHeight; float scale = pos.actZ * 250 / q->mHeight;
q->SetColor(ARGB((int)pos.actA,255,255,255)); q->SetColor(ARGB((int)pos.actA,255,255,255));
@@ -202,12 +217,12 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
WFont * font = resources.GetWFont("magic"); WFont * font = resources.GetWFont("magic");
float backup_scale = font->GetScale(); float backup_scale = font->GetScale();
font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(0.8 * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
{ {
char name[4096]; char name[4096];
sprintf(name, "%s", _(card->data->getName()).c_str()); sprintf(name, "%s", _(card->data->getName()).c_str());
float w = font->GetStringWidth(name) * 0.8 * pos.actZ; float w = font->GetStringWidth(name) * kWidthScaleFactor * pos.actZ;
if (w > BigWidth - 30) if (w > BigWidth - 30)
font->SetScale((BigWidth - 30) / w); font->SetScale((BigWidth - 30) / w);
font->DrawString(name, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (25 - BigHeight / 2)*pos.actZ); font->DrawString(name, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (25 - BigHeight / 2)*pos.actZ);
@@ -215,7 +230,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
// Write the description // Write the description
{ {
font->SetScale(0.8 * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
const std::vector<string> txt = card->data->formattedText(); const std::vector<string> txt = card->data->formattedText();
unsigned i = 0; unsigned i = 0;
unsigned h = neofont ? 14 : 11; unsigned h = neofont ? 14 : 11;
@@ -228,7 +243,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
{ {
char buffer[32]; char buffer[32];
sprintf(buffer, "%i/%i", card->data->power, card->data->toughness); sprintf(buffer, "%i/%i", card->data->power, card->data->toughness);
float w = font->GetStringWidth(buffer) * 0.8; float w = font->GetStringWidth(buffer) * kWidthScaleFactor;
font->DrawString(buffer, x + (65 - w / 2)*pos.actZ, pos.actY + (106)*pos.actZ); font->DrawString(buffer, x + (65 - w / 2)*pos.actZ, pos.actY + (106)*pos.actZ);
} }
@@ -242,25 +257,25 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
float yOffset = -112; float yOffset = -112;
while ((h = manacost->getHybridCost(j))) while ((h = manacost->getHybridCost(j)))
{ {
float scale = pos.actZ * 0.05 * cosf(2*M_PI*((float)t)/256.0); float scale = pos.actZ * 0.05f * cosf(2*M_PI*((float)t)/256.0f);
if (scale < 0) if (scale < 0)
{ {
renderer->RenderQuad(manaIcons[h->color1], x + (-12 * j + 75 + 3 * sinf(2*M_PI*((float)t)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(t-35))/256.0))*pos.actZ, 0, 0.4 + scale, 0.4 + scale); renderer->RenderQuad(manaIcons[h->color1], x + (-12 * j + 75 + 3 * SineHelperFunction((float)t))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)t))*pos.actZ, 0, 0.4f + scale, 0.4f + scale);
renderer->RenderQuad(manaIcons[h->color2], x + (-12 * j + 75 + 3 * sinf(2*M_PI*((float)v)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(v-35))/256.0))*pos.actZ, 0, 0.4 - scale, 0.4 - scale); renderer->RenderQuad(manaIcons[h->color2], x + (-12 * j + 75 + 3 * SineHelperFunction((float)v))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)v))*pos.actZ, 0, 0.4f - scale, 0.4f - scale);
} }
else else
{ {
renderer->RenderQuad(manaIcons[h->color2], x + (- 12 * j + 75 + 3 * sinf(2*M_PI*((float)v)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(v-35))/256.0))*pos.actZ, 0, 0.4 - scale, 0.4 - scale); renderer->RenderQuad(manaIcons[h->color2], x + (- 12 * j + 75 + 3 * SineHelperFunction((float)v))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)v))*pos.actZ, 0, 0.4f - scale, 0.4f - scale);
renderer->RenderQuad(manaIcons[h->color1], x + (- 12 * j + 75 + 3 * sinf(2*M_PI*((float)t)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(t-35))/256.0))*pos.actZ, 0, 0.4 + scale, 0.4 + scale); renderer->RenderQuad(manaIcons[h->color1], x + (- 12 * j + 75 + 3 * SineHelperFunction((float)t))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)t))*pos.actZ, 0, 0.4f + scale, 0.4f + scale);
} }
++j; ++j;
} }
for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i) for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i)
{ {
for (int cost = manacost->getCost(i); cost > 0; --cost) for (int cost = manacost->getCost(i); cost > 0; --cost)
{ {
renderer->RenderQuad(manaIcons[i], x + (-12*j + 75)*pos.actZ, pos.actY + (yOffset)*pos.actZ, 0, 0.4 * pos.actZ, 0.4 * pos.actZ); renderer->RenderQuad(manaIcons[i], x + (-12*j + 75)*pos.actZ, pos.actY + (yOffset)*pos.actZ, 0, 0.4f * pos.actZ, 0.4f * pos.actZ);
++j; ++j;
} }
} }
@@ -269,7 +284,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
{ {
char buffer[10]; char buffer[10];
sprintf(buffer, "%d", cost); sprintf(buffer, "%d", cost);
renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4 * pos.actZ, 0.4 * pos.actZ); renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4f * pos.actZ, 0.4f * pos.actZ);
float w = font->GetStringWidth(buffer); float w = font->GetStringWidth(buffer);
font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ); font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ);
++j; ++j;
@@ -279,7 +294,7 @@ void CardGui::alternateRender(MTGCard * card, const Pos& pos){
{ {
char buffer[10]; char buffer[10];
sprintf(buffer, "X"); sprintf(buffer, "X");
renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4 * pos.actZ, 0.4 * pos.actZ); renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4f * pos.actZ, 0.4f * pos.actZ);
float w = font->GetStringWidth(buffer); float w = font->GetStringWidth(buffer);
font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ); font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ);
} }
@@ -381,7 +396,7 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
} }
} }
if(q && q->mTex){ if(q && q->mTex){
q->SetHotSpot(q->mTex->mWidth/2,q->mTex->mHeight/2); q->SetHotSpot(static_cast<float>(q->mTex->mWidth/2), static_cast<float>(q->mTex->mHeight/2));
float scale = pos.actZ * displayScale * BigHeight / q->mHeight; float scale = pos.actZ * displayScale * BigHeight / q->mHeight;
q->SetColor(ARGB((int)pos.actA,255,255,255)); q->SetColor(ARGB((int)pos.actA,255,255,255));
@@ -405,12 +420,12 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
WFont * font = resources.GetWFont("magic"); WFont * font = resources.GetWFont("magic");
float backup_scale = font->GetScale(); float backup_scale = font->GetScale();
font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(0.8 * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
{ {
char name[4096]; char name[4096];
sprintf(name, "%s", _(card->data->getName()).c_str()); sprintf(name, "%s", _(card->data->getName()).c_str());
float w = font->GetStringWidth(name) * 0.8 * pos.actZ; float w = font->GetStringWidth(name) * kWidthScaleFactor * pos.actZ;
if (w > BigWidth - 30) if (w > BigWidth - 30)
font->SetScale((BigWidth - 30) / w); font->SetScale((BigWidth - 30) / w);
font->DrawString(name, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (25 - BigHeight / 2)*pos.actZ); font->DrawString(name, x + (22 - BigWidth / 2)*pos.actZ, pos.actY + (25 - BigHeight / 2)*pos.actZ);
@@ -418,7 +433,7 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
// Write the description // Write the description
{ {
font->SetScale(0.8 * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
float imgBottom = imgY + (imgScale * quad->mHeight/2); float imgBottom = imgY + (imgScale * quad->mHeight/2);
unsigned i = 0; unsigned i = 0;
unsigned h = neofont ? 14 : 11; unsigned h = neofont ? 14 : 11;
@@ -428,11 +443,11 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
// Write the strength // Write the strength
if (card->data->isCreature()) if (card->data->isCreature())
{ {
char buffer[32]; char buffer[32];
sprintf(buffer, "%i/%i", card->data->power, card->data->toughness); sprintf(buffer, "%i/%i", card->data->power, card->data->toughness);
float w = font->GetStringWidth(buffer) * 0.8; float w = font->GetStringWidth(buffer) * kWidthScaleFactor;
font->DrawString(buffer, x + (65 - w / 2)*pos.actZ, pos.actY + (106)*pos.actZ); font->DrawString(buffer, x + (65 - w / 2)*pos.actZ, pos.actY + (106)*pos.actZ);
} }
// Mana // Mana
@@ -444,35 +459,35 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
unsigned char v = t + 127; unsigned char v = t + 127;
float yOffset = -112; float yOffset = -112;
while ((h = manacost->getHybridCost(j))) while ((h = manacost->getHybridCost(j)))
{ {
float scale = pos.actZ * 0.05 * cosf(2*M_PI*((float)t)/256.0); float scale = pos.actZ * 0.05f * cosf(2*M_PI*((float)t)/256.0f);
if (scale < 0) if (scale < 0)
{ {
renderer->RenderQuad(manaIcons[h->color1], x + (-12 * j + 75 + 3 * sinf(2*M_PI*((float)t)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(t-35))/256.0))*pos.actZ, 0, 0.4 + scale, 0.4 + scale); renderer->RenderQuad(manaIcons[h->color1], x + (-12 * j + 75 + 3 * SineHelperFunction((float)t))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)t))*pos.actZ, 0, 0.4f + scale, 0.4f + scale);
renderer->RenderQuad(manaIcons[h->color2], x + (-12 * j + 75 + 3 * sinf(2*M_PI*((float)v)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(v-35))/256.0))*pos.actZ, 0, 0.4 - scale, 0.4 - scale); renderer->RenderQuad(manaIcons[h->color2], x + (-12 * j + 75 + 3 * SineHelperFunction((float)v))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)v))*pos.actZ, 0, 0.4f - scale, 0.4f - scale);
} }
else else
{ {
renderer->RenderQuad(manaIcons[h->color2], x + (- 12 * j + 75 + 3 * sinf(2*M_PI*((float)v)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(v-35))/256.0))*pos.actZ, 0, 0.4 - scale, 0.4 - scale); renderer->RenderQuad(manaIcons[h->color2], x + (- 12 * j + 75 + 3 * SineHelperFunction((float)v))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)v))*pos.actZ, 0, 0.4f - scale, 0.4f - scale);
renderer->RenderQuad(manaIcons[h->color1], x + (- 12 * j + 75 + 3 * sinf(2*M_PI*((float)t)/256.0))*pos.actZ, pos.actY + (yOffset + 3 * cosf(2*M_PI*((float)(t-35))/256.0))*pos.actZ, 0, 0.4 + scale, 0.4 + scale); renderer->RenderQuad(manaIcons[h->color1], x + (- 12 * j + 75 + 3 * SineHelperFunction((float)t))*pos.actZ, pos.actY + (yOffset + 3 * CosineHelperFunction((float)t))*pos.actZ, 0, 0.4f + scale, 0.4f + scale);
} }
++j;
}
for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i)
{
for (int cost = manacost->getCost(i); cost > 0; --cost)
{
renderer->RenderQuad(manaIcons[i], x + (-12*j + 75)*pos.actZ, pos.actY + (yOffset)*pos.actZ, 0, 0.4f * pos.actZ, 0.4f * pos.actZ);
++j; ++j;
} }
for (int i = Constants::MTG_NB_COLORS - 2; i >= 1; --i) }
{
for (int cost = manacost->getCost(i); cost > 0; --cost)
{
renderer->RenderQuad(manaIcons[i], x + (-12*j + 75)*pos.actZ, pos.actY + (yOffset)*pos.actZ, 0, 0.4 * pos.actZ, 0.4 * pos.actZ);
++j;
}
}
// Colorless mana // Colorless mana
if (int cost = manacost->getCost(0)) if (int cost = manacost->getCost(0))
{ {
char buffer[10]; char buffer[10];
sprintf(buffer, "%d", cost); sprintf(buffer, "%d", cost);
renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4 * pos.actZ, 0.4 * pos.actZ); renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4f * pos.actZ, 0.4f * pos.actZ);
float w = font->GetStringWidth(buffer); float w = font->GetStringWidth(buffer);
font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ); font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ);
++j; ++j;
@@ -482,7 +497,7 @@ void CardGui::tinyCropRender(MTGCard * card, const Pos& pos, JQuad * quad) {
{ {
char buffer[10]; char buffer[10];
sprintf(buffer, "X"); sprintf(buffer, "X");
renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4 * pos.actZ, 0.4 * pos.actZ); renderer->RenderQuad(manaIcons[0], x + (- 12*j + 75)*pos.actZ, pos.actY +(yOffset)*pos.actZ, 0, 0.4f * pos.actZ, 0.4f * pos.actZ);
float w = font->GetStringWidth(buffer); float w = font->GetStringWidth(buffer);
font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ); font->DrawString(buffer, x +(- 12*j + 76 - w/2)*pos.actZ, pos.actY + (yOffset - 5)*pos.actZ);
} }
@@ -598,7 +613,7 @@ void CardGui::renderCountersBig(const Pos& pos){
if (card->counters) { if (card->counters) {
WFont * font = resources.GetWFont("magic"); WFont * font = resources.GetWFont("magic");
font->SetColor(ARGB((int)pos.actA, 0, 0, 0)); font->SetColor(ARGB((int)pos.actA, 0, 0, 0));
font->SetScale(0.8 * pos.actZ); font->SetScale(kWidthScaleFactor * pos.actZ);
std::vector<string> txt = card->formattedText(); std::vector<string> txt = card->formattedText();
unsigned i = txt.size() + 1; unsigned i = txt.size() + 1;
Counter * c = NULL; Counter * c = NULL;

View File

@@ -282,7 +282,7 @@ void WGuiList::Render(){
} }
//Find out how large our list is, with all items and margin. //Find out how large our list is, with all items and margin.
for (int pos=0;pos < nbitems; pos++){ for (int pos=0;pos < nbitems; pos++){
listHeight+=items[pos]->getHeight()+1; //What does the +1 do exactly ? listHeight+=static_cast<int>(items[pos]->getHeight()+1); //What does the +1 do exactly ?
if(items[pos]->Selectable()){ if(items[pos]->Selectable()){
listSelectable++; listSelectable++;
if(pos < currentItem) adjustedCurrent++; if(pos < currentItem) adjustedCurrent++;
@@ -296,7 +296,7 @@ void WGuiList::Render(){
if(!items[start]->Visible()) if(!items[start]->Visible())
continue; continue;
vHeight += items[start]->getHeight()+5; vHeight += static_cast<int>(items[start]->getHeight()+5);
if(vHeight >= (SCREEN_HEIGHT-60)/2) if(vHeight >= (SCREEN_HEIGHT-60)/2)
break; break;
} }
@@ -305,7 +305,7 @@ void WGuiList::Render(){
for (nowPos=nbitems;nowPos > 1; nowPos--){ for (nowPos=nbitems;nowPos > 1; nowPos--){
if(!items[start]->Visible()) if(!items[start]->Visible())
continue; continue;
vHeight += items[nowPos-1]->getHeight()+5; vHeight += static_cast<int>(items[nowPos-1]->getHeight()+5);
} }
if(vHeight <= SCREEN_HEIGHT-40 && nowPos < start) if(vHeight <= SCREEN_HEIGHT-40 && nowPos < start)
@@ -327,7 +327,7 @@ void WGuiList::Render(){
continue; continue;
if(pos < start){ if(pos < start){
vHeight += items[pos]->getHeight() + 5; vHeight += static_cast<int>(items[pos]->getHeight() + 5);
continue; continue;
} }
@@ -337,7 +337,7 @@ void WGuiList::Render(){
items[pos]->setWidth(width-10); items[pos]->setWidth(width-10);
else else
items[pos]->setWidth(width); items[pos]->setWidth(width);
nowPos += items[pos]->getHeight() + 5; nowPos += static_cast<int>(items[pos]->getHeight() + 5);
renderBack(items[pos]); renderBack(items[pos]);
items[pos]->Render(); items[pos]->Render();
if(nowPos > SCREEN_HEIGHT) //Stop displaying things once we reach the bottom of the screen. if(nowPos > SCREEN_HEIGHT) //Stop displaying things once we reach the bottom of the screen.
@@ -346,8 +346,8 @@ void WGuiList::Render(){
//Draw scrollbar //Draw scrollbar
if(listHeight > SCREEN_HEIGHT && listSelectable > 1){ if(listHeight > SCREEN_HEIGHT && listSelectable > 1){
int barPosition = y-5+((float)adjustedCurrent/listSelectable)*(SCREEN_HEIGHT-y); float barPosition = static_cast<float>(y-5+((float)adjustedCurrent/listSelectable)*(SCREEN_HEIGHT-y));
int barLength = (SCREEN_HEIGHT-y) / listSelectable; float barLength = static_cast<float>((SCREEN_HEIGHT-y) / listSelectable);
if(barLength < 4) barLength = 4; if(barLength < 4) barLength = 4;
renderer->FillRect(x+width-2,y-1,2,SCREEN_HEIGHT-y, renderer->FillRect(x+width-2,y-1,2,SCREEN_HEIGHT-y,
getColor(WGuiColor::SCROLLBAR)); getColor(WGuiColor::SCROLLBAR));
@@ -802,7 +802,7 @@ bool WGuiMenu::CheckUserInput(JButton key){
return true; return true;
} }
else if(held == buttonPrev && duration > 1){ else if(held == buttonPrev && duration > 1){
duration = .92; duration = .92f;
if(prevItem()) if(prevItem())
return true; return true;
} }
@@ -813,7 +813,7 @@ bool WGuiMenu::CheckUserInput(JButton key){
return true; return true;
} }
else if(held == buttonNext && duration > 1){ else if(held == buttonNext && duration > 1){
duration = .92; duration = .92f;
if(nextItem()) if(nextItem())
return true; return true;
} }
@@ -974,10 +974,10 @@ void WGuiTabMenu::Render(){
if (!items.size()) if (!items.size())
return; return;
int offset = x; float offset = x;
mFont->SetScale(0.8); mFont->SetScale(0.8f);
for(vector<WGuiBase*>::iterator it = items.begin();it!=items.end();it++){ for(vector<WGuiBase*>::iterator it = items.begin();it!=items.end();it++){
int w = mFont->GetStringWidth(_((*it)->getDisplay()).c_str()); float w = mFont->GetStringWidth(_((*it)->getDisplay()).c_str());
mFont->SetColor((*it)->getColor(WGuiColor::TEXT_TAB)); mFont->SetColor((*it)->getColor(WGuiColor::TEXT_TAB));
renderer->FillRoundRect(offset+5,5,w + 5,25,2,(*it)->getColor(WGuiColor::BACK_TAB)); renderer->FillRoundRect(offset+5,5,w + 5,25,2,(*it)->getColor(WGuiColor::BACK_TAB));
mFont->DrawString(_((*it)->getDisplay()).c_str(),offset+10,10); mFont->DrawString(_((*it)->getDisplay()).c_str(),offset+10,10);
@@ -1001,7 +1001,7 @@ void WGuiTabMenu::save(){
void WGuiAward::Overlay(){ void WGuiAward::Overlay(){
JRenderer * r = JRenderer::GetInstance(); JRenderer * r = JRenderer::GetInstance();
WFont * mFont = resources.GetWFont(Constants::OPTION_FONT); WFont * mFont = resources.GetWFont(Constants::OPTION_FONT);
mFont->SetScale(.8); mFont->SetScale(0.8f);
mFont->SetColor(getColor(WGuiColor::TEXT)); mFont->SetColor(getColor(WGuiColor::TEXT));
string s = details; string s = details;
@@ -1338,7 +1338,7 @@ void WGuiListRow::Render(){
tallestRow = temp; tallestRow = temp;
if(temp > cTallest) if(temp > cTallest)
cTallest = temp; cTallest = temp;
nowPos += items[pos]->getWidth() + 5; nowPos += static_cast<int>(items[pos]->getWidth() + 5);
renderBack(items[pos]); renderBack(items[pos]);
if(x+nowPos+items[pos]->getWidth()+10 > SCREEN_WIDTH){ if(x+nowPos+items[pos]->getWidth()+10 > SCREEN_WIDTH){
nowPos = 0 + 20; //Indent newlines. nowPos = 0 + 20; //Indent newlines.
@@ -1941,7 +1941,7 @@ void WGuiKeyBinder::Render() {
renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(230, 255, 240, 240)); renderer->FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, ARGB(230, 255, 240, 240));
size_t pos = 0; size_t pos = 0;
u32 y = 20; float y = 20;
do { do {
size_t t = confirmationString.find_first_of("\n", pos); size_t t = confirmationString.find_first_of("\n", pos);
string s = confirmationString.substr(pos, t - pos); string s = confirmationString.substr(pos, t - pos);