Esempio n. 1
0
 public void LoadData()
 {
     { // Driver options
         CMSN.DriverOptionsSection driverOpts = (CMSN.DriverOptionsSection)MissionData.GetSection(CMSN.BaseSection.SectionType.DriverOptions);
         if (driverOpts != null)
         {
             DriverAmount = driverOpts.DriverAmount;
             for (uint i = 0; i < DriverAmount; i++)
             {
                 for (uint j = 0; j < 4; j++)
                 {
                     SetPartsSelection(i, j, driverOpts.DriverChoices[i][j]);
                 }
             }
         }
     }
     { // Mission Flags
         CMSN.MissionFlagsSection  missionFlags = (CMSN.MissionFlagsSection)MissionData.GetSection(CMSN.BaseSection.SectionType.MissionFlags);
         CTGP7CourseList.NameEntry nameEntry    = TranslateTable.NameEntryFromID(missionFlags.CourseID);
         if (nameEntry == null)
         {
             nameEntry = TranslateTable.NameEntryFromID(0);
         }
         if (nameEntry == null)
         {
             throw new InvalidOperationException("CTGP-7 course name data needs to be downloaded.");
         }
         courseSelector.SelectedCourseNameEntry = nameEntry;
         ccComboBox.SelectedIndex  = missionFlags.Class;
         cpuComboBox.SelectedIndex = missionFlags.CPUDifficulty - 1;
     }
     { // Item Options
         CMSN.ItemOptionsSection itemOptions = (CMSN.ItemOptionsSection)MissionData.GetSection(CMSN.BaseSection.SectionType.ItemOptions);
         itemsModeBox.SelectedIndex = (int)itemOptions.Mode;
         spawnBoxCheck.Checked      = itemOptions.SpawnItemBoxes;
         { // Player Config
             probabilityPlayerViewer.PopulateData(GetProbabilityTableRows(itemOptions.PlayerConfig.ConfigMode, true), ItemNames, itemOptions.PlayerConfig.Probabilities);
             modePlayerBox.SelectedIndex = (int)itemOptions.PlayerConfig.ConfigMode;
             giveItemPlayerCheck.Checked = itemOptions.PlayerConfig.GiveItemEach.Frames != 0;
             if (giveItemPlayerCheck.Checked)
             {
                 giveAfterPlayerNum.Value = (decimal)itemOptions.PlayerConfig.GiveItemOffset.TotalSeconds;
                 giveEachPlayerNum.Value  = (decimal)itemOptions.PlayerConfig.GiveItemEach.TotalSeconds;
                 giveIDPlayerNum.Value    = itemOptions.PlayerConfig.GiveItemID;
             }
             roulettePlayerCheck.Checked = itemOptions.PlayerConfig.RouletteSpeed.Frames != 0;
             if (roulettePlayerCheck.Checked)
             {
                 roulettePlayerNum.Value = (decimal)itemOptions.PlayerConfig.RouletteSpeed.TotalSeconds;
             }
         }
         { // CPU Config
             probabilityCPUViewer.PopulateData(GetProbabilityTableRows(itemOptions.CPUConfig.ConfigMode, false), ItemNames, itemOptions.CPUConfig.Probabilities);
             modeCPUBox.SelectedIndex = (int)itemOptions.CPUConfig.ConfigMode;
             giveItemCPUCheck.Checked = itemOptions.CPUConfig.GiveItemEach.Frames != 0;
             if (giveItemCPUCheck.Checked)
             {
                 giveAfterCPUNum.Value = (decimal)itemOptions.CPUConfig.GiveItemOffset.TotalSeconds;
                 giveEachCPUNum.Value  = (decimal)itemOptions.CPUConfig.GiveItemEach.TotalSeconds;
                 giveIDCPUNum.Value    = itemOptions.CPUConfig.GiveItemID;
             }
             rouletteCPUCheck.Checked = itemOptions.CPUConfig.RouletteSpeed.Frames != 0;
             if (rouletteCPUCheck.Checked)
             {
                 rouletteCPUNum.Value = (decimal)itemOptions.CPUConfig.RouletteSpeed.TotalSeconds;
             }
         }
     }
 }
Esempio n. 2
0
 public void SaveData()
 {
     { // Driver options
         CMSN.DriverOptionsSection driverOpts = (CMSN.DriverOptionsSection)MissionData.GetSection(CMSN.BaseSection.SectionType.DriverOptions);
         if (driverOpts != null)
         {
             driverOpts.DriverAmount = DriverAmount;
             for (uint i = 0; i < DriverAmount; i++)
             {
                 for (uint j = 0; j < 4; j++)
                 {
                     driverOpts.DriverChoices[i][j] = GetPartsSelection(i, j);
                 }
             }
         }
     }
     { // Mission Flags
         CMSN.MissionFlagsSection  missionFlags = (CMSN.MissionFlagsSection)MissionData.GetSection(CMSN.BaseSection.SectionType.MissionFlags);
         CTGP7CourseList.NameEntry nameEntry    = courseSelector.SelectedCourseNameEntry;
         if (nameEntry == null)
         {
             missionFlags.CourseID = 0;
         }
         else
         {
             missionFlags.CourseID = nameEntry.courseID;
         }
         missionFlags.Class         = (byte)ccComboBox.SelectedIndex;
         missionFlags.CPUDifficulty = (byte)(cpuComboBox.SelectedIndex + 1);
     }
     { // Item Options
         CMSN.ItemOptionsSection itemOptions = (CMSN.ItemOptionsSection)MissionData.GetSection(CMSN.BaseSection.SectionType.ItemOptions);
         itemOptions.Mode           = (CMSN.ItemOptionsSection.ItemMode)itemsModeBox.SelectedIndex;
         itemOptions.SpawnItemBoxes = spawnBoxCheck.Checked;
         if (itemOptions.Mode == CMSN.ItemOptionsSection.ItemMode.Custom)
         {
             { // Player config
                 itemOptions.PlayerConfig.ConfigMode = (CMSN.ItemOptionsSection.ItemConfig.ItemConfigMode)modePlayerBox.SelectedIndex;
                 if (giveItemPlayerCheck.Checked)
                 {
                     itemOptions.PlayerConfig.GiveItemOffset = new Common.MK7Timer((double)giveAfterPlayerNum.Value);
                     itemOptions.PlayerConfig.GiveItemEach   = new Common.MK7Timer((double)giveEachPlayerNum.Value);
                     itemOptions.PlayerConfig.GiveItemID     = (byte)giveIDPlayerNum.Value;
                 }
                 else
                 {
                     itemOptions.PlayerConfig.GiveItemOffset = new Common.MK7Timer(0);
                     itemOptions.PlayerConfig.GiveItemEach   = new Common.MK7Timer(0);
                     itemOptions.PlayerConfig.GiveItemID     = 0;
                 }
                 if (roulettePlayerCheck.Checked)
                 {
                     itemOptions.PlayerConfig.RouletteSpeed = new Common.MK7Timer((double)roulettePlayerNum.Value);
                 }
                 else
                 {
                     itemOptions.PlayerConfig.RouletteSpeed = new Common.MK7Timer(0);
                 }
                 itemOptions.PlayerConfig.Probabilities = probabilityPlayerViewer.Values;
             }
             { // CPU config
                 itemOptions.CPUConfig.ConfigMode = (CMSN.ItemOptionsSection.ItemConfig.ItemConfigMode)modeCPUBox.SelectedIndex;
                 if (giveItemCPUCheck.Checked)
                 {
                     itemOptions.CPUConfig.GiveItemOffset = new Common.MK7Timer((double)giveAfterCPUNum.Value);
                     itemOptions.CPUConfig.GiveItemEach   = new Common.MK7Timer((double)giveEachCPUNum.Value);
                     itemOptions.CPUConfig.GiveItemID     = (byte)giveIDCPUNum.Value;
                 }
                 else
                 {
                     itemOptions.CPUConfig.GiveItemOffset = new Common.MK7Timer(0);
                     itemOptions.CPUConfig.GiveItemEach   = new Common.MK7Timer(0);
                     itemOptions.CPUConfig.GiveItemID     = 0;
                 }
                 if (rouletteCPUCheck.Checked)
                 {
                     itemOptions.CPUConfig.RouletteSpeed = new Common.MK7Timer((double)rouletteCPUNum.Value);
                 }
                 else
                 {
                     itemOptions.CPUConfig.RouletteSpeed = new Common.MK7Timer(0);
                 }
                 itemOptions.CPUConfig.Probabilities = probabilityCPUViewer.Values;
             }
         }
     }
 }