public void MouseUp(int x, int y, int whichButton)
{
if (_showingLoadMenu)
{
for (int i = 0; i < _maxVisible; i++)
{
if (_saveGameButtons[i].MouseUp(x, y))
{
_gameMain.LoadGame(_files[i + _scrollBar.TopIndex].Name);
_gameMain.ChangeToScreen(Screen.Galaxy);
_showingLoadMenu = false;
return;
}
}
if (_scrollBar.MouseUp(x, y))
{
RefreshSaves();
return;
}
//Since the player didn't click on one of the buttons, it's considered as cancel.
_showingLoadMenu = false;
return;
}
for (int i = 0; i < _buttons.Length; i++)
{
if (_buttons[i].MouseUp(x, y))
{
switch (i)
{
case 0: //Continue button
FileInfo mostRecentGame = null;
foreach (var file in _files)
{
if (mostRecentGame == null)
{
mostRecentGame = file;
}
else if (mostRecentGame.LastWriteTime.CompareTo(file.LastWriteTime) < 0)
{
mostRecentGame = file;
}
}
if (mostRecentGame != null)
{
_gameMain.LoadGame(mostRecentGame.Name);
_gameMain.ChangeToScreen(Screen.Galaxy);
}
break;
case 1: //New Game button
_gameMain.ChangeToScreen(Screen.NewGame);
break;
case 2:
_showingLoadMenu = true;
break;
case 3:
_gameMain.ExitGame();
break;
}
}
}
}