Ejemplo n.º 1
0
 public Instruction.Result Unpack()
 {
     // if (!Unpacker) return Instruction.Result.ERROR;
     Instruction.Result result = Instruction.Result.ERROR;
     if (container is GridContainer)
     {
         GridContainer target = null;
         GridContainer from   = (GridContainer)container;
         result = from.QueryAdjacentContainer(antOri, ref target);
         if (result == Instruction.Result.SUCCEED)
         {
             if (!target.Compatible(this))
             {
                 return(Instruction.Result.INCOMPATIBLE);
             }
             result = from.TryUnpack(this);
             if (result == Instruction.Result.SUCCEED)
             {
                 from.Release(this);
                 target.Contain(this);
                 target.HoleCheck();
                 from.TargetCheck();
             }
         }
     }
     return(result);
 }
Ejemplo n.º 2
0
        public CrayonWindow(CrayonBoundUserInterface owner)
        {
            Title = Loc.GetString("Crayon");
            Owner = owner;

            var vbox = new VBoxContainer();

            Contents.AddChild(vbox);

            _search = new LineEdit();
            _search.OnTextChanged += (e) => RefreshList();
            vbox.AddChild(_search);

            _grid = new GridContainer()
            {
                Columns = 6,
            };
            var gridScroll = new ScrollContainer()
            {
                SizeFlagsVertical = SizeFlags.FillExpand,
                Children          =
                {
                    _grid
                }
            };

            vbox.AddChild(gridScroll);
        }
Ejemplo n.º 3
0
 public Instruction.Result Move(Orientation oriVal)
 {
     if (type == Type.Ant && antOri != oriVal)
     {
         return(Instruction.Result.INVALID_ANT_MOVE);
     }
     Instruction.Result result = Instruction.Result.ERROR;
     if (container is GridContainer)
     {
         GridContainer target = null;
         GridContainer from   = (GridContainer)container;
         result = from.QueryAdjacentContainer(oriVal, ref target);
         if (result == Instruction.Result.SUCCEED)
         {
             if (!target.Compatible(this))
             {
                 return(Instruction.Result.INCOMPATIBLE);
             }
             from.Release(this);
             target.Contain(this);
             target.HoleCheck();
         }
     }
     return(result);
 }
Ejemplo n.º 4
0
 private void Awake()
 {
     instance = this;
     player   = FindObjectOfType <PlayerController>().transform;
     gridRef  = GetComponent <GridContainer>();
     InstantiateDataPoints();
 }
Ejemplo n.º 5
0
    public void EndDrag(GameObject card)
    {
        //Current lowest distance between grid and currently held card
        float lowest_distance = MinimumDragDistance;

        GridContainer container_final = null;

        int new_index = -1;

        //Check all active containers to detect where item should be placed
        foreach (GridContainer container in CurrentlyActiveContainers)
        {
            for (int i = 0; i < container.CardMax; ++i)
            {
                //print("iterating " + i);
                GameObject grid_space  = container.GridDisplay.transform.GetChild(i).gameObject;
                float      curr_lowest = Vector2.Distance(grid_space.transform.position, card.transform.position);
                if (curr_lowest < lowest_distance)
                {
                    lowest_distance = curr_lowest;
                    container_final = container;
                    new_index       = i;
                }
            }
        }

        if (new_index != -1) //Switch
        {
            LastContainer.SwitchCards(LastIndex, card, container_final, new_index);
        }
        else // Do not switch
        {
            LastContainer.AddCard(card, LastIndex);
        }
    }
Ejemplo n.º 6
0
    /// <summary>
    /// Attempt to switch this container's card to the other container's index
    /// </summary>
    public void SwitchCards(int this_index, GameObject card, GridContainer container, int other_index)
    {
        //Debug.Log("from container " + this.name + " switch " + card.name + " in index " + this_index + " to container " + container.name + " at index " + other_index);
        if (!ValidIndex(this_index))
        {
            return;
        }
        else if (!container.ValidIndex(other_index))
        {
            return;
        }

        GameObject other_card = container.GetCardFromIndex(other_index);

        if (other_card != null) //card exists in other container
        {
            other_card.transform.SetParent(null);
            AddCard(other_card, this_index);
            container.AddCard(card, other_index);
        }
        else
        {
            container.AddCard(card, other_index);
        }
    }
        public void TestGridContainerAutoSizeUpdatesWhenChildBecomesDeadWithoutRemoval()
        {
            Box           box    = null;
            GridContainer parent = null;

            AddStep("create test", () =>
            {
                Child = parent = new GridContainer
                {
                    AutoSizeAxes     = Axes.Both,
                    RowDimensions    = new[] { new Dimension(GridSizeMode.AutoSize) },
                    ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            box = new TestBox1 {
                                Size = new Vector2(200)
                            }
                        },
                    }
                };
            });

            AddStep("make child dead", () => box.Expire());

            AddAssert("parent has size 0", () => Precision.AlmostEquals(Vector2.Zero, parent.DrawSize));
        }
Ejemplo n.º 8
0
 public NewsOverlay()
     : base(OverlayColourScheme.Purple, false)
 {
     Child = new GridContainer
     {
         RelativeSizeAxes = Axes.X,
         AutoSizeAxes     = Axes.Y,
         RowDimensions    = new[]
         {
             new Dimension(GridSizeMode.AutoSize)
         },
         ColumnDimensions = new[]
         {
             new Dimension(GridSizeMode.AutoSize),
             new Dimension()
         },
         Content = new[]
         {
             new Drawable[]
             {
                 sidebarContainer = new Container
                 {
                     AutoSizeAxes = Axes.X,
                     Child        = sidebar = new NewsSidebar()
                 },
                 content = new Container
                 {
                     RelativeSizeAxes = Axes.X,
                     AutoSizeAxes     = Axes.Y
                 }
             }
         }
     };
 }
Ejemplo n.º 9
0
 public void Setup() => Schedule(() =>
 {
     Child = gridParent = new Container
     {
         Anchor           = Anchor.Centre,
         Origin           = Anchor.Centre,
         RelativeSizeAxes = Axes.Both,
         Size             = new Vector2(0.5f),
         Children         = new Drawable[]
         {
             grid = new GridContainer {
                 RelativeSizeAxes = Axes.Both
             },
             new Container
             {
                 RelativeSizeAxes = Axes.Both,
                 Masking          = true,
                 BorderColour     = Color4.White,
                 BorderThickness  = 2,
                 Child            = new Box
                 {
                     RelativeSizeAxes = Axes.Both,
                     Alpha            = 0,
                     AlwaysPresent    = true
                 }
             }
         }
     };
 });
            /// <summary>
            ///     Creates a grid container filled with slot buttons loaded from an inventory template
            /// </summary>
            public void CreateInventory(Inventory inventory)
            {
                elements_x = inventory.Columns;

                GridContainer         = (GridContainer)GetChild("CenterContainer").GetChild("GridContainer");
                GridContainer.Columns = elements_x;
                IndexedSlots          = new List <Slots>(inventory.SlotMasks);

                foreach (Slots slot in IndexedSlots)
                {
                    InventoryButton newbutton = new InventoryButton(slot);

                    if (slot == Slots.NONE)
                    {
                        //TODO: Re-enable when godot grid container maintains grid with invisible elements
                        //newbutton.Visible = false;
                    }
                    else
                    {
                        //Store slot button and give it the default onpress behavior for empty elements
                        newbutton.GetChild <Button>("Button").OnPressed += AddToInventory;
                        InventorySlots.Add(slot, newbutton);
                    }

                    if (SlotNames.ContainsKey(slot))
                    {
                        var button = newbutton.GetChild <Button>("Button");
                        button.Text = button.ToolTip = SlotNames[slot];
                    }

                    GridContainer.AddChild(newbutton);
                }
            }
Ejemplo n.º 11
0
        public MultiplayerMatchFooter()
        {
            RelativeSizeAxes = Axes.Both;

            InternalChild = new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                Content          = new[]
                {
                    new Drawable[]
                    {
                        null,
                        new MultiplayerSpectateButton
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                        null,
                        new MatchStartControl
                        {
                            RelativeSizeAxes = Axes.Both,
                        },
                        null
                    }
                },
                ColumnDimensions = new[]
                {
                    new Dimension(),
                    new Dimension(maxSize: spectate_button_width),
                    new Dimension(GridSizeMode.Absolute, 5),
                    new Dimension(maxSize: ready_button_width),
                    new Dimension()
                }
            };
        }
Ejemplo n.º 12
0
    public override void _Ready()
    {
        sprites = new GridSprite[Instance.maxX][];
        grid    = GetNode <GridContainer>("NumberGrid");
        Grid   g    = new Grid(5, 5);
        Random rand = new Random(2);
        var    path = g.RandomPath(rand);

        g.FillPath(30, 90, path, rand);
        grid.Columns = Instance.maxX;
        for (int x = 0; x < Instance.maxX; x++)
        {
            sprites[x] = new GridSprite[Instance.maxY];
            for (int y = 0; y < Instance.maxY; y++)
            {
                sprites[x][y] = new GridSprite
                {
                    type   = g.At(x, y).op,
                    number = g.At(x, y).value
                };
                grid.AddChild(sprites[x][y]);
            }
        }

        foreach (var xy in path)
        {
            sprites[xy.x][xy.y].Modulate = Color.ColorN("red");
        }
    }
Ejemplo n.º 13
0
        public IDialog ShowDialog(string title, string url, ResultHandler callback, Size size, Panel container, IPageBrowser pageBrowser)
        {
            this.Title = title;

            if (!double.IsNaN(size.Height) && !double.IsInfinity(size.Height))
            {
                this.Height = size.Height;
            }

            if (!double.IsNaN(size.Width) && !double.IsInfinity(size.Width))
            {
                this.Width = size.Width;
            }

            var gridContainer = new GridContainer();

            gridContainer.LoadModule += container_LoadModule;
            gridContainer.Load(url);

            this.Content = gridContainer;

            if (callback != null)
            {
                this.m_handler = callback;
            }

            return(this);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Constructs a grid test case with the given dimensions.
        /// </summary>
        protected GridTestScene(int rows, int cols)
        {
            Rows = rows;
            Cols = cols;

            GridContainer testContainer;

            Add(testContainer = new GridContainer {
                RelativeSizeAxes = Axes.Both
            });

            cells = new Drawable[rows, cols];
            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    cells[r, c] = new Container {
                        RelativeSizeAxes = Axes.Both
                    }
                }
            }
            ;

            testContainer.Content = cells.ToJagged();
        }
Ejemplo n.º 15
0
    public override void _Ready()
    {
        Alpha = GD.Load("res://UI/Textures/Alpha.png") as Texture;
        InventoryIconScene = GD.Load <PackedScene>("res://UI/InventoryIcon.tscn");

        PlayerVBox = GetNode <VBoxContainer>("HBoxContainer/PlayerCenter/PlayerVBox");
        OtherGrid  = GetNode <GridContainer>("HBoxContainer/OtherVBox/OtherCenter/OtherGrid");

        Game.PossessedPlayer.MatchSome(
            (Plr) => {
            PlayerIcons = new InventoryIcon[Plr.Inventory.Contents.Length];
            for (int Index = 0; Index < Plr.Inventory.Contents.Length; Index++)
            {
                InventoryIcon Icon = InstantiateIcon(Index, Plr);
                PlayerVBox.AddChild(Icon);
                PlayerIcons[Index] = Icon;
            }
        }
            );

        if (Other != null)
        {
            OtherIcons = new InventoryIcon[Other.Inventory.Contents.Length];
            for (int Index = 0; Index < Other.Inventory.Contents.Length; Index++)
            {
                InventoryIcon Icon = InstantiateIcon(Index, Other);
                OtherGrid.AddChild(Icon);
                OtherIcons[Index] = Icon;
            }
        }
    }
        public void TestGridContainerAutoSizeUpdatesWhenChildBecomesAlive()
        {
            Box           box    = null;
            GridContainer parent = null;

            AddStep("create test", () =>
            {
                Child = parent = new GridContainer
                {
                    AutoSizeAxes     = Axes.Both,
                    RowDimensions    = new[] { new Dimension(GridSizeMode.AutoSize) },
                    ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
                    Content          = new[]
                    {
                        new Drawable[]
                        {
                            box = new Box
                            {
                                Size          = new Vector2(200),
                                LifetimeStart = double.MaxValue
                            }
                        },
                    }
                };
            });

            AddStep("make child alive", () => box.LifetimeStart = double.MinValue);

            AddAssert("parent has size 200", () => Precision.AlmostEquals(new Vector2(200), parent.DrawSize));
        }
Ejemplo n.º 17
0
 public void StartDrag(GameObject card)
 {
     LastContainer = card.transform.GetComponentInParent <GridContainer>();
     //LastContainer = card.transform.parent.parent.parent.GetComponent<GridContainer>();
     LastIndex = LastContainer.GetCardIndex(card);
     card.transform.SetParent(GetComponentInParent <Canvas>().gameObject.transform);
 }
Ejemplo n.º 18
0
        public CrayonWindow(CrayonBoundUserInterface owner)
        {
            MinSize = SetSize = (250, 300);
            Title   = Loc.GetString("crayon-window-title");
            Owner   = owner;

            var vbox = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            Contents.AddChild(vbox);

            _search = new LineEdit();
            _search.OnTextChanged += (_) => RefreshList();
            vbox.AddChild(_search);

            _grid = new GridContainer()
            {
                Columns = 6,
            };
            var gridScroll = new ScrollContainer()
            {
                VerticalExpand = true,
                Children       =
                {
                    _grid
                }
            };

            vbox.AddChild(gridScroll);
        }
        public CargoConsoleOrderMenu()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("cargo-console-order-menu-title");

            var vBox          = new VBoxContainer();
            var gridContainer = new GridContainer {
                Columns = 2
            };

            var requesterLabel = new Label {
                Text = Loc.GetString("cargo-console-order-menu-requester-label")
            };

            Requester = new LineEdit();
            gridContainer.AddChild(requesterLabel);
            gridContainer.AddChild(Requester);

            var reasonLabel = new Label {
                Text = Loc.GetString("cargo-console-order-menu-reason-label:")
            };

            Reason = new LineEdit();
            gridContainer.AddChild(reasonLabel);
            gridContainer.AddChild(Reason);

            var amountLabel = new Label {
                Text = Loc.GetString("cargo-console-order-menu-amount-label:")
            };

            Amount = new SpinBox
            {
                HorizontalExpand = true,
                Value            = 1
            };
            Amount.SetButtons(new List <int>()
            {
                -3, -2, -1
            }, new List <int>()
            {
                1, 2, 3
            });
            Amount.IsValid = (n) => {
                return(n > 0);
            };
            gridContainer.AddChild(amountLabel);
            gridContainer.AddChild(Amount);

            vBox.AddChild(gridContainer);

            SubmitButton = new Button()
            {
                Text      = Loc.GetString("cargo-console-order-menu-submit-button"),
                TextAlign = Label.AlignMode.Center,
            };
            vBox.AddChild(SubmitButton);

            Contents.AddChild(vBox);
        }
Ejemplo n.º 20
0
    public override void _Ready()
    {
        compoundBars = GetTree().GetNodesInGroup("CompoundBar");

        mouseHoverPanel              = GetNode <PanelContainer>(MouseHoverPanelPath);
        pauseButton                  = GetNode <TextureButton>(PauseButtonPath);
        resumeButton                 = GetNode <TextureButton>(ResumeButtonPath);
        leftPanels                   = GetNode <VBoxContainer>(LeftPanelsPath);
        agentsPanel                  = GetNode <Control>(AgentsPanelPath);
        environmentPanel             = GetNode <NinePatchRect>(EnvironmentPanelPath);
        environmentPanelBarContainer = GetNode <GridContainer>(EnvironmentPanelBarContainerPath);
        glucoseBar                   = GetNode <ProgressBar>(GlucoseBarPath);
        ammoniaBar                   = GetNode <ProgressBar>(AmmoniaBarPath);
        phosphateBar                 = GetNode <ProgressBar>(PhosphateBarPath);
        hydrogenSulfideBar           = GetNode <ProgressBar>(HydrogenSulfideBarPath);
        ironBar                    = GetNode <ProgressBar>(IronBarPath);
        compoundsPanel             = GetNode <NinePatchRect>(CompoundsPanelPath);
        CompoundsPanelBarContainer = GetNode <GridContainer>(CompoundsPanelBarContainerPath);
        oxytoxyBar                 = GetNode <ProgressBar>(OxytoxyBarPath);
        atpBar    = GetNode <TextureProgress>(AtpBarPath);
        healthBar = GetNode <TextureProgress>(HealthBarPath);
        ammoniaReproductionBar   = GetNode <TextureProgress>(AmmoniaReproductionBarPath);
        phosphateReproductionBar = GetNode <TextureProgress>(PhosphateReproductionBarPath);
        atpLabel        = GetNode <Label>(AtpLabelPath);
        hpLabel         = GetNode <Label>(HpLabelPath);
        menu            = GetNode <Control>(MenuPath);
        animationPlayer = GetNode <AnimationPlayer>(AnimationPlayerPath);
        hoveredItems    = GetNode <VBoxContainer>(HoveredItemsContainerPath);
        populationLabel = GetNode <Label>(PopulationLabelPath);
        patchLabel      = GetNode <Label>(PatchLabelPath);
        editorButton    = GetNode <TextureButton>(EditorButtonPath);
        helpScreen      = GetNode <Control>(HelpScreenPath);

        OnEnterStageTransition();
    }
Ejemplo n.º 21
0
 protected ImportLyricSubScreenWithTopNavigation()
 {
     Padding       = new MarginPadding(10);
     InternalChild = new GridContainer
     {
         RelativeSizeAxes = Axes.Both,
         RowDimensions    = new[]
         {
             new Dimension(GridSizeMode.Absolute, 40),
             new Dimension(GridSizeMode.Absolute, 10),
             new Dimension()
         },
         Content = new[]
         {
             new Drawable[]
             {
                 Navigation = CreateNavigation(),
             },
             new Drawable[] { },
             new[]
             {
                 CreateContent(),
             }
         }
     };
 }
Ejemplo n.º 22
0
        public IDialog ShowDialog(string title, FrameworkElement content, ResultHandler callback, Size size, Panel container)
        {
            var gridContainer = new GridContainer();

            gridContainer.Children.Add(content);

            if (!double.IsNaN(size.Height) && !double.IsInfinity(size.Height))
            {
                this.Height = size.Height;
            }

            if (!double.IsNaN(size.Width) && !double.IsInfinity(size.Width))
            {
                this.Width = size.Width;
            }

            this.Title   = title;
            this.Content = gridContainer;


            if (callback != null)
            {
                this.m_handler = callback;
            }

            this.Show();

            return(this);
        }
Ejemplo n.º 23
0
        public CargoConsoleOrderMenu()
        {
            IoCManager.InjectDependencies(this);

            Title = Loc.GetString("Order Form");

            var vBox          = new VBoxContainer();
            var gridContainer = new GridContainer {
                Columns = 2
            };

            var requesterLabel = new Label {
                Text = Loc.GetString("Name:")
            };

            Requester = new LineEdit();
            gridContainer.AddChild(requesterLabel);
            gridContainer.AddChild(Requester);

            var reasonLabel = new Label {
                Text = Loc.GetString("Reason:")
            };

            Reason = new LineEdit();
            gridContainer.AddChild(reasonLabel);
            gridContainer.AddChild(Reason);

            var amountLabel = new Label {
                Text = Loc.GetString("Amount:")
            };

            Amount = new SpinBox
            {
                SizeFlagsHorizontal = SizeFlags.FillExpand,
                Value = 1
            };
            Amount.SetButtons(new List <int>()
            {
                -100, -10, -1
            }, new List <int>()
            {
                1, 10, 100
            });
            Amount.IsValid = (n) => {
                return(n > 0);
            };
            gridContainer.AddChild(amountLabel);
            gridContainer.AddChild(Amount);

            vBox.AddChild(gridContainer);

            SubmitButton = new Button()
            {
                Text      = Loc.GetString("OK"),
                TextAlign = Label.AlignMode.Center,
            };
            vBox.AddChild(SubmitButton);

            Contents.AddChild(vBox);
        }
Ejemplo n.º 24
0
        public AlertsUI()
        {
            LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
            LayoutContainer.SetGrowVertical(this, LayoutContainer.GrowDirection.End);
            LayoutContainer.SetAnchorTop(this, 0f);
            LayoutContainer.SetAnchorRight(this, 1f);
            LayoutContainer.SetAnchorBottom(this, 1f);
            LayoutContainer.SetMarginBottom(this, -180);
            LayoutContainer.SetMarginTop(this, 250);
            LayoutContainer.SetMarginRight(this, -10);
            var panelContainer = new PanelContainer
            {
                StyleClasses        = { StyleNano.StyleClassTransparentBorderedWindowPanel },
                HorizontalAlignment = HAlignment.Right,
                VerticalAlignment   = VAlignment.Top
            };

            AddChild(panelContainer);

            Grid = new GridContainer
            {
                MaxGridHeight   = 64,
                ExpandBackwards = true
            };
            panelContainer.AddChild(Grid);

            MinSize = (64, 64);
        }
Ejemplo n.º 25
0
        private Control SetupGameGrid(Texture panelTex)
        {
            _gameGrid = new GridContainer
            {
                Columns             = 10,
                HSeparationOverride = 1,
                VSeparationOverride = 1
            };
            UpdateBlocks(new BlockGameBlock[0]);

            var back = new StyleBoxTexture
            {
                Texture  = panelTex,
                Modulate = Color.FromHex("#4a4a51"),
            };

            back.SetPatchMargin(StyleBox.Margin.All, 10);

            var gamePanel = new PanelContainer
            {
                PanelOverride         = back,
                SizeFlagsHorizontal   = SizeFlags.FillExpand,
                SizeFlagsStretchRatio = 60
            };
            var backgroundPanel = new PanelContainer
            {
                PanelOverride = new StyleBoxFlat {
                    BackgroundColor = Color.FromHex("#86868d")
                }
            };

            backgroundPanel.AddChild(_gameGrid);
            gamePanel.AddChild(backgroundPanel);
            return(gamePanel);
        }
Ejemplo n.º 26
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        width  = 79;
        height = 45;
        map    = new List <bool>();
        timer  = new Timer();
        AddChild(timer);
        AddUserSignal("finished");
        AddUserSignal("finished_generating");
        AddUserSignal("finished_pathfinding", new Godot.Collections.Array {
            this, new Godot.Collections.Array <int> (), new Godot.Collections.Array <int>()
        });

        container = GetNode("GridContainer") as GridContainer;
        container.SetColumns(width);

        for (int i = 0; i < width * height; i++)
        {
            ColorRect rect = new ColorRect();
            rect.SetFrameColor(wallColour);

            rect.SetCustomMinimumSize(blockSize);
            container.AddChild(rect);

            map.Add(false);
        }

        ResizeBlock();
    }
Ejemplo n.º 27
0
        private void load(SingerManager singerManager)
        {
            InternalChild = new GridContainer
            {
                RelativeSizeAxes = Axes.Both,
                RowDimensions    = new[]
                {
                    new Dimension(GridSizeMode.Absolute, 100),
                    new Dimension()
                },
                Content = new[]
                {
                    new Drawable[]
                    {
                        new DefaultLyricPlacementColumn
                        {
                            Name             = "Default",
                            RelativeSizeAxes = Axes.Both,
                        }
                    },
                    new Drawable[]
                    {
                        singerContainers = new SingerRearrangeableList
                        {
                            Name                  = "List of singer",
                            RelativeSizeAxes      = Axes.Both,
                            DisplayBottomDrawable = true,
                        }
                    }
                }
            };

            singerContainers.Items.BindTo(singerManager.Singers);
            singerContainers.OnOrderChanged += singerManager.ChangeOrder;
        }
Ejemplo n.º 28
0
        public Algorithm(
            IPoints points, IRectangle rect, StrategyType type = StrategyType.Grid, ILog2 log = null)
        {
            _log      = log ?? new NoLog();
            Rectangle = rect;
            Points    = points.Data;
            Singles   = new List <IP>();
            Knn       = new NearestNeighbor();

            GridContainer = new GridContainer(Rectangle, Points);

            switch (type)
            {
            case StrategyType.Naive:
                Strategy = new NaiveStrategy(_log);
                break;

            case StrategyType.Grid:
                Strategy = new GridStrategy(_log);
                break;

            case StrategyType.KdTree:
                Strategy = new KdTreeStrategy(Points);
                break;

            default:
                throw new NotImplementedException("Unknown strategy");
            }

            //_log.Info(MethodBase.GetCurrentMethod(), "object init");
        }
Ejemplo n.º 29
0
        public void TestBasic()
        {
            var grid = new GridContainer {
                Columns = 2
            };
            var child1 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child2 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child3 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child4 = new Control {
                CustomMinimumSize = (50, 50)
            };
            var child5 = new Control {
                CustomMinimumSize = (50, 50)
            };

            grid.AddChild(child1);
            grid.AddChild(child2);
            grid.AddChild(child3);
            grid.AddChild(child4);
            grid.AddChild(child5);

            Assert.That(grid.CombinedMinimumSize, Is.EqualTo(new Vector2(104, 158)));

            Assert.That(child1.Position, Is.EqualTo(Vector2.Zero));
            Assert.That(child2.Position, Is.EqualTo(new Vector2(54, 0)));
            Assert.That(child3.Position, Is.EqualTo(new Vector2(0, 54)));
            Assert.That(child4.Position, Is.EqualTo(new Vector2(54, 54)));
            Assert.That(child5.Position, Is.EqualTo(new Vector2(0, 108)));
        }
Ejemplo n.º 30
0
 public MatchStartControl()
 {
     InternalChild = new GridContainer
     {
         RelativeSizeAxes = Axes.Both,
         ColumnDimensions = new[]
         {
             new Dimension(),
             new Dimension(GridSizeMode.AutoSize)
         },
         Content = new[]
         {
             new Drawable[]
             {
                 readyButton = new MultiplayerReadyButton
                 {
                     RelativeSizeAxes = Axes.Both,
                     Size             = Vector2.One,
                     Action           = onReadyClick,
                 },
                 countdownButton = new MultiplayerCountdownButton
                 {
                     RelativeSizeAxes = Axes.Y,
                     Size             = new Vector2(40, 1),
                     Alpha            = 0,
                     Action           = startCountdown,
                     CancelAction     = cancelCountdown
                 }
             }
         }
     };
 }
Ejemplo n.º 31
0
 void Start()
 {
     panel = GridContainer.Create(new Vector3(.2f, .2f), new Vector2(300, 300), 3, 3);
     for (int g = 0; g < 9; g++)
     {
         panel.AddChild(BaseImage.Create("GUI/Button", new Vector3()));
         panel.elements[g].Click += EternityGUITester_Click;
     }
 }
Ejemplo n.º 32
0
 static void Main(string[] args)
 {
     Console.OutputEncoding = Encoding.Unicode;
     ConsoleManager cm = new ConsoleManager();
     //Canvas canvas = new Canvas(ConsoleColor.Gray);
     GridContainer container = new GridContainer();
     var SmallBox1 = new BoxObject(4, 4);
     var SmallBox2 = new BoxObject(4, 4);
     var SmallBox3 = new BoxObject(4, 4);
     var SmallBox4 = new BoxObject(15, 15);
     var BigBox1 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.DoubleLine };
     var BigBox2 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.DoubleHorizontalSingleVertical };
     var BigBox3 = new BoxObject(40, 40) { BoxChars = BoxObject.Presets.BoxChars.SingleHorizontalDoubleVertical };
     cm.AddObject(container);
     container.AddChild(SmallBox1);
     container.AddChild(SmallBox2);
     container.AddChild(SmallBox3);
     Console.ReadLine();
     for (int i = 0; i < 20; i++ )
         SmallBox2.UpdateSize = new Point(i, i);
     for (int i = 20; i >= 4; i--)
         SmallBox2.UpdateSize = new Point(i, i);
     Console.ReadLine();
     SmallBox2.UpdateSize = new Point(50, 50);
     GridContainer container2 = new GridContainer();
     Console.ReadLine();
     SmallBox2.AddChild(container2);
     Console.ReadLine();
     container2.AddChild(new TextObject("This is an embedded element."));
     Console.ReadLine();
     container2.AddChild(SmallBox1);
     Console.ReadLine();
     container2.AddChild(BigBox1);
     Console.ReadLine();
     container2.AddChild(BigBox2);
     Console.ReadLine();
     container2.AddChild(BigBox3);
     Console.ReadLine();
     BigBox1.AddChild(SmallBox4);
     Console.ReadLine();
     SmallBox4.AddChild(new TextObject("Hello World"));
     Console.ReadLine();
     container.RemoveChild(BigBox1);
     Console.ReadLine();
 }