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");
     }
 }
 public SharedSecretBase AddSecretBase(PlayerSecretBase secretBase)
 {
     GameSave.IsChanged = true;
     SharedSecretBase newSecretBase = new SharedSecretBase(secretBase, this);
     secretBases.Add(newSecretBase);
     Sort();
     return newSecretBase;
 }
Example #3
0
        public static bool Show(Window owner, SharedSecretBase secretBase, bool allowNoTeam, bool creating = false)
        {
            SecretBaseEditTrainerWindow window = new SecretBaseEditTrainerWindow(secretBase, allowNoTeam, creating);

            window.Owner = owner;
            var result = window.ShowDialog();

            return(result.HasValue ? result.Value : false);
        }
        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);
                    }
                }
            }
        }
        private void OnSendToClicked(object sender, RoutedEventArgs e)
        {
            if (secretBase.HasTeam) {
                var gameIndex = SecretBaseSendToWindow.ShowDialog(Window.GetWindow(this), gameSave.GameIndex);

                if (gameIndex.HasValue) {
                    if (gameIndex.Value == -1) {
                        PokeManager.AddSecretBase(secretBase);
                    }
                    else {
                        GBAGameSave sendToGameSave = (GBAGameSave)PokeManager.GetGameSaveAt(gameIndex.Value);
                        if (sendToGameSave.SecretBaseManager.SharedSecretBases.Count < 19) {
                            if (sendToGameSave.SecretBaseManager.IsLocationInUse(secretBase.LocationID)) {
                                MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Cannot send this Secret Base because its location is already in use. Would you like to select a new location?", "Location in Use", MessageBoxButton.YesNo);
                                if (result2 == MessageBoxResult.Yes) {
                                    byte? location = SecretBaseLocationChooser.Show(Window.GetWindow(this), secretBase.LocationID, sendToGameSave.SecretBaseManager, true);
                                    if (location.HasValue && location.Value != 0 && !sendToGameSave.SecretBaseManager.IsLocationInUse(location.Value)) {
                                        SharedSecretBase newSecretBase;
                                        if (secretBase.IsPlayerSecretBase)
                                            newSecretBase = new SharedSecretBase((PlayerSecretBase)secretBase, null);
                                        else
                                            newSecretBase = new SharedSecretBase((SharedSecretBase)secretBase, null);
                                        newSecretBase.SetNewLocation(location.Value);
                                        sendToGameSave.SecretBaseManager.AddSecretBase((SharedSecretBase)newSecretBase);
                                    }
                                }
                            }
                            else {
                                if (secretBase.IsPlayerSecretBase)
                                    sendToGameSave.SecretBaseManager.AddSecretBase((PlayerSecretBase)secretBase);
                                else
                                    sendToGameSave.SecretBaseManager.AddSecretBase((SharedSecretBase)secretBase);
                            }
                        }
                        else {
                            TriggerMessageBox.Show(Window.GetWindow(this), "This game already has the maximum amount of 19 shared Secret Bases", "Can't Send");
                        }
                    }
                }
            }
            else {
                TriggerMessageBox.Show(Window.GetWindow(this), "You cannot send a Secret Base without a Pokémon Team", "Can't Send");
            }
        }
        private void OnImportClicked(object sender, RoutedEventArgs e)
        {
            if (!IsGBAGame || GBAGameSave.SecretBaseManager.SharedSecretBases.Count < 19) {
                OpenFileDialog fileDialog = new OpenFileDialog();
                fileDialog.Title = "Import Secret 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 {
                        FileInfo fileInfo = new FileInfo(filePath);
                        if (fileInfo.Length != 160) {
                            TriggerMessageBox.Show(Window.GetWindow(this), "Cannot import Secret Base. A Secret Base file must be 160 bytes in size", "Import Error");
                        }
                        else {
                            SharedSecretBase newSecretBase = new SharedSecretBase(File.ReadAllBytes(filePath), null);
                            foreach (PlacedDecoration decoration in newSecretBase.PlacedDecorations) {
                                if (decoration.DecorationData == null)
                                    throw new Exception("Invalid Decoration ID in Secret Base. ID=" + decoration.ID);
                            }
                            if (IsGBAGame) {
                                bool added = false;
                                if (GBAGameSave.SecretBaseManager.IsLocationInUse(newSecretBase.LocationID)) {
                                    MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Cannot import this Secret Base because its location is already in use. Would you like to select a new location?", "Location in Use", MessageBoxButton.YesNo);
                                    if (result2 == MessageBoxResult.Yes) {
                                        byte? location = SecretBaseLocationChooser.Show(Window.GetWindow(this), newSecretBase.LocationID, GBAGameSave.SecretBaseManager, true);
                                        if (location.HasValue && location.Value != 0 && !GBAGameSave.SecretBaseManager.IsLocationInUse(location.Value)) {
                                            newSecretBase.SetNewLocation(location.Value);
                                            added = true;
                                        }
                                    }
                                }
                                else {
                                    added = true;
                                }
                                if (added && newSecretBase.PokemonTeam.Count == 0) {
                                    MessageBoxResult result3 = TriggerMessageBox.Show(Window.GetWindow(this), "This Secret Base has no Pokemon in its Team. You will need to add at least one Pokémon in order to import this Secret Base. Would you like to continue?", "No Team", MessageBoxButton.YesNo);
                                    if (result3 == MessageBoxResult.Yes) {
                                        added = SecretBaseEditTrainerWindow.Show(Window.GetWindow(this), newSecretBase, false);
                                    }
                                }
                                if (added) {
                                    newSecretBase = GBAGameSave.SecretBaseManager.AddSecretBase(newSecretBase);
                                    AddListViewItems();
                                    listViewSecretBases.SelectedIndex = 2 + GBAGameSave.SecretBaseManager.SharedSecretBases.IndexOf(newSecretBase);
                                    listViewSecretBases.ScrollIntoView(listViewSecretBases.SelectedItem);
                                    ((Control)listViewSecretBases.SelectedItem).Focus();
                                    /*for (int i = 0; i < GBAGameSave.SecretBaseManager.SharedSecretBases.Count; i++) {
                                        if (GBAGameSave.SecretBaseManager.SharedSecretBases[i] == newSecretBase) {
                                            listViewSecretBases.SelectedIndex = i + 2;
                                            break;
                                        }
                                    }*/
                                }
                            }
                            else {
                                newSecretBase = PokeManager.AddSecretBase(newSecretBase);
                                AddListViewItems();
                                listViewSecretBases.SelectedIndex = PokeManager.SecretBases.IndexOf(newSecretBase);
                                listViewSecretBases.ScrollIntoView(listViewSecretBases.SelectedItem);
                                ((Control)listViewSecretBases.SelectedItem).Focus();
                                /*for (int i = 0; i < PokeManager.SecretBases.Count; i++) {
                                    if (PokeManager.SecretBases[i] == newSecretBase) {
                                         = i;
                                        break;
                                    }
                                }*/
                            }
                        }
                    }
                    catch (Exception ex) {
                        MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Error reading Secret Base file. Would you like to see the error?", "Import Error", MessageBoxButton.YesNo);
                        if (result2 == MessageBoxResult.Yes)
                            ErrorMessageBox.Show(ex);
                    }
                }
            }
            else {
                TriggerMessageBox.Show(Window.GetWindow(this), "This game already has the maximum amount of 19 shared Secret Bases", "Can't Import");
            }
        }
        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);
                }
            }
        }
 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");
     }
 }
        private void OnImportClicked(object sender, RoutedEventArgs e)
        {
            if (!IsGBAGame || GBAGameSave.SecretBaseManager.SharedSecretBases.Count < 19)
            {
                OpenFileDialog fileDialog = new OpenFileDialog();
                fileDialog.Title  = "Import Secret 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 {
                        FileInfo fileInfo = new FileInfo(filePath);
                        if (fileInfo.Length != 160)
                        {
                            TriggerMessageBox.Show(Window.GetWindow(this), "Cannot import Secret Base. A Secret Base file must be 160 bytes in size", "Import Error");
                        }
                        else
                        {
                            SharedSecretBase newSecretBase = new SharedSecretBase(File.ReadAllBytes(filePath), null);
                            foreach (PlacedDecoration decoration in newSecretBase.PlacedDecorations)
                            {
                                if (decoration.DecorationData == null)
                                {
                                    throw new Exception("Invalid Decoration ID in Secret Base. ID=" + decoration.ID);
                                }
                            }
                            if (IsGBAGame)
                            {
                                bool added = false;
                                if (GBAGameSave.SecretBaseManager.IsLocationInUse(newSecretBase.LocationID))
                                {
                                    MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Cannot import this Secret Base because its location is already in use. Would you like to select a new location?", "Location in Use", MessageBoxButton.YesNo);
                                    if (result2 == MessageBoxResult.Yes)
                                    {
                                        byte?location = SecretBaseLocationChooser.Show(Window.GetWindow(this), newSecretBase.LocationID, GBAGameSave.SecretBaseManager, true);
                                        if (location.HasValue && location.Value != 0 && !GBAGameSave.SecretBaseManager.IsLocationInUse(location.Value))
                                        {
                                            newSecretBase.SetNewLocation(location.Value);
                                            added = true;
                                        }
                                    }
                                }
                                else
                                {
                                    added = true;
                                }
                                if (added && newSecretBase.PokemonTeam.Count == 0)
                                {
                                    MessageBoxResult result3 = TriggerMessageBox.Show(Window.GetWindow(this), "This Secret Base has no Pokemon in its Team. You will need to add at least one Pokémon in order to import this Secret Base. Would you like to continue?", "No Team", MessageBoxButton.YesNo);
                                    if (result3 == MessageBoxResult.Yes)
                                    {
                                        added = SecretBaseEditTrainerWindow.Show(Window.GetWindow(this), newSecretBase, false);
                                    }
                                }
                                if (added)
                                {
                                    newSecretBase = GBAGameSave.SecretBaseManager.AddSecretBase(newSecretBase);
                                    AddListViewItems();
                                    listViewSecretBases.SelectedIndex = 2 + GBAGameSave.SecretBaseManager.SharedSecretBases.IndexOf(newSecretBase);
                                    listViewSecretBases.ScrollIntoView(listViewSecretBases.SelectedItem);
                                    ((Control)listViewSecretBases.SelectedItem).Focus();

                                    /*for (int i = 0; i < GBAGameSave.SecretBaseManager.SharedSecretBases.Count; i++) {
                                     *      if (GBAGameSave.SecretBaseManager.SharedSecretBases[i] == newSecretBase) {
                                     *              listViewSecretBases.SelectedIndex = i + 2;
                                     *              break;
                                     *      }
                                     * }*/
                                }
                            }
                            else
                            {
                                newSecretBase = PokeManager.AddSecretBase(newSecretBase);
                                AddListViewItems();
                                listViewSecretBases.SelectedIndex = PokeManager.SecretBases.IndexOf(newSecretBase);
                                listViewSecretBases.ScrollIntoView(listViewSecretBases.SelectedItem);
                                ((Control)listViewSecretBases.SelectedItem).Focus();

                                /*for (int i = 0; i < PokeManager.SecretBases.Count; i++) {
                                 *      if (PokeManager.SecretBases[i] == newSecretBase) {
                                 *               = i;
                                 *              break;
                                 *      }
                                 * }*/
                            }
                        }
                    }
                    catch (Exception ex) {
                        MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Error reading Secret Base file. Would you like to see the error?", "Import Error", MessageBoxButton.YesNo);
                        if (result2 == MessageBoxResult.Yes)
                        {
                            ErrorMessageBox.Show(ex);
                        }
                    }
                }
            }
            else
            {
                TriggerMessageBox.Show(Window.GetWindow(this), "This game already has the maximum amount of 19 shared Secret Bases", "Can't Import");
            }
        }
        private void OnSendToClicked(object sender, RoutedEventArgs e)
        {
            if (secretBase.HasTeam)
            {
                var gameIndex = SecretBaseSendToWindow.ShowDialog(Window.GetWindow(this), gameSave.GameIndex);

                if (gameIndex.HasValue)
                {
                    if (gameIndex.Value == -1)
                    {
                        PokeManager.AddSecretBase(secretBase);
                    }
                    else
                    {
                        GBAGameSave sendToGameSave = (GBAGameSave)PokeManager.GetGameSaveAt(gameIndex.Value);
                        if (sendToGameSave.SecretBaseManager.SharedSecretBases.Count < 19)
                        {
                            if (sendToGameSave.SecretBaseManager.IsLocationInUse(secretBase.LocationID))
                            {
                                MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Cannot send this Secret Base because its location is already in use. Would you like to select a new location?", "Location in Use", MessageBoxButton.YesNo);
                                if (result2 == MessageBoxResult.Yes)
                                {
                                    byte?location = SecretBaseLocationChooser.Show(Window.GetWindow(this), secretBase.LocationID, sendToGameSave.SecretBaseManager, true);
                                    if (location.HasValue && location.Value != 0 && !sendToGameSave.SecretBaseManager.IsLocationInUse(location.Value))
                                    {
                                        SharedSecretBase newSecretBase;
                                        if (secretBase.IsPlayerSecretBase)
                                        {
                                            newSecretBase = new SharedSecretBase((PlayerSecretBase)secretBase, null);
                                        }
                                        else
                                        {
                                            newSecretBase = new SharedSecretBase((SharedSecretBase)secretBase, null);
                                        }
                                        newSecretBase.SetNewLocation(location.Value);
                                        sendToGameSave.SecretBaseManager.AddSecretBase((SharedSecretBase)newSecretBase);
                                    }
                                }
                            }
                            else
                            {
                                if (secretBase.IsPlayerSecretBase)
                                {
                                    sendToGameSave.SecretBaseManager.AddSecretBase((PlayerSecretBase)secretBase);
                                }
                                else
                                {
                                    sendToGameSave.SecretBaseManager.AddSecretBase((SharedSecretBase)secretBase);
                                }
                            }
                        }
                        else
                        {
                            TriggerMessageBox.Show(Window.GetWindow(this), "This game already has the maximum amount of 19 shared Secret Bases", "Can't Send");
                        }
                    }
                }
            }
            else
            {
                TriggerMessageBox.Show(Window.GetWindow(this), "You cannot send a Secret Base without a Pokémon Team", "Can't Send");
            }
        }
        public SecretBaseEditTrainerWindow(SharedSecretBase secretBase, bool allowNoTeam, bool creating)
        {
            InitializeComponent();

            this.secretBase = secretBase;
            this.newNameRaw = secretBase.TrainerNameRaw;
            this.newGender = secretBase.TrainerGender;
            this.newTrainerID = secretBase.TrainerID;
            this.newSecretID = secretBase.SecretID;
            this.newLanguage = secretBase.Language;
            this.newPokemonTeam = new List<GBAPokemon>();
            this.newPokemonTeam.AddRange(secretBase.PokemonTeam);

            this.allowNoTeam = allowNoTeam;
            this.creating = creating;

            this.textBoxName.Text = secretBase.TrainerName;
            this.numericTrainerID.Value = secretBase.TrainerID;
            this.numericSecretID.Value = secretBase.SecretID;
            this.radioButtonMale.IsChecked = secretBase.TrainerGender == Genders.Male;
            this.radioButtonFemale.IsChecked = secretBase.TrainerGender == Genders.Female;

            for (int i = 0; i < 5; i++)
                this.comboBoxTrainer.Items.Add(new ComboBoxItem());

            int index = 0;
            for (Languages langauge = Languages.Japanese; langauge <= Languages.Spanish; langauge++) {
                if (langauge == Languages.Korean)
                    continue;
                ComboBoxItem comboBoxItem = new ComboBoxItem();
                comboBoxItem.Content = langauge.ToString();
                comboBoxItem.Tag = langauge;
                comboBoxLanguage.Items.Add(comboBoxItem);
                if (langauge == secretBase.Language)
                    comboBoxLanguage.SelectedIndex = index;
                index++;
            }

            this.comboBoxTrainer.SelectedIndex = (secretBase.TrainerID % 256) % 5;

            RefreshTrainer();
            RefreshTeam();

            this.contextMenu = new ContextMenu();
            MenuItem change = new MenuItem();
            change.Header = "Change";
            change.Click += OnSetPokemon;
            MenuItem remove = new MenuItem();
            remove.Header = "Remove";
            remove.Click += OnRemovePokemon;

            this.contextMenu.Items.Add(change);
            this.contextMenu.Items.Add(remove);

            if (secretBase.Language == Languages.Japanese)
                textBoxName.MaxLength = 5;
            else
                textBoxName.MaxLength = 7;

            loaded = true;
        }
 public static bool Show(Window owner, byte locationID, SecretBaseManager manager, bool allowNoTeam)
 {
     SharedSecretBase secretBase = new SharedSecretBase(locationID, manager);
     return Show(owner, secretBase, allowNoTeam, true);
 }
 public static bool Show(Window owner, SharedSecretBase secretBase, bool allowNoTeam, bool creating = false)
 {
     SecretBaseEditTrainerWindow window = new SecretBaseEditTrainerWindow(secretBase, allowNoTeam, creating);
     window.Owner = owner;
     var result = window.ShowDialog();
     return (result.HasValue ? result.Value : false);
 }
Example #14
0
        public SecretBaseEditTrainerWindow(SharedSecretBase secretBase, bool allowNoTeam, bool creating)
        {
            InitializeComponent();

            this.secretBase     = secretBase;
            this.newNameRaw     = secretBase.TrainerNameRaw;
            this.newGender      = secretBase.TrainerGender;
            this.newTrainerID   = secretBase.TrainerID;
            this.newSecretID    = secretBase.SecretID;
            this.newLanguage    = secretBase.Language;
            this.newPokemonTeam = new List <GBAPokemon>();
            this.newPokemonTeam.AddRange(secretBase.PokemonTeam);

            this.allowNoTeam = allowNoTeam;
            this.creating    = creating;

            this.textBoxName.Text            = secretBase.TrainerName;
            this.numericTrainerID.Value      = secretBase.TrainerID;
            this.numericSecretID.Value       = secretBase.SecretID;
            this.radioButtonMale.IsChecked   = secretBase.TrainerGender == Genders.Male;
            this.radioButtonFemale.IsChecked = secretBase.TrainerGender == Genders.Female;

            for (int i = 0; i < 5; i++)
            {
                this.comboBoxTrainer.Items.Add(new ComboBoxItem());
            }

            int index = 0;

            for (Languages langauge = Languages.Japanese; langauge <= Languages.Spanish; langauge++)
            {
                if (langauge == Languages.Korean)
                {
                    continue;
                }
                ComboBoxItem comboBoxItem = new ComboBoxItem();
                comboBoxItem.Content = langauge.ToString();
                comboBoxItem.Tag     = langauge;
                comboBoxLanguage.Items.Add(comboBoxItem);
                if (langauge == secretBase.Language)
                {
                    comboBoxLanguage.SelectedIndex = index;
                }
                index++;
            }

            this.comboBoxTrainer.SelectedIndex = (secretBase.TrainerID % 256) % 5;

            RefreshTrainer();
            RefreshTeam();

            this.contextMenu = new ContextMenu();
            MenuItem change = new MenuItem();

            change.Header = "Change";
            change.Click += OnSetPokemon;
            MenuItem remove = new MenuItem();

            remove.Header = "Remove";
            remove.Click += OnRemovePokemon;

            this.contextMenu.Items.Add(change);
            this.contextMenu.Items.Add(remove);

            if (secretBase.Language == Languages.Japanese)
            {
                textBoxName.MaxLength = 5;
            }
            else
            {
                textBoxName.MaxLength = 7;
            }

            loaded = true;
        }
Example #15
0
        public static bool Show(Window owner, byte locationID, SecretBaseManager manager, bool allowNoTeam)
        {
            SharedSecretBase secretBase = new SharedSecretBase(locationID, manager);

            return(Show(owner, secretBase, allowNoTeam, true));
        }