public AdvancedSendSingleToWindow(int gameIndex, int max, string title, object sendType, bool withdrawMode, GameTypeFlags exclusives)
        {
            InitializeComponent();
            this.loaded = false;
            this.realMax = max;
            this.Title = title;
            this.max = 1;
            this.sendAll = false;
            this.itemType = (sendType is ItemTypes ? (ItemTypes)sendType : ItemTypes.Unknown);
            this.isDecoration = false;
            this.pocket = this.itemType;
            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;

            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);
        }
Beispiel #2
0
 public ItemData(DataRow row, Generations gen)
 {
     this.id				= (ushort)(long)row["ID"];
     this.name			= row["Name"] as string;
     this.description	= row["Description"] as string;
     this.pocketType		= ItemData.GetPocketTypeFromString(row["Pocket"] as string);
     this.subPocketType	= (row["SubPocket"] is DBNull ? this.pocketType : ItemData.GetPocketTypeFromString(row["SubPocket"] as string));
     this.transferUpID	= 0; //(ushort)(long)row["TransferUpID"];
     this.order			= (row["Order"] is DBNull ? 0 : (int)(long)row["Order"]);
     this.price			= (uint)(long)row["Price"];
     this.sell			= (uint)(long)row["Sell"];
     this.coinsPrice		= (uint)(long)row["Coins"];
     this.bpPrice		= (uint)(long)row["BP"];
     this.pcPrice		= (uint)(long)row["PC"];
     this.sootPrice		= (uint)(long)row["Soot"];
     this.obtainable		= (bool)row["Obtainable"];
     this.important		= (bool)row["Important"];
     this.exclusives		= ItemData.GetExclusivesFromString(row["Exclusive"] as string, gen);
 }
 public ItemData(DataRow row, Generations gen)
 {
     this.id            = (ushort)(long)row["ID"];
     this.name          = row["Name"] as string;
     this.description   = row["Description"] as string;
     this.pocketType    = ItemData.GetPocketTypeFromString(row["Pocket"] as string);
     this.subPocketType = (row["SubPocket"] is DBNull ? this.pocketType : ItemData.GetPocketTypeFromString(row["SubPocket"] as string));
     this.transferUpID  = 0;                  //(ushort)(long)row["TransferUpID"];
     this.order         = (row["Order"] is DBNull ? 0 : (int)(long)row["Order"]);
     this.price         = (uint)(long)row["Price"];
     this.sell          = (uint)(long)row["Sell"];
     this.coinsPrice    = (uint)(long)row["Coins"];
     this.bpPrice       = (uint)(long)row["BP"];
     this.pcPrice       = (uint)(long)row["PC"];
     this.sootPrice     = (uint)(long)row["Soot"];
     this.obtainable    = (bool)row["Obtainable"];
     this.important     = (bool)row["Important"];
     this.exclusives    = ItemData.GetExclusivesFromString(row["Exclusive"] as string, gen);
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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);
        }
 public static AdvancedSendSingleResults ShowDialog(Window owner, int gameIndex, int max, string title, object sendType, bool withdrawMode, GameTypeFlags exclusives = GameTypeFlags.AllGen3)
 {
     AdvancedSendSingleToWindow window = new AdvancedSendSingleToWindow(gameIndex, max, title, sendType, withdrawMode, exclusives);
     window.Owner = owner;
     var result = window.ShowDialog();
     if (result.HasValue && result.Value) {
         if (!withdrawMode)
             PokeManager.LastGameInDialogIndex = window.gameIndex;
         AdvancedSendSingleResults results = new AdvancedSendSingleResults();
         results.Count = (window.sendAll ? window.realMax : window.max);
         results.GameIndex = window.gameIndex;
         results.Pocket = window.pocket;
         return results;
     }
     return null;
 }
        private void OnContextMenuOpening(object sender, ContextMenuEventArgs e)
        {
            if (selectedItem != null && selectedItem.ItemData.ID != 0)
            {
                if (HasSelection)
                {
                    selectionIsImportant = -1;
                    selectionMax         = 0;
                    bool      roomInCollection = false;
                    bool      unknownItem      = false;
                    ItemTypes itemType         = SelectedItems[0].ItemData.PocketType;
                    selectionExclusives = GameTypeFlags.AllGen3;
                    foreach (Item item in SelectedItems)
                    {
                        selectionExclusives &= item.ItemData.Exclusives;
                        selectionMax         = Math.Max(selectionMax, (int)item.Count);
                        if (item.ItemData.ID == 0)
                        {
                            unknownItem = true;
                        }
                        else if (item.ItemData.IsImportant)
                        {
                            if (selectionIsImportant == -1)
                            {
                                selectionIsImportant = 1;
                            }
                            else if (selectionIsImportant == 0)
                            {
                                selectionIsImportant = 2;
                            }
                            if (PokeManager.ManagerGameSave.Inventory.Items[item.ItemData.PocketType].GetCountOfID(item.ID) == 0)
                            {
                                roomInCollection = true;
                            }
                        }
                        else
                        {
                            if (selectionIsImportant == -1)
                            {
                                selectionIsImportant = 0;
                            }
                            else if (selectionIsImportant == 1)
                            {
                                selectionIsImportant = 2;
                            }
                        }
                        if (item.ItemData.PocketType != itemType)
                        {
                            itemType = ItemTypes.Unknown;
                        }
                    }

                    ((MenuItem)contextMenu.Items[0]).Header = (pocket.PocketType == ItemTypes.PC ? "Withdraw" : "Deposit");
                    ((MenuItem)contextMenu.Items[1]).Header = (pocket.PocketType == ItemTypes.PC ? "Withdraw All" : "Deposit All");
                    ((MenuItem)contextMenu.Items[2]).Header = (selectionIsImportant == 1 ? "Add to Collection" : "Send To");

                    ((MenuItem)contextMenu.Items[0]).IsEnabled = !unknownItem && selectionIsImportant == 0 && pocket.Inventory.ContainsPocket(ItemTypes.PC);
                    ((MenuItem)contextMenu.Items[1]).IsEnabled = !unknownItem && selectionIsImportant == 0 && pocket.Inventory.ContainsPocket(ItemTypes.PC);
                    ((MenuItem)contextMenu.Items[2]).IsEnabled = !unknownItem && itemType != ItemTypes.Unknown && (selectionIsImportant == 0 || (roomInCollection && selectionIsImportant == 1));
                    ((MenuItem)contextMenu.Items[3]).IsEnabled = false;
                    ((MenuItem)contextMenu.Items[5]).IsEnabled = !unknownItem && (selectionIsImportant == 0 || pocket.GameSave.GameIndex == -1);
                    ((MenuItem)contextMenu.Items[6]).IsEnabled = !unknownItem && (selectionIsImportant == 0 || pocket.GameSave.GameIndex == -1);
                }
                else
                {
                    ((MenuItem)contextMenu.Items[0]).Header = (pocket.PocketType == ItemTypes.PC ? "Withdraw" : "Deposit");
                    ((MenuItem)contextMenu.Items[1]).Header = (pocket.PocketType == ItemTypes.PC ? "Withdraw All" : "Deposit All");
                    ((MenuItem)contextMenu.Items[2]).Header = (selectedItem.ItemData.IsImportant ? "Add to Collection" : "Send To");

                    ((MenuItem)contextMenu.Items[0]).IsEnabled = !selectedItem.ItemData.IsImportant && pocket.Inventory.ContainsPocket(ItemTypes.PC);
                    ((MenuItem)contextMenu.Items[1]).IsEnabled = !selectedItem.ItemData.IsImportant && pocket.Inventory.ContainsPocket(ItemTypes.PC);
                    ((MenuItem)contextMenu.Items[2]).IsEnabled = (!selectedItem.ItemData.IsImportant || PokeManager.ManagerGameSave.Inventory.Items[selectedItem.ItemData.PocketType].GetCountOfID(selectedItem.ID) == 0);
                    ((MenuItem)contextMenu.Items[3]).IsEnabled = !selectedItem.ItemData.IsImportant && (selectedItem.ID < 121 || (selectedItem.ID > 132 && selectedItem.ID < 500));
                    ((MenuItem)contextMenu.Items[5]).IsEnabled = (!selectedItem.ItemData.IsImportant || pocket.GameSave.GameIndex == -1);
                    ((MenuItem)contextMenu.Items[6]).IsEnabled = (!selectedItem.ItemData.IsImportant || pocket.GameSave.GameIndex == -1);
                }
            }
            else
            {
                ((MenuItem)contextMenu.Items[0]).IsEnabled = false;
                ((MenuItem)contextMenu.Items[1]).IsEnabled = false;
                ((MenuItem)contextMenu.Items[2]).IsEnabled = false;
                ((MenuItem)contextMenu.Items[3]).IsEnabled = false;
                ((MenuItem)contextMenu.Items[5]).IsEnabled = false;
                ((MenuItem)contextMenu.Items[6]).IsEnabled = false;
            }
        }
        private static GameTypeFlags GetExclusivesFromString(string exclusives, Generations gen)
        {
            GameTypeFlags gameTypeFlags = GameTypeFlags.None;

            if (gen == Generations.Gen3)
            {
                if (exclusives == null || exclusives == "")
                {
                    return(GameTypeFlags.AllGen3);
                }
                if (exclusives.Contains('R'))
                {
                    gameTypeFlags |= GameTypeFlags.Ruby;
                }
                if (exclusives.Contains('S'))
                {
                    gameTypeFlags |= GameTypeFlags.Sapphire;
                }
                if (exclusives.Contains('E'))
                {
                    gameTypeFlags |= GameTypeFlags.Emerald;
                }
                if (exclusives.Contains('F'))
                {
                    gameTypeFlags |= GameTypeFlags.FireRed;
                }
                if (exclusives.Contains('L'))
                {
                    gameTypeFlags |= GameTypeFlags.LeafGreen;
                }
                if (exclusives.Contains('C'))
                {
                    gameTypeFlags |= GameTypeFlags.Colosseum;
                }
                if (exclusives.Contains('X'))
                {
                    gameTypeFlags |= GameTypeFlags.XD;
                }
            }
            else if (gen == Generations.Gen2)
            {
                if (exclusives == null || exclusives == "")
                {
                    return(GameTypeFlags.AllGen2);
                }
                if (exclusives.Contains('G'))
                {
                    gameTypeFlags |= GameTypeFlags.Gold;
                }
                if (exclusives.Contains('S'))
                {
                    gameTypeFlags |= GameTypeFlags.Silver;
                }
                if (exclusives.Contains('C'))
                {
                    gameTypeFlags |= GameTypeFlags.Crystal;
                }
            }
            else if (gen == Generations.Gen1)
            {
                if (exclusives == null || exclusives == "")
                {
                    return(GameTypeFlags.AllGen1);
                }
                if (exclusives.Contains('R'))
                {
                    gameTypeFlags |= GameTypeFlags.Red;
                }
                if (exclusives.Contains('B'))
                {
                    gameTypeFlags |= GameTypeFlags.Blue;
                }
                if (exclusives.Contains('Y'))
                {
                    gameTypeFlags |= GameTypeFlags.Yellow;
                }
            }
            return(gameTypeFlags);
        }
        public static AdvancedSendSingleResults ShowDialog(Window owner, int gameIndex, int max, string title, object sendType, bool withdrawMode, GameTypeFlags exclusives = GameTypeFlags.AllGen3)
        {
            AdvancedSendSingleToWindow window = new AdvancedSendSingleToWindow(gameIndex, max, title, sendType, withdrawMode, exclusives);

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

            if (result.HasValue && result.Value)
            {
                if (!withdrawMode)
                {
                    PokeManager.LastGameInDialogIndex = window.gameIndex;
                }
                AdvancedSendSingleResults results = new AdvancedSendSingleResults();
                results.Count     = (window.sendAll ? window.realMax : window.max);
                results.GameIndex = window.gameIndex;
                results.Pocket    = window.pocket;
                return(results);
            }
            return(null);
        }