Esempio n. 1
0
        public void FillGridWithCardTypes(List <Ship> ships)
        {
            var names = ships.Select(p => p.Name).Distinct().ToList();

            ClickableToRemove = new List <IClickable>();
            gridCards.RemoveChildren();
            int i = 0;

            foreach (var name in names)
            {
                cardCouple couple = new cardCouple();
                Label      lbl    = new Label(coupleWidth, coupleHeight, Game1.self.GraphicsDevice, Gui, Gui.smediumFont, true)
                {
                    Text = name
                };
                Button button = new Button(coupleWidth, coupleHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
                {
                    Text = "Select skin"
                };
                button.clickEventObject += setTexture;
                Clickable.Add(button);
                ClickableToRemove.Add(button);
                couple.lbl    = lbl;
                couple.button = button;
                couples.Add(couple);
                gridCards.AddChild(lbl);
                gridCards.AddChild(button);
                i++;
            }

            gridCards.DrawBackground = false;
            gridCards.UpdateP();
            gridCards.UpdateActive(true);
            layout.Update();
        }
Esempio n. 2
0
        public override void Initialize(ContentManager Content)
        {
            ClickableToRemove = new List <IClickable>();
            Gui = new GUI(Content);


            gridCards            = new Grid(2, 100, coupleWidth, coupleHeight);
            gridCards.DrawBorder = true;
            gridCards.BorderSize = 3;
            gridCards.WitdhAndHeightColumnDependant = false;
            gridCards.AllVisible             = false;
            gridCards.VisibleRows            = 5;
            gridCards.ConstantRowsAndColumns = true;
            gridCards.MaxChildren            = true;
            gridCards.ChildMaxAmount         = 200;
            gridCards.Height = 5 * coupleHeight + 6 * gridCards.rowOffset;
            gridCards.Width  = 2 * coupleWidth + gridCards.columnOffset;
            up = new Button(gridCards.Width, 30, Game1.self.GraphicsDevice,
                            Gui, Gui.mediumFont, true)
            {
                Text = "up"
            };
            down = new Button(gridCards.Width, 30, Game1.self.GraphicsDevice,
                              Gui, Gui.mediumFont, true)
            {
                Text = "down"
            };
            back = new Button(gridCards.Width, coupleHeight, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                Text = "Back to menu"
            };
            up.clickEvent   += UpClick;
            down.clickEvent += DownClick;
            back.clickEvent += OnExit;
            Clickable.Add(back);
            layout.AddChild(gridCards);
            layout.AddChild(down);
            layout.AddChild(up);
            layout.AddChild(back);
            Clickable.Add(up);
            Clickable.Add(down);
            back.Update();
            up.Update();
            down.Update();
            gridCards.UpdateP();
            int z = 243123;

            SetClickables(true);
            layout.Update();
        }
Esempio n. 3
0
        public void onSave()
        {
            var    element = drop.GetSelected();
            int    width   = 1920;
            int    height  = 1080;
            Config conf    = new Config();

            if (element is Button)
            {
                Button button = (Button)element;
                if (button.text.Equals(Constants.hd))
                {
                    width           = 1280;
                    height          = 720;
                    conf.Resolution = Constants.hd;
                }
                else if (button.text.Equals(Constants.fullhd))
                {
                    width           = 1920;
                    height          = 1080;
                    conf.Resolution = Constants.fullhd;
                }
            }
            Game1.self.Wallpaper = Utils.CreateTexture(Game1.self.GraphicsDevice, width, height);
            Game1.self.graphics.PreferredBackBufferHeight = height;
            Game1.self.graphics.PreferredBackBufferWidth  = width;
            Game1.self.graphics.ApplyChanges();
            menus.ForEach(p =>
            {
                p.Reinitialize(Game1.self.Content);
            });


            TextWriter    writer = new StreamWriter("Config");
            XmlSerializer xml    = new XmlSerializer(typeof(Config));

            xml.Serialize(writer, conf);
            writer.Close();
        }
Esempio n. 4
0
        public void setTexture(object sender)
        {
            Button b        = sender as Button;
            var    cardName = couples.Single(p => p.button == b).lbl.Text;
            //TODO make there logic for setting texture for cards with this namevar fileContent = string.Empty;
            var filePath = string.Empty;

            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = "c:\\";
                openFileDialog.Filter           = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 2;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    //Get the path of specified file
                    filePath = openFileDialog.FileName;
                    //Read the contents of the file into a stream
                    Game1.self.SetTextureToShip(filePath, cardName);
                }
            }
        }
Esempio n. 5
0
        public override void Initialize(ContentManager Content)
        {
            Gui         = new GUI(Content);
            layout      = new RelativeLayout();
            grid        = new Grid();
            buttonsGrid = new Grid();
            cardsGrid   = new Grid(5, 3, CardWidth, CardHeight);
            slots       = new List <CardSlot>();
            for (int row = 0; row < 3; row++)
            {
                for (int column = 0; column < 5; column++)
                {
                    CardSlot c = new CardSlot(CardWidth, CardHeight, Game1.self.GraphicsDevice, Gui);
                    grid.AddChild(c, row, column);
                    c.clickEvent += CardSlotClick;
                    slots.Add(c);
                    Clickable.Add(c);
                }
            }
            grid.Origin = new Point(50, 50);
            grid.UpdateP();
            cardsGrid.WitdhAndHeightColumnDependant = false;
            cardsGrid.Width    = (int)((int)Game1.self.graphics.PreferredBackBufferWidth * CardGridWidthMulti);
            cardsGrid.Height   = (int)((int)Game1.self.graphics.PreferredBackBufferHeight * CardGridHeightMulti);
            buttonsGrid.Origin = new Point(Game1.self.graphics.PreferredBackBufferWidth / 2 - 100, Game1.self.graphics.PreferredBackBufferHeight - 200);
            cardsGrid.Origin   = new Point(50, buttonsGrid.Origin.Y - 200);
            Button up = new Button(new Point(cardsGrid.Origin.X + (int)(cardsGrid.Width / 2), cardsGrid.Origin.Y), 60, 30, Game1.self.GraphicsDevice,
                                   Gui, Gui.mediumFont, true)
            {
                Text = "up"
            };

            up.clickEvent += upClick;
            Button down = new Button(new Point(cardsGrid.Origin.X + (int)(cardsGrid.Width / 2), cardsGrid.Origin.Y + 30), 60, 30, Game1.self.GraphicsDevice,
                                     Gui, Gui.mediumFont, true)
            {
                Text = "down"
            };

            down.clickEvent += downClick;

            save = new Button(200, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                text = "Ready"
            };
            save.clickEvent += onSave;
            tipLabel         = new Label(new Point(grid.Origin.X + grid.Width + 50, grid.Origin.Y), Game1.self.graphics.PreferredBackBufferWidth - 150 - grid.Width, 150, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                Text = "You have 2 minutes to choose your fleet's shape. There's no difference between positions in rows, all the ships in the end will be put to the left border."
            };
            // tipLabel.HeightDerivatingFromText = true;
            // tipLabel.Update();
            layout.AddChild(tipLabel);


            Grid   popupGrid       = new Grid();
            Button popupExitButton = new Button(200, 100, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                text = "Exit to menu"
            };

            popupExitButton.DrawBackground = false;
            popupExitButton.clickEvent    += onExit;
            Clickable.Add(popupExitButton);
            lbl = new Label(200, 200, Game1.self.GraphicsDevice, Gui, Gui.mediumFont, true)
            {
                Text = "You lost the game due to not choosing shape of fleet for longer than 2 minutes"
            };
            lbl.DrawBackground = false;
            popupGrid.AddChild(lbl, 0, 0);
            popupGrid.AddChild(popupExitButton, 1, 0);
            Point popupOrigin = new Point(Game1.self.graphics.PreferredBackBufferWidth / 2 - 100, Game1.self.graphics.PreferredBackBufferHeight / 2 - 150);

            popup      = new Popup(popupOrigin, 200, 300, Game1.self.GraphicsDevice, Gui);
            popup.grid = popupGrid;
            popup.SetToGrid();



            buttonsGrid.AddChild(save, 0, 0);
            Clickable.Add(save);
            layout.AddChild(up);
            layout.AddChild(down);
            Clickable.Add(up);
            Clickable.Add(down);
            cardsGrid.AllVisible             = false;
            cardsGrid.VisibleRows            = 1;
            cardsGrid.ConstantRowsAndColumns = true;
            cardsGrid.MaxChildren            = true;
            cardsGrid.ChildMaxAmount         = 15;
            cardsGrid.UpdateP();
            buttonsGrid.UpdateP();
            SetClickables(true);
            layout.Update();
        }