Skip to content

Commit

Permalink
Merge pull request #41 from Talberon/SOL-42_configuration_enhancements
Browse files Browse the repository at this point in the history
Sol 42 configuration enhancements
  • Loading branch information
Talberon authored Jul 1, 2019
2 parents 6ad1c06 + 13fa170 commit 119833f
Show file tree
Hide file tree
Showing 77 changed files with 486 additions and 225 deletions.
26 changes: 13 additions & 13 deletions SolStandard/Containers/Contexts/ControlContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,31 @@ private static void NetworkMenuControls(ControlMapper controlMapper)
GameContext.NetworkMenuView.Exit();
}

if (GameContext.NetworkMenuView.DialMenu == null) return;
if (GameContext.NetworkMenuView.Menu == null) return;

if (controlMapper.Press(Input.CursorUp, PressType.Single))
{
GameContext.NetworkMenuView.DialMenu.MoveMenuCursor(MenuCursorDirection.Up);
GameContext.NetworkMenuView.Menu.MoveMenuCursor(MenuCursorDirection.Up);
}

if (controlMapper.Press(Input.CursorDown, PressType.Single))
{
GameContext.NetworkMenuView.DialMenu.MoveMenuCursor(MenuCursorDirection.Down);
GameContext.NetworkMenuView.Menu.MoveMenuCursor(MenuCursorDirection.Down);
}

if (controlMapper.Press(Input.CursorLeft, PressType.Single))
{
GameContext.NetworkMenuView.DialMenu.MoveMenuCursor(MenuCursorDirection.Left);
GameContext.NetworkMenuView.Menu.MoveMenuCursor(MenuCursorDirection.Left);
}

if (controlMapper.Press(Input.CursorRight, PressType.Single))
{
GameContext.NetworkMenuView.DialMenu.MoveMenuCursor(MenuCursorDirection.Right);
GameContext.NetworkMenuView.Menu.MoveMenuCursor(MenuCursorDirection.Right);
}

if (controlMapper.Press(Input.Confirm, PressType.Single))
{
GameContext.NetworkMenuView.DialMenu.SelectOption();
GameContext.NetworkMenuView.Menu.SelectOption();
}
}

Expand Down Expand Up @@ -433,7 +433,7 @@ private static void SelectUnitControl(ControlMapper controlMapper)
if (controlMapper.Press(Input.Menu, PressType.DelayedRepeat))
{
AssetManager.MenuConfirmSFX.Play();
GameContext.CurrentGameState = GameContext.GameState.PauseScreen;
PauseScreenView.OpenScreen(PauseScreenView.PauseMenus.Primary);
}

if (controlMapper.Press(Input.Confirm, PressType.Single))
Expand Down Expand Up @@ -548,32 +548,32 @@ private static void PauseMenuControl(ControlMapper controlMapper)
{
if (controlMapper.Press(Input.CursorUp, PressType.DelayedRepeat))
{
GameContext.GameMapContext.MovePauseMenuCursor(MenuCursorDirection.Up);
PauseScreenView.CurrentMenu.MoveMenuCursor(MenuCursorDirection.Up);
}

if (controlMapper.Press(Input.CursorDown, PressType.DelayedRepeat))
{
GameContext.GameMapContext.MovePauseMenuCursor(MenuCursorDirection.Down);
PauseScreenView.CurrentMenu.MoveMenuCursor(MenuCursorDirection.Down);
}

if (controlMapper.Press(Input.CursorLeft, PressType.DelayedRepeat))
{
GameContext.GameMapContext.MovePauseMenuCursor(MenuCursorDirection.Left);
PauseScreenView.CurrentMenu.MoveMenuCursor(MenuCursorDirection.Left);
}

if (controlMapper.Press(Input.CursorRight, PressType.DelayedRepeat))
{
GameContext.GameMapContext.MovePauseMenuCursor(MenuCursorDirection.Right);
PauseScreenView.CurrentMenu.MoveMenuCursor(MenuCursorDirection.Right);
}

if (controlMapper.Press(Input.Confirm, PressType.Single))
{
GameContext.GameMapContext.SelectPauseMenuOption();
PauseScreenView.CurrentMenu.SelectOption();
}

if (controlMapper.Press(Input.Menu, PressType.Single))
{
GameContext.GameMapContext.PauseScreenView.ChangeMenu(PauseScreenView.PauseMenus.Primary);
PauseScreenView.ChangeMenu(PauseScreenView.PauseMenus.Primary);
GameContext.CurrentGameState = GameContext.GameState.InGame;
}
}
Expand Down
2 changes: 2 additions & 0 deletions SolStandard/Containers/Contexts/GameContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum GameState
public static StatusScreenView StatusScreenView { get; private set; }
public static MainMenuView MainMenuView { get; private set; }
public static NetworkMenuView NetworkMenuView { get; private set; }
public static BackgroundView BackgroundView { get; private set; }
public static DraftContext DraftContext { get; private set; }
public static DeploymentContext DeploymentContext { get; private set; }
public static CodexContext CodexContext { get; private set; }
Expand Down Expand Up @@ -101,6 +102,7 @@ public static void Initialize(MainMenuView mainMenuView, NetworkMenuView network
DraftContext = new DraftContext();
CodexContext = new CodexContext();
CreditsContext = new CreditsContext(new CreditsView());
BackgroundView = new BackgroundView();
LoadMapSelect();
CurrentGameState = GameState.MainMenu;
P1Team = Team.Red;
Expand Down
12 changes: 0 additions & 12 deletions SolStandard/Containers/Contexts/GameMapContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public enum TurnState
private Vector2 selectedUnitOriginalPosition;
public static GameMapView GameMapView { get; private set; }
public MapContainer MapContainer { get; }
public PauseScreenView PauseScreenView { get; }
public int TurnCounter { get; private set; }
public int RoundCounter { get; private set; }
public bool CanCancelAction { get; set; }
Expand All @@ -62,7 +61,6 @@ public GameMapContext(MapContainer mapContainer, GameMapView gameMapController)
GameMapView = gameMapController;
CurrentTurnState = TurnState.SelectUnit;
selectedUnitOriginalPosition = new Vector2();
PauseScreenView = new PauseScreenView();
TurnCounter = 1;
RoundCounter = 1;
CanCancelAction = true;
Expand Down Expand Up @@ -625,16 +623,6 @@ public static void RemoveExpiredEffectTiles(IEnumerable<IEffectTile> effectTiles
}
}

public void MovePauseMenuCursor(MenuCursorDirection direction)
{
PauseScreenView.CurrentMenu.MoveMenuCursor(direction);
}

public void SelectPauseMenuOption()
{
PauseScreenView.CurrentMenu.SelectOption();
}

public void OpenDraftMenu()
{
CurrentTurnState = TurnState.AdHocDraft;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
using SolStandard.HUD.Window.Content;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Microsoft.Xna.Framework;
using SolStandard.Entity.General.Item;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Linq;
using Microsoft.Xna.Framework;
using SolStandard.Entity.General.Item;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
Expand Down
1 change: 0 additions & 1 deletion SolStandard/Containers/Contexts/WinConditions/Escape.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
using SolStandard.HUD.Window.Content;
Expand Down
2 changes: 1 addition & 1 deletion SolStandard/Containers/Contexts/WinConditions/Objective.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void EndGame()
private static void TransferToResultsScreen()
{
GameContext.CurrentGameState = GameContext.GameState.Results;
MusicBox.PlayLoop(AssetManager.MusicTracks.Find(song => song.Name.Equals("VictoryTheme")), 0.5f);
MusicBox.PlayLoop(AssetManager.MusicTracks.Find(song => song.Name.Equals("VictoryTheme")));
}
}
}
3 changes: 1 addition & 2 deletions SolStandard/Containers/Contexts/WinConditions/RoutArmy.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using SolStandard.Entity.Unit;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
using SolStandard.HUD.Window.Content;
using SolStandard.Utility;
Expand Down
3 changes: 1 addition & 2 deletions SolStandard/Containers/Contexts/WinConditions/Seize.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using SolStandard.HUD.Window;
using SolStandard.HUD.Window;
using SolStandard.HUD.Window.Content;
using SolStandard.Utility;
using SolStandard.Utility.Assets;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
using SolStandard.HUD.Window.Content;
Expand Down
1 change: 0 additions & 1 deletion SolStandard/Containers/Contexts/WinConditions/Taxes.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using SolStandard.Entity.General;
using SolStandard.Entity.Unit;
using SolStandard.HUD.Window;
Expand Down
35 changes: 35 additions & 0 deletions SolStandard/Containers/View/BackgroundView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SolStandard.Utility;
using SolStandard.Utility.Assets;

namespace SolStandard.Containers.View
{
public class BackgroundView : IUserInterface
{
private static SpriteAtlas Background =>
new SpriteAtlas(AssetManager.MainMenuBackground,
new Vector2(AssetManager.MainMenuBackground.Width, AssetManager.MainMenuBackground.Height),
GameDriver.ScreenSize);

private bool IsVisible { get; set; }

public BackgroundView()
{
IsVisible = true;
}

public void ToggleVisible()
{
IsVisible = !IsVisible;
}

public void Draw(SpriteBatch spriteBatch)
{
if (!IsVisible) return;
Vector2 centerScreen = GameDriver.ScreenSize / 2;
Vector2 backgroundCenter = new Vector2(Background.Width, Background.Height) / 2;
Background.Draw(spriteBatch, centerScreen - backgroundCenter);
}
}
}
13 changes: 0 additions & 13 deletions SolStandard/Containers/View/CodexView.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Windows.Forms;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using SolStandard.Entity.Unit;
Expand All @@ -11,7 +10,6 @@
using SolStandard.HUD.Window.Content;
using SolStandard.Utility;
using SolStandard.Utility.Assets;
using HorizontalAlignment = SolStandard.HUD.Window.HorizontalAlignment;

namespace SolStandard.Containers.View
{
Expand All @@ -21,7 +19,6 @@ public class CodexView : IUserInterface
public readonly TwoDimensionalMenu UnitListMenu;
private Window unitActionListWindow;
private Window unitDetailWindow;
private readonly SpriteAtlas background;

private const int WindowEdgeBuffer = 10;

Expand All @@ -33,9 +30,6 @@ public CodexView(IReadOnlyList<GameUnit> unitArchetypes)
{
UnitListMenu = BuildUnitMenu(unitArchetypes);
visible = true;
background = new SpriteAtlas(AssetManager.MainMenuBackground,
new Vector2(AssetManager.MainMenuBackground.Width, AssetManager.MainMenuBackground.Height),
new Vector2(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
}

public void ToggleVisible()
Expand Down Expand Up @@ -208,19 +202,12 @@ private Vector2 UnitActionListWindowPosition()

public void Draw(SpriteBatch spriteBatch)
{
DrawBackground(spriteBatch);
UnitListMenu?.Draw(spriteBatch, UnitListMenuPosition());

if (unitDetailWindow == null) return;
unitDetailWindow.Draw(spriteBatch, UnitDetailWindowPosition());
unitActionListWindow?.Draw(spriteBatch, UnitActionListWindowPosition());
}

private void DrawBackground(SpriteBatch spriteBatch)
{
Vector2 centerScreen = GameDriver.ScreenSize / 2;
Vector2 backgroundCenter = new Vector2(background.Width, background.Height) / 2;
background.Draw(spriteBatch, centerScreen - backgroundCenter);
}
}
}
8 changes: 3 additions & 5 deletions SolStandard/Containers/View/GameMapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,20 +254,17 @@ public void GenerateActionMenus()
private void GenerateMenuDescriptionWindow(MenuType menuType, Color windowColor)
{
string menuName;
IRenderable buttonIcon;
RenderText windowText;

switch (menuType)
{
case MenuType.ActionMenu:
menuName = "Unit Actions";
windowText = new RenderText(AssetManager.HeaderFont, menuName);
buttonIcon = InputIconProvider.GetInputIcon(Input.PreviewItem, new Vector2(windowText.Height));
break;
case MenuType.InventoryMenu:
menuName = "Inventory";
windowText = new RenderText(AssetManager.HeaderFont, menuName);
buttonIcon = InputIconProvider.GetInputIcon(Input.PreviewUnit, new Vector2(windowText.Height));
break;
default:
throw new ArgumentOutOfRangeException(nameof(menuType), menuType, null);
Expand All @@ -279,8 +276,9 @@ private void GenerateMenuDescriptionWindow(MenuType menuType, Color windowColor)
new[,]
{
{
buttonIcon,
windowText
InputIconProvider.GetInputIcon(Input.PreviewUnit, new Vector2(windowText.Height)),
windowText,
InputIconProvider.GetInputIcon(Input.PreviewItem, new Vector2(windowText.Height))
}
},
3,
Expand Down
33 changes: 11 additions & 22 deletions SolStandard/Containers/View/MainMenuView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ public class MainMenuView : IUserInterface
public static readonly Color MenuColor = new Color(10, 35, 50, 100);
private readonly SpriteAtlas title;
private readonly AnimatedSpriteSheet logo;
private readonly SpriteAtlas background;
private readonly RenderText copyright;
private bool visible;

public MainMenuView(SpriteAtlas title, AnimatedSpriteSheet logo, SpriteAtlas background)
public MainMenuView(SpriteAtlas title, AnimatedSpriteSheet logo)
{
this.title = title;
this.logo = logo;
this.background = background;
visible = true;
MainMenu = GenerateMainMenu();
copyright = new RenderText(AssetManager.WindowFont, "Copyright @Talberon 2019",
Expand All @@ -39,6 +37,7 @@ private static VerticalMenu GenerateMainMenu()
new HostGameOption(MenuColor),
new JoinGameOption(MenuColor),
new OpenCodexOption(MenuColor),
new MainMenuConfigOption(MenuColor),
new CreditsOption(MenuColor),
new QuitGameOption(MenuColor)
};
Expand All @@ -55,28 +54,18 @@ public void ToggleVisible()

public void Draw(SpriteBatch spriteBatch)
{
if (visible)
{
Vector2 centerScreen = GameDriver.ScreenSize / 2;

DrawBackground(spriteBatch, centerScreen);
if (!visible) return;
Vector2 centerScreen = GameDriver.ScreenSize / 2;

const int titleVertCoordinate = 20;
Vector2 titleCenter = new Vector2(title.Width, title.Height) / 2;
Vector2 titlePosition = new Vector2(centerScreen.X - titleCenter.X, titleVertCoordinate);
logo.Draw(spriteBatch, titlePosition);
title.Draw(spriteBatch, titlePosition + new Vector2(100));
const int titleVertCoordinate = 20;
Vector2 titleCenter = new Vector2(title.Width, title.Height) / 2;
Vector2 titlePosition = new Vector2(centerScreen.X - titleCenter.X, titleVertCoordinate);
logo.Draw(spriteBatch, titlePosition);
title.Draw(spriteBatch, titlePosition + new Vector2(100));

DrawMenu(spriteBatch, centerScreen, titlePosition);
DrawMenu(spriteBatch, centerScreen, titlePosition);

copyright.Draw(spriteBatch, GameDriver.ScreenSize - new Vector2(copyright.Width, copyright.Height));
}
}

private void DrawBackground(SpriteBatch spriteBatch, Vector2 centerScreen)
{
Vector2 backgroundCenter = new Vector2(background.Width, background.Height) / 2;
background.Draw(spriteBatch, centerScreen - backgroundCenter);
copyright.Draw(spriteBatch, GameDriver.ScreenSize - new Vector2(copyright.Width, copyright.Height));
}

private void DrawMenu(SpriteBatch spriteBatch, Vector2 centerScreen, Vector2 titlePosition)
Expand Down
Loading

0 comments on commit 119833f

Please sign in to comment.