private void OnToss(object sender, EventArgs e) { MessageBoxResult result = MessageBoxResult.Yes; if (HasSelection) { var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, "Toss Item Selection", ItemTypes.TheVoid, true); if (results != null) { if (PokeManager.Settings.TossConfirmation) { result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + listViewItems.SelectedItems.Count + " items?", "Toss Items", MessageBoxButton.YesNo); } if (result == MessageBoxResult.Yes) { foreach (Item item in SelectedItems) { int finalCount = results.GetFinalCount(item.Count); if (finalCount > 0) { pocket.TossItemAt(pocket.IndexOf(item), (uint)finalCount); } } } } } else { if (selectedItem.Count == 1) { OnTossAll(sender, e); } else { var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedItem.Count, "Toss Item", ItemTypes.TheVoid, true); //int? count = ItemCountWindow.ShowDialog(Window.GetWindow(this), "Toss", 1, (int)selectedItem.Count); if (results != null) { if (PokeManager.Settings.TossConfirmation) { if (results.Count == 1) { result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedItem.ItemData.Name + "?", "Toss Item", MessageBoxButton.YesNo); } else { result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + results.Count + " " + selectedItem.ItemData.Name + "s?", "Toss Item", MessageBoxButton.YesNo); } } if (result == MessageBoxResult.Yes) { pocket.TossItemAt(selectedIndex, (uint)results.Count); } } } } }
public static AdvancedSendSelectionResults ShowDialog(Window owner, int gameIndex, int max, string title, object sendType, bool withdrawMode, GameTypeFlags exclusives = GameTypeFlags.AllGen3) { AdvancedSendSelectionToWindow window = new AdvancedSendSelectionToWindow(gameIndex, max, title, sendType, withdrawMode, exclusives); window.Owner = owner; var result = window.ShowDialog(); if (result.HasValue && result.Value) { if (!withdrawMode) { PokeManager.LastGameInDialogIndex = window.gameIndex; } AdvancedSendSelectionResults results = new AdvancedSendSelectionResults(); results.Max = (window.sendAll ? window.realMax : (window.percentage ? window.percentageMax : window.max)); results.Min = (window.sendAll ? 0 : window.min); results.Keep = (window.sendAll ? 0 : window.keep); results.AsPercentage = (window.sendAll ? false : window.percentage); results.GameIndex = window.gameIndex; results.Pocket = window.pocket; return(results); } return(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"); } } } } }
private void OnDecorationToss(object sender, EventArgs e) { if (HasSelection) { var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, "Toss Decoration Selection", pocket.PocketType, true); 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 && PokeManager.Settings.TossConfirmation) { result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + listViewItems.SelectedItems.Count + " decorations?", "Toss Decoration Selection", MessageBoxButton.YesNo); } if (result == MessageBoxResult.Yes) { foreach (Decoration decoration in SelectedDecorations) { if (pocket.Inventory.IsDecorationInUse(pocket.IndexOf(decoration), pocket.PocketType)) { pocket.Inventory.PutAwayDecoration(pocket.IndexOf(decoration), pocket.PocketType); } int finalCount = results.GetFinalCount(decoration.Count); if (finalCount > 0) { pocket.TossDecorationAt(pocket.IndexOf(decoration), (uint)finalCount); } } } } } else { if (selectedDecoration.Count == 1) { OnDecorationTossAll(sender, e); } else { var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedDecoration.Count, "Toss Decoration", pocket.PocketType, true); //int? count = ItemCountWindow.ShowDialog(Window.GetWindow(this), "Toss", 1, (int)selectedDecoration.Count); if (results != null) { MessageBoxResult result = MessageBoxResult.Yes; if (pocket.AreAllDecorationsOfIDInUse(selectedDecoration.ID)) { DecorationUsages usage = pocket.Inventory.GetDecorationUsage(selectedIndex, pocket.PocketType); string usageString = (usage == DecorationUsages.SecretBase ? "Secret Base" : "Bedroom"); result = TriggerMessageBox.Show(Window.GetWindow(this), "Put away the " + selectedDecoration.DecorationData.Name + " in your " + usageString + "?", "Put Away", MessageBoxButton.YesNo); } if (result == MessageBoxResult.Yes && PokeManager.Settings.TossConfirmation) { if (results.Count == 1) { result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + selectedDecoration.DecorationData.Name + "?", "Toss Decoration", MessageBoxButton.YesNo); } else { result = TriggerMessageBox.Show(Window.GetWindow(this), "Are you sure you want to toss " + results.Count + " " + selectedDecoration.DecorationData.Name + "s?", "Toss Decoration", MessageBoxButton.YesNo); } } if (result == MessageBoxResult.Yes) { pocket.TossDecorationAt(selectedIndex, (uint)results.Count); } } } } }
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 OnDeposit(object sender, EventArgs e) { if (HasSelection) { string deposit = (pocket.PocketType == ItemTypes.PC ? "Withdraw" : "Deposit"); var results = AdvancedSendSelectionToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, selectionMax, deposit + " Item Selection", pocket.PocketType == ItemTypes.PC ? ItemTypes.Any : ItemTypes.PC, true, selectionExclusives); if (results != null) { bool noRoom = false; foreach (Item item in SelectedItems) { ItemTypes pocketType = (pocket.PocketType == ItemTypes.PC ? item.ItemData.PocketType : ItemTypes.PC); int finalCount = results.GetFinalCount(item.Count); if (finalCount > 0) { if (pocket.Inventory[pocketType].HasRoomForItem(item.ID, (uint)finalCount)) { pocket.Inventory[pocketType].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.Count == 1) { OnDepositAll(null, null); } else { string deposit = (pocket.PocketType == ItemTypes.PC ? "Withdraw" : "Deposit"); var results = AdvancedSendSingleToWindow.ShowDialog(Window.GetWindow(this), pocket.GameSave.GameIndex, (int)selectedItem.Count, deposit + " Item", pocket.PocketType == ItemTypes.PC ? selectedItem.ItemData.PocketType : ItemTypes.PC, true, selectedItem.ItemData.Exclusives); //int? count = ItemCountWindow.ShowDialog(Window.GetWindow(this), pocket.PocketType == ItemTypes.PC ? "Withdraw" : "Deposit", 1, (int)selectedItem.Count); if (results != null) { ItemTypes pocketType = (pocket.PocketType == ItemTypes.PC ? selectedItem.ItemData.PocketType : ItemTypes.PC); if (pocket.Inventory[pocketType].HasRoomForItem(selectedItem.ID, (uint)results.Count)) { pocket.Inventory[pocketType].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"); } } } } }