mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Fix cycling title BG more than once per frame
This can happen if you select an option in a menu that (A) returns to the previous menu and (B) saves settings. If the settings save fails, this will create another menu on the same frame that cycles the tower BG after it's already been cycled for that frame. Examples are the slowdown and glitchrunner menus. I could fix this by creating a new function that copy-pastes all of Game::savestatsandsettings_menu() except for the map.nexttowercolour() at the end. But that's copy-pasting code. Instead what I've done is added a variable to signal if the color has already been cycled this frame, so we don't cycle it again. This also covers cases of possible double-cycling in the future as well.
This commit is contained in:
parent
b9202dee8b
commit
45dd7c39b7
3 changed files with 11 additions and 1 deletions
|
@ -82,6 +82,8 @@ mapclass::mapclass(void)
|
|||
cameraseek = 0;
|
||||
minitowermode = false;
|
||||
roomtexton = false;
|
||||
|
||||
nexttowercolour_set = false;
|
||||
}
|
||||
|
||||
//Areamap starts at 100,100 and extends 20x20
|
||||
|
@ -631,6 +633,13 @@ void mapclass::updatetowerglow(TowerBG& bg_obj)
|
|||
|
||||
void mapclass::nexttowercolour(void)
|
||||
{
|
||||
/* Prevent cycling title BG more than once per frame. */
|
||||
if (nexttowercolour_set)
|
||||
{
|
||||
return;
|
||||
}
|
||||
nexttowercolour_set = true;
|
||||
|
||||
graphics.titlebg.colstate+=5;
|
||||
if (graphics.titlebg.colstate >= 30) graphics.titlebg.colstate = 0;
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
void updatetowerglow(TowerBG& bg_obj);
|
||||
|
||||
void nexttowercolour(void);
|
||||
bool nexttowercolour_set;
|
||||
|
||||
void settowercolour(int t);
|
||||
|
||||
|
|
|
@ -724,7 +724,7 @@ static void unfocused_run(void)
|
|||
|
||||
static void focused_begin(void)
|
||||
{
|
||||
/* no-op. */
|
||||
map.nexttowercolour_set = false;
|
||||
}
|
||||
|
||||
static void focused_end(void)
|
||||
|
|
Loading…
Reference in a new issue