Ejemplo n.º 1
0
        private void SetPlayerDeck(MemTools.YdcDeck deck, int playerIndex, bool allowNull)
        {
            if (!allowNull && deck.Equals(default(MemTools.YdcDeck)))
            {
                return;
            }

            playerDecks[playerIndex] = deck;
            switch (playerIndex)
            {
            case 0:
                player1DeckLabel.Text = "P1: " + deck.DeckName;
                break;

            case 1:
                player2DeckLabel.Text = "P2: " + deck.DeckName;
                break;

            case 2:
                player3DeckLabel.Text = "P3: " + deck.DeckName;
                break;

            case 3:
                player4DeckLabel.Text = "P4: " + deck.DeckName;
                break;
            }
        }
Ejemplo n.º 2
0
 private void decksListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     MemTools.YdcDeck deck = GetSelectedDeck();
     if (!deck.Equals(default(MemTools.YdcDeck)))
     {
         if (autoViewDeckCheckBox.Checked)
         {
             ViewDeck(deck);
         }
     }
 }
Ejemplo n.º 3
0
        private void ViewDeck(MemTools.YdcDeck deck)
        {
            if (deck.Equals(default(MemTools.YdcDeck)))
            {
                return;
            }

            if (lastViewDeck < DateTime.Now - TimeSpan.FromSeconds(0.5))
            {
                ViewDeckNow(deck);
            }
            else
            {
                nextViewDeck = deck;
                viewDeckDelayTimer.Enabled = true;
            }
        }
Ejemplo n.º 4
0
        private void ViewDeckNow(MemTools.YdcDeck deck)
        {
            if (!Program.MemTools.IsFullyLoaded)
            {
                return;
            }

            if (deck.Equals(default(MemTools.YdcDeck)))
            {
                return;
            }

            MemTools.ScreenState screenState = Program.MemTools.GetScreenState();
            if (screenState == MemTools.ScreenState.Duel ||
                screenState == MemTools.ScreenState.DuelLoadingScreen)
            {
                // Don't interrupt a duel
                return;
            }

            lastViewDeck = DateTime.Now;
            MemTools.YdcDeck[] userDecks = Program.MemTools.ReadUserDecks();
            if (userDecks != null)
            {
                string           deckName      = reservedDeckSlotName;
                int              lastDeckIndex = userDecks.Length - 1;
                MemTools.YdcDeck lastDeck      = userDecks[lastDeckIndex];

                if (lastDeck.DeckName != deckName)
                {
                    if (MessageBox.Show("This will wipe over the deck in user slot 32. Continue?", "Warning", MessageBoxButtons.YesNo) !=
                        DialogResult.Yes)
                    {
                        return;
                    }
                }

                lastDeck                 = deck;
                lastDeck.DeckName        = deckName;
                userDecks[lastDeckIndex] = lastDeck;

                Program.MemTools.WriteUserDecks(userDecks);
                Program.MemTools.SelectUserDeck(lastDeckIndex, true);
            }
        }
Ejemplo n.º 5
0
        private void exportDeckButton_Click(object sender, EventArgs e)
        {
            MemTools.YdcDeck deck = GetSelectedDeck();
            if (deck.Equals(default(MemTools.YdcDeck)))
            {
                return;
            }

            try
            {
                if (!Directory.Exists(deckFilesDir))
                {
                    Directory.CreateDirectory(deckFilesDir);
                }
            }
            catch
            {
            }

            if (Directory.Exists(deckFilesDir))
            {
                string filename = MakeSafeFileName(deck.DeckName).Trim();
                if (string.IsNullOrEmpty(filename))
                {
                    return;
                }
                filename += deckFilesExtension;
                string path = Path.Combine(deckFilesDir, filename);
                try
                {
                    DialogResult result = MessageBox.Show("Would you like to export this as YDK (instead of YDL)?", "Export", MessageBoxButtons.YesNoCancel);
                    if (result == DialogResult.Yes)
                    {
                        YdkHelper.SaveDeck(deck, Path.ChangeExtension(path, YdkHelper.FileExtension));
                    }
                    else if (result == DialogResult.No)
                    {
                        File.WriteAllBytes(path, MemTools.StructToByteArray(deck));
                    }
                }
                catch
                {
                }
            }
        }