centered position of player controls
authorBernhard Lindner <bernhard@Bernhards-MacBook-Pro.local>
Tue, 18 Dec 2018 18:07:25 +0000 (19:07 +0100)
committerBernhard Lindner <bernhard@Bernhards-MacBook-Pro.local>
Tue, 18 Dec 2018 18:07:25 +0000 (19:07 +0100)
src/full_system/ConnectionTest/ConnectionTest/ConnectionTest/InGamePage.cs

index deebb0f..24c068f 100644 (file)
@@ -24,6 +24,7 @@ namespace Bomberman
         Label labelLives;
 
         Playground playground;
+        Grid ButtonGrid;
 
         public InGamePage(TcpJsonConnection connection)
         {
@@ -35,6 +36,18 @@ namespace Bomberman
             //con.Connect(IPAddress.Parse("192.168.0.5"));
             //con.Connect(Dns.GetHostEntry(Dns.GetHostName()).AddressList[1]);    //localhost
 
+            ButtonGrid = new Grid();
+
+            ButtonGrid.ColumnDefinitions = new ColumnDefinitionCollection()
+            {
+                new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
+                new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
+                new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
+                new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
+                new ColumnDefinition(){Width = new GridLength(1, GridUnitType.Star)},
+
+            };
+
             labelLives = new Label
             {
                 Text = "Lives: 3",
@@ -43,8 +56,7 @@ namespace Bomberman
                 HorizontalOptions = LayoutOptions.CenterAndExpand
             };
 
-            ButtonLayout.Children.Add(labelLives);
-
+            ButtonGrid.Children.Add(labelLives, 0, 0);
 
             for (int i = 0; i < 3; i++)
             {
@@ -69,6 +81,7 @@ namespace Bomberman
                         up.Text = "^";
                         horizontalLayout.Children.Add(up);
                         horizontalLayout.Children.Add(dummy);
+                        ButtonGrid.Children.Add(up, 2, 0);
                         break;
 
                     case 1:
@@ -77,18 +90,21 @@ namespace Bomberman
                         left.Pressed += Left_Pressed;
                         left.Released += Left_Released;
                         horizontalLayout.Children.Add(left);
+                        ButtonGrid.Children.Add(left, 1, 1);
 
                         Button bomb = new Button();
                         bomb.Pressed += Bomb_Pressed;
                         bomb.Released += Bomb_Released;
                         bomb.Text = "*";
                         horizontalLayout.Children.Add(bomb);
+                        ButtonGrid.Children.Add(bomb, 2, 1);
 
                         Button right = new Button();
                         right.Pressed += Right_Pressed;
                         right.Released += Right_Released;
                         right.Text = ">";
                         horizontalLayout.Children.Add(right);
+                        ButtonGrid.Children.Add(right, 3, 1);
                         break;
 
                     case 2:
@@ -99,6 +115,7 @@ namespace Bomberman
                         down.Text = "V";
                         horizontalLayout.Children.Add(down);
                         horizontalLayout.Children.Add(dummy);
+                        ButtonGrid.Children.Add(down, 2, 2);
                         break;
 
 
@@ -147,9 +164,12 @@ namespace Bomberman
             BombermanPlayground.Playground.c_ImageNamespace = "ConnectionTest";
             BombermanPlayground.BombermanBlock.BlockSize = Width / (size + 1);
 
+            ButtonGrid.TranslationY = Width;
             fullLayout.Children.Add(playground);
-            fullLayout.Children.Add(ButtonLayout);
-            ButtonLayout.TranslationY = Width;
+            //fullLayout.Children.Add(ButtonLayout);
+            //ButtonLayout.TranslationY = Width;
+            //fullLayout.Children.Add(labelLives);
+            fullLayout.Children.Add(ButtonGrid);
             Content = fullLayout;
 
         }