Beispiel #1
0
 public Mission_Popup(int active)
 {
     InitializeComponent();
     StatesInit();
     for (int i = 0; i < retStates.Length; i++)
     {
         for (int j = 0; j < retStates[i].Length; j++)
         {
             retStates[i][j] = (((savedata[MissionCards.Ofset(i, j)] >> MissionCards.Shift(i, j)) & 1) == 1);
         }
     }
     NUP_Active.Value   = active;
     NUP_Mission.Value  = (active > 0) ? active : 1;
     NUP_Active.Maximum = NUP_Mission.Maximum = db.Missions.Length;
     UpdateForm();
 }
Beispiel #2
0
        private void B_MissionCards_Click(object sender, EventArgs e)
        {
            bool[][] missions = db.Missions;                                          //default values
            int      max = missions.Length, active = Math.Min(savedata[0xB6FB], max); //default values
            bool     boool = false;                                                   //default values

            if (ModifierKeys == Keys.Control)
            {
                using (var form = new Mission_Popup(active))
                {
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.OK)
                    {
                        active   = Math.Min(form.retActive, max);
                        missions = form.retStates;
                        boool    = true;
                    }
                    else
                    {
                        return;
                    }
                }
            }
            savedata[MissionCards.Ofset(0) - 1] = (byte)active;
            for (int i = 0; i < missions.Length; i++)
            {
                int data = BitConverter.ToInt32(savedata, MissionCards.Ofset(i)) & ~(0x3FF << MissionCards.Shift(i));
                for (int j = 0; j < missions[i].Length; j++)
                {
                    data |= ((missions[i][j] ? 1 : 0) << (MissionCards.Shift(i) + j));
                }
                Array.Copy(BitConverter.GetBytes(data), 0, savedata, MissionCards.Ofset(i), 4);
            }
            string str = null;

            if (!boool || missions == db.Missions)
            {
                str = "All Mission cards have been fully completed.";
            }
            else
            {
                Cases cases = 0;
                for (int i = 0; i < missions.Length; i++)
                {
                    for (int j = 0; db.Missions[i][j] == true; j++)
                    {
                        if (cases == Cases.Full && missions[i][j] == false)
                        {
                            cases = Cases.Select;
                        }
                        if (cases == Cases.Select && missions[i][j] == true)
                        {
                            cases = Cases.None;
                        }
                    }
                }
                if (cases == Cases.Select)
                {
                    str = "Mission cards fully reseted.";
                }
                if (cases == Cases.None)
                {
                    str = "Selected missions marked as completed.";
                }
            }
            str += "\n";
            str += (active == 0)
                ? "No Mission Card currently selected."
                : "Selected Mission Card is number " + active + ".";
            MessageBox.Show(str);
        }