An open API service indexing awesome lists of open source software.

https://github.com/benpollarduk/netaf.wpf

An extension library for NetAF targeting WPF and providing controls to allow NetAF to be easily integrated into WPF applications.
https://github.com/benpollarduk/netaf.wpf

csharp framework interactive-fiction netaf text-adventure wpf

Last synced: 3 days ago
JSON representation

An extension library for NetAF targeting WPF and providing controls to allow NetAF to be easily integrated into WPF applications.

Awesome Lists containing this project

README

          

# NetAF.WPF
An extension library for NetAF targeting WPF and providing controls to allow NetAF to be easily integrated into WPF applications.

![icon](.nuget/Icon.bmp)

[![main-ci](https://github.com/benpollarduk/NetAF.WPF/actions/workflows/main-ci.yml/badge.svg)](https://github.com/benpollarduk/NetAF.WPF/actions/workflows/main-ci.yml)
[![GitHub release](https://img.shields.io/github/release/benpollarduk/NetAF.WPF.svg)](https://github.com/benpollarduk/NetAF.WPF/releases)
[![NuGet](https://img.shields.io/nuget/v/netaf.wpf.svg)](https://www.nuget.org/packages/netaf.wpf/)
[![NuGet Downloads](https://img.shields.io/nuget/dt/netaf.wpf)](https://www.nuget.org/packages/netaf.wpf/)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=benpollarduk_NetAF.WPF&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=benpollarduk_NetAF.WPF)
[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=benpollarduk_NetAF.WPF&metric=sqale_rating)](https://sonarcloud.io/summary/new_code?id=benpollarduk_NetAF.WPF)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=benpollarduk_NetAF.WPF&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=benpollarduk_NetAF.WPF)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=benpollarduk_NetAF.WPF&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=benpollarduk_NetAF.WPF)
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=benpollarduk_NetAF.WPF&metric=bugs)](https://sonarcloud.io/summary/new_code?id=benpollarduk_NetAF.WPF)
[![License](https://img.shields.io/github/license/benpollarduk/NetAF.WPF.svg)](https://opensource.org/licenses/MIT)

## Getting Started

### Running the Example
Getting started running [NetAF](https://github.com/benpollarduk/NetAF/) in WPF is easy!

* Clone the repo.
* Build and run NetAF.WPF.TestApp.

![wpf-example](https://github.com/user-attachments/assets/39ba248f-5a21-414b-9ee2-75f30249528d)

## How it Works
You need a couple of components to run a NetAF game:

* Input - a way to interact with the game.
* Output - a way to view the game.

### Input
NetAF.WPF provides some easy ways to interact with the game:

#### Prompt
The prompt allows direct text entry. Add the prompt to a window or control:

```

```

This will send input directly to the active game, in a window it looks like this:

```








```

#### Command Buttons
Command buttons make it easier to interact with a game. There are a few main types:

* **NetAFCommandPicker** - functions as a general command picker for all commands.
* **NetAFMovementCommandPicker** - functions as a general command picker for movement commands.
* **NetAFRegionMapCommandPicker** - functions as a general command picker for navigating the region map.

These can be used individually or as a combination. The **ButtonLayout** control provides a preconfigured control that combines all of the above controls.

```

```

Adding that to the window:

```









```

### Output
NetAF provides a options for viewing the game:

#### Text Terminal
A basic terminal that just displays text without any styling.

image

```

```

Adding that to the window:

```










```

#### Markup Terminal
The markup terminal is highly recommended as it provides customisable styling to frames.

image

```

```

Adding that to the window:

```










```

#### Directing Game Output to the Terminal
The game output needs to be pointed to the terminal. This is done with adapters. In the case of a NetAFTextTerminal the terminal is passed directly to the adapter on configuration:

```csharp
using NetAF.Logic;
using NetAF.Rendering.FrameBuilders;
using NetAF.Targets.Text;
using System.Windows;

namespace NetAF.WPF.TestApp
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

var configuration = new GameConfiguration(new TextAdapter(Terminal), FrameBuilderCollections.Text, Assets.Size.Dynamic);
GameExecutor.Execute(ExampleGame.Create(configuration));
}
}
}
```

And in the case that markup is used:

```csharp
using NetAF.Logic;
using NetAF.Rendering.FrameBuilders;
using NetAF.Targets.Markup;
using System.Windows;

namespace NetAF.WPF.TestApp
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

var configuration = new GameConfiguration(new MarkupAdapter(Terminal), FrameBuilderCollections.Markup, Assets.Size.Dynamic);
GameExecutor.Execute(ExampleGame.Create(configuration));
}
}
}
```

With that you should be ready to go!

## Persistence
The **NetAFFileManager** control adds easy persistence options to a game:

```

```

image

No configuration is required.

## Styling
The controls can all be styled. By default a dark style is included - Targets/WPF/Styles/Dark.xaml.

To use this style merge it with the resource dictionary of your window or control:

```





```

And then apply the styles to the various controls:

```

```

## Example Game
The [ExampleGame](NetAF.WPF.TestApp/Example.cs) is included in the repo.

## Documentation
Please visit [https://benpollarduk.github.io/NetAF-docs/](https://benpollarduk.github.io/NetAF-docs/) to view the NetAF documentation.

## For Open Questions
Visit https://github.com/benpollarduk/NetAF.WPF/issues