aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-08 21:02:39 +0000
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2021-09-08 21:02:39 +0000
commit12f598499addc88a2994215b0521bbe074f7ae87 (patch)
treea8eebddf5f4e21c2a93488f1e1729bd35a951944
parent85445c6b6b659094c4b6ff8b99cc666bb6eeca0b (diff)
debug & wip
-rw-r--r--src/Piece.cs13
-rw-r--r--src/VkChess.cs47
-rw-r--r--ui/Window.template9
-rw-r--r--ui/checkBox.tmp5
-rw-r--r--ui/chess.crow7
-rw-r--r--ui/chess.style24
-rw-r--r--ui/menuCommand.itmp2
-rw-r--r--ui/menuItem.template4
-rw-r--r--ui/winLog.crow18
-rw-r--r--ui/winOptions.crow4
10 files changed, 88 insertions, 45 deletions
diff --git a/src/Piece.cs b/src/Piece.cs
index f509132..fd95c31 100644
--- a/src/Piece.cs
+++ b/src/Piece.cs
@@ -169,15 +169,12 @@ namespace vkChess {
public void Reset(bool animate = true) {
xAngle = 0f;
- Z = 0f;
if (HasMoved) {
if (animate)
Animation.StartAnimation(new PathAnimation(this, "Position",
new BezierPath(
Position,
new Vector3(initX, initY, 0f), Vector3.UnitZ)));
- //else
- // Position = new Vector3(initX, initY, 0f);
}
if (IsPromoted)
Unpromote();
@@ -189,11 +186,11 @@ namespace vkChess {
BoardCell = newPos;
if (animate) {
if (Captured)
- Animation.StartAnimation (new PathAnimation (this, "Position",
- new BezierPath (
- Position,
- capturePos, Vector3.UnitZ), VkChess.animationSteps),
- 0);
+ Animation.StartAnimation (new PathAnimation (this, "Position",
+ new BezierPath (
+ Position,
+ capturePos, Vector3.UnitZ), VkChess.animationSteps),
+ 0);
else if (BoardCell.X != Position.X || BoardCell.Y != Position.Y)
Animation.StartAnimation (new PathAnimation (this, "Position",
new BezierPath (
diff --git a/src/VkChess.cs b/src/VkChess.cs
index 8a84461..54751d1 100644
--- a/src/VkChess.cs
+++ b/src/VkChess.cs
@@ -14,7 +14,7 @@ using System.Reflection;
namespace vkChess
{
public enum GameState { Init, SceneInitialized, StockFishStarted, Play, Pad, Checked, Checkmate };
- public enum PlayerType { Human, AI };
+ //public enum PlayerType { Human, AI };
public enum ChessColor { White, Black };
public enum PieceType { Pawn, Rook, Knight, Bishop, King, Queen };
@@ -531,10 +531,6 @@ namespace vkChess
else
saveCurrentGame ();
break;
- case Glfw.Key.S:
- syncStockfish ();
- sendToStockfish ("go");
- break;
case Glfw.Key.Keypad0:
whites [0].X = 0;
whites [0].Y = 0;
@@ -657,8 +653,10 @@ namespace vkChess
if (CurrentState < GameState.Play)
return;
if (!playerIsAi(CurrentPlayer) && enableHint) {
- searchStopRequested = true;
- sendToStockfish ("stop");
+ lock (movesMutex) {
+ searchStopRequested = true;
+ sendToStockfish ("stop");
+ }
while (searchStopRequested)
System.Threading.Thread.Sleep (10);
}
@@ -667,39 +665,44 @@ namespace vkChess
get => CameraRotation.Y;
set => CameraRotation = new Vector3(CameraRotation.X, value, CameraRotation.Z);
}
- void rotateBoard (float targetYAngle) {
-
- }
void onNewWhiteGame (object sender, MouseButtonEventArgs e) {
closeWindow ("ui/newGame.crow");
+ if (CurrentState < GameState.Play)
+ return;
Log(LogType.Custom1, "New White Game");
terminateCurrentGame();
- CurrentState = GameState.Play;
+ CurrentState = GameState.StockFishStarted;
WhitesAreAI = false;
BlacksAreAI = true;
+ CurrentState = GameState.Play;
+
resetBoard ();
syncStockfish ();
if (enableHint)
sendToStockfish ("go infinite");
- Animation.StartAnimation (new AngleAnimation (this, "CameraAngleY", 0, 0.05f));
+ Animation.StartAnimation (new AngleAnimation (this, "CameraAngleY", 0, 0.15f));
}
void onNewBlackGame (object sender, MouseButtonEventArgs e) {
closeWindow ("ui/newGame.crow");
+ if (CurrentState < GameState.Play)
+ return;
Log(LogType.Custom1, "New Black Game");
terminateCurrentGame();
- CurrentState = GameState.Play;
+ CurrentState = GameState.StockFishStarted;
WhitesAreAI = true;
BlacksAreAI = false;
+ CurrentState = GameState.Play;
+
resetBoard ();
syncStockfish ();
@@ -708,7 +711,7 @@ namespace vkChess
else
sendToStockfish ("go depth 1");
- Animation.StartAnimation (new AngleAnimation (this, "CameraAngleY", MathHelper.Pi, 0.05f));
+ Animation.StartAnimation (new AngleAnimation (this, "CameraAngleY", MathHelper.Pi, 0.15f));
}
void onPromoteToQueenClick (object sender, MouseButtonEventArgs e) {
closeWindow ("ui/promote.crow");
@@ -874,7 +877,7 @@ namespace vkChess
}
}*/
public Vector3 CameraRotation {
- get => ExtensionMethods.ParseVec3 (Configuration.Global.Get<string> ("CameraRotation", "<0.6f,0,0>"));
+ get => ExtensionMethods.ParseVec3 (Configuration.Global.Get<string> ("CameraRotation", "<0.6,0,0>"));
set {
if (value == CameraRotation)
return;
@@ -1017,8 +1020,15 @@ namespace vkChess
if (value == WhitesAreAI)
return;
+ if (CurrentState >= GameState.Play)
+ terminateCurrentGame ();
+
Configuration.Global.Set ("WhitesAreAI", value);
NotifyValueChanged ("WhitesAreAI", value);
+
+ if (CurrentState >= GameState.Play)
+ startTurn ();
+
}
}
public bool BlacksAreAI {
@@ -1026,9 +1036,16 @@ namespace vkChess
set {
if (value == BlacksAreAI)
return;
+
+ if (CurrentState >= GameState.Play)
+ terminateCurrentGame ();
Configuration.Global.Set ("BlacksAreAI", value);
NotifyValueChanged ("BlacksAreAI", value);
+
+ if (CurrentState >= GameState.Play)
+ startTurn ();
+
}
}
string stockfishPositionCommand
diff --git a/ui/Window.template b/ui/Window.template
index cdd8a5e..0b9c4ea 100644
--- a/ui/Window.template
+++ b/ui/Window.template
@@ -1,17 +1,14 @@
<?xml version="1.0"?>
-<Border Name="SizeHandle" Style="winBorder" CornerRadius="{./CornerRadius}" Background="{./Background}" >
+<Border Name="SizeHandle" Style="winBorder" CornerRadius="{./CornerRadius}" Background="{./Background}" >
<VerticalStack Spacing="0">
- <Group Margin="6" Height="Fit">
- <Label Font="serif, 20" Name="MoveHandle" Width="Fit" Foreground="${WindowTitleBarForeground" Margin="2" HorizontalAlignment="Center" Text="{./Caption}" />
+ <Group Margin="2" Height="Fit">
+ <Label Font="serif, 18" Name="MoveHandle" Width="90%" Foreground="${WindowTitleBarForeground" Margin="1" TextAlignment="Center" Text="{./Caption}" />
<ListBox Data="{./Commands}" Fit="true" HorizontalAlignment="Right" VerticalAlignment="Top">
<Template>
<HorizontalStack Name="ItemsContainer" />
</Template>
<ItemTemplate Path="#Crow.WindowButton.template"/>
</ListBox>
-
- <!--<Button MinimumSize="1,1" Fit="true" Command="{./CMDClose}" Template="#Crow.WindowButton.template" VerticalAlignment="Top"
- HorizontalAlignment="Right"/>-->
</Group>
<Container Name="Content" MinimumSize="0,0" />
</VerticalStack>
diff --git a/ui/checkBox.tmp b/ui/checkBox.tmp
index fe284dd..94277e5 100644
--- a/ui/checkBox.tmp
+++ b/ui/checkBox.tmp
@@ -1,8 +1,5 @@
<?xml version="1.0"?>
<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 Background="0.1,0.3,0.9,0.3" Visible="{./IsChecked}"/>
- </Group>
+ <Label Margin="3" Font="{./Font}" Foreground="{./Foreground}" Text="{./Caption}"/>
</Border>
diff --git a/ui/chess.crow b/ui/chess.crow
index 183107e..1a0f3da 100644
--- a/ui/chess.crow
+++ b/ui/chess.crow
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<HorizontalStack Height="Fit" Background="vgradient|0:Grey|0.3:Jet|0.7:Jet|1:Black" VerticalAlignment="Bottom" Margin="5">
+<HorizontalStack Height="Fit" Background="${MenusBackground}" VerticalAlignment="Bottom" Margin="4">
<Menu Data="{Commands}" Height="Stretched" Width="Fit">
<Template>
<HorizontalStack Name="ItemsContainer" />
@@ -12,7 +12,10 @@
</MenuItem>
</ItemTemplate>
</Menu>
- <CheckBox Caption="Hint" IsChecked="{²EnableHint}" />
+ <CheckBox Caption="Hint" IsChecked="{²EnableHint}" Height="Stretched"
+ Background="Transparent" Foreground="White"
+ Checked="{Background=${ControlHighlight}}"
+ Unchecked = "{Background=Transparent}"/>
<Widget Width="Stretched"/>
<VerticalStack Style="hsStatus">
<Label Style="labStatus" Text="State:" />
diff --git a/ui/chess.style b/ui/chess.style
index 8e3d580..2079d61 100644
--- a/ui/chess.style
+++ b/ui/chess.style
@@ -1,7 +1,13 @@
-ControlHighlight = "DodgerBlue";
+//ControlHighlight = "0.2,0.3,0.8,0.9";
+ControlHighlight = "MidnightBlue";
LogFont = "consolas, 10";
WindowBackground = "0.01,0.01,0.02,0.8";
ContainerBackground = "0.01,0.01,0.01,0.9";
+StateCtrlInactiveBackground = "0.02,0.02,0.02,0.9";
+StateCtrlInactiveForeground = "White";
+StateCtrlHighlightForeground = "Black";
+StatusElementBackground = "#040404";
+MenusBackground = "0.1,0.1,0.1,0.7";
icon {
Width="14";
@@ -11,13 +17,13 @@ icon {
hsStatus {
Height="Fit";
Width="100";
- Background="#2E8BB6";
+ Background="${StatusElementBackground}";
Margin="3";
}
labStatus {
Width="Fit";
- Foreground="LightGrey";
- Font="serif bold, 10";
+ Foreground="Grey";
+ Font="serif, 10";
Margin="0";
}
labStatus2 {
@@ -34,12 +40,18 @@ CheckBox {
MinimumSize = "80, 30";
Width="Fit";
Height= "Fit";
+ Background="${StateCtrlInactiveBackground}";
+ Checked="{Background=${ControlHighlight}}";
+ Unchecked = "{Background=${StateCtrlInactiveBackground}}";
}
RadioButton {
Template = "ui/checkBox.tmp";
MinimumSize = "80, 30";
Width="Fit";
Height= "Fit";
+ Background="${StateCtrlInactiveBackground}";
+ Checked="{Background=${ControlHighlight}}";
+ Unchecked = "{Background=${StateCtrlInactiveBackground}}";
}
Button {
Template = "ui/Button.tmp";
@@ -107,4 +119,8 @@ LightingSlider {
Vector3Widget {
Template = "ui/Vector3Widget.template";
Width="Fit";
+}
+winBorder {
+ StickyMouseEnabled="true";
+ StickyMouse="10";
} \ No newline at end of file
diff --git a/ui/menuCommand.itmp b/ui/menuCommand.itmp
index 324e4fa..8e572e3 100644
--- a/ui/menuCommand.itmp
+++ b/ui/menuCommand.itmp
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<Button Command="{}" Width="Stretched">
+<Button Command="{}" Width="Stretched" Height="Stretched">
<Template>
<Container Width="Stretched" Height="Stretched" Margin="6"
MouseEnter="{Background=${ControlHighlight}}"
diff --git a/ui/menuItem.template b/ui/menuItem.template
index 4a72422..bca07bf 100644
--- a/ui/menuItem.template
+++ b/ui/menuItem.template
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<Popper PopDirection="Top" Caption="{Caption}" Width="Stretched" IsPopped="{²./IsOpened}"
+<Popper PopDirection="Top" Caption="{Caption}" Width="Stretched" Height="Stretched" IsPopped="{²./IsOpened}"
MouseEnter="{Background=${ControlHighlight}}"
MouseLeave="{Background=Transparent}">
<Template>
@@ -7,7 +7,7 @@
<Label Text="{./Caption}" HorizontalAlignment="Left" />
</Container>
</Template>
- <VerticalStack Margin="0" Name="ItemsContainer" Fit="true" Background="Jet"/>
+ <VerticalStack Margin="5" Name="ItemsContainer" Fit="true" Background="${MenusBackground}" />
</Popper>
diff --git a/ui/winLog.crow b/ui/winLog.crow
index 8d3cf66..666d7e9 100644
--- a/ui/winLog.crow
+++ b/ui/winLog.crow
@@ -1,8 +1,24 @@
<?xml version="1.0"?>
<Window Caption="Log" Width="Stretched" Height="40%" VerticalAlignment="Top" >
+ <Template>
+ <Border Name="SizeHandle" Style="winBorder" CornerRadius="{./CornerRadius}" Background="{./Background}" >
+ <Group>
+ <Group Margin="2" Height="Fit" VerticalAlignment="Top">
+ <Label Font="serif, 18" Name="MoveHandle" Width="90%" Foreground="${WindowTitleBarForeground" Margin="1" TextAlignment="Center" Text="{./Caption}" />
+ <ListBox Data="{./Commands}" Fit="true" HorizontalAlignment="Right" VerticalAlignment="Top">
+ <Template>
+ <HorizontalStack Name="ItemsContainer" />
+ </Template>
+ <ItemTemplate Path="#Crow.WindowButton.template"/>
+ </ListBox>
+ </Group>
+ <Container Name="Content" MinimumSize="0,0" Height="95%" VerticalAlignment="Bottom" />
+ </Group>
+ </Border>
+ </Template>
<VerticalStack RootDataLevel="true" >
<HorizontalStack Height="Fit">
- <CheckBox Caption="Scroll on Output" IsChecked="{²../../log.ScrollOnOutput}"/>
+ <CheckBox MinimumSize = "80,20" Caption="Scroll on Output" IsChecked="{²../../log.ScrollOnOutput}"/>
</HorizontalStack>
<HorizontalStack Spacing="0">
<LogViewerWidget Name="log" Lines="{MainLog}" Font="${LogFont}" MaxScrollX="1000" ContextCommands="{LogContextMenu}"/>
diff --git a/ui/winOptions.crow b/ui/winOptions.crow
index 908497c..5929511 100644
--- a/ui/winOptions.crow
+++ b/ui/winOptions.crow
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
-<Window Caption="Options" Width="50%" Height="Fit" >
- <VerticalStack Spacing="1" Margin="10" >
+<Window Caption="Options" Top="10" Width="30%" Height="Fit" >
+ <VerticalStack Spacing="10" Margin="10" >
<VerticalStack Height="Fit" Background="${ContainerBackground}" Margin="5">
<HorizontalStack >
<Label Text="Stockfish executable path:"/>