dev
This commit is contained in:
parent
acb9201725
commit
6bebafe402
|
|
@ -0,0 +1,42 @@
|
|||
@using KoogleApp.Model
|
||||
|
||||
|
||||
<MudDialog Style="height: 400px; width:600px">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Favorite" Class="mr-3 mb-n1"/>
|
||||
Save as favorite?
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudSelect T="ThrowMode" Label="Modus" @bind-Value="ThrowMode">
|
||||
<MudSelectItem Value="ThrowMode.Reposition">in die Vollen</MudSelectItem>
|
||||
<MudSelectItem Value="ThrowMode.Reposition">Abräumen</MudSelectItem>
|
||||
</MudSelect>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Abbrechen</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Start">Start</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; }
|
||||
|
||||
public ThrowMode ThrowMode { get; set; } = ThrowMode.Reposition;
|
||||
|
||||
[Parameter]
|
||||
public string Description { get; set; } = "";
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// if (!string.IsNullOrEmpty(Description))
|
||||
{
|
||||
// Snackbar.Add("Favorite added", Severity.Success);
|
||||
MudDialog.Close(DialogResult.Ok(ThrowMode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@
|
|||
@using Microsoft.AspNetCore.Authorization
|
||||
@using Microsoft.AspNetCore.SignalR.Client
|
||||
@using KoogleApp.Components.Controls
|
||||
@using KoogleApp.Components.Dialogs
|
||||
@using KoogleApp.Model.EventMessages
|
||||
@using KoogleApp.Model.Framework
|
||||
@using KoogleApp.Store.Game
|
||||
|
|
@ -22,6 +23,7 @@
|
|||
@inject IMyEventAggregator EventAggregator
|
||||
@inject IState<ThrowPanelState> ThrowPanelState
|
||||
@inject IDispatcher Dispatcher
|
||||
@inject IDialogService DialogService
|
||||
|
||||
@* @inject IGameStatusDataService _dataService; *@
|
||||
|
||||
|
|
@ -251,10 +253,38 @@
|
|||
// }
|
||||
}
|
||||
|
||||
private void StartStopClick()
|
||||
private async Task StartStopClick()
|
||||
{
|
||||
var action = new StartStopAction(ThrowPanelState.Value);
|
||||
Dispatcher.Dispatch(action);
|
||||
if (!ThrowPanelState.Value.IsStated)
|
||||
{
|
||||
var parameters = new DialogParameters<StartGameDialog> { { x => x.Description, "" }};
|
||||
// parameters.Add<TimeRecordDto>(x => x.Record, Record);
|
||||
|
||||
var options = new DialogOptions
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
|
||||
var dialog = await DialogService.ShowAsync<StartGameDialog>("Spiel starten", parameters, options);
|
||||
var result = await dialog.Result;
|
||||
|
||||
if (!result.Canceled)
|
||||
{
|
||||
var action = new StartStopAction(ThrowPanelState.Value, new StartParams());
|
||||
Dispatcher.Dispatch(action);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = await DialogService.ShowMessageBox("Spiel beenden?", "Spiel wirklich abbrechen?", "JA", "NEIN");
|
||||
if (result.Value)
|
||||
{
|
||||
var action = new StartStopAction(ThrowPanelState.Value,null);
|
||||
Dispatcher.Dispatch(action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// _throwPanelState = ThrowPanelState.Create();
|
||||
// await BroadcastThrowPanelStateAction(_throwPanelState);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace KoogleApp.Hub
|
|||
await _hubConnection.StartAsync();
|
||||
}
|
||||
|
||||
public async Task HandleStartAction(StartStopAction stopAction, IDispatcher dispatcher)
|
||||
public async Task HandelBroadcastThrowPanelStateAction(BroadcastThrowPanelStateAction action, IDispatcher dispatcher)
|
||||
{
|
||||
if (_hubConnection?.State != HubConnectionState.Connected)
|
||||
{
|
||||
|
|
@ -64,7 +64,7 @@ namespace KoogleApp.Hub
|
|||
{
|
||||
if (_hubConnection is not null)
|
||||
{
|
||||
await _hubConnection.SendAsync("BroadcastThrowPanelState", stopAction.State);
|
||||
await _hubConnection.SendAsync("BroadcastThrowPanelState", action.State);
|
||||
}
|
||||
|
||||
//await Clients.Others.SendAsync("ReceiveThrowPanelState", new ThrowPanelState());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
namespace KoogleApp.Model
|
||||
{
|
||||
public record StartParams(ThrowMode ThrowMode, int ThrowsPerRound)
|
||||
{
|
||||
public StartParams() : this(ThrowMode: ThrowMode.Reposition, ThrowsPerRound:3)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,16 +5,23 @@ using Microsoft.IdentityModel.Tokens;
|
|||
|
||||
namespace KoogleApp.Model
|
||||
{
|
||||
public enum ThrowMode
|
||||
{
|
||||
Reposition, // in die Vollen
|
||||
Decrease // Abräumen
|
||||
}
|
||||
|
||||
[FeatureState]
|
||||
public record ThrowPanelState(bool IsStated, bool BellValue,
|
||||
bool Pin1Value, bool Pin2Value, bool Pin3Value, bool Pin4Value, bool Pin5Value, bool Pin6Value, bool Pin7Value, bool Pin8Value, bool Pin9Value,
|
||||
bool Pin1Disabled, bool Pin2Disabled, bool Pin3Disabled, bool Pin4Disabled, bool Pin5Disabled, bool Pin6Disabled, bool Pin7Disabled, bool Pin8Disabled, bool Pin9Disabled
|
||||
)
|
||||
bool Pin1Disabled, bool Pin2Disabled, bool Pin3Disabled, bool Pin4Disabled, bool Pin5Disabled, bool Pin6Disabled, bool Pin7Disabled, bool Pin8Disabled, bool Pin9Disabled,
|
||||
int ThrowsPerRound, int ThrowCounter, ThrowMode ThrowMode)
|
||||
{
|
||||
// Required for creating initial state
|
||||
public ThrowPanelState() : this(BellValue:false, IsStated:false,
|
||||
Pin1Value:false, Pin2Value:false, Pin3Value: false, Pin4Value: false, Pin5Value: false, Pin6Value: false, Pin7Value: false, Pin8Value: false, Pin9Value: false,
|
||||
Pin1Disabled:false, Pin2Disabled:false, Pin3Disabled: false, Pin4Disabled: false, Pin5Disabled: false, Pin6Disabled: false, Pin7Disabled: false, Pin8Disabled: false, Pin9Disabled: false
|
||||
Pin1Disabled:false, Pin2Disabled:false, Pin3Disabled: false, Pin4Disabled: false, Pin5Disabled: false, Pin6Disabled: false, Pin7Disabled: false, Pin8Disabled: false, Pin9Disabled: false,
|
||||
ThrowsPerRound : 3, ThrowCounter : 0, ThrowMode : ThrowMode.Reposition
|
||||
)
|
||||
{ }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
{
|
||||
public record TogglePinValueAction(bool IsOn, int PinNumber);
|
||||
|
||||
public record StartStopAction(ThrowPanelState State);
|
||||
public record StartStopAction(ThrowPanelState State, StartParams? StartParams);
|
||||
|
||||
public record ConnectToHubAction();
|
||||
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ namespace KoogleApp.Store.Game.ThrowPanel
|
|||
// TODO error handling
|
||||
}
|
||||
|
||||
await _sharedModelHub.HandleStartAction(new StartStopAction(_state.Value), dispatcher);
|
||||
await _sharedModelHub.HandelBroadcastThrowPanelStateAction(action, dispatcher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"IsStated": true,
|
||||
"IsStated": false,
|
||||
"BellValue": true,
|
||||
"Pin1Value": true,
|
||||
"Pin2Value": true,
|
||||
"Pin3Value": true,
|
||||
"Pin4Value": true,
|
||||
"Pin5Value": true,
|
||||
"Pin6Value": true,
|
||||
"Pin7Value": false,
|
||||
"Pin1Value": false,
|
||||
"Pin2Value": false,
|
||||
"Pin3Value": false,
|
||||
"Pin4Value": false,
|
||||
"Pin5Value": false,
|
||||
"Pin6Value": false,
|
||||
"Pin7Value": true,
|
||||
"Pin8Value": true,
|
||||
"Pin9Value": true,
|
||||
"Pin1Disabled": false,
|
||||
|
|
@ -18,5 +18,8 @@
|
|||
"Pin6Disabled": false,
|
||||
"Pin7Disabled": false,
|
||||
"Pin8Disabled": false,
|
||||
"Pin9Disabled": false
|
||||
"Pin9Disabled": false,
|
||||
"ThrowsPerRound": 3,
|
||||
"ThrowCounter": 0,
|
||||
"ThrowMode": 0
|
||||
}
|
||||
Loading…
Reference in New Issue