public static byte?Show(Window owner, byte location, SecretBaseManager manager = null, bool startInvalid = false)
        {
            SecretBaseLocationChooser window = new SecretBaseLocationChooser(location, manager, startInvalid);

            window.Owner = owner;
            window.ShowDialog();
            if (window.DialogResult.HasValue && window.DialogResult.Value)
            {
                return(window.location);
            }
            return(null);
        }
        public SecretBaseLocationChooser(byte location, SecretBaseManager manager, bool startInvalid)
        {
            InitializeComponent();

            this.originalLocation = location;
            this.location         = (location == 0 ? (byte)181 : location);
            this.manager          = manager;
            this.startInvalid     = startInvalid;

            for (int i = 0; i < SecretBaseDatabase.NumLocations; i++)
            {
                LocationData locationData = SecretBaseDatabase.GetLocationAt(i);

                ListViewItem listViewItem = new ListViewItem();
                listViewItem.Tag = locationData.ID;
                StackPanel stackPanel = new StackPanel();
                stackPanel.Orientation = Orientation.Horizontal;
                Grid grid = new Grid();
                grid.Width  = 16;
                grid.Height = 16;

                Image type = new Image();
                type.Width  = 16;
                type.Height = 16;
                type.HorizontalAlignment = HorizontalAlignment.Center;
                type.VerticalAlignment   = VerticalAlignment.Center;
                type.Source = ResourceDatabase.GetImageFromName("SecretBaseType" + locationData.Type.ToString());

                Label layout = new Label();
                layout.Padding                    = new Thickness(0, 0, 0, 0);
                layout.Width                      = 16;
                layout.Height                     = 16;
                layout.HorizontalAlignment        = HorizontalAlignment.Center;
                layout.VerticalAlignment          = VerticalAlignment.Center;
                layout.HorizontalContentAlignment = HorizontalAlignment.Center;
                layout.VerticalContentAlignment   = VerticalAlignment.Center;
                layout.Content                    = locationData.Layout.ToString();
                layout.FontWeight                 = FontWeights.Bold;
                //layout.Foreground = new SolidColorBrush(Color.FromRgb(255, 255, 255));

                grid.Children.Add(type);
                grid.Children.Add(layout);

                Label label = new Label();
                label.VerticalAlignment = System.Windows.VerticalAlignment.Center;
                label.Padding           = new Thickness(4, 0, 4, 0);
                label.Content           = "Route " + locationData.RouteData.ID;
                if ((startInvalid || originalLocation != locationData.ID) && manager != null && manager.IsLocationInUse(locationData.ID))
                {
                    label.Foreground = new SolidColorBrush(Color.FromRgb(220, 0, 0));
                }
                else if (OriginalLocationData != null && locationData.Type == OriginalLocationData.Type && locationData.Layout == OriginalLocationData.Layout)
                {
                    label.Foreground = new SolidColorBrush(Color.FromRgb(0, 140, 60));
                    label.FontWeight = FontWeights.Bold;
                }

                stackPanel.Children.Add(grid);
                stackPanel.Children.Add(label);
                listViewItem.Content = stackPanel;
                listViewSecretBases.Items.Add(listViewItem);
                if (locationData.ID == this.location)
                {
                    listViewSecretBases.SelectedIndex = listViewSecretBases.Items.Count - 1;
                }
            }
            if (listViewSecretBases.SelectedIndex == -1)
            {
                OnLocationSelected(null, null);
            }
        }
Exemplo n.º 3
0
        public static bool Show(Window owner, byte locationID, SecretBaseManager manager, bool allowNoTeam)
        {
            SharedSecretBase secretBase = new SharedSecretBase(locationID, manager);

            return(Show(owner, secretBase, allowNoTeam, true));
        }
Exemplo n.º 4
0
        public BlockDataCollection(GBAGameSave gameSave, byte[] data)
        {
            if (data.Length != 57344)
            {
                throw new Exception("Save data size must be 57344 bytes");
            }

            this.inventory = new Inventory(gameSave);
            this.pokePC    = new GBAPokePC(gameSave);
            this.mailbox   = new Mailbox(gameSave, 10);
            this.gameSave  = gameSave;

            // Find the trainer info block data first to get vital information
            // AKA: GameCode and Security Key
            for (int i = 0; i < 14; i++)
            {
                if (ReadSectionID(data, i) == SectionTypes.TrainerInfo)
                {
                    Add(new TrainerInfoBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                    break;
                }
            }

            // Now that we have the trainer info we can get the rest of the blocks
            for (int i = 0; i < 14; i++)
            {
                SectionTypes sectionID = ReadSectionID(data, i);
                if (sectionID == SectionTypes.TeamAndItems)
                {
                    Add(new TeamAndItemsBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                }
                else if (sectionID == SectionTypes.Unknown1)
                {
                    Add(new NationalPokedexBAndCBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                }
                else if (sectionID == SectionTypes.Unknown2)
                {
                    Add(new DecorationBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                }
                else if (sectionID == SectionTypes.RivalInfo)
                {
                    Add(new RivalInfoBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                }
                else if (sectionID >= SectionTypes.PCBufferA && sectionID <= SectionTypes.PCBufferI)
                {
                    Add(new PokeBoxBlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                }
                else if (sectionID != SectionTypes.TrainerInfo)
                {
                    Add(new BlockData(gameSave, ByteHelper.SubByteArray(i * 4096, data, 4096), this));
                }
            }

            // Sort the block data list, why not
            List <IBlockData> list = Enumerable.ToList <IBlockData>((IEnumerable <IBlockData>)Enumerable.OrderBy <IBlockData, SectionTypes>(this, (Func <IBlockData, SectionTypes>)(u => u.SectionID)));

            Clear();
            AddRange((IEnumerable <IBlockData>)list);

            // Gather Secret Base Data
            if (GameCode == GameCodes.Emerald || GameCode == GameCodes.RubySapphire)
            {
                List <byte> sbData = new List <byte>(19 * 160);
                if (GameCode == GameCodes.Emerald)
                {
                    sbData.AddRange(ByteHelper.SubByteArray(3004, NationalPokedexBAndC.Raw, 964));
                    sbData.AddRange(ByteHelper.SubByteArray(0, DecorationData.Raw, 2076));
                }
                else if (GameCode == GameCodes.RubySapphire)
                {
                    sbData.AddRange(ByteHelper.SubByteArray(2856, NationalPokedexBAndC.Raw, 1112));
                    sbData.AddRange(ByteHelper.SubByteArray(0, DecorationData.Raw, 1928));
                }
                secretBaseManager = new SecretBaseManager(gameSave, sbData.ToArray());
            }

            // Gather the PC data
            List <byte>       pcData      = new List <byte>(33730);
            List <IBlockData> pcBlockList = this.Where <IBlockData>((IBlockData u) => {
                if (u.SectionID < SectionTypes.PCBufferA)
                {
                    return(false);
                }
                return(u.SectionID <= SectionTypes.PCBufferI);
            }).ToList <IBlockData>();

            foreach (IBlockData blockData in pcBlockList)
            {
                pcData.AddRange((blockData as PokeBoxBlockData).GetBoxData());
            }
            this.pokePC.Load(pcData.ToArray());
        }