This commit is contained in:
beo3000 2025-11-10 16:03:02 +01:00
parent 6bebafe402
commit 0d7a4d9ba5
7 changed files with 78 additions and 75 deletions

View File

@ -37,7 +37,7 @@
</MudItem> </MudItem>
<MudFlexBreak/> <MudFlexBreak/>
@if (ShowNumbers) @if (ThrowPanelState.Value.ThrowMode == ThrowMode.Reposition)
{ {
<MudItem xs="4"> <MudItem xs="4">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0"> <MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
@ -137,13 +137,6 @@
@code { @code {
[Parameter]
public bool ShowNumbers
{
get;
set;
}
[Parameter] [Parameter]
public bool CanSelectPlayer public bool CanSelectPlayer
{ {

View File

@ -4,46 +4,15 @@
<MudItem xs="12" md="6"> <MudItem xs="12" md="6">
<NumberPanel ShowNumbers="ShowNumbers" <NumberPanel/>
CanSelectPlayer="CanSelectPlayers"
/>
</MudItem> </MudItem>
<MudItem xs="12" md="6"> <MudItem xs="12" md="6">
<PinPanel @ref="_pinPanel" <PinPanel/>
/>
</MudItem> </MudItem>
@code { @code {
// [Parameter]
// public ThrowPanelState? ThrowPanelState { get; set; }
PinPanel _pinPanel;
NumberPanel _numberPanel;
[Parameter]
public bool ShowNumbers
{
get;
set;
}
[Parameter]
public bool CanSelectPlayers
{
get;
set;
}
// public void UpdatePanelState(ThrowPanelState state)
// {
// _pinPanel.UpdatePanelState(state);
// }
} }

View File

@ -10,11 +10,7 @@
@if (ThrowPanelState.Value.IsStated) @if (ThrowPanelState.Value.IsStated)
{ {
<MudGrid> <MudGrid>
<NumberPinPanel />
<NumberPinPanel ShowNumbers="true"
CanSelectPlayers="true"
/>
<MudItem xs="4"> <MudItem xs="4">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0"> <MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
<MudButton OnClick="SinkLeftClick"> <MudButton OnClick="SinkLeftClick">

View File

@ -9,9 +9,12 @@
</MudText> </MudText>
</TitleContent> </TitleContent>
<DialogContent> <DialogContent>
<MudSelect T="ThrowMode" Label="Modus" @bind-Value="ThrowMode"> <MudSelect T="Tuple<string, ThrowMode>" Label="Modus" @bind-Value="_valueThrowMode" HelperText="Wähle zwischen Abräumen und in die Vollen"
<MudSelectItem Value="ThrowMode.Reposition">in die Vollen</MudSelectItem> OpenIcon="@Icons.Material.Filled.Mode" AdornmentColor="Color.Primary">
<MudSelectItem Value="ThrowMode.Reposition">Abräumen</MudSelectItem> @foreach (var item in _items)
{
<MudSelectItem T="Tuple<string, ThrowMode>" Value="@(item)">@item.Item1</MudSelectItem>
}
</MudSelect> </MudSelect>
</DialogContent> </DialogContent>
<DialogActions> <DialogActions>
@ -21,10 +24,25 @@
</MudDialog> </MudDialog>
@code { @code {
private List<Tuple<string, ThrowMode>> _items = new List<Tuple<string, ThrowMode>>();
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
_items.Add(new Tuple<string, ThrowMode>("in die Vollen", ThrowMode.Reposition));
_items.Add(new Tuple<string, ThrowMode>("Abräumen", ThrowMode.Decrease));
_valueThrowMode = _items[0];
StateHasChanged();
}
}
[CascadingParameter] [CascadingParameter]
private IMudDialogInstance MudDialog { get; set; } private IMudDialogInstance MudDialog { get; set; }
public ThrowMode ThrowMode { get; set; } = ThrowMode.Reposition; // [Parameter]
private Tuple<string, ThrowMode> _valueThrowMode;
[Parameter] [Parameter]
public string Description { get; set; } = ""; public string Description { get; set; } = "";
@ -36,7 +54,21 @@
// if (!string.IsNullOrEmpty(Description)) // if (!string.IsNullOrEmpty(Description))
{ {
// Snackbar.Add("Favorite added", Severity.Success); // Snackbar.Add("Favorite added", Severity.Success);
MudDialog.Close(DialogResult.Ok(ThrowMode)); MudDialog.Close(DialogResult.Ok(new StartParams(_valueThrowMode.Item2, 3)));
} }
} }
private string ValueToString(ThrowMode item)
{
switch (item)
{
case ThrowMode.Reposition:
return "Abräumen";
case ThrowMode.Decrease:
return "in die Vollen";
default:
throw new ArgumentOutOfRangeException(nameof(item), item, null);
}
}
} }

View File

@ -239,18 +239,18 @@
private async Task UndoClick() private async Task UndoClick()
{ {
// if (hubConnection is not null) // if (hubConnection is not null)
// { // {
// await hubConnection.SendAsync("RequestUndo", _userName); // await hubConnection.SendAsync("RequestUndo", _userName);
// } // }
} }
private async Task RedoClick() private async Task RedoClick()
{ {
// if (hubConnection is not null) // if (hubConnection is not null)
// { // {
// await hubConnection.SendAsync("RequestRedo", _userName); // await hubConnection.SendAsync("RequestRedo", _userName);
// } // }
} }
private async Task StartStopClick() private async Task StartStopClick()
@ -268,10 +268,10 @@
var dialog = await DialogService.ShowAsync<StartGameDialog>("Spiel starten", parameters, options); var dialog = await DialogService.ShowAsync<StartGameDialog>("Spiel starten", parameters, options);
var result = await dialog.Result; var result = await dialog.Result;
var startParams = result.Data as StartParams;
if (!result.Canceled) if (!result.Canceled)
{ {
var action = new StartStopAction(ThrowPanelState.Value, new StartParams()); var action = new StartStopAction(ThrowPanelState.Value, startParams);
Dispatcher.Dispatch(action); Dispatcher.Dispatch(action);
} }
} }

View File

@ -41,9 +41,22 @@ namespace KoogleApp.Store.Game.ThrowPanel
} }
[ReducerMethod] [ReducerMethod]
public static ThrowPanelState OnStartStop(ThrowPanelState state, StartStopAction stopAction) public static ThrowPanelState OnStartStop(ThrowPanelState state, StartStopAction startStopAction)
{ {
return state with { IsStated = !state.IsStated }; if (state.IsStated)
{
return state with { IsStated = false };
}
if (startStopAction.StartParams != null)
return state with
{
IsStated = !state.IsStated,
ThrowMode = startStopAction.StartParams.ThrowMode,
ThrowsPerRound = startStopAction.StartParams.ThrowsPerRound
};
return state;
} }
[ReducerMethod] [ReducerMethod]

View File

@ -1,12 +1,12 @@
{ {
"IsStated": false, "IsStated": true,
"BellValue": true, "BellValue": false,
"Pin1Value": false, "Pin1Value": true,
"Pin2Value": false, "Pin2Value": true,
"Pin3Value": false, "Pin3Value": true,
"Pin4Value": false, "Pin4Value": true,
"Pin5Value": false, "Pin5Value": true,
"Pin6Value": false, "Pin6Value": true,
"Pin7Value": true, "Pin7Value": true,
"Pin8Value": true, "Pin8Value": true,
"Pin9Value": true, "Pin9Value": true,