101 lines
2.5 KiB
C#
101 lines
2.5 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using EvilSatellites.Menu;
|
||
|
|
using Microsoft.Xna.Framework;
|
||
|
|
using Microsoft.Xna.Framework.Input;
|
||
|
|
using DavyKager;
|
||
|
|
|
||
|
|
namespace EvilSatellites.Screens
|
||
|
|
{
|
||
|
|
public class MenuScreen : IScreen
|
||
|
|
{
|
||
|
|
public MenuContainer MenuOptions;
|
||
|
|
public int CursorPosition;
|
||
|
|
public ScreenManager _Manager;
|
||
|
|
public ScreenState _State;
|
||
|
|
public InputManager Inputs = new InputManager();
|
||
|
|
public MenuScreen(ScreenManager manager, MenuContainer options)
|
||
|
|
{
|
||
|
|
_Manager = manager;
|
||
|
|
MenuOptions = options;
|
||
|
|
}
|
||
|
|
|
||
|
|
ScreenManager IScreen.Manager { get => _Manager; set => _Manager = value; }
|
||
|
|
ScreenState IScreen.State { get => _State; set => _State = value; }
|
||
|
|
|
||
|
|
void IScreen.Activate()
|
||
|
|
{
|
||
|
|
CursorPosition = 0;
|
||
|
|
Tolk.Output(MenuOptions.Title, true);
|
||
|
|
Tolk.Output(MenuOptions.Description, false);
|
||
|
|
Tolk.Output(MenuOptions.Entries[CursorPosition].Name);
|
||
|
|
}
|
||
|
|
|
||
|
|
void IScreen.Deactivate()
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
void IScreen.HandleInput(GameTime gameTime, KeyboardState inputs)
|
||
|
|
{
|
||
|
|
Inputs.Update();
|
||
|
|
if (Inputs.IsJustPressed(Keys.Down))
|
||
|
|
{
|
||
|
|
NextItem();
|
||
|
|
}
|
||
|
|
if (Inputs.IsJustPressed(Keys.Down))
|
||
|
|
{
|
||
|
|
PreviousItem();
|
||
|
|
}
|
||
|
|
if (Inputs.IsJustPressed(Keys.Enter))
|
||
|
|
{
|
||
|
|
SelectItem();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void IScreen.Update(GameTime gameTime)
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
|
||
|
|
public void PreviousItem()
|
||
|
|
{
|
||
|
|
CursorPosition--;
|
||
|
|
CheckMenuBounds();
|
||
|
|
ReadMenuItem();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void NextItem()
|
||
|
|
{
|
||
|
|
CursorPosition++;
|
||
|
|
CheckMenuBounds();
|
||
|
|
ReadMenuItem();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void CheckMenuBounds()
|
||
|
|
{
|
||
|
|
if (CursorPosition > MenuOptions.Entries.Count-1)
|
||
|
|
{
|
||
|
|
CursorPosition = 0;
|
||
|
|
}
|
||
|
|
if (CursorPosition < 0)
|
||
|
|
{
|
||
|
|
CursorPosition = MenuOptions.Entries.Count - 1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void ReadMenuItem()
|
||
|
|
{
|
||
|
|
Tolk.Output(MenuOptions.Entries[CursorPosition].Name, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SelectItem()
|
||
|
|
{
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|