mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-03 15:39:46 +01:00
Move menu ACTION press handling to separate function
This takes out 3 indentation levels from the ACTION press handling, making titleinput() easier to read as a whole. Unfortunately, we have to put menuactionpress() first, even though I'd want it the other way around, otherwise titleinput() won't know what it is.
This commit is contained in:
parent
fe178f817b
commit
be64d4f704
1 changed files with 1351 additions and 1346 deletions
|
@ -110,86 +110,7 @@ void updatebuttonmappings(int bind)
|
|||
}
|
||||
}
|
||||
|
||||
void titleinput()
|
||||
{
|
||||
//game.mx = (mouseX / 4);
|
||||
//game.my = (mouseY / 4);
|
||||
|
||||
//TODO bit wasteful doing this every poll
|
||||
key.setSensitivity(game.controllerSensitivity);
|
||||
|
||||
game.press_left = false;
|
||||
game.press_right = false;
|
||||
game.press_action = false;
|
||||
game.press_map = false;
|
||||
|
||||
if (graphics.flipmode)
|
||||
{
|
||||
if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_DOWN) || key.isDown(KEYBOARD_a) || key.isDown(KEYBOARD_s) || key.controllerWantsRight(true)) game.press_left = true;
|
||||
if (key.isDown(KEYBOARD_RIGHT) || key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_d) || key.isDown(KEYBOARD_w) || key.controllerWantsLeft(true)) game.press_right = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_a) || key.isDown(KEYBOARD_w) || key.controllerWantsLeft(true))
|
||||
{
|
||||
game.press_left = true;
|
||||
}
|
||||
if (key.isDown(KEYBOARD_RIGHT) || key.isDown(KEYBOARD_DOWN) || key.isDown(KEYBOARD_d) || key.isDown(KEYBOARD_s) || key.controllerWantsRight(true))
|
||||
{
|
||||
game.press_right = true;
|
||||
}
|
||||
}
|
||||
if (key.isDown(KEYBOARD_z) || key.isDown(KEYBOARD_SPACE) || key.isDown(KEYBOARD_v) || key.isDown(game.controllerButton_flip)) game.press_action = true;
|
||||
//|| key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_DOWN)) game.press_action = true; //on menus, up and down don't work as action
|
||||
if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
|
||||
|
||||
//In the menu system, all keypresses are single taps rather than holds. Therefore this test has to be done for all presses
|
||||
if (!game.press_action && !game.press_left && !game.press_right) game.jumpheld = false;
|
||||
if (!game.press_map) game.mapheld = false;
|
||||
|
||||
if (!game.jumpheld && graphics.fademode==0)
|
||||
{
|
||||
if (game.press_action || game.press_left || game.press_right || game.press_map)
|
||||
{
|
||||
game.jumpheld = true;
|
||||
}
|
||||
|
||||
if (key.isDown(27) && game.currentmenuname != "youwannaquit" && game.menustart)
|
||||
{
|
||||
music.playef(11);
|
||||
game.previousmenuname = game.currentmenuname;
|
||||
game.createmenu("youwannaquit");
|
||||
map.nexttowercolour();
|
||||
}
|
||||
|
||||
if(game.menustart)
|
||||
{
|
||||
if (game.press_left)
|
||||
{
|
||||
game.currentmenuoption--;
|
||||
}
|
||||
else if (game.press_right)
|
||||
{
|
||||
game.currentmenuoption++;
|
||||
}
|
||||
}
|
||||
|
||||
if (game.currentmenuoption < 0) game.currentmenuoption = game.menuoptions.size()-1;
|
||||
if (game.currentmenuoption >= (int) game.menuoptions.size() ) game.currentmenuoption = 0;
|
||||
|
||||
if (game.press_action)
|
||||
{
|
||||
if (!game.menustart)
|
||||
{
|
||||
game.menustart = true;
|
||||
music.play(6);
|
||||
music.playef(18);
|
||||
game.screenshake = 10;
|
||||
game.flashlight = 5;
|
||||
map.colstate = 10;
|
||||
map.nexttowercolour();
|
||||
}
|
||||
else
|
||||
void menuactionpress()
|
||||
{
|
||||
if (game.currentmenuname == "mainmenu")
|
||||
{
|
||||
|
@ -1538,6 +1459,90 @@ void titleinput()
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void titleinput()
|
||||
{
|
||||
//game.mx = (mouseX / 4);
|
||||
//game.my = (mouseY / 4);
|
||||
|
||||
//TODO bit wasteful doing this every poll
|
||||
key.setSensitivity(game.controllerSensitivity);
|
||||
|
||||
game.press_left = false;
|
||||
game.press_right = false;
|
||||
game.press_action = false;
|
||||
game.press_map = false;
|
||||
|
||||
if (graphics.flipmode)
|
||||
{
|
||||
if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_DOWN) || key.isDown(KEYBOARD_a) || key.isDown(KEYBOARD_s) || key.controllerWantsRight(true)) game.press_left = true;
|
||||
if (key.isDown(KEYBOARD_RIGHT) || key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_d) || key.isDown(KEYBOARD_w) || key.controllerWantsLeft(true)) game.press_right = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (key.isDown(KEYBOARD_LEFT) || key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_a) || key.isDown(KEYBOARD_w) || key.controllerWantsLeft(true))
|
||||
{
|
||||
game.press_left = true;
|
||||
}
|
||||
if (key.isDown(KEYBOARD_RIGHT) || key.isDown(KEYBOARD_DOWN) || key.isDown(KEYBOARD_d) || key.isDown(KEYBOARD_s) || key.controllerWantsRight(true))
|
||||
{
|
||||
game.press_right = true;
|
||||
}
|
||||
}
|
||||
if (key.isDown(KEYBOARD_z) || key.isDown(KEYBOARD_SPACE) || key.isDown(KEYBOARD_v) || key.isDown(game.controllerButton_flip)) game.press_action = true;
|
||||
//|| key.isDown(KEYBOARD_UP) || key.isDown(KEYBOARD_DOWN)) game.press_action = true; //on menus, up and down don't work as action
|
||||
if (key.isDown(KEYBOARD_ENTER)) game.press_map = true;
|
||||
|
||||
//In the menu system, all keypresses are single taps rather than holds. Therefore this test has to be done for all presses
|
||||
if (!game.press_action && !game.press_left && !game.press_right) game.jumpheld = false;
|
||||
if (!game.press_map) game.mapheld = false;
|
||||
|
||||
if (!game.jumpheld && graphics.fademode==0)
|
||||
{
|
||||
if (game.press_action || game.press_left || game.press_right || game.press_map)
|
||||
{
|
||||
game.jumpheld = true;
|
||||
}
|
||||
|
||||
if (key.isDown(27) && game.currentmenuname != "youwannaquit" && game.menustart)
|
||||
{
|
||||
music.playef(11);
|
||||
game.previousmenuname = game.currentmenuname;
|
||||
game.createmenu("youwannaquit");
|
||||
map.nexttowercolour();
|
||||
}
|
||||
|
||||
if(game.menustart)
|
||||
{
|
||||
if (game.press_left)
|
||||
{
|
||||
game.currentmenuoption--;
|
||||
}
|
||||
else if (game.press_right)
|
||||
{
|
||||
game.currentmenuoption++;
|
||||
}
|
||||
}
|
||||
|
||||
if (game.currentmenuoption < 0) game.currentmenuoption = game.menuoptions.size()-1;
|
||||
if (game.currentmenuoption >= (int) game.menuoptions.size() ) game.currentmenuoption = 0;
|
||||
|
||||
if (game.press_action)
|
||||
{
|
||||
if (!game.menustart)
|
||||
{
|
||||
game.menustart = true;
|
||||
music.play(6);
|
||||
music.playef(18);
|
||||
game.screenshake = 10;
|
||||
game.flashlight = 5;
|
||||
map.colstate = 10;
|
||||
map.nexttowercolour();
|
||||
}
|
||||
else
|
||||
{
|
||||
menuactionpress();
|
||||
}
|
||||
}
|
||||
if ( game.currentmenuname == "controller" &&
|
||||
game.currentmenuoption > 0 &&
|
||||
|
|
Loading…
Reference in a new issue