Skip to content

Commit

Permalink
Streamlined game configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_singer committed Nov 29, 2024
1 parent 088c05c commit bc167b6
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 34 deletions.
3 changes: 0 additions & 3 deletions NetAF.Tests/TestGameConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using NetAF.Interpretation;
using NetAF.Logic;
using NetAF.Logic.Configuration;
using NetAF.Rendering;
using NetAF.Rendering.FrameBuilders;

namespace NetAF.Tests
Expand All @@ -20,8 +19,6 @@ internal class TestGameConfiguration(Size displaySize, ExitMode exitMode, IIOAda
new CustomCommandInterpreter());

public FrameBuilderCollection FrameBuilders { get; set; } = FrameBuilderCollections.Default;
public bool DisplayCommandListInSceneFrames { get; set; } = true;
public KeyType SceneMapKeyType { get; set; } = KeyType.Dynamic;
public IIOAdapter Adapter { get; private set; } = adapter;
}
}
6 changes: 4 additions & 2 deletions NetAF/Commands/Frame/CommandsOff.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NetAF.Commands.Frame
using NetAF.Logic.Modes;

namespace NetAF.Commands.Frame
{
/// <summary>
/// Represents the CommandsOff command.
Expand Down Expand Up @@ -26,7 +28,7 @@ public Reaction Invoke(Logic.Game game)
if (game == null)
return new(ReactionResult.Error, "No game specified.");

game.Configuration.DisplayCommandListInSceneFrames = false;
SceneMode.DisplayCommandList = false;
return new(ReactionResult.Inform, "Commands have been turned off.");
}

Expand Down
6 changes: 4 additions & 2 deletions NetAF/Commands/Frame/CommandsOn.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace NetAF.Commands.Frame
using NetAF.Logic.Modes;

namespace NetAF.Commands.Frame
{
/// <summary>
/// Represents the CommandsOn command.
Expand Down Expand Up @@ -26,7 +28,7 @@ public Reaction Invoke(Logic.Game game)
if (game == null)
return new(ReactionResult.Error, "No game specified.");

game.Configuration.DisplayCommandListInSceneFrames = true;
SceneMode.DisplayCommandList = true;
return new(ReactionResult.Inform, "Commands have been turned on.");
}

Expand Down
5 changes: 3 additions & 2 deletions NetAF/Commands/Frame/KeyOff.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NetAF.Rendering;
using NetAF.Logic.Modes;
using NetAF.Rendering;

namespace NetAF.Commands.Frame
{
Expand Down Expand Up @@ -28,7 +29,7 @@ public Reaction Invoke(Logic.Game game)
if (game == null)
return new(ReactionResult.Error, "No game specified.");

game.Configuration.SceneMapKeyType = KeyType.None;
SceneMode.KeyType = KeyType.None;
return new(ReactionResult.Inform, "Key has been turned off.");
}

Expand Down
5 changes: 3 additions & 2 deletions NetAF/Commands/Frame/KeyOn.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NetAF.Rendering;
using NetAF.Logic.Modes;
using NetAF.Rendering;

namespace NetAF.Commands.Frame
{
Expand Down Expand Up @@ -28,7 +29,7 @@ public Reaction Invoke(Logic.Game game)
if (game == null)
return new(ReactionResult.Error, "No game specified.");

game.Configuration.SceneMapKeyType = KeyType.Dynamic;
SceneMode.KeyType = KeyType.Dynamic;
return new(ReactionResult.Inform, "Key has been turned on.");
}

Expand Down
11 changes: 0 additions & 11 deletions NetAF/Logic/Configuration/ConsoleGameConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using NetAF.Assets;
using NetAF.Interpretation;
using NetAF.Rendering.FrameBuilders;
using NetAF.Rendering;

namespace NetAF.Logic.Configuration
{
Expand Down Expand Up @@ -45,16 +44,6 @@ public sealed class ConsoleGameConfiguration(Size displaySize, ExitMode exitMode
/// </summary>
public FrameBuilderCollection FrameBuilders { get; set; } = FrameBuilderCollections.Default;

/// <summary>
/// Get or set if the command list is displayed in scene frames.
/// </summary>
public bool DisplayCommandListInSceneFrames { get; set; } = true;

/// <summary>
/// Get or set the type of key to use on the scene map.
/// </summary>
public KeyType SceneMapKeyType { get; set; } = KeyType.Dynamic;

/// <summary>
/// Get the I/O adapter.
/// </summary>
Expand Down
11 changes: 0 additions & 11 deletions NetAF/Logic/Configuration/IGameConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using NetAF.Adapters;
using NetAF.Assets;
using NetAF.Interpretation;
using NetAF.Rendering;
using NetAF.Rendering.FrameBuilders;

namespace NetAF.Logic.Configuration
Expand Down Expand Up @@ -33,16 +32,6 @@ public interface IGameConfiguration
/// </summary>
public FrameBuilderCollection FrameBuilders { get; set; }

/// <summary>
/// Get or set if the command list is displayed in scene frames.
/// </summary>
public bool DisplayCommandListInSceneFrames { get; set; }

/// <summary>
/// Get or set the type of key to use on the scene map.
/// </summary>
public KeyType SceneMapKeyType { get; set; }

/// <summary>
/// Get the I/O adapter.
/// </summary>
Expand Down
17 changes: 16 additions & 1 deletion NetAF/Logic/Modes/SceneMode.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NetAF.Assets.Locations;
using NetAF.Commands;
using NetAF.Interpretation;
using NetAF.Rendering;
using System.Collections.Generic;

namespace NetAF.Logic.Modes
Expand All @@ -10,6 +11,20 @@ namespace NetAF.Logic.Modes
/// </summary>
public sealed class SceneMode : IGameMode
{
#region StaticProperties

/// <summary>
/// Get or set if the command list is displayed.
/// </summary>
public static bool DisplayCommandList { get; set; } = true;

/// <summary>
/// Get or set the type of key to use on the map.
/// </summary>
public static KeyType KeyType { get; set; } = KeyType.Dynamic;

#endregion

#region Implementation of IGameMode

/// <summary>
Expand All @@ -32,7 +47,7 @@ public void Render(Game game)
commands.AddRange(Interpreter.GetContextualCommandHelp(game));
commands.AddRange(game.Configuration.Interpreter.GetContextualCommandHelp(game));

var frame = game.Configuration.FrameBuilders.SceneFrameBuilder.Build(game.Overworld.CurrentRegion.CurrentRoom, ViewPoint.Create(game.Overworld.CurrentRegion), game.Player, game.Configuration.DisplayCommandListInSceneFrames ? [.. commands] : null, game.Configuration.SceneMapKeyType, game.Configuration.DisplaySize);
var frame = game.Configuration.FrameBuilders.SceneFrameBuilder.Build(game.Overworld.CurrentRegion.CurrentRoom, ViewPoint.Create(game.Overworld.CurrentRegion), game.Player, DisplayCommandList ? [.. commands] : null, KeyType, game.Configuration.DisplaySize);
game.Configuration.Adapter.RenderFrame(frame);
}

Expand Down

0 comments on commit bc167b6

Please sign in to comment.