private void ModifyAllLevelRanges(object sender, EventArgs e) { if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, "Modify all current Level ranges?", "Cannot undo.")) { return; } // Disable Interface while modifying Enabled = false; // Cycle through each location to modify levels var amp = NUD_LevelAmp.Value; foreach (var area in Areas) { var tables = area.Tables; foreach (var table in tables) { table.MinLevel = Randomizer.GetModifiedLevel(table.MinLevel, amp); table.MaxLevel = Randomizer.GetModifiedLevel(table.MaxLevel, amp); table.Write(); } encdata[area.FileNumber] = Area7.GetDayNightTableBinary(tables); } // Enable Interface... modification complete. Enabled = true; WinFormsUtil.Alert("Modified all Level ranges according to specification!", "Press the Dump Tables button to view the new Level ranges!"); UpdatePanel(sender, e); }
public void Execute(IEnumerable <Area7> Areas, lzGARCFile encdata) { GetTableRandSettings((RandOption)TableRandomizationOption, out int slotStart, out int slotStop, out bool copy); foreach (var Map in Areas) { foreach (var Table in Map.Tables) { if (ModifyLevel) { Table.MinLevel = Randomizer.getModifiedLevel(Table.MinLevel, LevelAmplifier); Table.MaxLevel = Randomizer.getModifiedLevel(Table.MaxLevel, LevelAmplifier); } RandomizeTable7(Table, slotStart, slotStop); if (copy) // copy row 0 to rest { Table.CopySlotsToSOS(); } Table.Write(); } encdata[Map.FileNumber] = Area7.GetDayNightTableBinary(Map.Tables); } }
public SMWE(lzGARCFile ed, lzGARCFile zd, lzGARCFile wd) { InitializeComponent(); PB_DayIcon.Image = Properties.Resources.sun; PB_NightIcon.Image = Properties.Resources.moon; PB_DayIcon.SizeMode = PictureBoxSizeMode.CenterImage; PB_NightIcon.SizeMode = PictureBoxSizeMode.CenterImage; font = L_Location.Font; speciesList[0] = "(None)"; var locationList = Main.Config.getText(TextName.metlist_000000); locationList = GetGoodLocationList(locationList); nup_spec = LoadFormeNUD(); cb_spec = LoadSpeciesComboBoxes(); rate_spec = LoadRateNUD(); encdata = ed; var areas = Area7.GetArray(ed, zd, wd, locationList); Areas = areas.OrderBy(a => a.Zones[0].Name).ToArray(); LoadData(); // ExportEncounters("um", "uu"); }
private void RefreshTableImages(Area7 Map) { int base_id = CB_TableID.SelectedIndex / 2; base_id *= 2; PB_DayTable.Image = Map.Tables[base_id].GetTableImg(font); PB_NightTable.Image = Map.Tables[base_id + 1].GetTableImg(font); }
private void B_Export_Click(object sender, EventArgs e) { B_Save_Click(sender, e); Directory.CreateDirectory("encdata"); foreach (var Map in Areas) { var packed = Area7.GetDayNightTableBinary(Map.Tables); File.WriteAllBytes(Path.Combine("encdata", Map.FileNumber.ToString()), packed); } WinFormsUtil.Alert("Exported all tables!"); }
private void LoadData() { loadingdata = true; int fileCount = encdata.FileCount; var numAreas = fileCount / 11; Areas = new Area7[numAreas]; for (int i = 0; i < numAreas; i++) { Areas[i] = new Area7 { FileNumber = 9 + 11 * i, Zones = Zones.Where(z => z.AreaIndex == i).ToArray() }; var md = encdata[Areas[i].FileNumber]; if (md.Length > 0) { byte[][] Tables = mini.unpackMini(md, "EA"); Areas[i].HasTables = Tables.Any(t => t.Length > 0); if (Areas[i].HasTables) { foreach (var Table in Tables) { var DayTable = Table.Skip(4).Take(0x164).ToArray(); var NightTable = Table.Skip(0x168).ToArray(); Areas[i].Tables.Add(new EncounterTable(DayTable)); Areas[i].Tables.Add(new EncounterTable(NightTable)); } } } else { Areas[i].HasTables = false; } } Areas = Areas.OrderBy(a => a.Zones[0].Name).ToArray(); CB_LocationID.Items.Clear(); CB_LocationID.Items.AddRange(Areas.Select(a => a.Name).ToArray()); foreach (Control ctrl in Controls) { ctrl.Enabled = true; } B_Randomize.Enabled = true; // Randomization: complete CB_SlotRand.SelectedIndex = 0; CB_LocationID.SelectedIndex = 0; loadingdata = false; updateMap(null, null); }
private void B_Save_Click(object sender, EventArgs e) { var sum = TotalEncounterRate; if (sum != 100 && sum != 0) { WinFormsUtil.Error("Encounter rates must add up to either 0% or 100%."); return; } CurrentTable.Write(); var area = Areas[CB_LocationID.SelectedIndex]; area.Tables[CB_TableID.SelectedIndex] = CurrentTable; // Set data back to GARC encdata[area.FileNumber] = Area7.GetDayNightTableBinary(area.Tables); }
public SMWE(lzGARCFile ed, lzGARCFile zd, lzGARCFile wd) { InitializeComponent(); PB_DayIcon.Image = Properties.Resources.sun; PB_NightIcon.Image = Properties.Resources.moon; PB_DayIcon.SizeMode = PictureBoxSizeMode.CenterImage; PB_NightIcon.SizeMode = PictureBoxSizeMode.CenterImage; font = L_Location.Font; speciesList[0] = "(None)"; var locationList = Main.Config.getText(TextName.metlist_000000); locationList = GetGoodLocationList(locationList); nup_spec = LoadFormeNUD(); cb_spec = LoadSpeciesComboBoxes(); rate_spec = LoadRateNUD(); encdata = ed; var areas = Area7.GetArray(ed, zd, wd, locationList); Areas = areas.OrderBy(a => a.Zones[0].Name).ToArray(); LoadData(); RandSettings.GetFormSettings(this, GB_Tweak.Controls); var weather = string.Format("If weather is active, create a random number.{0}If 0, use slot 0.{0}If <= 10, use slot 1.{0}Else, pick an SOS table and a slot.", Environment.NewLine); new ToolTip().SetToolTip(L_AddSOS, weather); var sos = new[] { L_SOS1, L_SOS2, L_SOS3, L_SOS4, L_SOS5, L_SOS6, L_SOS7 }; var rates = new[] { 1, 1, 1, 10, 10, 10, 67 }; for (int i = 0; i < sos.Length; i++) { new ToolTip().SetToolTip(sos[i], $"Table Selection Rate: {rates[i]}%"); } // ExportEncounters("um", "uu"); }
public static Area7[] GetArray(lzGARCFile ed, ZoneData7[] zd) { int fileCount = ed.FileCount; var numAreas = fileCount / 11; var areas = new Area7[numAreas]; for (int i = 0; i < numAreas; i++) { areas[i] = new Area7 { FileNumber = 9 + (11 * i), Zones = zd.Where(z => z.AreaIndex == i).ToArray() }; var md = ed[areas[i].FileNumber]; if (md.Length <= 0) { areas[i].HasTables = false; continue; } byte[][] Tables = Mini.UnpackMini(md, PackIdentifier); areas[i].HasTables = Tables.Any(t => t.Length > 0); if (!areas[i].HasTables) { continue; } foreach (var Table in Tables) { var DayTable = Table.Skip(4).Take(0x164).ToArray(); var NightTable = Table.Skip(0x168).ToArray(); areas[i].Tables.Add(new EncounterTable(DayTable)); areas[i].Tables.Add(new EncounterTable(NightTable)); } } return(areas); }