Beispiel #1
0
 public CardPanelControl(Pile p, Action<CardButton> f)
 {
     panel = new CardPanel(() =>
     {
         var b = new CardButton(new FML(clickedCallback, f));
         b.setHeight(150);
         return b;
     }, new LayoutArgs(false, false));
     panel.Size = new Size(300, 150);
     panel.BackColor = Color.Navy;
     p.addObserver(panel);
     window = GUI.showWindow(panel);
 }
Beispiel #2
0
        public DraftPanel()
        {
            BackColor = Color.DodgerBlue;

            cards = new Pile(new Card[0]);
            choices = new CardPanel(() => new CardButton(new FML(clicked
                )), new LayoutArgs(false, false), cards);
            Controls.Add(choices);

            dealEm = new Button();
            dealEm.Click += (_, __) => dealm();
            Controls.Add(dealEm);
        }
Beispiel #3
0
 public void showGraveyard(Player p)
 {
     FML f = new FML((a) => { gameElementPressed(new GameElement(a.Card)); }, (a, b) => { }, () => { }, (c) => setFocusCard(c.Card));
     CardPanel l = new CardPanel(() => new CardButton(f), new LayoutArgs(false, false),p.graveyard);
     GUI.showWindow(l, new WindowedPanelArgs("Graveyard", true, true, false));
 }
Beispiel #4
0
        public DeckEditorPanel()
        {
            BackColor = Color.Beige;
            currentSortingColor = Colour.GREY;
            int currentPage = 0;
            int cardsPerPage = 8;
            sortedIds = new List<Card>();
            myDeckIsHard = new Pile(new Card[] { });
            p = new CardPanel(new Func<CardButton>(() => new CardButton()), new LayoutArgs(true, true));
            myDeckIsHard.addObserver(p);
            ids =
                ((CardId[])Enum.GetValues(typeof (CardId))).Select(id => new Card(id))
                    .Where(c => c.rarity != Rarity.Token)
                    .OrderBy(card => card.colour)
                    .ToArray();
            cardInfo = new CardInfoPanel();
            cardInfo.BackColor = BackColor;
            Controls.Add(cardInfo);
            cardSlot = new CardButton[8];
            cardCount = new Label();

            int nrOfCards = ids.Length;
            cards = new CardButton[nrOfCards];

            for (int i = 0; i < nrOfCards; i++)
            {
                cards[i] = new CardButton(ids[i].cardId);
                sortedIds.Add(ids[i]);
            }

            for (int i = 0; i < cardsPerPage; i++)
            {
                int i0 = i;
                cardSlot[i] = cards[i];
                cardSlot[i].Size = new Size(200,300);
                Controls.Add(cardSlot[i]);
                cardSlot[i].MouseDown += (_, __) =>
                {
                    if (__.Button == MouseButtons.Left) addToDeck(cards[i0].Card.cardId);
                    else if (__.Button == MouseButtons.Right) removeFromDeck(cards[i0].Card.cardId);
                };
                cardSlot[i].MouseHover += (_, __) =>
                {
                    cardInfo.showCard(cardSlot[i0].Card);
                };
            }

            scrollLeftButton = new Button();
            scrollRightButton = new Button();
            scrollLeftButton.Image = ImageLoader.getStepImage("arrowLeft", new Size(60, 60));
            scrollRightButton.Image = ImageLoader.getStepImage("arrowRight", new Size(60, 60));

            //todo: you need to double press if you scroll one way then the other.
            scrollLeftButton.MouseDown += (_, __) =>
            {
                if (currentPage > 0) currentPage--;
                int cardSlotNr = cardsPerPage-1;
                for (int i = currentPage*cardsPerPage+cardsPerPage-1; i > currentPage*cardsPerPage-1; i--)
                {
                    cardSlot[cardSlotNr].Visible = true;
                    cardSlot[cardSlotNr].notifyObserver(new Card(sortedIds[i].cardId), null);
                    cardSlotNr--;
                }
                Console.WriteLine(currentPage);
            };
            scrollRightButton.MouseDown += (_, __) =>
            {
                //this if doesn't even make sense, but it just werks. todo
                if (currentPage * cardsPerPage - cardsPerPage < sortedIds.Count - cardsPerPage * 2) currentPage++;
                int cardSlotNr = 0;
                for (int i = currentPage * cardsPerPage - cardsPerPage; i < currentPage * cardsPerPage; i++)
                {
                    if (i < sortedIds.Count - cardsPerPage)
                    {
                        cardSlot[cardSlotNr].Visible = true;
                        cardSlot[cardSlotNr].notifyObserver(new Card(sortedIds[i + cardsPerPage].cardId), null);
                    }
                    else cardSlot[cardSlotNr].Visible = false;
                    cardSlotNr++;
                }
            };

            backToMainMenuButton = new Button();
            backToMainMenuButton.Size = new Size(120, 40);
            backToMainMenuButton.Text = "back to main menu";
            backToMainMenuButton.MouseDown += (_, __) =>
            {
                GUI.transitionToMainMenu();
            };

            Controls.Add(scrollLeftButton);
            Controls.Add(scrollRightButton);

            noDeckName = new Label();
            noDeckName.Text = "Every deck needs a name.";
            noDeckName.Visible = false;
            noDeckName.Size = new Size(250, 25);
            noDeckName.BackColor = Color.Red;

            loadButton = new Button();
            loadButton.Image = ImageLoader.getStepImage("load", new Size(60, 60));
            loadButton.Size = loadButton.Image.Size;
            loadButton.MouseDown += (_, __) =>
            {
                loadDeckFromFile((s) => loadIntoEditor(loadDeck(s)));
            };

            saveButton = new Button();
            saveButton.Image = ImageLoader.getStepImage("save", new Size(60, 60));
            saveButton.Size = saveButton.Image.Size;
            saveButton.MouseDown += (_, __) =>
            {
                if (tb.Text != "")
                    saveDeck();
                else
                {
                    noDeckName.Visible = true;
                }
            };

            sortButtons = new Button[6];
            //todo use images or something, instead of solid colors
            Color[] colors = new Color[6] {Color.White, Color.Blue, Color.Black, Color.Red, Color.Green, Color.Gray};
            for(int i = 0; i < sortButtons.Count(); i++)
            {
                //todo ask seba why i0 is needed

                int i0 = i;
                sortButtons[i] = new Button();
                sortButtons[i].Tag = (Colour)i;
                sortButtons[i].BackColor = colors[i];
                sortButtons[i].Location = new Point(Size.Width / 2 + 50 * i, 50);
                sortButtons[i].Size = new Size(50, 50);
                sortButtons[i].MouseDown += (_, __) =>
                {
                    sortAfterColor((Colour)sortButtons[i0].Tag);
                };
                Controls.Add(sortButtons[i]);
            }

            tb = new TextBox();
            Controls.Add(cardCount);
            Controls.Add(saveButton);
            Controls.Add(noDeckName);
            Controls.Add(loadButton);
            Controls.Add(tb);
            Controls.Add(p);
            Controls.Add(backToMainMenuButton);
        }