aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-28 05:14:47 +0200
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-03-28 05:14:47 +0200
commit30f1e58efb3910a41cee30ff89a1028fba97c3c1 (patch)
tree26e45ad8676969ee6b12280b2fd10af9ac3ba1bb
parent5c546234343f5d31d3030c2a4ee0188c76c6264a (diff)
wip
-rw-r--r--CrowWindow/CrowWindow.csproj5
-rw-r--r--CrowWindow/VkCrowWindow.cs14
-rw-r--r--src/VkChess.cs35
-rw-r--r--ui/Button.tmp11
-rw-r--r--ui/checkBox.tmp7
-rw-r--r--ui/chess.crow7
-rw-r--r--ui/chess.style20
-rw-r--r--ui/main.crow2
8 files changed, 61 insertions, 40 deletions
diff --git a/CrowWindow/CrowWindow.csproj b/CrowWindow/CrowWindow.csproj
index 6f52fca..1da19de 100644
--- a/CrowWindow/CrowWindow.csproj
+++ b/CrowWindow/CrowWindow.csproj
@@ -1,4 +1,4 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>CrowWindow</AssemblyName>
@@ -15,10 +15,9 @@
</PropertyGroup>
<ItemGroup>
- <PackageReference Include="Crow" Version="0.9.3-beta" />
+ <PackageReference Include="Crow" Version="0.9.4-beta" />
<PackageReference Include="vke" Version="0.2.0-beta" />
<PackageReference Include="SpirVTasks" Version="0.1.44" />
-
</ItemGroup>
<ItemGroup>
<GLSLShader Include="shaders\**\*.frag;shaders\**\*.vert;shaders\**\*.comp;shaders\**\*.geom" />
diff --git a/CrowWindow/VkCrowWindow.cs b/CrowWindow/VkCrowWindow.cs
index 6cfba67..f37fda2 100644
--- a/CrowWindow/VkCrowWindow.cs
+++ b/CrowWindow/VkCrowWindow.cs
@@ -63,8 +63,18 @@ namespace vke {
ui.IsBackground = true;
ui.Start ();
}
- protected virtual void CreateRenderPass () {
- renderPass = new RenderPass (dev, swapChain.ColorFormat, VkSampleCountFlags.SampleCount1);
+ protected virtual void CreateRenderPass () {
+ renderPass = new RenderPass (dev, VkSampleCountFlags.SampleCount1);
+ renderPass.AddAttachment (swapChain.ColorFormat, VkImageLayout.PresentSrcKHR, VkSampleCountFlags.SampleCount1, VkAttachmentLoadOp.Load);//final outpout
+ SubPass subpass0 = new SubPass ();
+ subpass0.AddColorReference (0, VkImageLayout.ColorAttachmentOptimal);
+ renderPass.AddSubpass (subpass0);
+ renderPass.AddDependency (Vk.SubpassExternal, 0,
+ VkPipelineStageFlags.BottomOfPipe, VkPipelineStageFlags.ColorAttachmentOutput,
+ VkAccessFlags.MemoryRead, VkAccessFlags.ColorAttachmentWrite);
+ renderPass.AddDependency (0, Vk.SubpassExternal,
+ VkPipelineStageFlags.ColorAttachmentOutput, VkPipelineStageFlags.BottomOfPipe,
+ VkAccessFlags.ColorAttachmentWrite, VkAccessFlags.MemoryRead);
}
diff --git a/src/VkChess.cs b/src/VkChess.cs
index c31e4dd..3264f60 100644
--- a/src/VkChess.cs
+++ b/src/VkChess.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -495,15 +495,12 @@ namespace vkChess
lock (movesMutex) {
bool hintIsEnabled = EnableHint;
EnableHint = false;
-
- GameState lastState = currentState;
- if ((currentState != GameState.Pad && currentState != GameState.Checkmate) || !playerIsAi (CurrentPlayer))//undo ai move
+
+ if (currentState != GameState.Pad && currentState != GameState.Checkmate && !playerIsAi (CurrentPlayer) && playerIsAi (Opponent))//undo ai move
undoLastMove ();
undoLastMove ();
- //to have checkColor removed
- currentState = lastState;
- CurrentState = GameState.Play;
+
startTurn ();
NotifyValueChanged ("board", board);
@@ -542,6 +539,9 @@ namespace vkChess
void onNewGameClick (object sender, MouseButtonEventArgs e) {
loadWindow ("ui/newGame.crow", this);
}
+ void onOptionsClick (object sender, MouseButtonEventArgs e) {
+ loadWindow ("ui/main.crow", this);
+ }
void onNewWhiteGame (object sender, MouseButtonEventArgs e) {
closeWindow ("ui/newGame.crow");
@@ -930,13 +930,11 @@ namespace vkChess
if (currentState == value)
return;
- if (currentState == GameState.Checked) {
+ if (currentState == GameState.Checked || currentState == GameState.Checkmate) {
Point kPos = CurrentPlayerPieces.First (p => p.Type == PieceType.King).BoardCell;
Piece.UpdateCase (kPos.X, kPos.Y, -kingCheckedColor);
- } else if (currentState == GameState.Checkmate) {
- Point kPos = OpponentPieces.First (p => p.Type == PieceType.King).BoardCell;
- Piece.UpdateCase (kPos.X, kPos.Y, -kingCheckedColor);
}
+
currentState = value;
if ((int)currentState > 2) {
@@ -953,8 +951,17 @@ namespace vkChess
NotifyValueChanged ("CurrentState", currentState);
}
}
+ ChessColor currentPlayer;
- public ChessColor CurrentPlayer;
+ public ChessColor CurrentPlayer {
+ get => currentPlayer;
+ set {
+ if (currentPlayer == value)
+ return;
+ currentPlayer = value;
+ NotifyValueChanged ("CurrentPlayer", currentPlayer);
+ }
+ }
public ChessColor Opponent {
get { return CurrentPlayer == ChessColor.White ? ChessColor.Black : ChessColor.White; }
@@ -1627,6 +1634,8 @@ namespace vkChess
Piece p = board [pCurPos.X, pCurPos.Y];
+ CurrentState = GameState.Play;
+
replaySilently ();
Piece pCaptured = board [pCurPos.X, pCurPos.Y];
@@ -1643,8 +1652,6 @@ namespace vkChess
}
}
-// syncStockfish ();
-
//animate undo capture
if (pCaptured == null)
return;
diff --git a/ui/Button.tmp b/ui/Button.tmp
index 89d1d10..4fcdde1 100644
--- a/ui/Button.tmp
+++ b/ui/Button.tmp
@@ -1,5 +1,10 @@
<?xml version="1.0"?>
-<Border Margin="0" Foreground="Jet" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Jet}"
- MouseDown="{Background=0.1,0.3,0.9,0.3}" MouseUp="{Background=Transparent}">
- <Label Margin="4" Font="{./Font}" Foreground="{./Foreground}" Text="{./Caption}" />
+<Border Background="{./Background}" Name="Content" Width="Stretched" Height="Stretched"
+ Foreground="Transparent" CornerRadius="{../CornerRadius}" BorderWidth="1"
+ MouseEnter="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black};{caption.Foreground=White}"
+ MouseLeave="{Foreground=Transparent};{caption.Foreground=LightGrey}"
+ MouseDown="{Foreground=vgradient|0:Black|0.05:Grey|0.85:Grey|1:White}"
+ MouseUp="{Foreground=vgradient|0:White|0.2:Grey|0.9:Grey|1:Black}"
+ >
+ <Label Font="{./Font}" Name="caption" Margin="3" Foreground="LightGrey" Text="{./Caption}"/>
</Border>
diff --git a/ui/checkBox.tmp b/ui/checkBox.tmp
index 98e0fb0..fe284dd 100644
--- a/ui/checkBox.tmp
+++ b/ui/checkBox.tmp
@@ -1,7 +1,8 @@
<?xml version="1.0"?>
-<Border Margin="0" Foreground="Transparent" Background="{./Background}" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}">
- <Group Margin="1">
+<Border Margin="0" Foreground="Transparent" Background="{./Background}" MouseEnter="{Foreground=White}" MouseLeave="{Foreground=Transparent}"
+ Height="Stretched" Width="Stretched">
+ <Group Margin="1">
<Label Margin="3" Font="{./Font}" Foreground="{./Foreground}" Text="{./Caption}"/>
- <Widget Height="Stretched" Background="0.1,0.3,0.9,0.3" Visible="{./IsChecked}"/>
+ <Widget Background="0.1,0.3,0.9,0.3" Visible="{./IsChecked}"/>
</Group>
</Border>
diff --git a/ui/chess.crow b/ui/chess.crow
index 16099a7..6050a36 100644
--- a/ui/chess.crow
+++ b/ui/chess.crow
@@ -3,7 +3,8 @@
<CheckBox Caption="Hint" IsChecked="{²EnableHint}"/>
<Button Caption="Undo" MouseClick="onUndoClick"/>
<Button Caption="New Game" MouseClick="onNewGameClick"/>
- <Widget Width="Stretched"/>
+ <Button Caption="Options" MouseClick="onOptionsClick"/>
+ <Widget Width="Stretched" Height="1"/>
<Button Caption="Quit" MouseClick="onQuitClick"/>
<VerticalStack Style="hsStatus" >
<Label Style="labStatus" Text="State:"/>
@@ -13,6 +14,10 @@
<Label Style="labStatus" Text="Hover:"/>
<Label Style="labStatus2" Text="{SelCell}"/>
</VerticalStack>
+ <VerticalStack Style="hsStatus" >
+ <Label Style="labStatus" Text="Current Player:"/>
+ <Label Style="labStatus2" Text="{CurrentPlayer}"/>
+ </VerticalStack>
<Image Width="30" Height="20" Path="#Crow.Icons.IconAlerte.svg" Visible="{StockfishNotFound}"/>
<Label Text="Stockfish not found" Font="droid bold, 10" Visible="{StockfishNotFound}"/>
</HorizontalStack>
diff --git a/ui/chess.style b/ui/chess.style
index fd5d67d..b79aa91 100644
--- a/ui/chess.style
+++ b/ui/chess.style
@@ -27,26 +27,20 @@ labStatus2 {
CheckBox {
Template = "ui/checkBox.tmp";
+ MinimumSize = "80, 30";
+ Width="Fit";
Height= "Fit";
- Width = "80";
}
RadioButton {
Template = "ui/checkBox.tmp";
+ MinimumSize = "80, 30";
+ Width="Fit";
Height= "Fit";
}
-Button {
+Button {
Template = "ui/Button.tmp";
- Height = "Fit";
- Width = "80";
-}
-Menu {
- Margin="0";
- Spacing="0";
- Background = "Transparent";
-}
-MenuItem {
- Background = "Transparent";
- Margin = "0";
+ MinimumSize = "80, 30";
+ Width="Fit";
}
Slider {
Foreground = "Jet";
diff --git a/ui/main.crow b/ui/main.crow
index 10dde48..949ae8a 100644
--- a/ui/main.crow
+++ b/ui/main.crow
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<Window Caption="Options" Left="10" Top="1" Width="70%" Height="50%" CornerRadius="5" >
+<Window Caption="Options" Left="10" Top="1" Width="70%" Height="Fit" CornerRadius="5" >
<VerticalStack Spacing="1" Margin="10" >
<HorizontalStack Height="Fit" Margin="5">
<Label Text="Stockfish executable path:"/>