Initial options screen

This commit is contained in:
2021-04-23 21:08:37 +02:00
parent 1aa7a57d91
commit db9c3cceea
10 changed files with 128 additions and 10 deletions
Binary file not shown.
-2
View File
@@ -36,8 +36,6 @@ namespace EvilSatellites
protected override void Update(GameTime gameTime) protected override void Update(GameTime gameTime)
{ {
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here // TODO: Add your update logic here
_manager.Update(gameTime); _manager.Update(gameTime);
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EvilSatellites
{
public static class GameSettings
{
public static bool PreferSAPI = true;
}
}
+5 -2
View File
@@ -9,6 +9,7 @@ namespace EvilSatellites
{ {
public class MusicManager public class MusicManager
{ {
public string CurrentFile;
public ISoundEffect Song; public ISoundEffect Song;
public float _Volume; public float _Volume;
public float Volume { public float Volume {
@@ -17,9 +18,9 @@ namespace EvilSatellites
{ {
if (IsPlaying) if (IsPlaying)
{ {
Song.Volume = Volume; Song.Volume = value;
} }
_Volume = Volume; _Volume = value;
} }
} }
public bool IsPlaying; public bool IsPlaying;
@@ -33,6 +34,7 @@ namespace EvilSatellites
public void Play(string path) public void Play(string path)
{ {
if (path == CurrentFile) return;
if (IsPlaying) if (IsPlaying)
{ {
Song.Stop(); Song.Stop();
@@ -43,6 +45,7 @@ namespace EvilSatellites
Song.Play(); Song.Play();
Song.Volume = _Volume; Song.Volume = _Volume;
Song.Loop = true; Song.Loop = true;
CurrentFile = path;
IsPlaying = true; IsPlaying = true;
} }
+5 -3
View File
@@ -9,10 +9,12 @@ namespace EvilSatellites
{ {
DavyKager.Tolk.Load(); DavyKager.Tolk.Load();
DavyKager.Tolk.TrySAPI(true); if (GameSettings.PreferSAPI)
{
DavyKager.Tolk.PreferSAPI(true); DavyKager.Tolk.TrySAPI(true);
DavyKager.Tolk.PreferSAPI(true);
}
using (var game = new Game1()) using (var game = new Game1())
game.Run(); game.Run();
} }
+12
View File
@@ -223,6 +223,18 @@ namespace EvilSatellites.Screens
{ {
DavyKager.Tolk.Output(Objects.Count.ToString()); DavyKager.Tolk.Output(Objects.Count.ToString());
} }
if (Input.IsJustPressed(Keys.PageUp))
{
Manager.Music.Volume = Manager.Music.Volume + 0.05f;
}
if (Input.IsJustPressed(Keys.PageDown))
{
Manager.Music.Volume = Manager.Music.Volume - 0.05f;
}
if (Input.IsJustPressed(Keys.Escape))
{
EndGame();
}
} }
private void CheckCollisions() private void CheckCollisions()
+12 -3
View File
@@ -15,20 +15,29 @@ namespace EvilSatellites.Screens
MenuOptions = new MenuContainer("Main Menu", "Navigate with up and down arrows,, and enter to select."); MenuOptions = new MenuContainer("Main Menu", "Navigate with up and down arrows,, and enter to select.");
MenuOptions.Add(new MenuEntry("Start", "Start the game")) MenuOptions.Add(new MenuEntry("Start", "Start the game"))
.Add(new MenuEntry("Exit", "Exit the game")) .Add(new MenuEntry("Options", "Change game options"))
.Add(new MenuEntry("Something Else", "Do something else")); .Add(new MenuEntry("Exit", "Exit the game"));
base.Activate(); base.Activate();
} }
public override void SelectItem() public override void SelectItem()
{ {
Manager.Sound.PlayOneshot(@"sfx/ui/menuChoose.wav"); base.SelectItem();
if (CursorPosition == 0) if (CursorPosition == 0)
{ {
Manager.AddScreen(new GameScreen()); Manager.AddScreen(new GameScreen());
Manager.RemoveScreen(this); Manager.RemoveScreen(this);
Manager.Game.ResetElapsedTime(); Manager.Game.ResetElapsedTime();
} }
if (CursorPosition == 2)
{
Environment.Exit(0);
}
if (CursorPosition == 1)
{
Manager.RemoveScreen(this);
Manager.AddScreen(new OptionsScreen());
}
} }
} }
} }
+1
View File
@@ -96,6 +96,7 @@ namespace EvilSatellites.Screens
public virtual void SelectItem() public virtual void SelectItem()
{ {
Manager.Sound.PlayOneshot(@"sfx/ui/menuChoose.wav");
return; return;
} }
} }
+77
View File
@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EvilSatellites.Menu;
using DavyKager;
namespace EvilSatellites.Screens
{
public class OptionsScreen : MenuScreen
{
public override void Activate()
{
MenuOptions = new MenuContainer("Options", "Set global options for the game.");
MenuOptions.Add(new MenuEntry("Music Volume", "Toggle between music volumes"))
.Add(new MenuEntry("Use screen reader", "Use screen reader speech instead of SAPI"))
.Add(new MenuEntry("Back", "Go Back to previous screen"));
base.Activate();
}
public override void SelectItem()
{
base.SelectItem();
if (CursorPosition == 0)
{
ChangeVolume();
}
if (CursorPosition == 1)
{
ChangeSpeech();
}
if (CursorPosition == 2)
{
Manager.RemoveScreen(this);
Manager.AddScreen(new MainMenuScreen());
}
}
public void ChangeSpeech()
{
if (GameSettings.PreferSAPI)
{
Tolk.PreferSAPI(false);
Tolk.TrySAPI(false);
Tolk.Output("Prefering screen reader");
} else
{
Tolk.PreferSAPI(true);
Tolk.TrySAPI(true);
Tolk.Output("Prefering SAPI");
}
}
public void ChangeVolume()
{
Inputs.Update();
if (Manager.Music.Volume > 0.9)
{
Manager.Music.Volume = 0f;
return;
}
if (Manager.Music.Volume < 0)
{
Manager.Music.Volume = 1;
}
if (Inputs.IsPressed(Microsoft.Xna.Framework.Input.Keys.LeftShift))
{
Manager.Music.Volume = Manager.Music.Volume - 0.1f;
} else
{
Manager.Music.Volume = Manager.Music.Volume + 0.1f;
}
}
}
}
+2
View File
@@ -19,10 +19,12 @@ namespace EvilSatellites.Screens
.Add(new MenuEntry("Satellite collisions: " + GameStats.SatelliteCollisions.ToString(), "How many satellites you crashed into")) .Add(new MenuEntry("Satellite collisions: " + GameStats.SatelliteCollisions.ToString(), "How many satellites you crashed into"))
.Add(new MenuEntry("Total play time: " + GameStats.TotalPlayTime.ToString(), "How much time you spent on this run")) .Add(new MenuEntry("Total play time: " + GameStats.TotalPlayTime.ToString(), "How much time you spent on this run"))
.Add(new MenuEntry("OK", "Go back to main menu")); .Add(new MenuEntry("OK", "Go back to main menu"));
base.Activate();
} }
public override void SelectItem() public override void SelectItem()
{ {
base.SelectItem();
if (CursorPosition == MenuOptions.Entries.Count-1) if (CursorPosition == MenuOptions.Entries.Count-1)
{ {
Manager.RemoveScreen(this); Manager.RemoveScreen(this);