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