Example #1
0
        private void B_Save_Click(object sender, EventArgs e)
        {
            ushort[] constants = SAV.GetEventConsts();
            for (int i = 0; i < CellCount; i++)
            {
                string str = (string)dgv.Rows[i].Cells[2].Value;
                int    val = Array.IndexOf(states, str);
                if (val < 0)
                {
                    throw new IndexOutOfRangeException("Unable to find cell index.");
                }

                constants[celloffset + i] = (ushort)val;
            }

            constants[cellstotal]     = (ushort)NUD_Cells.Value;
            constants[cellscollected] = (ushort)NUD_Collected.Value;
            if (SAV is SAV7USUM)
            {
                SAV.SetRecord(72, (int)NUD_Collected.Value);
            }

            SAV.SetEventConsts(constants);
            Origin.CopyChangesFrom(SAV);

            Close();
        }
Example #2
0
        public SAV_ZygardeCell(SaveFile sav)
        {
            InitializeComponent();
            WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
            SAV = (SAV7)(Origin = sav).Clone();

            // Constants @ 0x1C00
            // Cell Data @ 0x1D8C
            // Use constants 0x18C/2 = 198 thru +95
            ushort[] constants = SAV.GetEventConsts();
            var      cells     = constants.AsSpan(celloffset, CellCount);

            int cellCount     = constants[cellstotal];
            int cellCollected = constants[cellscollected];

            NUD_Cells.Value     = cellCount;
            NUD_Collected.Value = cellCollected;

            var combo = (DataGridViewComboBoxColumn)dgv.Columns[2];

            foreach (string t in states)
            {
                combo.Items.Add(t); // add only the Names
            }
            dgv.Columns[0].ValueType = typeof(int);

            // Populate Grid
            dgv.Rows.Add(CellCount);
            var locations = SAV is SAV7SM ? locationsSM : locationsUSUM;

            for (int i = 0; i < CellCount; i++)
            {
                if (cells[i] > 2)
                {
                    throw new IndexOutOfRangeException("Unable to find cell index.");
                }

                dgv.Rows[i].Cells[0].Value = (i + 1);
                dgv.Rows[i].Cells[1].Value = locations[i];
                dgv.Rows[i].Cells[2].Value = states[cells[i]];
            }
        }