private void GameChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) { return; } gameIndex = comboBoxGame.SelectedGameIndex; if (gameIndex >= -1) { int max = Math.Min((int)GetCurrency(SendFromGameIndex), (int)GetMaxCurrency(SendToGameIndex) - (int)GetCurrency(SendToGameIndex)); if (max <= 0) { max = 0; upDownCurrencyCount.Value = 0; upDownCurrencyCount.Maximum = 0; } else { upDownCurrencyCount.Value = Math.Min(amount, max); upDownCurrencyCount.Maximum = max; } labelName1.Content = PokeManager.GetGameSaveAt(SendFromGameIndex).TrainerName + "'s"; labelName2.Content = PokeManager.GetGameSaveAt(SendToGameIndex).TrainerName + "'s"; labelCurrency1.Content = FormatCurrencyString(GetCurrency(SendFromGameIndex)); labelCurrency2.Content = FormatCurrencyString(GetCurrency(SendToGameIndex)); } else { } }
public SelectItemWindow(ushort[] validItemIDs, ItemTypes[] pocketTypes, string windowName, string buttonName, bool pcDefault) { InitializeComponent(); selectedIndex = -1; selectedItem = null; this.validItemIDs = validItemIDs; this.pocketTypes = pocketTypes; this.Title = windowName; this.buttonOK.Content = buttonName; this.pcDefault = pcDefault; for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType == GameTypes.PokemonBox) { comboBoxGame.SetGameSaveVisible(i, false); } } comboBoxGame.SelectedGameIndex = -1; //comboBoxPocket.Items.Add("Items"); //comboBoxPocket.SelectedIndex = 0; loaded = true; OnGameSelectionChanged(null, null); }
public GiveItemWindow(IGameSave gameSave) { InitializeComponent(); selectedIndex = -1; selectedItem = null; this.gameIndex = gameSave.GameIndex; for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType == GameTypes.PokemonBox) { comboBoxGame.SetGameSaveVisible(i, false); } } if (gameSave.GameType != GameTypes.PokemonBox) { comboBoxGame.SelectedGameIndex = gameIndex; } else { comboBoxGame.SelectedGameIndex = -1; } loaded = true; OnGameSelectionChanged(null, null); }
public SecretBaseSendToWindow(int gameIndex) { InitializeComponent(); loaded = false; for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (i == gameIndex) { comboBoxGame.SetGameSaveVisible(i, false); continue; } IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType != GameTypes.Ruby && game.GameType != GameTypes.Sapphire && game.GameType != GameTypes.Emerald && game.GameType != GameTypes.Any) { comboBoxGame.SetGameSaveVisible(i, false); } } this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; GameChanged(null, null); }
public ReplaceBallWindow(IPokemon pokemon) { InitializeComponent(); ballID = 0; selectedIndex = -1; selectedItem = null; this.pokemon = pokemon; for (int i = 0; i < PokeManager.NumGameSaves; i++) { IGameSave game = (IGameSave)PokeManager.GetGameSaveAt(i); if (game.GameType == GameTypes.PokemonBox) { comboBoxGame.SetGameSaveVisible(i, false); } } this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { comboBoxGame.SelectedIndex = 0; this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; OnGameSelectionChanged(null, null); }
public SendMailToWindow(int gameIndex) { InitializeComponent(); loaded = false; for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (i == gameIndex) { comboBoxGame.SetGameSaveVisible(i, false); continue; } IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType == GameTypes.Colosseum || game.GameType == GameTypes.XD || game.GameType == GameTypes.PokemonBox) { comboBoxGame.SetGameSaveVisible(i, false); } } this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; GameChanged(null, null); }
public int GetNumRows(int gameIndex) { if (PokeManager.GetGameSaveAt(gameIndex) is ManagerGameSave) { return((PokeManager.GetGameSaveAt(gameIndex) as ManagerGameSave).NumPokePCRows); } return(1); }
private void OnPocketSelectionChanged(object sender, SelectionChangedEventArgs e) { if (gameIndex != -2 && comboBoxPocket.SelectedItem != null) { pocket = PokeManager.GetGameSaveAt(gameIndex).Inventory.Items[(ItemTypes)((ComboBoxItem)comboBoxPocket.SelectedItem).Tag]; UpdateItemList(); } }
private void FindNextGameIndex(PokemonBoxViewer boxViewer, int invalidGameIndex1, int invalidRow1, int invalidGameIndex2, int invalidRow2) { // Check if we don't need to change things if (boxViewer.ComboBoxGames.SelectedGameIndex != -2) { int index = boxViewer.ComboBoxGames.SelectedGameIndex; int row = boxViewer.ComboBoxRows.SelectedIndex; if (boxViewer.ComboBoxGames.SelectedGameSave is ManagerGameSave) { if ((index != invalidGameIndex1 || row != invalidRow1) && (index != invalidGameIndex2 || row != invalidRow2)) { return; } else { for (int j = 0; j < (PokeManager.GetGameSaveAt(index) as ManagerGameSave).NumPokePCRows; j++) { if ((index != invalidGameIndex1 || j != invalidRow1) && (index != invalidGameIndex2 || j != invalidRow2)) { boxViewer.ComboBoxGames.SelectedGameIndex = index; boxViewer.comboBoxRows.SelectedIndex = j; break; //boxViewer.LoadGame(PokeManager.GetGameSaveAt(i), pokemonViewer, i, j); } } } } else if (index != invalidGameIndex1 && index != invalidGameIndex2) { return; } } bool finished = false; for (int i = -1; i < PokeManager.NumGameSaves && !finished; i++) { if (PokeManager.GetGameSaveAt(i) is ManagerGameSave) { for (int j = 0; j < (PokeManager.GetGameSaveAt(i) as ManagerGameSave).NumPokePCRows; j++) { if ((i != invalidGameIndex1 || j != invalidRow1) && (i != invalidGameIndex2 || j != invalidRow2)) { boxViewer.ComboBoxGames.SelectedGameIndex = i; boxViewer.comboBoxRows.SelectedIndex = j; finished = true; break; //boxViewer.LoadGame(PokeManager.GetGameSaveAt(i), pokemonViewer, i, j); } } } else if (i != invalidGameIndex1 && i != invalidGameIndex2) { //boxViewer.LoadGame(PokeManager.GetGameSaveAt(i), pokemonViewer, i); boxViewer.ComboBoxGames.SelectedGameIndex = i; break; } } }
public SendItemToWindow(int gameIndex, ushort id, uint maxCount) { InitializeComponent(); upDownItemCount.Minimum = 0; upDownItemCount.Value = 1; upDownItemCount.Maximum = (int)maxCount; itemID = id; pocketTypes = new List <ItemTypes>(); loaded = false; count = 1; for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (i == gameIndex) { comboBoxGame.SetGameSaveVisible(i, false); continue; } IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType != GameTypes.Any && !ItemDatabase.GetItemFromID(id).Exclusives.HasFlag((GameTypeFlags)(1 << ((int)game.GameType - 1)))) { comboBoxGame.SetGameSaveVisible(i, false); } } pocketTypes.Clear(); comboBoxPocket.Items.Clear(); /*if (this.gameIndex == -1) { * pocketTypes.Add(ItemDatabase.GetItemFromID(itemID).PocketType); * comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemDatabase.GetItemFromID(itemID).PocketType)); * comboBoxPocket.SelectedIndex = 0; * } * else { * pocketTypes.Add(ItemTypes.PC); * pocketTypes.Add(ItemDatabase.GetItemFromID(itemID).PocketType); * comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemTypes.PC)); * comboBoxPocket.Items.Add(ItemDatabase.GetPocketName(ItemDatabase.GetItemFromID(itemID).PocketType)); * comboBoxPocket.SelectedIndex = 1; * }*/ this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { //comboBoxGame.SelectedIndex = 0; this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; GameChanged(null, null); }
public int GetNumRows(PokemonBoxViewer viewer) { IGameSave gameSave = PokeManager.GetGameSaveAt(GetGameIndex(viewer)); if (gameSave is ManagerGameSave) { return((gameSave as ManagerGameSave).NumPokePCRows); } return(1); }
private void FillComboBoxItem(int gameIndex, ComboBoxItem comboBoxItem) { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; /*Image gameImage = new Image(); * BitmapImage bitmap = ResourceDatabase.GetImageFromName(gameSave.GameType.ToString() + "Physical"); * gameImage.Source = bitmap; * if (bitmap == null) * gameImage.Width = 20; * else * gameImage.Width = bitmap.PixelWidth * (20.0 / bitmap.PixelHeight); * gameImage.Height = 20; * gameImage.VerticalAlignment = VerticalAlignment.Center;*/ TextBlock gameName = new TextBlock(); string gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString()); if (PokeManager.GetGameSaveFileInfoNickname(gameIndex) != "") { gameName.Text = PokeManager.GetGameSaveFileInfoNickname(gameIndex) + (gameSave.GameType != GameTypes.PokemonBox && gameSave.GameType != GameTypes.Any ? " [" : ""); } else { gameName.Text = gameTypeName + (gameSave.GameType != GameTypes.PokemonBox && gameSave.GameType != GameTypes.Any ? " [" : ""); } gameName.VerticalAlignment = VerticalAlignment.Center; //gameName.Margin = new Thickness(5, 0, 0, 0); TextBlock trainerName = new TextBlock(); trainerName.Text = gameSave.TrainerName; trainerName.Foreground = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0))); trainerName.VerticalAlignment = VerticalAlignment.Center; TextBlock ending = new TextBlock(); ending.VerticalAlignment = VerticalAlignment.Center; ending.Text = "]"; //stackPanel.Children.Add(gameImage); stackPanel.Children.Add(gameName); if (gameSave.GameType != GameTypes.PokemonBox && gameSave.GameType != GameTypes.Any) { stackPanel.Children.Add(trainerName); stackPanel.Children.Add(ending); } comboBoxItem.Content = stackPanel; comboBoxItem.Tag = gameIndex; }
private void TryAddPocket(ItemTypes pocket) { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); if (gameSave.Inventory.Items.ContainsPocket(pocket)) { ComboBoxItem comboBoxItem = new ComboBoxItem(); comboBoxItem.Content = ItemDatabase.GetPocketName(pocket); comboBoxItem.Tag = pocket; comboBoxPockets.Items.Add(comboBoxItem); } }
private void OnBallSelectionChanged(object sender, SelectionChangedEventArgs e) { selectedIndex = listViewBalls.SelectedIndex; if (selectedIndex != -1) { ItemPocket pocket = PokeManager.GetGameSaveAt(gameIndex).Inventory.Items[ItemTypes.PokeBalls]; selectedItem = pocket[selectedIndex]; } else { selectedItem = null; } }
private void OnPocketSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) { return; } if (gameIndex != -2 && comboBoxPocket.SelectedIndex != -1) { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); pocket = gameSave.Inventory.Items[(ItemTypes)(comboBoxPocket.SelectedItem as ComboBoxItem).Tag]; UpdateItemList(); } }
private uint GetMaxCurrency(int gameIndex) { GameTypes gameType = PokeManager.GetGameSaveAt(gameIndex).GameType; if (gameType == GameTypes.Any) { return(1000000000); } switch (currencyType) { case CurrencyTypes.Money: if (gameType == GameTypes.Colosseum || gameType == GameTypes.XD) { return(99999999); } return(999999); case CurrencyTypes.Coins: if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire || gameType == GameTypes.Emerald || gameType == GameTypes.FireRed || gameType == GameTypes.LeafGreen) { return(9999); } return(0); case CurrencyTypes.BattlePoints: if (gameType == GameTypes.Emerald) { return(9999); } return(0); case CurrencyTypes.PokeCoupons: if (gameType == GameTypes.Colosseum || gameType == GameTypes.XD) { return(9999999); } return(0); case CurrencyTypes.VolcanicAsh: if (gameType == GameTypes.Ruby || gameType == GameTypes.Sapphire || gameType == GameTypes.Emerald) { return(9999); } return(0); } return(0); }
private void GameChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) { return; } gameIndex = comboBoxGame.SelectedGameIndex; rowIndex = 0; if (gameIndex == -2) { pokeBoxControl.UnloadBox(); } else { if (comboBoxGame.SelectedGameSave is ManagerGameSave) { buttonParty.Visibility = Visibility.Hidden; comboBoxRows.Visibility = Visibility.Visible; } else { buttonParty.Visibility = Visibility.Visible; comboBoxRows.Visibility = Visibility.Hidden; } pokePC = PokeManager.GetGameSaveAt(this.gameIndex).PokePC; boxIndex = pokePC.CurrentBox; if (pokePC.Party == null) { partyMode = false; buttonParty.Content = "Show Party"; buttonParty.IsEnabled = false; pokeBoxControlParty.Visibility = Visibility.Hidden; } else { buttonParty.IsEnabled = true; } pokeBoxControl.LoadBox(pokePC[boxIndex], gameIndex); if (partyMode) { pokeBoxControlParty.LoadBox(pokePC.Party, gameIndex); } } }
public SendCurrencyToWindow(int gameIndex, CurrencyTypes currencyType, bool sendMode) { InitializeComponent(); upDownCurrencyCount.Maximum = 1000000000; upDownCurrencyCount.Minimum = 0; upDownCurrencyCount.Value = 1; this.loaded = false; this.sendMode = sendMode; this.sendGameIndex = gameIndex; this.currencyType = currencyType; labelCurrencyType.Content = CurrencyName; if (!sendMode) { Title = "Send Currency From"; } for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (i == gameIndex) { comboBoxGame.SetGameSaveVisible(i, false); continue; } IGameSave game = (IGameSave)PokeManager.GetGameSaveAt(i); if (GetMaxCurrency(i) == 0 || game.GameType == GameTypes.PokemonBox) { comboBoxGame.SetGameSaveVisible(i, false); } } this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } this.loaded = true; GameChanged(null, null); }
public uint GetCurrency(int gameIndex) { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); switch (currencyType) { case CurrencyTypes.Money: return(gameSave.Money); case CurrencyTypes.Coins: return(gameSave.Coins); case CurrencyTypes.BattlePoints: return(gameSave.BattlePoints); case CurrencyTypes.PokeCoupons: return(gameSave.PokeCoupons); case CurrencyTypes.VolcanicAsh: return(gameSave.VolcanicAsh); } return(0); }
public uint ChangeCurrency(int gameIndex, int amountChange) { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); switch (currencyType) { case CurrencyTypes.Money: return(gameSave.Money = (uint)((int)gameSave.Money + amountChange)); case CurrencyTypes.Coins: return(gameSave.Coins = (ushort)((int)gameSave.Coins + amountChange)); case CurrencyTypes.BattlePoints: return(gameSave.BattlePoints = (ushort)((int)gameSave.BattlePoints + amountChange)); case CurrencyTypes.PokeCoupons: return(gameSave.PokeCoupons = (uint)((int)gameSave.PokeCoupons + amountChange)); case CurrencyTypes.VolcanicAsh: return(gameSave.VolcanicAsh = (ushort)((int)gameSave.VolcanicAsh + amountChange)); } return(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"); } } }
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 FindNextRow(PokemonBoxViewer boxViewer, int invalidGameIndex1, int invalidRow1, int invalidGameIndex2, int invalidRow2) { int index = boxViewer.ComboBoxGames.SelectedGameIndex; int row = boxViewer.ComboBoxRows.SelectedIndex; if (PokeManager.GetGameSaveAt(index) is ManagerGameSave) { if ((index == invalidGameIndex1 && row == invalidRow1) || (index == invalidGameIndex2 && row == invalidRow2)) { for (int j = 0; j < (PokeManager.GetGameSaveAt(index) as ManagerGameSave).NumPokePCRows; j++) { if ((index != invalidGameIndex1 || j != invalidRow1) && (index != invalidGameIndex2 || j != invalidRow2)) { //boxViewer.LoadGame(boxViewer.ComboBoxGames.SelectedGameSave, pokemonViewer, boxViewer.ComboBoxGames.SelectedGameIndex, j); boxViewer.ComboBoxRows.SelectedIndex = j; break; } } } } }
public SendDecorationToWindow(int gameIndex, byte id, uint maxCount) { InitializeComponent(); upDownItemCount.Minimum = 0; upDownItemCount.Value = 1; upDownItemCount.Maximum = (int)maxCount; count = 1; decorationID = id; loaded = false; for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (i == gameIndex) { comboBoxGame.SetGameSaveVisible(i, false); continue; } IGameSave game = PokeManager.GetGameSaveAt(i); if (game.GameType != GameTypes.Any && game.GameType != GameTypes.Ruby && game.GameType != GameTypes.Sapphire && game.GameType != GameTypes.Emerald) { comboBoxGame.SetGameSaveVisible(i, false); } } this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; GameChanged(null, null); }
private void OnDecorationSendTo(object sender, EventArgs e) { if (HasSelection) { var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, "Send Decoration Selection", pocket.PocketType, false); if (results != null) { 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) { bool noRoom = false; foreach (Decoration decoration in SelectedDecorations) { if (pocket.Inventory.IsDecorationInUse(pocket.IndexOf(decoration), pocket.PocketType)) { pocket.Inventory.PutAwayDecoration(pocket.IndexOf(decoration), pocket.PocketType); } int finalCount = results.GetFinalCount(decoration.Count); if (finalCount > 0) { if (PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Decorations[pocket.PocketType].HasRoomForDecoration(decoration.ID, (uint)finalCount)) { PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Decorations[pocket.PocketType].AddDecoration(decoration.ID, (uint)finalCount); pocket.TossDecorationAt(pocket.IndexOf(decoration), (uint)finalCount); } 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 { var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedDecoration.Count, "Send Decoration", pocket.PocketType, false); //SendDecorationToResult result = SendDecorationToWindow.ShowDialog(Window.GetWindow(this), pocket.Inventory.GameIndex, selectedDecoration.ID, selectedDecoration.Count); if (results != null) { bool cancel = false; if (pocket.AreAllDecorationsOfIDInUse(selectedDecoration.ID)) { DecorationUsages usage = pocket.Inventory.GetDecorationUsage(selectedIndex, pocket.PocketType); string usageString = (usage == DecorationUsages.SecretBase ? "Secret Base" : "Bedroom"); MessageBoxResult result2 = TriggerMessageBox.Show(Window.GetWindow(this), "Put away the " + selectedDecoration.DecorationData.Name + " in your " + usageString + "?", "Put Away", MessageBoxButton.YesNo); if (result2 == MessageBoxResult.No) { cancel = true; } } if (!cancel) { if (PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Decorations[pocket.PocketType].HasRoomForDecoration(selectedDecoration.ID, (uint)results.Count)) { PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Decorations[pocket.PocketType].AddDecoration(selectedDecoration.ID, (uint)results.Count); pocket.TossDecorationAt(selectedIndex, (uint)results.Count); } else { // No room for item TriggerMessageBox.Show(Window.GetWindow(this), "No room for that decoration", "No Room"); } } } } }
public SendPokemonToWindow(SendPokemonModes mode, int gameIndex, IPokemon pokemon, IPokeContainer container, int containerIndex, Item giveItem, bool noEggs = false) { InitializeComponent(); loaded2 = false; loaded = false; this.pokemon = pokemon; this.pokeBoxControl.MouseMoveTarget = this; this.pokeBoxControlParty.MouseMoveTarget = this; this.pokeBoxControl.AddSlave(this.pokeBoxControlParty); this.pokeBoxControlParty.Visibility = Visibility.Hidden; this.mode = mode; this.giveItem = giveItem; this.gameIndex = -2; this.noEggs = noEggs; this.pokeBoxControl.PokemonViewer = pokemonViewer; this.pokeBoxControlParty.PokemonViewer = pokemonViewer; this.pokeBoxControl.PokemonSelected += OnPokemonSelected; this.pokeBoxControlParty.PokemonSelected += OnPokemonSelected; if (mode == SendPokemonModes.SendFrom) { this.container = container; this.containerIndex = containerIndex; } else if (mode == SendPokemonModes.GiveItem) { this.Title = "Give Item"; } for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave game = PokeManager.GetGameSaveAt(i); if (i == gameIndex && (!(game is ManagerGameSave) || (game as ManagerGameSave).NumPokePCRows == 1)) { comboBoxGame.SetGameSaveVisible(i, false); continue; } if (pokemon != null && (mode != SendPokemonModes.GiveItem && (pokemon.IsEgg && (game.GameType == GameTypes.Colosseum || game.GameType == GameTypes.XD)))) { comboBoxGame.SetGameSaveVisible(i, false); continue; } else if (mode == SendPokemonModes.SendMulti && PokeManager.SelectionHasEgg && (game.GameType == GameTypes.Colosseum || game.GameType == GameTypes.XD)) { comboBoxGame.SetGameSaveVisible(i, false); continue; } } this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGame.IsGameSaveVisible(this.gameIndex)) { comboBoxGame.SelectedIndex = 0; this.gameIndex = comboBoxGame.SelectedGameIndex; } else { comboBoxGame.SelectedGameIndex = this.gameIndex; } loaded = true; if (this.gameIndex != -2) { boxIndex = comboBoxGame.SelectedGameSave.PokePC.CurrentBox; pokePC = PokeManager.GetGameSaveAt(this.gameIndex).PokePC; if (pokePC.Party == null) { partyMode = false; buttonParty.Content = "Show Party"; buttonParty.IsEnabled = false; pokeBoxControlParty.Visibility = Visibility.Hidden; } else { buttonParty.IsEnabled = true; } pokeBoxControl.LoadBox(pokePC[boxIndex], gameIndex); } GameChanged(null, null); }
private void AddListViewItem(int gameIndex, object pocketType, string pocket, int count) { ListViewItem listViewItem = new ListViewItem(); if (decorationMode) { listViewItem.Tag = new ItemPocketGameTag(gameIndex, (DecorationTypes)pocketType); } else { listViewItem.Tag = new ItemPocketGameTag(gameIndex, (ItemTypes)pocketType); } listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 250; StackPanel stackPanel = new StackPanel(); stackPanel.Orientation = Orientation.Horizontal; if (gameIndex == -1) { TextBlock gameName = new TextBlock(); gameName.Text = PokeManager.Settings.ManagerNickname; gameName.VerticalAlignment = VerticalAlignment.Center; stackPanel.Children.Add(gameName); } else { IGameSave gameSave = PokeManager.GetGameSaveAt(gameIndex); GameSaveFileInfo gameSaveFile = PokeManager.GetGameSaveFileInfoAt(gameIndex); TextBlock gameName = new TextBlock(); string gameTypeName = (gameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : gameSave.GameType.ToString()); if (gameSaveFile.Nickname != "") { gameName.Text = gameSaveFile.Nickname + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); } else { gameName.Text = gameTypeName + (gameSaveFile.GameType != GameTypes.PokemonBox ? " [" : ""); } gameName.VerticalAlignment = VerticalAlignment.Center; //gameName.Margin = new Thickness(5, 0, 0, 0); TextBlock trainerName = new TextBlock(); trainerName.Text = gameSave.TrainerName; trainerName.Foreground = new SolidColorBrush(gameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (gameSave.TrainerGender == Genders.Female ? Color.FromRgb(248, 24, 168) : Color.FromRgb(0, 0, 0))); trainerName.VerticalAlignment = VerticalAlignment.Center; TextBlock ending = new TextBlock(); ending.Text = "]"; // " + pocket; ending.VerticalAlignment = VerticalAlignment.Center; //stackPanel.Children.Add(gameImage); stackPanel.Children.Add(gameName); if (gameSaveFile.GameType != GameTypes.PokemonBox) { stackPanel.Children.Add(trainerName); stackPanel.Children.Add(ending); } } TextBlock itemPocket = new TextBlock(); itemPocket.VerticalAlignment = VerticalAlignment.Center; itemPocket.HorizontalAlignment = HorizontalAlignment.Right; itemPocket.TextAlignment = TextAlignment.Right; itemPocket.Text = pocket + " "; itemPocket.Width = Double.NaN; itemPocket.MinWidth = 10; TextBlock itemX = new TextBlock(); itemX.VerticalAlignment = VerticalAlignment.Center; itemX.HorizontalAlignment = HorizontalAlignment.Right; itemX.TextAlignment = TextAlignment.Right; itemX.Text = "x"; itemX.MinWidth = 10; TextBlock itemCount = new TextBlock(); itemCount.VerticalAlignment = VerticalAlignment.Center; itemCount.HorizontalAlignment = HorizontalAlignment.Right; itemCount.TextAlignment = TextAlignment.Right; itemCount.Width = 30; itemCount.Text = count.ToString(); listViewItem.Content = dockPanel; listViewResults.Items.Add(listViewItem); dockPanel.Children.Add(stackPanel); dockPanel.Children.Add(itemCount); dockPanel.Children.Add(itemX); dockPanel.Children.Add(itemPocket); DockPanel.SetDock(itemX, Dock.Right); DockPanel.SetDock(itemCount, Dock.Right); DockPanel.SetDock(stackPanel, Dock.Left); }
private void UpdateResults() { listViewResults.Items.Clear(); if (selectedItemID == 0) { return; } for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave gameSave = PokeManager.GetGameSaveAt(i); if (gameSave.Inventory == null) { continue; } if (decorationMode && gameSave.Inventory.Decorations != null) { if (gameSave.Inventory.Decorations.ContainsPocket(SelectedDecorationData.DecorationType)) { DecorationPocket pocket = gameSave.Inventory.Decorations[SelectedDecorationData.DecorationType]; int count = 0; for (int j = 0; j < pocket.SlotsUsed; j++) { if (pocket[j].ID == (byte)selectedItemID) { count += (int)pocket[j].Count; } } if (count > 0) { AddListViewItem(i, pocket.PocketType, ItemDatabase.GetDecorationContainerName(pocket.PocketType), count); } } } else if (!decorationMode) { ItemPocket pocket; int count; if (gameSave.Inventory.Items.ContainsPocket(ItemTypes.PC)) { pocket = gameSave.Inventory.Items[ItemTypes.PC]; count = 0; for (int j = 0; j < pocket.SlotsUsed; j++) { if (pocket[j].ID == (ushort)selectedItemID) { count += (int)pocket[j].Count; } } if (count > 0) { AddListViewItem(i, pocket.PocketType, ItemDatabase.GetPocketName(pocket.PocketType), count); } } if (gameSave.Inventory.Items.ContainsPocket(SelectedItemData.PocketType)) { pocket = gameSave.Inventory.Items[SelectedItemData.PocketType]; count = 0; for (int j = 0; j < pocket.SlotsUsed; j++) { if (pocket[j].ID == (ushort)selectedItemID) { count += (int)pocket[j].Count; } } if (count > 0) { AddListViewItem(i, pocket.PocketType, ItemDatabase.GetPocketName(pocket.PocketType), count); } } if (SelectedItemData.HasSubPocket && gameSave.Inventory.Items.ContainsPocket(SelectedItemData.SubPocketType)) { pocket = gameSave.Inventory.Items[SelectedItemData.SubPocketType]; count = 0; for (int j = 0; j < pocket.SlotsUsed; j++) { if (pocket[j].ID == (ushort)selectedItemID) { count += (int)pocket[j].Count; } } if (count > 0) { AddListViewItem(i, pocket.PocketType, ItemDatabase.GetPocketName(pocket.PocketType), count); } } } } if (!decorationMode) { pokemonHoldingItem.Clear(); for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave gameSave = PokeManager.GetGameSaveAt(i); if (gameSave is ManagerGameSave) { for (int j = 0; j < (gameSave as ManagerGameSave).NumPokePCRows; j++) { foreach (IPokemon pokemon in (gameSave as ManagerGameSave).GetPokePCRow(j)) { if (pokemon.HeldItemID == selectedItemID) { pokemonHoldingItem.Add(pokemon); } } } } else { foreach (IPokemon pokemon in gameSave.PokePC) { if (pokemon.HeldItemID == selectedItemID) { pokemonHoldingItem.Add(pokemon); } } } } if (pokemonHoldingItem.Count > 0) { ListViewItem listViewItem = new ListViewItem(); listViewItem.Tag = new ItemPocketGameTag(-2); listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 250; TextBlock itemPocket = new TextBlock(); itemPocket.VerticalAlignment = VerticalAlignment.Center; itemPocket.Text = "Holding Pokémon"; itemPocket.MinWidth = 10; TextBlock itemX = new TextBlock(); itemX.VerticalAlignment = VerticalAlignment.Center; itemX.HorizontalAlignment = HorizontalAlignment.Right; itemX.TextAlignment = TextAlignment.Right; itemX.Text = "x"; itemX.MinWidth = 10; TextBlock itemCount = new TextBlock(); itemCount.VerticalAlignment = VerticalAlignment.Center; itemCount.HorizontalAlignment = HorizontalAlignment.Right; itemCount.TextAlignment = TextAlignment.Right; itemCount.Width = 30; itemCount.Text = pokemonHoldingItem.Count.ToString(); listViewItem.Content = dockPanel; dockPanel.Children.Add(itemCount); dockPanel.Children.Add(itemX); dockPanel.Children.Add(itemPocket); DockPanel.SetDock(itemX, Dock.Right); DockPanel.SetDock(itemCount, Dock.Right); DockPanel.SetDock(itemPocket, Dock.Left); Separator separator = new Separator(); separator.Height = 7; separator.BorderBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0)); listViewResults.Items.Add(separator); listViewResults.Items.Add(listViewItem); } } buttonSeeResults.IsEnabled = false; }
public AdvancedSendSelectionToWindow(int gameIndex, int max, string title, object sendType, bool withdrawMode, GameTypeFlags exclusives) { InitializeComponent(); this.loaded = false; this.realMax = max; this.Title = title; this.percentageMax = 100; this.max = 1; this.min = 1; this.keep = 0; this.percentage = false; this.sendAll = false; this.itemType = (sendType is ItemTypes ? (ItemTypes)sendType : ItemTypes.Unknown); this.isDecoration = false; this.pocket = this.itemType; this.maxMode = false; this.withdrawMode = withdrawMode; if (sendType is DecorationTypes) { this.comboBoxPockets.Items.Add(ItemDatabase.GetDecorationContainerName((DecorationTypes)sendType)); this.comboBoxPockets.SelectedIndex = 0; this.comboBoxPockets.IsEnabled = false; this.isDecoration = true; } this.numericMax.Maximum = max; this.numericMin.Maximum = max; this.numericKeep.Maximum = max; for (int i = -1; i < PokeManager.NumGameSaves; i++) { if (withdrawMode) { if (i != gameIndex) { comboBoxGames.SetGameSaveVisible(i, false); continue; } } else { if (i == gameIndex) { comboBoxGames.SetGameSaveVisible(i, false); continue; } IGameSave gameSave = PokeManager.GetGameSaveAt(i); if (!this.isDecoration && gameSave.GameType != GameTypes.Any && !exclusives.HasFlag((GameTypeFlags)(1 << ((int)gameSave.GameType - 1)))) { comboBoxGames.SetGameSaveVisible(i, false); } else if (gameSave.GameType == GameTypes.PokemonBox || (this.isDecoration && gameSave.Inventory.Decorations == null)) { comboBoxGames.SetGameSaveVisible(i, false); } } } if (withdrawMode) { this.gameIndex = gameIndex; comboBoxGames.SelectedGameIndex = gameIndex; comboBoxGames.IsEnabled = false; comboBoxPockets.IsEnabled = false; } else { this.gameIndex = PokeManager.LastGameInDialogIndex; if (this.gameIndex == -2 || !comboBoxGames.IsGameSaveVisible(this.gameIndex)) { this.gameIndex = comboBoxGames.SelectedGameIndex; } else { comboBoxGames.SelectedGameIndex = this.gameIndex; } } this.loaded = true; OnGameChanged(null, null); }
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"); } }