private void OnSetImageClicked(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "Image Files (*.png, *.jpg, *.bmp)|*.png;*.bmp;*.jpg|All Files (*.*)|*.*";
            var result = dialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                PokeManager.TryCreateDirectory(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources"));
                PokeManager.TryCreateDirectory(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Trainer"));
                try {
                    BitmapSource bitmap = PokeManager.LoadImage(dialog.FileName);
                    try {
                        PokeManager.SaveImage(bitmap, System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Trainer", "Trainer.png"));
                        PokeManager.CustomTrainerImage   = bitmap;
                        imageTrainer.Width               = Math.Min(90, bitmap.PixelWidth);
                        imageTrainer.Height              = Math.Min(138, bitmap.PixelHeight);
                        imageTrainer.Source              = bitmap;
                        this.buttonRemoveImage.IsEnabled = PokeManager.CustomTrainerImage != null;
                    }
                    catch (Exception ex) {
                        TriggerMessageBox.Show(this, "Error saving trainer image to Trigger's PC directory", "Image Error");
                    }
                }
                catch (Exception ex) {
                    TriggerMessageBox.Show(this, "Error loading trainer image", "Image Error");
                }
            }
        }
 private void OnRemoveClicked(object sender, RoutedEventArgs e)
 {
     if (secretBase.IsPlayerSecretBase)
     {
         MessageBoxResult result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to remove the player's Secret Base?", "Remove Secret Base", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             GBAGameSave.SecretBaseLocation = 0;
         }
     }
     else
     {
         MessageBoxResult result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to remove this Secret Base?", "Remove Secret Base", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             if (IsGBAGame)
             {
                 GBAGameSave.SecretBaseManager.SharedSecretBases.Remove((SharedSecretBase)secretBase);
                 GBAGameSave.IsChanged = true;
             }
             else
             {
                 PokeManager.SecretBases.Remove((SharedSecretBase)secretBase);
                 PokeManager.ManagerGameSave.IsChanged = true;
             }
         }
     }
     AddListViewItems();
 }
Пример #3
0
        private void OnSetPokemon(object sender, RoutedEventArgs e)
        {
            IPokemon pokemon = SendPokemonToWindow.ShowSelectDialog(this, true);

            if (pokemon != null)
            {
                for (int i = 0; i < newPokemonTeam.Count; i++)
                {
                    if (i == teamIndex)
                    {
                        continue;
                    }
                    if (pokemon.Personality == newPokemonTeam[i].Personality &&
                        PokemonDatabase.GetStartingEvolutionDexID(pokemon.DexID) == PokemonDatabase.GetStartingEvolutionDexID(newPokemonTeam[i].DexID))
                    {
                        TriggerMessageBox.Show(this, "Cannot use more than one Pokémon with the same personality and family.", "Duplicate Pokémon Detected");
                        return;
                    }
                }
                if (teamIndex < newPokemonTeam.Count)
                {
                    newPokemonTeam[teamIndex] = pokemon.CreateGBAPokemon(GameTypes.Any, false);
                }
                else
                {
                    newPokemonTeam.Add(pokemon.CreateGBAPokemon(GameTypes.Any, false));
                }
                RefreshTeam();
            }
        }
Пример #4
0
        private void OnPokeblockToss(object sender, EventArgs e)
        {
            if (HasSelection)
            {
                MessageBoxResult result = MessageBoxResult.Yes;
                if (result == MessageBoxResult.Yes && PokeManager.Settings.TossConfirmation)
                {
                    result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + listViewItems.SelectedItems.Count + " Pokéblocks?", "Toss Pokéblock Selection", MessageBoxButton.YesNo);
                }
                if (result == MessageBoxResult.Yes)
                {
                    foreach (Pokeblock block in SelectedBlocks)
                    {
                        blockCase.TossPokeblockAt(blockCase.IndexOf(block));
                    }
                }
            }
            else
            {
                MessageBoxResult result = MessageBoxResult.Yes;
                if (PokeManager.Settings.TossConfirmation)
                {
                    result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedBlock.Color + " Pokéblock?", "Toss Pokéblock", MessageBoxButton.YesNo);
                }

                if (result == MessageBoxResult.Yes)
                {
                    blockCase.TossPokeblockAt(selectedIndex);
                }
            }
        }
Пример #5
0
        private void OnTakeMailFromParty(object sender, RoutedEventArgs e)
        {
            int numSent = 0;

            for (int i = 0; i < 6; i++)
            {
                if (i < mailbox.PartyMailCount && mailbox[i, true] != null)
                {
                    if (mailbox.HasRoomForMail)
                    {
                        mailbox.AddMail(mailbox[i, true]);
                        mailbox[i, true] = null;
                    }
                    else
                    {
                        PokeManager.ManagerGameSave.Mailbox.AddMail(mailbox[i, true]);
                        mailbox[i, true] = null;
                        numSent++;
                    }
                }
            }
            foreach (IPokemon pokemon in mailbox.GameSave.PokePC.Party)
            {
                if (pokemon.IsHoldingMail)
                {
                    pokemon.HeldItemID = 0;
                }
            }
            if (numSent > 0)
            {
                TriggerMessageBox.Show(Window.GetWindow(this), "The mailbox filled up before all the mail could be stored. The rest was sent to " + PokeManager.Settings.ManagerNickname, "Mailbox Full");
            }
            buttonTakeMail.IsEnabled = false;
        }
Пример #6
0
        private void OnReplaceBallClick(object sender, RoutedEventArgs e)
        {
            if (pokemon.BallCaughtID == 1 || pokemon.BallCaughtID == 5 || pokemon.BallCaughtID == 11)
            {
                MessageBoxResult boxResult = TriggerMessageBox.Show(Window.GetWindow(this), pokemon.Nickname + " is caught in a rare ball, are you sure you want to replace it?", "Replace Ball", MessageBoxButton.YesNo);
                if (boxResult == MessageBoxResult.No)
                {
                    return;
                }
            }
            byte?result = ReplaceBallWindow.ShowDialog(Window.GetWindow(this), pokemon);

            if (result.HasValue)
            {
                if (result.Value == 1 || result.Value == 11)
                {
                    MessageBoxResult boxResult = TriggerMessageBox.Show(Window.GetWindow(this), ItemDatabase.GetItemFromID(result.Value).Name + " is a rare ball, are you sure you want to use it?", "Replace Ball", MessageBoxButton.YesNo);
                    if (boxResult == MessageBoxResult.No)
                    {
                        return;
                    }
                }
                pokemon.BallCaughtID         = result.Value;
                this.imageBallCaught.Source  = PokemonDatabase.GetBallCaughtImageFromID(pokemon.BallCaughtID);
                this.imageBallCaught2.Source = PokemonDatabase.GetBallCaughtImageFromID(pokemon.BallCaughtID);
            }
        }
 private void OnDecorationPutAway(object sender, EventArgs e)
 {
     if (HasSelection)
     {
         MessageBoxResult result = TriggerMessageBox.Show(Window.GetWindow(this), "Would you like to put away the selected decorations?", "Put Away Decoration Selection", MessageBoxButton.YesNo);
         if (result == MessageBoxResult.Yes)
         {
             foreach (Decoration decoration in SelectedDecorations)
             {
                 if (pocket.Inventory.IsDecorationInUse(pocket.IndexOf(decoration), pocket.PocketType))
                 {
                     pocket.Inventory.PutAwayDecoration(pocket.IndexOf(decoration), pocket.PocketType);
                 }
             }
         }
     }
     else
     {
         DecorationUsages usage       = pocket.Inventory.GetDecorationUsage(selectedIndex, pocket.PocketType);
         MessageBoxResult result      = MessageBoxResult.No;
         string           usageString = (usage == DecorationUsages.SecretBase ? "Secret Base" : "Bedroom");
         if (usage != DecorationUsages.Unused)
         {
             result = TriggerMessageBox.Show(Window.GetWindow(this), "Put away the " + selectedDecoration.DecorationData.Name + " in your " + usageString + "?", "Put Away", MessageBoxButton.YesNo);
         }
         if (result == MessageBoxResult.Yes)
         {
             pocket.Inventory.PutAwayDecoration(selectedIndex, pocket.PocketType);
         }
     }
 }
Пример #8
0
        private void OnGotoClicked(object sender, RoutedEventArgs e)
        {
            IPokemon pokemon = clickSelection.Tag as IPokemon;

            if (pokemon.ContainerIndex == -1)
            {
                pokemon            = pokemon.PokemonFinder.Pokemon;
                clickSelection.Tag = pokemon;
            }
            if (pokemon.IsReleased)
            {
                TriggerMessageBox.Show(this, "Cannot goto this Pokémon, it has been released", "Released Pokémon");
            }
            else if (pokemon.IsMoving)
            {
                TriggerMessageBox.Show(this, "Cannot goto a Pokémon while it is being moved", "Moving Pokémon");
            }
            else if (pokemon.ContainerIndex == -1)
            {
                TriggerMessageBox.Show(this, "The Search Results have lost track of " + pokemon.Nickname + " because it has been moved to a different game. This should not happen. Let me know if it does.", "Can't Find Pokémon");
            }

            /*else if (pokemon.PokeContainer.Type == ContainerTypes.Purifier) {
             *      TriggerMessageBox.Show(this, "Cannot view Pokémon in the Purifier", "Can't Goto");
             * }*/
            else
            {
                PokeManager.ManagerWindow.GotoPokemon(pokemon);
            }
        }
 private void OnAddClicked(object sender, RoutedEventArgs e)
 {
     if (!IsGBAGame || GBAGameSave.SecretBaseManager.SharedSecretBases.Count < 19)
     {
         var location = SecretBaseLocationChooser.Show(Window.GetWindow(this), 0, IsGBAGame ? GBAGameSave.SecretBaseManager : null);
         if (location.HasValue && location.Value != 0)
         {
             SharedSecretBase newSecretBase = new SharedSecretBase(location.Value, null);
             if (IsGBAGame)
             {
                 bool result = SecretBaseEditTrainerWindow.Show(Window.GetWindow(this), newSecretBase, false);
                 if (result)
                 {
                     newSecretBase = GBAGameSave.SecretBaseManager.AddSecretBase(newSecretBase);
                     AddListViewItems();
                     listViewSecretBases.SelectedIndex = 2 + GBAGameSave.SecretBaseManager.SharedSecretBases.IndexOf(newSecretBase);
                     listViewSecretBases.ScrollIntoView(listViewSecretBases.SelectedItem);
                     ((Control)listViewSecretBases.SelectedItem).Focus();
                 }
             }
             else
             {
                 newSecretBase = PokeManager.AddSecretBase(newSecretBase);
                 AddListViewItems();
                 listViewSecretBases.SelectedIndex = PokeManager.SecretBases.IndexOf(newSecretBase);
                 listViewSecretBases.ScrollIntoView(listViewSecretBases.SelectedItem);
                 ((Control)listViewSecretBases.SelectedItem).Focus();
             }
         }
     }
     else
     {
         TriggerMessageBox.Show(Window.GetWindow(this), "This game already has the maximum amount of 19 shared Secret Bases", "Can't Import");
     }
 }
Пример #10
0
        private void OnMailReturnToInventory(object sender, EventArgs e)
        {
            MessageBoxResult result = MessageBoxResult.Yes;

            if (PokeManager.Settings.TossConfirmation)
            {
                result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to delete this message and return the " + selectedMail.MailItemData.Name + " to your inventory?", "Return Mail", MessageBoxButton.YesNo);
            }
            string sentTo = "";

            if (result == MessageBoxResult.Yes)
            {
                if (mailbox.GameSave.Inventory.Items[selectedMail.MailItemData.PocketType].HasRoomForItem(selectedMail.MailItemID, 1))
                {
                    mailbox.GameSave.Inventory.Items[selectedMail.MailItemData.PocketType].AddItem(selectedMail.MailItemID, 1);
                    if (mailbox.GameSave.GameType == GameTypes.Any)
                    {
                        sentTo = PokeManager.Settings.ManagerNickname;
                    }
                    else
                    {
                        sentTo = mailbox.GameSave.TrainerName + "'s Bag";
                    }
                }
                else if (mailbox.GameSave.Inventory.Items.ContainsPocket(ItemTypes.PC) && mailbox.GameSave.Inventory.Items[ItemTypes.PC].HasRoomForItem(selectedMail.MailItemID, 1))
                {
                    result = TriggerMessageBox.Show(Window.GetWindow(this), "There is no room in your bag to store " + selectedMail.MailItemData.Name + ". Where would you like to send it?", "No Room", MessageBoxButton.YesNoCancel, "Your PC", "Game's PC");

                    if (result == MessageBoxResult.Yes)
                    {
                        PokeManager.ManagerGameSave.Inventory.Items[selectedMail.MailItemData.PocketType].AddItem(selectedMail.MailItemID, 1);
                        sentTo = PokeManager.Settings.ManagerNickname;
                    }
                    else if (result == MessageBoxResult.No)
                    {
                        mailbox.GameSave.Inventory.Items[ItemTypes.PC].AddItem(selectedMail.MailItemID, 1);
                        sentTo = mailbox.GameSave.TrainerName + "'s PC";
                    }
                }
                else
                {
                    result = TriggerMessageBox.Show(Window.GetWindow(this), "There is no room in your bag or PC to store " + selectedMail.MailItemData.Name + ". Would you like to send it to " + PokeManager.Settings.ManagerNickname + "?", "No Room", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        PokeManager.ManagerGameSave.Inventory.Items[selectedMail.MailItemData.PocketType].AddItem(selectedMail.MailItemID, 1);
                        sentTo = PokeManager.Settings.ManagerNickname;
                    }
                    else
                    {
                        result = MessageBoxResult.Cancel;
                    }
                }
                if (result != MessageBoxResult.Cancel)
                {
                    TriggerMessageBox.Show(Window.GetWindow(this), "Returned " + selectedMail.MailItemData.Name + " to " + sentTo, "Mail Returned");
                    mailbox.TossMailAt(selectedIndex);
                }
            }
        }
 private void OnWindowLoaded(object sender, RoutedEventArgs e)
 {
     if (comboBoxGame.SelectedGameIndex == -2)
     {
         TriggerMessageBox.Show(this, "No available games to send with", "Can't Send");
         Close();
     }
 }
Пример #12
0
        private void OnToss(object sender, EventArgs e)
        {
            MessageBoxResult result = MessageBoxResult.Yes;

            if (HasSelection)
            {
                var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, "Toss Item Selection", ItemTypes.TheVoid, true);
                if (results != null)
                {
                    if (PokeManager.Settings.TossConfirmation)
                    {
                        result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + listViewItems.SelectedItems.Count + " items?", "Toss Items", MessageBoxButton.YesNo);
                    }
                    if (result == MessageBoxResult.Yes)
                    {
                        foreach (Item item in SelectedItems)
                        {
                            int finalCount = results.GetFinalCount(item.Count);
                            if (finalCount > 0)
                            {
                                pocket.TossItemAt(pocket.IndexOf(item), (uint)finalCount);
                            }
                        }
                    }
                }
            }
            else
            {
                if (selectedItem.Count == 1)
                {
                    OnTossAll(sender, e);
                }
                else
                {
                    var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedItem.Count, "Toss Item", ItemTypes.TheVoid, true);
                    //int? count = ItemCountWindow.ShowDialog(Window.GetWindow(this), "Toss", 1, (int)selectedItem.Count);
                    if (results != null)
                    {
                        if (PokeManager.Settings.TossConfirmation)
                        {
                            if (results.Count == 1)
                            {
                                result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedItem.ItemData.Name + "?", "Toss Item", MessageBoxButton.YesNo);
                            }
                            else
                            {
                                result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + results.Count + " " + selectedItem.ItemData.Name + "s?", "Toss Item", MessageBoxButton.YesNo);
                            }
                        }
                        if (result == MessageBoxResult.Yes)
                        {
                            pocket.TossItemAt(selectedIndex, (uint)results.Count);
                        }
                    }
                }
            }
        }
Пример #13
0
 private void OnLoaded(object sender, RoutedEventArgs e)
 {
     this.upDownItemCount.SelectAll();
     if (comboBoxGame.SelectedGameIndex == -2)
     {
         TriggerMessageBox.Show(this, "No available games to send with", "Can't Send");
         Close();
     }
 }
 private void OnDecorationTossAll(object sender, EventArgs e)
 {
     if (HasSelection)
     {
         MessageBoxResult result = MessageBoxResult.Yes;
         if (selectionIsInUse != 0)
         {
             result = TriggerMessageBox.Show(Window.GetWindow(this), "Some of the selected decorations are in use. Would you like to put them away?", "Decoration Selection In Use", MessageBoxButton.YesNo);
         }
         if (result == MessageBoxResult.Yes && PokeManager.Settings.TossConfirmation)
         {
             result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + listViewItems.SelectedItems.Count + " decorations?", "Toss Decoration Selection", MessageBoxButton.YesNo);
         }
         if (result == MessageBoxResult.Yes)
         {
             foreach (Decoration decoration in SelectedDecorations)
             {
                 if (pocket.Inventory.IsDecorationInUse(pocket.IndexOf(decoration), pocket.PocketType))
                 {
                     pocket.Inventory.PutAwayDecoration(pocket.IndexOf(decoration), pocket.PocketType);
                 }
                 pocket.TossDecorationAt(pocket.IndexOf(decoration), decoration.Count);
             }
         }
     }
     else
     {
         MessageBoxResult result = MessageBoxResult.Yes;
         if (pocket.AreAllDecorationsOfIDInUse(selectedDecoration.ID))
         {
             DecorationUsages usage       = pocket.Inventory.GetDecorationUsage(selectedIndex, pocket.PocketType);
             string           usageString = (usage == DecorationUsages.SecretBase ? "Secret Base" : "Bedroom");
             result = TriggerMessageBox.Show(Window.GetWindow(this), "Put away the " + selectedDecoration.DecorationData.Name + " in your " + usageString + "?", "Put Away", MessageBoxButton.YesNo);
         }
         if (result == MessageBoxResult.Yes && PokeManager.Settings.TossConfirmation)
         {
             if (selectedDecoration.Count == 1)
             {
                 result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedDecoration.DecorationData.Name + "?", "Toss Decoration", MessageBoxButton.YesNo);
             }
             else
             {
                 result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedDecoration.Count + " " + selectedDecoration.DecorationData.Name + "s?", "Toss Decoration", MessageBoxButton.YesNo);
             }
         }
         if (result == MessageBoxResult.Yes)
         {
             pocket.TossDecorationAt(selectedIndex);
         }
     }
 }
 private void OnChangeGameType(object sender, RoutedEventArgs e)
 {
     if ((selectedGameSave.GameSave.GameType == GameTypes.Ruby || selectedGameSave.GameSave.GameType == GameTypes.Sapphire ||
          selectedGameSave.GameSave.GameType == GameTypes.FireRed || selectedGameSave.GameType == GameTypes.LeafGreen ||
          selectedGameSave.GameSave.GameType == GameTypes.Emerald) && selectedGameSave.GameSave is GBAGameSave)
     {
         var results = SelectGameTypeFullWindow.ShowDialog(this, selectedGameSave.IsJapanese);
         if (results != null)
         {
             GameTypes        gameType     = results.GameType;
             MessageBoxResult result       = MessageBoxResult.Yes;
             bool             reloadNeeded = false;
             if (((selectedGameSave.GameSave.GameType == GameTypes.Ruby || selectedGameSave.GameSave.GameType == GameTypes.Sapphire) && (gameType != GameTypes.Ruby && gameType != GameTypes.Sapphire)) ||
                 ((selectedGameSave.GameSave.GameType == GameTypes.FireRed || selectedGameSave.GameSave.GameType == GameTypes.LeafGreen) && (gameType != GameTypes.FireRed && gameType != GameTypes.LeafGreen)) ||
                 (selectedGameSave.GameSave.GameType == GameTypes.Emerald && gameType != GameTypes.Emerald))
             {
                 result = TriggerMessageBox.Show(this, "In order to change the game type to this the save must be reloaded. Are you sure you want to reload this save? Any unsaved changes will be lost.", "Reload Needed", MessageBoxButton.YesNo);
                 if (result == MessageBoxResult.Yes)
                 {
                     reloadNeeded = true;
                 }
             }
             if (result == MessageBoxResult.Yes)
             {
                 selectedGameSave.GameType            = gameType;
                 selectedGameSave.IsJapanese          = results.IsJapanese;
                 selectedGameSave.GameSave.IsJapanese = results.IsJapanese;
                 ((GBAGameSave)selectedGameSave.GameSave).GameType = gameType;
                 FillListViewItem(selectedGameSave, gameSaves[selectedIndex]);
                 if (reloadNeeded)
                 {
                     try {
                         PokeManager.ReloadGameSave(selectedGameSave);
                     }
                     catch (Exception ex) {
                         result = TriggerMessageBox.Show(this, "Error loading save after changing game type, this may not be the correct game type for it. Would you like to see the error?", "Load Error", MessageBoxButton.YesNo);
                         if (result == MessageBoxResult.Yes)
                         {
                             ErrorMessageBox.Show(ex);
                         }
                     }
                 }
             }
         }
     }
     else
     {
         // No need
         TriggerMessageBox.Show(this, "Only one game type applies to this save");
     }
 }
        private void OnRegisterClicked(object sender, RoutedEventArgs e)
        {
            if (SecretBaseManager.RegistrationCount < 10 || ((SharedSecretBase)secretBase).IsRegistered)
            {
                ((SharedSecretBase)secretBase).IsRegistered = !((SharedSecretBase)secretBase).IsRegistered;

                buttonRegister.Content = ((SharedSecretBase)secretBase).IsRegistered ? "Unregister" : "Register";
                UpdateListViewItems();
            }
            else
            {
                TriggerMessageBox.Show(Window.GetWindow(this), "You can only have 10 Secret Bases registered per game.", "Can't Register");
            }
        }
 private void OnDeleteBox(object sender, RoutedEventArgs e)
 {
     if (selectedBox.NumPokemon > 0)
     {
         TriggerMessageBox.Show(this, "Cannot remove a box containing Pokémon. Release them first.", "Remove Box");
     }
     else if (pokePC.NumBoxes > 1 && selectedIndex < pokePC.NumBoxes && selectedIndex != -1)
     {
         pokePC.RemoveBoxAt(selectedIndex);
         boxes.RemoveAt(selectedIndex);
         UpdateBoxNames();
         pokeBoxControl.UnloadBox();
         selectedIndex = -1;
     }
 }
        public static MessageBoxResult Show(Window window, string message, string title, MessageBoxButton buttons, string buttonName1 = null, string buttonName2 = null, string buttonName3 = null)
        {
            TriggerMessageBox messageBox = new TriggerMessageBox(title, message, buttons, buttonName1, buttonName2, buttonName3);

            if (window == null || window.Visibility != Visibility.Visible)
            {
                messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            }
            else
            {
                messageBox.Owner = window;
            }
            messageBox.ShowDialog();
            return(messageBox.result);
        }
        private void OnExportClicked(object sender, RoutedEventArgs e)
        {
            SharedSecretBase finalSecretBase;

            if (secretBase.IsPlayerSecretBase)
            {
                finalSecretBase = new SharedSecretBase((PlayerSecretBase)secretBase, null);
            }
            else
            {
                finalSecretBase = new SharedSecretBase((SharedSecretBase)secretBase, null);
            }
            if (IsGBAGame && secretBase.IsPlayerSecretBase)
            {
                MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Would you like to edit your Secret Base's trainer before exporting?", "Edit Trainer", MessageBoxButton.YesNo);
                if (result2 == MessageBoxResult.Yes)
                {
                    finalSecretBase = new SharedSecretBase((PlayerSecretBase)secretBase, null);

                    SecretBaseEditTrainerWindow.Show(Window.GetWindow(this), finalSecretBase, true);
                }
            }
            SaveFileDialog fileDialog = new SaveFileDialog();

            fileDialog.Title        = "Export Secret Base";
            fileDialog.AddExtension = true;
            fileDialog.DefaultExt   = ".scrtb";
            fileDialog.FileName     = finalSecretBase.TrainerName + "'s Base";
            fileDialog.Filter       = "Secret Base Files (*.scrtb)|*.scrtb|All Files (*.*)|*.*";
            var result = fileDialog.ShowDialog(Window.GetWindow(this));

            if (result.HasValue && result.Value)
            {
                string filePath = fileDialog.FileName;
                filePath = System.IO.Path.GetFullPath(filePath);

                try {
                    File.WriteAllBytes(filePath, finalSecretBase.GetFinalData());
                }
                catch (Exception ex) {
                    MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Error saving Secret Base file. Would you like to see the error?", "Export Error", MessageBoxButton.YesNo);
                    if (result2 == MessageBoxResult.Yes)
                    {
                        ErrorMessageBox.Show(ex);
                    }
                }
            }
        }
Пример #20
0
 private void OnActivateClicked(object sender, RoutedEventArgs e)
 {
     if (selectedEvent.HasRoomForReward(gameSave))
     {
         this.buttonActivate.IsEnabled = false;
         selectedEvent.GenerateReward(gameSave);
         selectedEvent.GiveReward(gameSave);
         PokeManager.CompleteEventBy(selectedEvent.ID, gameSave);
         UpdateEvents();
     }
     else
     {
         TriggerMessageBox.Show(Window.GetWindow(this),
                                "There's no room for this event, make room in your " +
                                (selectedEvent.RewardType == EventRewardTypes.Pokemon ? "PC" : "Bag") + " for the reward", "No Room"
                                );
     }
 }
Пример #21
0
        private void OnMailSendTo(object sender, EventArgs e)
        {
            int?result = SendMailToWindow.ShowDialog(Window.GetWindow(this), mailbox.GameSave.GameIndex);

            if (result != null)
            {
                if (PokeManager.GetGameSaveAt(result.Value).Mailbox.HasRoomForMail)
                {
                    PokeManager.GetGameSaveAt(result.Value).Mailbox.AddMail(selectedMail);
                    mailbox.TossMailAt(selectedIndex);
                }
                else
                {
                    // No room for item
                    TriggerMessageBox.Show(Window.GetWindow(this), "No room for that mail. Mailbox is full", "No Room");
                }
            }
        }
Пример #22
0
        private void OnSendToClicked(object sender, RoutedEventArgs e)
        {
            IPokemon pokemon = clickSelection.Tag as IPokemon;

            if (pokemon.ContainerIndex == -1)
            {
                pokemon            = pokemon.PokemonFinder.Pokemon;
                clickSelection.Tag = pokemon;
            }
            if (pokemon.IsReleased)
            {
                TriggerMessageBox.Show(this, "Cannot send this Pokémon, it has been released", "Released Pokémon");
            }
            else if (pokemon.IsMoving)
            {
                TriggerMessageBox.Show(this, "Cannot send a Pokémon while it is being moved", "Moving Pokémon");
            }
            else if (pokemon.ContainerIndex == -1)
            {
                TriggerMessageBox.Show(this, "The Search Results have lost track of " + pokemon.Nickname + " because it has been moved to a different game. This should not happen. Let me know if it does.", "Can't Find Pokémon");
            }

            /*else if (pokemon.PokeContainer.Type == ContainerTypes.Purifier) {
             *      TriggerMessageBox.Show(this, "Cannot send Pokémon in the Purifier", "Can't Send");
             * }*/
            else if (pokemon.IsShadowPokemon)
            {
                TriggerMessageBox.Show(this, "Cannot send Shadow Pokémon to other games", "Can't Send");
            }
            else if (PokeManager.CanPickupPokemon(pokemon))
            {
                SendPokemonToWindow.ShowSendToDialog(PokeManager.ManagerWindow, pokemon.PokePC.GameIndex, pokemon);
                PokeManager.RefreshUI();
            }
            else if (PokeManager.IsPartyHoldingMail(pokemon.PokeContainer))
            {
                TriggerMessageBox.Show(this, "Cannot send that Pokémon. One of the Pokémon in your party is holding mail. To remove the mail goto the mailbox tab and click Take Mail From Party", "Can't Send");
            }
            else
            {
                TriggerMessageBox.Show(this, "Cannot send that Pokémon. It is the last valid Pokémon in your party", "Can't Send");
            }
        }
Пример #23
0
        private void OnPokeblockSendTo(object sender, EventArgs e)
        {
            int?result = SendPokeblockToWindow.ShowDialog(Window.GetWindow(this), blockCase.Inventory.GameIndex);

            if (result != null)
            {
                if (HasSelection)
                {
                    bool noRoom = false;
                    foreach (Pokeblock block in SelectedBlocks)
                    {
                        if (PokeManager.GetGameSaveAt(result.Value).Inventory.Pokeblocks.HasRoomForPokeblock)
                        {
                            PokeManager.GetGameSaveAt(result.Value).Inventory.Pokeblocks.AddPokeblock(block);
                            blockCase.TossPokeblockAt(blockCase.IndexOf(block));
                        }
                        else
                        {
                            noRoom = true;
                        }
                    }
                    if (noRoom)
                    {
                        TriggerMessageBox.Show(Window.GetWindow(this), "The Pokéblock Case filled up before all of the selection could be sent", "No Room");
                    }
                }
                else
                {
                    if (PokeManager.GetGameSaveAt(result.Value).Inventory.Pokeblocks.HasRoomForPokeblock)
                    {
                        PokeManager.GetGameSaveAt(result.Value).Inventory.Pokeblocks.AddPokeblock(selectedBlock);
                        blockCase.TossPokeblockAt(selectedIndex);
                    }
                    else
                    {
                        // No room for item
                        TriggerMessageBox.Show(Window.GetWindow(this), "No room for that Pokéblock", "No Room");
                    }
                }
            }
        }
        private void OnRemoveRow(object sender, RoutedEventArgs e)
        {
            int numPokemon = 0;

            foreach (IPokemon pokmeon in PokeManager.ManagerGameSave.GetPokePCRow(rowIndex))
            {
                numPokemon++;
            }
            if (numPokemon > 0)
            {
                TriggerMessageBox.Show(this, "Cannot remove a row containing boxes with Pokémon in them. Release them first.", "Remove Row");
            }
            else if (PokeManager.ManagerGameSave.NumPokePCRows > 1 && rowIndex < PokeManager.ManagerGameSave.NumPokePCRows)
            {
                PokeManager.ManagerGameSave.RemovePokePCRow(rowIndex);
                comboBoxRows.ReloadRows();
                buttonRemoveRow.IsEnabled   = PokeManager.ManagerGameSave.NumPokePCRows > 1;
                buttonMoveRowUp.IsEnabled   = rowIndex != 0;
                buttonMoveRowDown.IsEnabled = rowIndex + 1 < PokeManager.ManagerGameSave.NumPokePCRows;
            }
        }
 private void OnRemoveImageClicked(object sender, RoutedEventArgs e)
 {
     if (PokeManager.CustomTrainerImage != null)
     {
         try {
             if (File.Exists(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Trainer", "Trainer.png")))
             {
                 File.Delete(System.IO.Path.Combine(PokeManager.ApplicationDirectory, "Resources", "Trainer", "Trainer.png"));
             }
         }
         catch (Exception ex) {
             TriggerMessageBox.Show(this, "Error trying to delete custom trainer image file", "File Error");
         }
         PokeManager.CustomTrainerImage = null;
         BitmapSource trainerImage = PokeManager.TrainerImage;
         imageTrainer.Width  = Math.Min(90, trainerImage.PixelWidth);
         imageTrainer.Height = Math.Min(138, trainerImage.PixelHeight);
         imageTrainer.Source = trainerImage;
         this.buttonRemoveImage.IsEnabled = false;
     }
 }
        private void OnRemoveSave(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = TriggerMessageBox.Show(this, "Are you sure you want to remove this game save?", "Remove Save", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes && selectedGameSave.GameSave.IsChanged)
            {
                result = TriggerMessageBox.Show(this, "Would you like to save changes made to this game before removing it?", "Save Changes", MessageBoxButton.YesNoCancel);
            }

            if (result == MessageBoxResult.Yes && selectedGameSave.GameSave.IsChanged)
            {
                selectedGameSave.GameSave.Save(selectedGameSave.FilePath);
            }

            if (result != MessageBoxResult.Cancel)
            {
                gameSaves.RemoveAt(selectedIndex);
                selectedIndex    = -1;
                selectedGameSave = null;
            }
        }
Пример #27
0
        private void OnWindowClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (playerCry != null)
            {
                playerCry.Close();
            }
            if (playerEvolutionCry != null)
            {
                playerEvolutionCry.Close();
            }
            playerMusic.Close();

            ushort[] moves = PokemonDatabase.GetMovesLearnedAtLevel(pokemon);
            foreach (ushort moveID in moves)
            {
                Move move = new Move(moveID);
                if (pokemon.NumMoves == 4)
                {
                    var result = LearnMoveWindow.ShowDialog(Window.GetWindow(this), pokemon, move.ID);
                    if (result.HasValue && result.Value)
                    {
                        TriggerMessageBox.Show(this, pokemon.Nickname + " learned " + move.MoveData.Name + "!", "Move Learned");
                        PokeManager.RefreshUI();
                    }
                }
                else
                {
                    pokemon.SetMoveAt(pokemon.NumMoves, move);
                    TriggerMessageBox.Show(this, pokemon.Nickname + " learned " + move.MoveData.Name + "!", "Move Learned");
                    PokeManager.RefreshUI();
                }
            }

            if (shedinjaAdded)
            {
                TriggerMessageBox.Show(PokeManager.ManagerWindow, "A Shedinja has appeared from the shed exoskeleton of " + pokemon.Nickname, "New Pokémon");
            }
        }
Пример #28
0
 private void OnDepositAll(object sender, EventArgs e)
 {
     if (HasSelection)
     {
         bool noRoom = false;
         foreach (Item item in SelectedItems)
         {
             ItemTypes pocketType = (pocket.PocketType == ItemTypes.PC ? item.ItemData.PocketType : ItemTypes.PC);
             if (pocket.Inventory[pocketType].HasRoomForItem(item.ID, item.Count))
             {
                 pocket.Inventory[pocketType].AddItem(item.ID, item.Count);
                 pocket.TossItemAt(pocket.IndexOf(item), item.Count);
             }
             else
             {
                 noRoom = true;
             }
         }
         if (noRoom)
         {
             TriggerMessageBox.Show(Window.GetWindow(this), "The pocket filled up before all of the selection could be sent", "No Room");
         }
     }
     else
     {
         ItemTypes pocketType = (pocket.PocketType == ItemTypes.PC ? selectedItem.ItemData.PocketType : ItemTypes.PC);
         if (pocket.Inventory[pocketType].HasRoomForItem(selectedItem.ID, selectedItem.Count))
         {
             pocket.Inventory[pocketType].AddItem(selectedItem.ID, selectedItem.Count);
             pocket.TossItemAt(selectedIndex);
         }
         else
         {
             // No room for item
             TriggerMessageBox.Show(Window.GetWindow(this), "No room for that item", "No Room");
         }
     }
 }
Пример #29
0
 private void OnOKClicked(object sender, RoutedEventArgs e)
 {
     //newNameRaw = GBACharacterEncoding.GetString(GBACharacterEncoding.GetBytes(textBoxName.Text, 7, newLanguage), newLanguage);
     if (NewName.Length == 0)
     {
         TriggerMessageBox.Show(this, "Trainer name cannot be empty", "Name Required");
     }
     else if (newPokemonTeam.Count != 0 || allowNoTeam)
     {
         secretBase.Language       = newLanguage;
         secretBase.TrainerNameRaw = newNameRaw;
         secretBase.TrainerGender  = newGender;
         secretBase.TrainerID      = newTrainerID;
         secretBase.SecretID       = newSecretID;
         secretBase.PokemonTeam.Clear();
         secretBase.PokemonTeam.AddRange(newPokemonTeam);
         DialogResult = true;
     }
     else
     {
         TriggerMessageBox.Show(this, "You must add at least one Pokémon to the team for this Secret Base", "Team Required");
     }
 }
Пример #30
0
        private void OnTossAll(object sender, EventArgs e)
        {
            MessageBoxResult result = MessageBoxResult.Yes;

            if (HasSelection)
            {
                if (PokeManager.Settings.TossConfirmation)
                {
                    result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + listViewItems.SelectedItems.Count + " items?", "Toss Items", MessageBoxButton.YesNo);
                }
                if (result == MessageBoxResult.Yes)
                {
                    foreach (Item item in SelectedItems)
                    {
                        pocket.TossItemAt(pocket.IndexOf(item), item.Count);
                    }
                }
            }
            else
            {
                if (PokeManager.Settings.TossConfirmation)
                {
                    if (selectedItem.Count == 1)
                    {
                        result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedItem.ItemData.Name + "?", "Toss Item", MessageBoxButton.YesNo);
                    }
                    else
                    {
                        result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedItem.Count + " " + selectedItem.ItemData.Name + "s?", "Toss Item", MessageBoxButton.YesNo);
                    }
                }
                if (result == MessageBoxResult.Yes)
                {
                    pocket.TossItemAt(selectedIndex);
                }
            }
        }
 public static MessageBoxResult Show(Window window, string message, string title, MessageBoxButton buttons, string buttonName1 = null, string buttonName2 = null, string buttonName3 = null)
 {
     TriggerMessageBox messageBox = new TriggerMessageBox(title, message, buttons, buttonName1, buttonName2, buttonName3);
     if (window == null || window.Visibility != Visibility.Visible)
         messageBox.WindowStartupLocation = WindowStartupLocation.CenterScreen;
     else
         messageBox.Owner = window;
     messageBox.ShowDialog();
     return messageBox.result;
 }