public SaveManager() { InitializeComponent(); this.gameSaves = new ObservableCollection <ListViewItem>(); this.selectedGameSave = null; this.selectedIndex = -1; CreateContextMenu(); if (!DesignerProperties.GetIsInDesignMode(this)) { this.listViewGameSaves.ItemsSource = gameSaves; this.dropManager = new ListViewDragDropManager <ListViewItem>(listViewGameSaves); for (int i = 0; i < PokeManager.NumGameSaves; i++) { GameSaveFileInfo gameSave = PokeManager.GetGameSaveFileInfoAt(i); ListViewItem listViewItem = new ListViewItem(); FillListViewItem(gameSave, listViewItem); gameSaves.Add(listViewItem); } } }
private void OnTooltipOpening(object sender, ToolTipEventArgs e) { IPokemon pokemon = hoverSelection.Tag as IPokemon; if (pokemon.ContainerIndex == -1) { pokemon = pokemon.PokemonFinder.Pokemon; hoverSelection.Tag = pokemon; } if (pokemon.IsReleased) { hoverSelection.ToolTip = "(Released)"; } else if (pokemon.IsMoving) { hoverSelection.ToolTip = "(Moving)"; } else if (pokemon.ContainerIndex == -1) { hoverSelection.ToolTip = "(Unable to Find - This shouldn't happen)"; } else { StackPanel tooltip = new StackPanel(); tooltip.Orientation = Orientation.Horizontal; TextBlock gameName = new TextBlock(); string gameTypeName = (pokemon.GameSave.GameType == GameTypes.PokemonBox ? "Pokémon Box" : pokemon.GameSave.GameType.ToString()); if (PokeManager.GetGameSaveFileInfoNickname(pokemon.GameSave.GameIndex) != "") { gameName.Text = PokeManager.GetGameSaveFileInfoNickname(pokemon.GameSave.GameIndex) + (pokemon.GameSave.GameType != GameTypes.PokemonBox && pokemon.GameSave.GameType != GameTypes.Any ? " [" : ""); } else { gameName.Text = gameTypeName + (pokemon.GameSave.GameType != GameTypes.PokemonBox && pokemon.GameSave.GameType != GameTypes.Any ? " [" : " "); } gameName.VerticalAlignment = VerticalAlignment.Center; TextBlock trainerName = new TextBlock(); trainerName.Text = pokemon.GameSave.TrainerName; trainerName.Foreground = new SolidColorBrush(pokemon.GameSave.TrainerGender == Genders.Male ? Color.FromRgb(32, 128, 248) : (pokemon.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 = "]"; TextBlock storage = new TextBlock(); storage.VerticalAlignment = VerticalAlignment.Center; storage.Text = " ("; int indexOf = pokemon.PokeContainer.IndexOf(pokemon); if (pokemon.PokeContainer.Type == ContainerTypes.Box) { if (pokemon.PokePC is ManagerPokePC) { storage.Text += "Row " + (((ManagerPokePC)pokemon.PokePC).RowIndex + 1).ToString() + " \"" + ((ManagerPokePC)pokemon.PokePC).Name + "\" "; } storage.Text += "Box " + ((pokemon.PokeContainer as IPokeBox).BoxNumber + 1).ToString() + " \"" + (pokemon.PokeContainer as IPokeBox).Name.ToString() + "\""; } else if (pokemon.PokeContainer.Type == ContainerTypes.Party) { storage.Text += "Party Slot " + (indexOf + 1).ToString(); } else if (pokemon.PokeContainer.Type == ContainerTypes.Daycare) { if (indexOf == 2 || pokemon.PokeContainer.NumSlots == 1) { storage.Text += "Single Daycare"; } else { storage.Text += "Double Daycare Slot " + (indexOf + 1).ToString(); } } else if (pokemon.PokeContainer.Type == ContainerTypes.Purifier) { storage.Text += "Purifier Chamber " + (((XDPurificationChamber)pokemon.PokeContainer).ChamberNumber + 1).ToString() + " "; if (indexOf == 0) { storage.Text += "Inside"; } else { storage.Text += "Outside Slot " + indexOf.ToString(); } } storage.Text += ")"; tooltip.Children.Add(gameName); if (pokemon.GameSave.GameType != GameTypes.PokemonBox && pokemon.GameSave.GameType != GameTypes.Any) { tooltip.Children.Add(trainerName); tooltip.Children.Add(ending); } tooltip.Children.Add(storage); hoverSelection.ToolTip = tooltip; } }
private void OnItemListSelectionChanged(object sender, SelectionChangedEventArgs e) { int index = listViewItems.SelectedIndex; if (index < listViewItems.Items.Count) { if (index != -1) { selectedIndex = index; } if (selectedIndex != -1 && selectedIndex < listViewItems.Items.Count) { selectedEvent = (listViewItems.Items[selectedIndex] as EventDisplayItem).Event; this.labelTitle.Content = selectedEvent.GetTitle(gameSave) + (PokeManager.IsEventCompletedBy(selectedEvent.ID, gameSave) ? " (Completed)" : ""); this.textBlockDescription.Text = selectedEvent.GetDescription(gameSave); this.textBlockRequirements.Text = selectedEvent.GetRequirements(gameSave); this.imageSprite.Width = selectedEvent.BigSprite.PixelWidth; this.imageSprite.Height = selectedEvent.BigSprite.PixelHeight; this.imageSprite.Source = selectedEvent.BigSprite; this.buttonActivate.IsEnabled = !PokeManager.IsEventCompletedBy(selectedEvent.ID, gameSave) && selectedEvent.IsRequirementsFulfilled(gameSave); } else { selectedEvent = null; this.labelTitle.Content = ""; this.textBlockDescription.Text = ""; this.textBlockRequirements.Text = ""; this.imageSprite.Source = null; this.buttonActivate.IsEnabled = false; } } else { selectedEvent = null; selectedIndex = -1; this.labelTitle.Content = ""; this.textBlockDescription.Text = ""; this.textBlockRequirements.Text = ""; this.imageSprite.Source = null; this.buttonActivate.IsEnabled = false; } }
public void LoadPokemon(IPokemon pokemon) { this.gameIndex = PokeManager.GetIndexOfGame(pokemon.GameSave); this.currentMoveIndex = -1; this.pokemon = pokemon; this.imagePokemon.Source = pokemon.Sprite; this.imagePokemon2.Source = pokemon.Sprite; if (pokemon.IsShadowPokemon) { this.rectShadowMask.OpacityMask = new ImageBrush(this.imagePokemon.Source); this.rectShadowMask2.OpacityMask = new ImageBrush(this.imagePokemon.Source); this.rectShadowMask.Visibility = Visibility.Visible; this.rectShadowMask2.Visibility = Visibility.Visible; this.imageShadowAura.Visibility = Visibility.Visible; this.imageShadowAura2.Visibility = Visibility.Visible; } else { this.rectShadowMask.Visibility = Visibility.Hidden; this.rectShadowMask2.Visibility = Visibility.Hidden; this.imageShadowAura.Visibility = Visibility.Hidden; this.imageShadowAura2.Visibility = Visibility.Hidden; } this.imageShinyStar.Visibility = (pokemon.IsShiny ? Visibility.Visible : Visibility.Hidden); this.imageShinyStar2.Visibility = (pokemon.IsShiny ? Visibility.Visible : Visibility.Hidden); this.imageBallCaught.Source = PokemonDatabase.GetBallCaughtImageFromID(pokemon.BallCaughtID); this.imageBallCaught2.Source = PokemonDatabase.GetBallCaughtImageFromID(pokemon.BallCaughtID); if (pokemon.IsEgg) { this.labelNickname.Content = "EGG"; } else { this.labelNickname.Content = pokemon.Nickname; } this.labelLevel.Content = "Lv " + pokemon.Level.ToString(); if (pokemon.Gender == Genders.Male) { this.labelGender.Content = "♂"; this.labelGender.Foreground = new SolidColorBrush(Color.FromRgb(0, 136, 184)); } else if (pokemon.Gender == Genders.Female) { this.labelGender.Content = "♀"; this.labelGender.Foreground = new SolidColorBrush(Color.FromRgb(184, 88, 80)); } else { this.labelGender.Content = ""; } if (pokemon.IsEgg) { this.labelOTName.Content = "?????"; this.labelOTName.Foreground = new SolidColorBrush(Color.FromRgb(0, 0, 0)); this.labelOTID.Content = "?????"; this.labelSecretID.Content = "?????"; } else { this.labelOTName.Content = pokemon.TrainerName; if (pokemon.TrainerGender == Genders.Male) { this.labelOTName.Foreground = new SolidColorBrush(Color.FromRgb(0, 136, 184)); } else if (pokemon.TrainerGender == Genders.Female) { this.labelOTName.Foreground = new SolidColorBrush(Color.FromRgb(184, 88, 80)); } this.labelOTID.Content = pokemon.TrainerID.ToString("00000"); this.labelSecretID.Content = pokemon.SecretID.ToString("00000"); } if (pokemon.HasForm) { this.labelSpeciesName.Content = pokemon.PokemonFormData.Name; } else { this.labelSpeciesName.Content = pokemon.PokemonData.Name; } this.labelSpeciesNumber.Content = "No. " + pokemon.DexID.ToString("000"); this.labelHPIV.Content = pokemon.HPIV.ToString(); this.labelAttackIV.Content = pokemon.AttackIV.ToString(); this.labelDefenseIV.Content = pokemon.DefenseIV.ToString(); this.labelSpAttackIV.Content = pokemon.SpAttackIV.ToString(); this.labelSpDefenseIV.Content = pokemon.SpDefenseIV.ToString(); this.labelSpeedIV.Content = pokemon.SpeedIV.ToString(); this.labelHPEV.Content = pokemon.HPEV.ToString(); this.labelAttackEV.Content = pokemon.AttackEV.ToString(); this.labelDefenseEV.Content = pokemon.DefenseEV.ToString(); this.labelSpAttackEV.Content = pokemon.SpAttackEV.ToString(); this.labelSpDefenseEV.Content = pokemon.SpDefenseEV.ToString(); this.labelSpeedEV.Content = pokemon.SpeedEV.ToString(); this.labelHPStat.Content = pokemon.HP.ToString(); this.labelAttackStat.Content = pokemon.Attack.ToString(); this.labelDefenseStat.Content = pokemon.Defense.ToString(); this.labelSpAttackStat.Content = pokemon.SpAttack.ToString(); this.labelSpDefenseStat.Content = pokemon.SpDefense.ToString(); this.labelSpeedStat.Content = pokemon.Speed.ToString(); this.labelCool.Content = pokemon.Coolness.ToString(); this.labelBeauty.Content = pokemon.Beauty.ToString(); this.labelCute.Content = pokemon.Cuteness.ToString(); this.labelSmart.Content = pokemon.Smartness.ToString(); this.labelTough.Content = pokemon.Toughness.ToString(); this.labelFeel.Content = pokemon.Feel.ToString(); if (pokemon.Move1ID != 0) { this.labelMove1Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).Name; this.labelMove1PP.Content = pokemon.Move1TotalPP.ToString(); this.typeMove1.Type = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).Type; this.typeMove1.Visibility = Visibility.Visible; this.labelContestMove1Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).Name; this.labelContestMove1PP.Content = (pokemon.Move1Data.PP == 0 ? "--" : pokemon.Move1TotalPP.ToString()); this.conditionMove1.Type = PokemonDatabase.GetMoveFromID(pokemon.Move1ID).ConditionType; this.conditionMove1.Visibility = Visibility.Visible; } else { this.labelMove1Name.Content = "-"; this.labelMove1PP.Content = "--"; this.typeMove1.Visibility = Visibility.Hidden; this.labelContestMove1Name.Content = "-"; this.labelContestMove1PP.Content = "--"; this.conditionMove1.Visibility = Visibility.Hidden; } if (pokemon.Move2ID != 0) { this.labelMove2Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).Name; this.labelMove2PP.Content = pokemon.Move2TotalPP.ToString(); this.typeMove2.Type = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).Type; this.typeMove2.Visibility = Visibility.Visible; this.labelContestMove2Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).Name; this.labelContestMove2PP.Content = (pokemon.Move2Data.PP == 0 ? "--" : pokemon.Move2TotalPP.ToString()); this.conditionMove2.Type = PokemonDatabase.GetMoveFromID(pokemon.Move2ID).ConditionType; this.conditionMove2.Visibility = Visibility.Visible; } else { this.labelMove2Name.Content = "-"; this.labelMove2PP.Content = "--"; this.typeMove2.Visibility = Visibility.Hidden; this.labelContestMove2Name.Content = "-"; this.labelContestMove2PP.Content = "--"; this.conditionMove2.Visibility = Visibility.Hidden; } if (pokemon.Move3ID != 0) { this.labelMove3Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).Name; this.labelMove3PP.Content = pokemon.Move3TotalPP.ToString(); this.typeMove3.Type = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).Type; this.typeMove3.Visibility = Visibility.Visible; this.labelContestMove3Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).Name; this.labelContestMove3PP.Content = (pokemon.Move3Data.PP == 0 ? "--" : pokemon.Move3TotalPP.ToString()); this.conditionMove3.Type = PokemonDatabase.GetMoveFromID(pokemon.Move3ID).ConditionType; this.conditionMove3.Visibility = Visibility.Visible; } else { this.labelMove3Name.Content = "-"; this.labelMove3PP.Content = "--"; this.typeMove3.Visibility = Visibility.Hidden; this.labelContestMove3Name.Content = "-"; this.labelContestMove3PP.Content = "--"; this.conditionMove3.Visibility = Visibility.Hidden; } if (pokemon.Move4ID != 0) { this.labelMove4Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).Name; this.labelMove4PP.Content = pokemon.Move4TotalPP.ToString(); this.typeMove4.Type = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).Type; this.typeMove4.Visibility = Visibility.Visible; this.labelContestMove4Name.Content = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).Name; this.labelContestMove4PP.Content = (pokemon.Move4Data.PP == 0 ? "--" : pokemon.Move4TotalPP.ToString()); this.conditionMove4.Type = PokemonDatabase.GetMoveFromID(pokemon.Move4ID).ConditionType; this.conditionMove4.Visibility = Visibility.Visible; } else { this.labelMove4Name.Content = "-"; this.labelMove4PP.Content = "--"; this.typeMove4.Visibility = Visibility.Hidden; this.labelContestMove4Name.Content = "-"; this.labelContestMove4PP.Content = "--"; this.conditionMove4.Visibility = Visibility.Hidden; } if (pokemon.IsHoldingItem) { this.imageHeldItem.Source = ItemDatabase.GetItemImageFromID(pokemon.HeldItemID); this.labelHeldItem.Content = ItemDatabase.GetItemFromID(pokemon.HeldItemID).Name; } else { this.imageHeldItem.Source = null; this.labelHeldItem.Content = "None"; } if (pokemon.IsEgg) { this.labelFriendshipText.Content = "Hatch Counter"; this.labelFriendship.Content = pokemon.Friendship.ToString() + " Cycles"; } else { this.labelFriendshipText.Content = "Friendship"; this.labelFriendship.Content = pokemon.Friendship.ToString(); } this.labelNature.Content = pokemon.NatureData.Name; this.labelNatureRaised.Content = "+" + pokemon.NatureData.RaisedStat.ToString(); this.labelNatureLowered.Content = "-" + pokemon.NatureData.LoweredStat.ToString(); this.labelAbility.Content = pokemon.AbilityData.Name; this.textBlockAbilityDescription.Text = pokemon.AbilityData.Description; if (pokemon.IsShadowPokemon) { uint totalPurification = pokemon.HeartGauge; uint levelStartExp = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, pokemon.Level); this.labelNextLevelText.Content = "Exp Stored"; this.labelNextLevel.Content = pokemon.ExperienceStored.ToString() + " (+" + (PokemonDatabase.GetLevelFromExperience(pokemon.PokemonData.ExperienceGroup, pokemon.Experience + pokemon.ExperienceStored) - pokemon.Level).ToString() + ")"; this.labelTotalExperience.Content = pokemon.Experience.ToString(); this.labelExperienceText2.Content = "Heart Gauge"; this.labelTotalExperience2.Content = pokemon.Purification.ToString(); double ratio = (double)Math.Max(0, pokemon.Purification) / (double)totalPurification; LinearGradientBrush purBrush = new LinearGradientBrush(); purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(160, 72, 220), 0)); purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(160, 72, 220), ratio)); purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(225, 235, 250), ratio)); purBrush.GradientStops.Add(new GradientStop(Color.FromRgb(225, 235, 250), 1)); this.rectExperienceBar.Fill = purBrush; this.rectPurificationBorder1.Visibility = Visibility.Visible; this.rectPurificationBorder2.Visibility = Visibility.Visible; } else { this.labelExperienceText.Content = "Experience"; this.labelNextLevelText.Content = "Next Level"; this.labelExperienceText2.Content = ""; this.labelTotalExperience2.Content = ""; uint levelStartExp = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, pokemon.Level); uint levelNextExp = PokemonDatabase.GetExperienceFromLevel(pokemon.PokemonData.ExperienceGroup, (byte)Math.Min(100, (int)pokemon.Level + 1)); this.labelTotalExperience.Content = pokemon.Experience.ToString(); this.labelNextLevel.Content = (levelNextExp - levelStartExp).ToString(); double ratio = (double)(pokemon.Experience - levelStartExp) / (double)(levelNextExp - levelStartExp); LinearGradientBrush expBrush = new LinearGradientBrush(); expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 160, 220), 0)); expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 160, 220), ratio)); expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(100, 100, 100), ratio)); expBrush.GradientStops.Add(new GradientStop(Color.FromRgb(100, 100, 100), 1)); this.rectExperienceBar.Fill = expBrush; this.rectPurificationBorder1.Visibility = Visibility.Hidden; this.rectPurificationBorder2.Visibility = Visibility.Hidden; } this.labelPokerus.Content = pokemon.PokerusStatus.ToString(); if (pokemon.IsEgg) { this.labelMetAtText.Content = "Waiting to Hatch"; this.labelMetAtLevel.Content = ""; this.labelMetAtLocation.Content = ""; this.labelGame.Content = ""; } else { if (pokemon.LevelMet == 0) { this.labelMetAtText.Content = "Hatched At"; this.labelMetAtLevel.Content = "Lv 5"; } else { this.labelMetAtText.Content = (pokemon.IsFatefulEncounter ? "Fateful Encounter At" : "Met At"); this.labelMetAtLevel.Content = "Lv " + pokemon.LevelMet.ToString(); } this.labelMetAtLocation.Content = (pokemon.GameOrigin == GameOrigins.ColosseumXD ? "Orre Region" : PokemonDatabase.GetMetLocationFromID(pokemon.MetLocationID)); this.labelGame.Content = pokemon.GameOrigin.ToString() + " (" + pokemon.Language.ToString() + ")"; } this.type1Pokemon.Type = pokemon.PokemonData.Type1; if (pokemon.PokemonData.HasTwoTypes) { this.type2Pokemon.Type = pokemon.PokemonData.Type2; this.type2Pokemon.Visibility = Visibility.Visible; } else { this.type2Pokemon.Visibility = Visibility.Hidden; } Brush unmarkedBrush = new SolidColorBrush(Color.FromRgb(200, 200, 200)); Brush markedBrush = new SolidColorBrush(Color.FromRgb(0, 0, 0)); markCircle.Foreground = (pokemon.IsCircleMarked ? markedBrush : unmarkedBrush); markSquare.Foreground = (pokemon.IsSquareMarked ? markedBrush : unmarkedBrush); markTriangle.Foreground = (pokemon.IsTriangleMarked ? markedBrush : unmarkedBrush); markHeart.Foreground = (pokemon.IsHeartMarked ? markedBrush : unmarkedBrush); stackPanelRibbons.Children.Clear(); for (int i = 0; i < pokemon.CoolRibbonCount; i++) { AddRibbon("COOL-" + (i + 1).ToString()); } for (int i = 0; i < pokemon.BeautyRibbonCount; i++) { AddRibbon("BEAUTY-" + (i + 1).ToString()); } for (int i = 0; i < pokemon.CuteRibbonCount; i++) { AddRibbon("CUTE-" + (i + 1).ToString()); } for (int i = 0; i < pokemon.SmartRibbonCount; i++) { AddRibbon("SMART-" + (i + 1).ToString()); } for (int i = 0; i < pokemon.ToughRibbonCount; i++) { AddRibbon("TOUGH-" + (i + 1).ToString()); } /*for (int i = 0; i < 4; i++) * AddRibbon("COOL-" + (i + 1).ToString()); * for (int i = 0; i < 4; i++) * AddRibbon("BEAUTY-" + (i + 1).ToString()); * for (int i = 0; i < 4; i++) * AddRibbon("CUTE-" + (i + 1).ToString()); * for (int i = 0; i < 4; i++) * AddRibbon("SMART-" + (i + 1).ToString()); * for (int i = 0; i < 4; i++) * AddRibbon("TOUGH-" + (i + 1).ToString());*/ /*AddRibbon("CHAMPION"); * AddRibbon("WINNING"); * AddRibbon("VICTORY"); * AddRibbon("ARTIST"); * AddRibbon("EFFORT"); * AddRibbon("MARINE"); * AddRibbon("LAND"); * AddRibbon("SKY"); * AddRibbon("COUNTRY"); * AddRibbon("NATIONAL"); * AddRibbon("EARTH"); * AddRibbon("WORLD");*/ if (pokemon.HasChampionRibbon) { AddRibbon("CHAMPION"); } if (pokemon.HasWinningRibbon) { AddRibbon("WINNING"); } if (pokemon.HasVictoryRibbon) { AddRibbon("VICTORY"); } if (pokemon.HasArtistRibbon) { AddRibbon("ARTIST"); } if (pokemon.HasEffortRibbon) { AddRibbon("EFFORT"); } if (pokemon.HasMarineRibbon) { AddRibbon("MARINE"); } if (pokemon.HasLandRibbon) { AddRibbon("LAND"); } if (pokemon.HasSkyRibbon) { AddRibbon("SKY"); } if (pokemon.HasCountryRibbon) { AddRibbon("COUNTRY"); } if (pokemon.HasNationalRibbon) { AddRibbon("NATIONAL"); } if (pokemon.HasEarthRibbon) { AddRibbon("EARTH"); } if (pokemon.HasWorldRibbon) { AddRibbon("WORLD"); } buttonBall.IsEnabled = !pokemon.IsEgg; buttonNickname.IsEnabled = !pokemon.IsEgg && !pokemon.IsShadowPokemon; buttonDeoxys.IsEnabled = pokemon.DexID == 386; ButtonEVs.IsEnabled = !pokemon.IsEgg && !pokemon.IsShadowPokemon; buttonMarkings.IsEnabled = true; buttonMoves.IsEnabled = !pokemon.IsEgg && !pokemon.IsShadowPokemon; buttonGive.IsEnabled = !pokemon.IsEgg; buttonTake.IsEnabled = pokemon.IsHoldingItem; SetCurrentMove(-1); }
private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e) { PokeManager.DropSelection(); PokeManager.DropPokemon(); }
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 OnAddSaveClicked(object sender, RoutedEventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = "Add Generation III Save"; fileDialog.Filter = "GBA and GameCube Saves (*.sav, *.gci)|*.sav;*.gci|GBA Saves (*.sav)|*.sav|GameCube Saves (*.gci)|*.gci|All Files (*.*)|*.*"; var result = fileDialog.ShowDialog(this); if (result.HasValue && result.Value) { string filePath = fileDialog.FileName; filePath = System.IO.Path.GetFullPath(filePath); foreach (ListViewItem item in gameSaves) { GameSaveFileInfo save = item.Tag as GameSaveFileInfo; if (filePath.ToLower() == System.IO.Path.GetFullPath(save.FilePath).ToLower()) { TriggerMessageBox.Show(this, "This game save already exists", "Already Exists"); return; } } try { FileInfo fileInfo = new FileInfo(filePath); GameSaveFileInfo gameSaveFile; GameTypes gameType = GameTypes.Any; bool isJapanese = false; if (fileInfo.Length == 131072 || fileInfo.Length == 65536 || fileInfo.Length == 139264) { var results = SelectGameTypeFullWindow.ShowDialog(this, false); if (results != null) { gameType = results.GameType; isJapanese = results.IsJapanese; } } gameSaveFile = PokeManager.MakeNewGameSaveFileInfo(filePath, gameType, isJapanese); ListViewItem listViewItem = new ListViewItem(); FillListViewItem(gameSaveFile, listViewItem); gameSaves.Add(listViewItem); listViewGameSaves.SelectedIndex = listViewGameSaves.Items.Count - 1; // Hackish thing to make sure the list view is always scrolled at the bottom when adding a new box //http://stackoverflow.com/questions/211971/scroll-wpf-listview-to-specific-line /*VirtualizingStackPanel vsp = * (VirtualizingStackPanel)typeof(ItemsControl).InvokeMember("_itemsHost", * BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, * listViewGameSaves, null); * double scrollHeight = vsp.ScrollOwner.ScrollableHeight; * vsp.SetVerticalOffset(vsp.ScrollOwner.ScrollableHeight * 2);*/ listViewGameSaves.ScrollIntoView(listViewGameSaves.SelectedItem); ((Control)listViewGameSaves.SelectedItem).Focus(); } catch (Exception ex) { MessageBoxResult result2 = TriggerMessageBox.Show(this, "Error loading game save file. Would you like to see the error?", "Read Error", MessageBoxButton.YesNo); if (result2 == MessageBoxResult.Yes) { ErrorMessageBox.Show(ex); } } } }
private void OKClicked(object sender, RoutedEventArgs e) { deoxys.DeoxysForm = form; PokeManager.RefreshUI(); DialogResult = true; }
private void OnSaveClicked(object sender, RoutedEventArgs e) { byte[] trainerNameBytes = GBACharacterEncoding.GetBytes(trainerName, 7); string newTrainerName = GBACharacterEncoding.GetString(trainerNameBytes); bool setName = newTrainerName != gameSave.TrainerName; bool setGender = trainerGender != gameSave.TrainerGender; if (setName || setGender) { MessageBoxResult result = TriggerMessageBox.Show(this, "Warning: Renaming a trainer or changing their gender will also change the OT Trainer of every Pokémon caught by this trainer in all saves. Are you sure you want to continue?", "Warning", MessageBoxButton.YesNo); //if (result == MessageBoxResult.Yes && (gameSave.GameType == GameTypes.Ruby || gameSave.GameType == GameTypes.Sapphire || gameSave.GameType == GameTypes.Emerald)) // result = TriggerMessageBox.Show(this, "Warning: Certain scripts may act incorrectly if you change your gender. This includes after you beat the Elite Four where you will get stuck in a wall. Are you sure you want to continue?", "Warning", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { if (setName) { gameSave.TrainerName = GBACharacterEncoding.CheckString(newTrainerName, gameSave.IsJapanese ? Languages.Japanese : Languages.English); } if (setGender) { gameSave.TrainerGender = trainerGender; } for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave newGameSave = PokeManager.GetGameSaveAt(i); if (newGameSave is ManagerGameSave) { for (int j = 0; j < (newGameSave as ManagerGameSave).NumPokePCRows; j++) { foreach (IPokemon pokemon in (newGameSave as ManagerGameSave).GetPokePCRow(j)) { if (pokemon.TrainerID == gameSave.TrainerID && pokemon.SecretID == gameSave.SecretID) { if (setName) { pokemon.TrainerName = newTrainerName; } if (setGender) { pokemon.TrainerGender = trainerGender; } } } } } else { foreach (IPokemon pokemon in newGameSave.PokePC) { if (pokemon.TrainerID == gameSave.TrainerID && pokemon.SecretID == gameSave.SecretID) { if (setName) { pokemon.TrainerName = newTrainerName; } if (setGender) { pokemon.TrainerGender = trainerGender; } } } } } gameSave.IsChanged = true; PokeManager.RefreshUI(); } } DialogResult = true; }
private void OnSendFrom(object sender, RoutedEventArgs e) { SendCurrencyToWindow.ShowDialog(Window.GetWindow(this), PokeManager.GetIndexOfGame(gameSave), selectedCurrency, false); }
public void UpdateDisplay() { this.labeTitle.Content = eventDist.GetTitle(gameSave) + (PokeManager.IsEventCompletedBy(eventDist.ID, gameSave) ? " (Completed)" : ""); }
public void SearchPokemon() { if (Search.SearchMode == SearchModes.NewSearch) { Results.Clear(); } else { // Make sure to recapture the location and final class of every pokemon for (int i = 0; i < Results.Count; i++) { if (Results[i].ContainerIndex == -1) { Results[i] = Results[i].PokemonFinder.Pokemon; } } } if (Search.SearchMode == SearchModes.RefineResults) { List <IPokemon> previousResults = Results; Results = new List <IPokemon>(); foreach (IPokemon pokemon in previousResults) { if (Search.GameEnabled && Search.GameIndex != pokemon.GameSave.GameIndex) { continue; } if (IsPokemonValid(pokemon)) { Results.Add(pokemon); } } } else { for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave gameSave = PokeManager.GetGameSaveAt(i); if (Search.GameEnabled && Search.GameIndex != i) { continue; } if (gameSave is ManagerGameSave) { for (int j = 0; j < (gameSave as ManagerGameSave).NumPokePCRows; j++) { foreach (IPokemon pokemon in (gameSave as ManagerGameSave).GetPokePCRow(j)) { if (IsPokemonValid(pokemon) && (Search.SearchMode == SearchModes.NewSearch || !Results.Contains(pokemon))) { Results.Add(pokemon); } } } } else { foreach (IPokemon pokemon in gameSave.PokePC) { if (IsPokemonValid(pokemon) && (Search.SearchMode == SearchModes.NewSearch || !Results.Contains(pokemon))) { Results.Add(pokemon); } } } } } // Sorting time if (Search.SortMethod != SortMethods.None) { if (Search.SortMethod == SortMethods.Alphabetical) { if (Search.SortOrder == SortOrders.LowestToHighest) { Results.Sort((p1, p2) => (string.Compare(p1.PokemonData.Name, p2.PokemonData.Name, true))); } else { Results.Sort((p1, p2) => (string.Compare(p2.PokemonData.Name, p1.PokemonData.Name, true))); } } else { if (Search.SortOrder == SortOrders.LowestToHighest) { Results.Sort((p1, p2) => (int)(GetSortMethodValue(p1) - GetSortMethodValue(p2))); } else { Results.Sort((p1, p2) => (int)(GetSortMethodValue(p2) - GetSortMethodValue(p1))); } } } }
private void OnWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { PokeManager.SaveSettings(); PokeManager.RefreshUI(); }
// Use this for initialization void Start() { //WildPokemonTrigger.StartBattle.AddListener(StartBattle); pokeManager = FindObjectOfType <PokeManager>(); }
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 FillListViewItems() { listViewDecorations.Items.Clear(); /*for (byte i = 0; i < pocket.SlotsUsed; i++) { * int countLeft = (int)pocket[i].Count; * if (pocket.MaxStackSize == 0) { * foreach (PlacedDecoration decoration in secretBase.PlacedDecorations) { * if (decoration.ID == pocket[i].ID) * countLeft--; * } * if (countLeft <= 0) * continue; * } * else { * if (pocket.Inventory.IsDecorationInUse(i, pocket.PocketType)) * continue; * } * AddDecorationListViewItem(pocket[i], countLeft); * }*/ if (pocket.MaxStackSize == 0) { List <int> decorations = new List <int>(); for (int i = 0; i <= 120; i++) { decorations.Add(0); } for (int i = -1; i < PokeManager.NumGameSaves; i++) { IGameSave gameSave = PokeManager.GetGameSaveAt(i); if (gameSave.Inventory != null && gameSave.Inventory.Decorations != null) { DecorationPocket newPocket = gameSave.Inventory.Decorations[pocket.PocketType]; for (int j = 0; j < newPocket.SlotsUsed; j++) { if (gameSave.Inventory.Decorations.IsDecorationInUse(j, pocket.PocketType)) { continue; } decorations[newPocket[j].ID] += (int)newPocket[j].Count; } } } for (int i = 1; i <= 120; i++) { if (decorations[i] == 0) { continue; } int countLeft = decorations[i]; foreach (PlacedDecoration decoration in secretBase.PlacedDecorations) { if (decoration.ID == i) { countLeft--; } } if (countLeft <= 0) { continue; } AddDecorationListViewItem(new Decoration((byte)i, (uint)decorations[i], null), countLeft); } } else { for (byte i = 0; i < pocket.SlotsUsed; i++) { if (pocket.Inventory.IsDecorationInUse(i, pocket.PocketType)) { continue; } AddDecorationListViewItem(pocket[i]); } } }
private void OnWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { PokeManager.ReloadRowComboBoxes(); }
private void OKClicked(object sender, RoutedEventArgs e) { pokemon.Markings = markings; PokeManager.RefreshUI(); DialogResult = true; }
public void OnGameSwitch(PokemonBoxViewer caller = null) { if (PokeManager.IsHoldingPokemon || PokeManager.HasSelection) { PokeManager.DropAll(); PokeManager.ClearSelectedPokemon(); PokeManager.RefreshUI(); } if (!PokeManager.Settings.AllowDoubleBoxRows) { if (caller == null) { caller = boxViewer1; } int callerIndex = GetIndex(caller); PokemonBoxViewer[] priorities = new PokemonBoxViewer[3]; boxViewer1.SupressIndexChanged = true; boxViewer2.SupressIndexChanged = true; boxViewer3.SupressIndexChanged = true; priorities[0] = boxViewer1; if (callerIndex == 1) { if (IsValid(boxViewer2, caller) || !IsValid(boxViewer3, caller)) { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } else { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } boxViewer2.ComboBoxGames.ResetGameSaveVisibility(); boxViewer3.ComboBoxGames.ResetGameSaveVisibility(); if (GetNumRows(caller) == 1) { boxViewer2.ComboBoxGames.SetGameSaveVisible(GameIndex, false); boxViewer3.ComboBoxGames.SetGameSaveVisible(GameIndex, false); } } else if (callerIndex == 2) { if (GetNumRows(caller) > 2) { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } else { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } //FindAvailableRow(priorities[1], priorities[1]); } else { if (GetNumRows(caller) > 2) { priorities[1] = boxViewer2; priorities[2] = boxViewer3; } else { priorities[1] = boxViewer3; priorities[2] = boxViewer2; } //FindAvailableRow(priorities[1], priorities[1]); } MakeValid(priorities[1], priorities[0]); MakeValid(priorities[2], priorities[0], priorities[1]); boxViewer1.SupressIndexChanged = false; boxViewer2.SupressIndexChanged = false; boxViewer3.SupressIndexChanged = false; } else { boxViewer2.ComboBoxGames.ResetGameSaveVisibility(); boxViewer3.ComboBoxGames.ResetGameSaveVisibility(); } }
private void OnSendTo(object sender, EventArgs e) { if (HasSelection) { if (selectionIsImportant == 1) { foreach (Item item in SelectedItems) { ItemPocket pocket = PokeManager.ManagerGameSave.Inventory.Items[item.ItemData.PocketType]; if (pocket.GetCountOfID(item.ID) == 0) { pocket.AddItem(item.ID, 1); } } } else { var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, "Send Item Selection", SelectedItems[0].ItemData.PocketType, false, selectionExclusives); if (results != null) { bool noRoom = false; foreach (Item item in SelectedItems) { int finalCount = results.GetFinalCount(item.Count); if (finalCount > 0) { if (PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].HasRoomForItem(item.ID, (uint)finalCount)) { PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].AddItem(item.ID, (uint)finalCount); pocket.TossItemAt(pocket.IndexOf(item), (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 if (selectedItem.ItemData.IsImportant) { ItemPocket pocket = PokeManager.ManagerGameSave.Inventory.Items[selectedItem.ItemData.PocketType]; if (pocket.GetCountOfID(selectedItem.ID) == 0) { pocket.AddItem(selectedItem.ID, 1); } } else { var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedItem.Count, "Send Item", selectedItem.ItemData.PocketType, false, selectedItem.ItemData.Exclusives); //SendItemToResult result = SendItemToWindow.ShowDialog(Window.GetWindow(this), pocket.Inventory.GameIndex, selectedItem.ID, selectedItem.Count); if (results != null) { if (PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].HasRoomForItem(selectedItem.ID, (uint)results.Count)) { PokeManager.GetGameSaveAt(results.GameIndex).Inventory.Items[results.Pocket].AddItem(selectedItem.ID, (uint)results.Count); pocket.TossItemAt(selectedIndex, (uint)results.Count); } else { // No room for item TriggerMessageBox.Show(Window.GetWindow(this), "No room for that item", "No Room"); } } } }
private void OnPokemonSelected(object sender, PokemonSelectedEventArgs e) { if (mode == SendPokemonModes.GiveItem && ((PokeBoxControl)sender).IsPickupMode && e.Pokemon != null) { if (e.Pokemon.IsEgg) { TriggerMessageBox.Show(this, "Cannot give items to Eggs", "Can't Hold"); } else if (e.Pokemon.HeldItemID != 0 && e.Pokemon.HeldItemData.ID == 0) { TriggerMessageBox.Show(this, "Cannot switch " + e.Pokemon.Nickname + "'s item because it is an Unknown Item", "Unknown Item"); } else if (e.Pokemon.HeldItemID == giveItem.ID) { TriggerMessageBox.Show(this, e.Pokemon.Nickname + " is already holding " + e.Pokemon.HeldItemData.Name, "Already Holding"); } else { MessageBoxResult result = MessageBoxResult.Yes; if (e.Pokemon.IsHoldingMail) { result = MessageBoxResult.No; TriggerMessageBox.Show(this, "Cannot give " + giveItem.ItemData.Name + " to this Pokémon because it is holding mail. To remove the mail goto the mailbox tab and click Take Mail From Party", "Can't Give Item"); } else if (e.Pokemon.IsHoldingItem) { result = TriggerMessageBox.Show(this, e.Pokemon.Nickname + " is already holding " + e.Pokemon.HeldItemData.Name + ", would you like to switch it with " + giveItem.ItemData.Name + "?", "Switch Items", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { PokeManager.ManagerGameSave.Inventory.Items[e.Pokemon.HeldItemData.PocketType].AddItem(e.Pokemon.HeldItemID, 1); } } if (result == MessageBoxResult.Yes) { e.Pokemon.HeldItemID = giveItem.ID; giveItem.Pocket.TossItemAt(giveItem.Pocket.IndexOf(giveItem), 1); TriggerMessageBox.Show(Window.GetWindow(this), "Gave " + giveItem.ItemData.Name + " to " + e.Pokemon.Nickname, "Gave Item"); PokeManager.RefreshUI(); PokeManager.LastGameInDialogIndex = gameIndex; DialogResult = true; } } } else if (mode == SendPokemonModes.SendTo && e.Pokemon == null) { if (!PokeManager.CanSafelyPlaceHeldUnknownItem(e.PokeContainer)) { MessageBoxResult unknownItemResult = TriggerMessageBox.Show(Window.GetWindow(this), "The Pokémon that you are trying to send is holding an Unknown Item. Sending it to a different game may cause problems. Are you sure you want to send it?", "Unknown Item", MessageBoxButton.YesNo); if (unknownItemResult == MessageBoxResult.No) { return; } } PokeManager.PlacePokemon(e.PokeContainer, e.Index); PokeManager.LastGameInDialogIndex = gameIndex; DialogResult = true; } else if (mode == SendPokemonModes.SendFrom && e.Pokemon != null) { if (e.Pokemon.HeldItemID != 0 && e.Pokemon.HeldItemData.ID == 0 && e.Pokemon.GameSave != container.GameSave) { MessageBoxResult unknownItemResult = TriggerMessageBox.Show(Window.GetWindow(this), "That Pokémon is holding an Unknown Item. Sending it to a different game may cause problems. Are you sure you want to send it?", "Unknown Item", MessageBoxButton.YesNo); if (unknownItemResult == MessageBoxResult.No) { return; } } if (PokeManager.CanPickupPokemon(e.Pokemon)) { PokeManager.PickupPokemon(e.Pokemon, null); PokeManager.PlacePokemon(container, containerIndex); PokeManager.LastGameInDialogIndex = gameIndex; DialogResult = true; } else if (PokeManager.IsPartyHoldingMail(e.PokeContainer)) { TriggerMessageBox.Show(Window.GetWindow(this), "Cannot send that Pokémon. A 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(Window.GetWindow(this), "Cannot send that Pokémon. It is the last valid Pokémon in your party", "Can't Send"); } } else if (mode == SendPokemonModes.SendMulti && e.Pokemon == null) { if (!PokeManager.CanSafelyPlaceHeldUnknownItem(e.PokeContainer)) { MessageBoxResult unknownItemResult = TriggerMessageBox.Show(Window.GetWindow(this), "A Pokémon that you are trying to send is holding an Unknown Item. Sending it to a different game may cause problems. Are you sure you want to send it?", "Unknown Item", MessageBoxButton.YesNo); if (unknownItemResult == MessageBoxResult.No) { return; } } if (e.PokeContainer.PokePC.HasRoomForPokemon(PokeManager.NumSelectedPokemon)) { PokeManager.PlaceSelection(e.PokeContainer, e.Index); PokeManager.ClearSelectedPokemon(); PokeManager.LastGameInDialogIndex = gameIndex; DialogResult = true; } else { TriggerMessageBox.Show(Window.GetWindow(this), "Not enough room in game to store all selected Pokémon", "No Room"); } } else if (mode == SendPokemonModes.SelectPokemon && e.Pokemon != null && ((PokeBoxControl)sender).IsPickupMode && (!e.Pokemon.IsEgg || !noEggs) && !e.Pokemon.IsShadowPokemon) { pokemon = e.Pokemon; DialogResult = true; } }
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); }
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 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; }
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"); } } } } }
private void OnGameSelectionChanged(object sender, SelectionChangedEventArgs e) { if (!loaded) { return; } gameIndex = comboBoxGame.SelectedGameIndex; ItemPocket pocket = PokeManager.GetGameSaveAt(gameIndex).Inventory.Items[ItemTypes.PokeBalls]; listViewBalls.Items.Clear(); selectedIndex = -1; selectedItem = null; for (int i = 0; i < pocket.SlotsUsed; i++) { Item item = pocket[i]; ListViewItem listViewItem = new ListViewItem(); listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 170; Image image = new Image(); image.Source = PokemonDatabase.GetBallCaughtImageFromID((byte)item.ID); image.Stretch = Stretch.None; image.SnapsToDevicePixels = true; image.UseLayoutRounding = true; image.HorizontalAlignment = HorizontalAlignment.Center; image.VerticalAlignment = VerticalAlignment.Center; TextBlock itemName = new TextBlock(); itemName.VerticalAlignment = VerticalAlignment.Center; itemName.Text = ItemDatabase.GetItemFromID(item.ID).Name; itemName.TextTrimming = TextTrimming.CharacterEllipsis; itemName.Margin = new Thickness(4, 0, 0, 0); TextBlock itemX = new TextBlock(); itemX.VerticalAlignment = VerticalAlignment.Center; itemX.HorizontalAlignment = HorizontalAlignment.Right; itemX.TextAlignment = TextAlignment.Right; itemX.Text = "x"; itemX.Width = Double.NaN; itemX.MinWidth = 10; TextBlock itemCount = new TextBlock(); itemCount.VerticalAlignment = VerticalAlignment.Center; itemCount.HorizontalAlignment = HorizontalAlignment.Right; itemCount.TextAlignment = TextAlignment.Right; itemCount.Width = 30; itemCount.Text = item.Count.ToString(); listViewItem.Content = dockPanel; listViewBalls.Items.Add(listViewItem); dockPanel.Children.Add(image); dockPanel.Children.Add(itemName); dockPanel.Children.Add(itemCount); dockPanel.Children.Add(itemX); DockPanel.SetDock(image, Dock.Left); DockPanel.SetDock(itemCount, Dock.Right); } }