mirror of
https://github.com/dborth/snes9xgx.git
synced 2024-11-24 03:29:22 +01:00
only update battery images when required
This commit is contained in:
parent
bb34e47633
commit
b80e800101
@ -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);
|
||||
|
||||
if(level == 0)
|
||||
batteryImg[i]->SetImage(&batteryRed);
|
||||
else
|
||||
batteryImg[i]->SetImage(&battery);
|
||||
|
||||
batteryBtn[i]->SetAlpha(255);
|
||||
newStatus = true;
|
||||
newLevel = (userInput[i].wpad.battery_level / 100.0) * 4;
|
||||
if(newLevel > 4) newLevel = 4;
|
||||
}
|
||||
else // controller not connected
|
||||
else
|
||||
{
|
||||
batteryBarImg[i]->SetTile(0);
|
||||
batteryImg[i]->SetImage(&battery);
|
||||
batteryBtn[i]->SetAlpha(150);
|
||||
newStatus = false;
|
||||
newLevel = 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);
|
||||
}
|
||||
else // controller not connected
|
||||
{
|
||||
batteryBtn[i]->SetAlpha(150);
|
||||
batteryBarImg[i]->SetTile(0);
|
||||
batteryImg[i]->SetImage(&battery);
|
||||
}
|
||||
status[i] = newStatus;
|
||||
level[i] = newLevel;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user