dev undo funktion

This commit is contained in:
beo3000 2025-11-11 14:25:51 +01:00
parent 0cc84e31e0
commit 1f3df7723f
6 changed files with 116 additions and 79 deletions

View File

@ -26,7 +26,7 @@
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0" Style="height: 76px;">
<MudStack Spacing="0" Wrap="Wrap.Wrap">
<MudChip T="string" Color="Color.Dark" Size="Size.Small">@(GetThrowModeName(ThrowPanelState.Value.ThrowMode))</MudChip>
<MudChip T="string" Color="Color.Dark" Size="Size.Small">Wurf @ThrowPanelState.Value.ThrowCounter von @ThrowPanelState.Value.ThrowsPerRound</MudChip>
<MudChip T="string" Color="Color.Dark" Size="Size.Small">Wurf @ThrowPanelState.Value.ThrowCounterPerRound von @ThrowPanelState.Value.ThrowsPerRound</MudChip>
</MudStack>
</MudPaper>
</MudItem>

View File

@ -19,13 +19,15 @@
{
<MudItem xs="6">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
@if (!_canUnlock)
@if (!CanUnlock)
{
<MudText>Wurf @(UndoRedoState.Value.Version - 1) von XX um YY</MudText>
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.DirectionsRun"></MudIcon>
<MudText>Wurf: @(ThrowPanelState.Value.ThrowCounter + 1) von XX um YY</MudText>
}
else
{
<MudText>Bild @((UndoRedoState.Value.Version / 2) + 1)</MudText>
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.AccessibilityNew"></MudIcon>
<MudText>Bild: @((UndoRedoState.Value.Version / 2) + 1)</MudText>
}
</MudPaper>
</MudItem>
@ -33,11 +35,11 @@
<MudItem xs="6">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
<MudButton OnClick="UnlockClick"
Disabled="!_canUnlock">
Disabled="!CanUnlock">
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ChangeHistory"
Color="@(!_canUnlock ? Color.Dark : Color.Secondary)"
Color="@(!CanUnlock ? Color.Dark : Color.Secondary)"
Style="font-size: 3rem;"/>
Korrigieren
<MudText>@(CanUnlock ? "ab hier Wurf korrigieren" : "nur Bilder sind korrigierbar")</MudText>
</MudButton>
</MudPaper>
</MudItem>
@ -47,9 +49,9 @@
<MudItem xs="4">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
<MudButton OnClick="SinkLeftClick"
Disabled="@_disabled">
Disabled="@Disabled">
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ArrowCircleLeft"
Color="@(_disabled ? Color.Dark : Color.Error)"
Color="@(Disabled ? Color.Dark : Color.Error)"
Style="font-size: 3rem;"/>
Gosse
</MudButton>
@ -57,9 +59,9 @@
</MudItem>
<MudItem xs="4">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
<MudButton OnClick="ThrowClick" Disabled="_disabled">
<MudButton OnClick="ThrowClick" Disabled="Disabled">
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ArrowCircleUp"
Color="@(_disabled ? Color.Dark : Color.Success)"
Color="@(Disabled ? Color.Dark : Color.Success)"
Style="font-size: 3rem;"/>
Wurf
</MudButton>
@ -68,9 +70,9 @@
<MudItem xs="4">
<MudPaper Class="d-flex align-center justify-center mud-width-full py-0">
<MudButton OnClick="SinkRightClick"
Disabled="@_disabled">
Disabled="@Disabled">
<MudIcon Class="ma-2" Icon="@Icons.Material.Filled.ArrowCircleRight"
Color="@(_disabled ? Color.Dark : Color.Error)"
Color="@(Disabled ? Color.Dark : Color.Error)"
Style="font-size: 3rem;"/>
Gosse
</MudButton>
@ -82,11 +84,12 @@
@code {
private bool _canUnlock => ThrowPanelState.Value.ThrowPanelStateStatus == ThrowPanelStateStatus.AfterThrow || ThrowPanelState.Value.ThrowPanelStateStatus == ThrowPanelStateStatus.GameStart;
private bool CanUnlock => ThrowPanelState.Value.ThrowPanelStateStatus == ThrowPanelStateStatus.AfterThrow || ThrowPanelState.Value.ThrowPanelStateStatus == ThrowPanelStateStatus.GameStart;
private bool _locked = true;
private bool _disabled => (UndoRedoState.Value.CanRedo && _locked) && !_correcting;
private bool Disabled => (UndoRedoState.Value.CanRedo && _locked) && !_correcting;
private bool _correcting = false;
private int _version = 0;
protected override void OnAfterRender(bool firstRender)
{
@ -95,6 +98,15 @@
Dispatcher.Dispatch(new LoadStateFromSessionAction());
}
_locked = true;
if (_version != UndoRedoState.Value.Version)
{
_version = UndoRedoState.Value.Version;
_correcting = false;
_locked = true;
}
base.OnAfterRender(firstRender);
}
@ -119,10 +131,27 @@
Dispatcher.Dispatch(new ThrowAction(LeftSink: leftSink, RightSink: rightSink));
}
private void UnlockClick(MouseEventArgs obj)
private async Task UnlockClick(MouseEventArgs obj)
{
_correcting = true;
_locked = false;
if (!CanUnlock)
return;
// if (!CanUnlock)
// {
// Dispatcher.Dispatch(new UndoAction());
// await Task.Run(() =>
// {
// Task.Delay(200);
// _correcting = true;
// _locked = false;
// Task.Delay(200);
// });
// }
// else
// {
_correcting = true;
_locked = false;
// }
}
}

View File

@ -29,12 +29,11 @@
@* @inject IGameStatusDataService _dataService; *@
@ThrowPanelState.Value.ThrowPanelStateStatus
<!-- Fixierter Bereich innerhalb des Containers -->
<div style="position: sticky; top: 64px; z-index: 100; background-color: var(--mud-palette-surface); padding: 16px 0; margin: 0 -24px; padding-left: 24px; padding-right: 24px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<MudToolBar>
<MudText>@UndoRedoState.Value.Version</MudText>
<MudTooltip Text="Undo" Color="Color.Primary" Placement="Placement.Bottom" Arrow="true">
<MudIconButton Icon="@Icons.Material.Filled.Undo" Variant="Variant.Filled" Color="Color.Primary"
Disabled="@(!UndoRedoState.Value.CanUndo)"
@ -55,7 +54,10 @@
Variant="Variant.Filled" Color="Color.Primary"
Class="mr-5" OnClick="StartStopClick"/>
</MudTooltip>
<MudText>Status @UndoRedoState.Value.Version (@ThrowPanelState.Value.ThrowPanelStateStatus)</MudText>
</MudToolBar>
</div>

View File

@ -182,9 +182,9 @@ namespace KoogleApp.Store.Game.ThrowPanel
{
var nextCounter = 1;
var reset = true;
if (state.ThrowCounter < state.ThrowsPerRound)
if (state.ThrowCounterPerRound < state.ThrowsPerRound)
{
nextCounter = state.ThrowCounter + 1;
nextCounter = state.ThrowCounterPerRound + 1;
reset = state.ThrowMode != ThrowMode.Decrease;
}
@ -254,9 +254,10 @@ namespace KoogleApp.Store.Game.ThrowPanel
Pin8Disabled = _pins[1].Disabled,
Pin9Value = _pins[0].Value,
Pin9Disabled = _pins[0].Disabled,
ThrowCounter = nextCounter,
ThrowCounterPerRound = nextCounter,
BellValue = false,
ThrowPanelStateStatus = ThrowPanelStateStatus.AfterThrow
ThrowPanelStateStatus = ThrowPanelStateStatus.AfterThrow,
ThrowCounter = state.ThrowCounter + 1
};
}

View File

@ -24,13 +24,13 @@ namespace KoogleApp.Store.Game.ThrowPanel
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,
int ThrowsPerRound, int ThrowCounter, ThrowMode ThrowMode, ThrowPanelStateStatus ThrowPanelStateStatus)
int ThrowsPerRound, int ThrowCounterPerRound, ThrowMode ThrowMode, ThrowPanelStateStatus ThrowPanelStateStatus, int ThrowCounter)
{
// 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,
ThrowsPerRound : 3, ThrowCounter : 1, ThrowMode : ThrowMode.Reposition, ThrowPanelStateStatus: ThrowPanelStateStatus.undefined
ThrowsPerRound : 3, ThrowCounterPerRound : 1, ThrowMode : ThrowMode.Reposition, ThrowPanelStateStatus: ThrowPanelStateStatus.undefined, ThrowCounter:0
)
{ }
}

View File

@ -10,8 +10,8 @@
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": true,
"Pin8Value": true,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
@ -19,17 +19,18 @@
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": true,
"Pin8Disabled": true,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounter": 3,
"ThrowCounterPerRound": 3,
"ThrowMode": 1,
"ThrowPanelStateStatus": 3
"ThrowPanelStateStatus": 3,
"ThrowCounter": 2
}
},
"Version": 5,
"LastModified": "2025-11-11T13:46:24.8835415+01:00",
"LastModified": "2025-11-11T14:25:20.7054454+01:00",
"LastModifiedBy": "test1@test.de"
},
"UndoHistory": [
@ -44,40 +45,7 @@
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": true,
"Pin8Value": true,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
"Pin3Disabled": false,
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": true,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounter": 2,
"ThrowMode": 1,
"ThrowPanelStateStatus": 2
}
},
"Version": 4,
"LastModified": "2025-11-11T13:46:24.8797561+01:00",
"LastModifiedBy": "test1@test.de"
},
{
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": false,
"Pin1Value": false,
"Pin2Value": false,
"Pin3Value": false,
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": true,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
@ -86,17 +54,18 @@
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": true,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounter": 2,
"ThrowCounterPerRound": 2,
"ThrowMode": 1,
"ThrowPanelStateStatus": 3
"ThrowPanelStateStatus": 2,
"ThrowCounter": 1
}
},
"Version": 3,
"LastModified": "2025-11-11T13:45:23.5062354+01:00",
"Version": 4,
"LastModified": "2025-11-11T14:25:20.6996276+01:00",
"LastModifiedBy": "test1@test.de"
},
{
@ -110,7 +79,41 @@
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": true,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
"Pin2Disabled": false,
"Pin3Disabled": false,
"Pin4Disabled": false,
"Pin5Disabled": false,
"Pin6Disabled": false,
"Pin7Disabled": false,
"Pin8Disabled": false,
"Pin9Disabled": true,
"ThrowsPerRound": 3,
"ThrowCounterPerRound": 2,
"ThrowMode": 1,
"ThrowPanelStateStatus": 3,
"ThrowCounter": 1
}
},
"Version": 3,
"LastModified": "2025-11-11T14:21:38.6653918+01:00",
"LastModifiedBy": "test1@test.de"
},
{
"Status": {
"ThrowPanelState": {
"IsStated": true,
"BellValue": false,
"Pin1Value": false,
"Pin2Value": false,
"Pin3Value": false,
"Pin4Value": false,
"Pin5Value": false,
"Pin6Value": false,
"Pin7Value": false,
"Pin8Value": false,
"Pin9Value": true,
"Pin1Disabled": false,
@ -123,13 +126,14 @@
"Pin8Disabled": false,
"Pin9Disabled": false,
"ThrowsPerRound": 3,
"ThrowCounter": 1,
"ThrowCounterPerRound": 1,
"ThrowMode": 1,
"ThrowPanelStateStatus": 2
"ThrowPanelStateStatus": 2,
"ThrowCounter": 0
}
},
"Version": 2,
"LastModified": "2025-11-11T13:45:23.4953972+01:00",
"LastModified": "2025-11-11T14:21:38.6623607+01:00",
"LastModifiedBy": "test1@test.de"
},
{
@ -156,13 +160,14 @@
"Pin8Disabled": false,
"Pin9Disabled": false,
"ThrowsPerRound": 3,
"ThrowCounter": 1,
"ThrowCounterPerRound": 1,
"ThrowMode": 1,
"ThrowPanelStateStatus": 1
"ThrowPanelStateStatus": 1,
"ThrowCounter": 0
}
},
"Version": 1,
"LastModified": "2025-11-11T12:00:15.1075206+01:00",
"LastModified": "2025-11-11T14:21:31.2803757+01:00",
"LastModifiedBy": "test1@test.de"
}
],