only update battery images when required

This commit is contained in:
dborth 2009-06-17 07:46:10 +00:00
parent bb34e47633
commit b80e800101

View File

@ -1259,8 +1259,12 @@ static int MenuGame()
closeBtn.SetEffectGrow();
#ifdef HW_RVL
int i, level;
int i;
char txt[3];
bool status[4] = { false, false, false, false };
int level[4] = { 0, 0, 0, 0 };
bool newStatus;
int newLevel;
GuiText * batteryTxt[4];
GuiImage * batteryImg[4];
GuiImage * batteryBarImg[4];
@ -1349,24 +1353,38 @@ static int MenuGame()
#ifdef HW_RVL
for(i=0; i < 4; i++)
{
if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE) // controller connected
if(WPAD_Probe(i, NULL) == WPAD_ERR_NONE)
{
level = (userInput[i].wpad.battery_level / 100.0) * 4;
if(level > 4) level = 4;
batteryBarImg[i]->SetTile(level);
newStatus = true;
newLevel = (userInput[i].wpad.battery_level / 100.0) * 4;
if(newLevel > 4) newLevel = 4;
}
else
{
newStatus = false;
newLevel = 0;
}
if(level == 0)
if(status[i] != newStatus || level[i] != newLevel)
{
if(newStatus == true) // controller connected
{
batteryBtn[i]->SetAlpha(255);
batteryBarImg[i]->SetTile(newLevel);
if(newLevel == 0)
batteryImg[i]->SetImage(&batteryRed);
else
batteryImg[i]->SetImage(&battery);
batteryBtn[i]->SetAlpha(255);
}
else // controller not connected
{
batteryBtn[i]->SetAlpha(150);
batteryBarImg[i]->SetTile(0);
batteryImg[i]->SetImage(&battery);
batteryBtn[i]->SetAlpha(150);
}
status[i] = newStatus;
level[i] = newLevel;
}
}
#endif