Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ The puzzle is presented as a cube map in the same manner as in [Old Pochman](htt

![Image](./misc/netcube-system-design.png)

> Note: The above diagram depicts the end goal, rather than the current state of the system.

> Yet to be implemented: AdminPanel, CubeProxy

## Usage

### Setup
Expand Down
9 changes: 5 additions & 4 deletions Solution/AdminPanel/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:AdminPanel"
mc:Ignorable="d"
Title="MainWindow" Height="200" Width="320">

Title="AdminPanel" Height="200" Width="320"
KeyDown="Window_KeyDown"
Focusable="True"
KeyUp="Window_KeyUp"
>

<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">

<Button Margin="5" Height="30" Width="150" Click="Reset_Click">Reset Cube</Button>
<Button Margin="5" Height="30" Width="150" Click="Shuffle_Click">Shuffle Cube</Button>

</StackPanel>

</Window>
17 changes: 17 additions & 0 deletions Solution/AdminPanel/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,22 @@ private async void Shuffle_Click(object sender, RoutedEventArgs e)
{
await ShuffleStrategy.ShuffleCubeAsync();
}

private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.R)
{
Reset_Click(this, new RoutedEventArgs());
}
else if (e.Key == Key.S)
{
Shuffle_Click(this, new RoutedEventArgs());
}
}

private void Window_KeyUp(object sender, KeyEventArgs e)
{
return;
}
}
}
6 changes: 5 additions & 1 deletion Solution/CubeManipulator/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CubeManipulator"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="450">
Title="CubeManipulator" Height="350" Width="450"
KeyDown="Window_KeyDown"
Focusable="True"
KeyUp="Window_KeyUp"
>

<StackPanel Orientation="Vertical" HorizontalAlignment="Center" VerticalAlignment="Center">

Expand Down
39 changes: 38 additions & 1 deletion Solution/CubeManipulator/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Windows;
using LibCubeIntegration.PerformMoveStrategies;
using System.Windows;
using System.Windows.Input;

namespace CubeManipulator
{
Expand All @@ -7,11 +9,46 @@ namespace CubeManipulator
/// </summary>
public partial class MainWindow : Window
{
MoveViaApiStrategy moveStrategy = new MoveViaApiStrategy("CubeProxy");

private readonly Dictionary<Key, string> moveKeyMap = new()
{
{ Key.U, "U" },
{ Key.L, "L" },
{ Key.B, "B" },
{ Key.M, "M" },
{ Key.F, "F" },
{ Key.R, "R" },
{ Key.D, "D" },
{ Key.S, "S" },
};

public MainWindow()
{
InitializeComponent();

DataContext = new CubeManipulatorViewModel(); //Get ViewModel
}

private void Window_KeyDown(object sender, KeyEventArgs e)
{
if (moveKeyMap.TryGetValue(e.Key, out string? moveFound))
{
if (moveFound is string move)
{
ProcessMove(move);
}
}
}

private void Window_KeyUp(object sender, KeyEventArgs e)
{
return;
}

private void ProcessMove(string x)
{
_ = moveStrategy.PerformMoveAsync(x);
}
}
}
40 changes: 34 additions & 6 deletions Solution/CubeVisualizer/CubeGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class CubeGame : Game
float _YRotation = MathHelper.ToRadians(225);
float _XRotation = MathHelper.ToRadians(45);

bool _userInteracted = false;
KeyboardState _prevKeyboardState = Keyboard.GetState();

private HubConnection _connection;

public CubeGame(string pWindowName, int pWindowHeight, int pWindowWidth, Color pBGColour)
Expand All @@ -46,6 +49,8 @@ public CubeGame(string pWindowName, int pWindowHeight, int pWindowWidth, Color p
_graphics.PreferredBackBufferHeight = pWindowHeight;
_graphics.PreferredBackBufferWidth = pWindowWidth;
_BackgroundColour = pBGColour;

this.InactiveSleepTime = TimeSpan.Zero;
}

protected override void Initialize()
Expand Down Expand Up @@ -105,8 +110,8 @@ private HubConnection GetHubConnection()

protected override void Update(GameTime gameTime)
{
if (!IsActive)
return;
//if (!IsActive)
// return;

if (Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
Expand All @@ -116,12 +121,35 @@ protected override void Update(GameTime gameTime)
float rotation = (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f;

MouseState mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed && _PrevMouseState.LeftButton == ButtonState.Pressed)

if (!_userInteracted && (mouseState.LeftButton == ButtonState.Pressed || mouseState.RightButton == ButtonState.Pressed || mouseState.MiddleButton == ButtonState.Pressed))
{
_userInteracted = true;
}

KeyboardState keyboardState = Keyboard.GetState();

if (keyboardState.IsKeyDown(Keys.Enter) && _prevKeyboardState.IsKeyUp(Keys.Enter))
{
xDelta = mouseState.X - _PrevMouseState.X;
yDelta = _PrevMouseState.Y - mouseState.Y;
_userInteracted = !_userInteracted;
}
_PrevMouseState = mouseState;
_prevKeyboardState = keyboardState;

if (_userInteracted && IsActive)
{
if (mouseState.LeftButton == ButtonState.Pressed && _PrevMouseState.LeftButton == ButtonState.Pressed)
{
xDelta = mouseState.X - _PrevMouseState.X;
yDelta = _PrevMouseState.Y - mouseState.Y;
}
_PrevMouseState = mouseState;
}
else
{
xDelta = 20f * rotation; // passive Y rotation speed
yDelta = 0.0f;
}


_YRotation += xDelta * rotation * MouseSpeed;
_XRotation += yDelta * rotation * MouseSpeed;
Expand Down
3 changes: 1 addition & 2 deletions Solution/FaceViewerCLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class Program
{
static readonly FacePresenter Presenter = new();
static CubeState _cubeState = new(new CubePuzzle().GetState());

static readonly CubeServiceFacade _cubeService = new CubeServiceFacade("CubeService");
static readonly CubeServiceFacade _cubeService = new CubeServiceFacade("CubeProxy");

static async Task Main()
{
Expand Down
Binary file modified misc/example-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading