private void listView1_SelectedIndexChanged(object sender, EventArgs e) { textBox1.Text = ""; if (listView1.SelectedItems.Count != 1) { return; } uint fnum = uint.Parse(listView1.SelectedItems[0].SubItems[0].Text); SkyDisk.FileHeader fh = SkyDisk.get().readHeader(fnum); String s = String.Format(@"flags=0x{0:X} x={1:d} (0x{1:X}) y={2:d} (0x{2:X}) width={3:d} (0x{3:X}) height={4:d} (0x{4:X}) sp_size=0x{5:X} tot_size=0x{6:X} n_sprites={7:d} (0x{7:X}) offset_x={8:d} (0x{8:X}) offset_y={9:d} (0x{9:X}) compressed_size=0x{10:X} ------- total_size=0x{11:X} flags_byte=0x{12:X} " , fh.flags, fh.x, fh.y, fh.width, fh.height, fh.sp_size, fh.tot_size, fh.n_sprites, fh.offset_x, fh.offset_y, fh.compressed_size, fh.totalsize, fh.flagbyte ); textBox1.Text = s; clearRes(); Config.FileInfo fi = Config.get().findFile(fnum); if (fi.fid != 0) { BResource res = BResourceHelper.getResource(fi.node); if (res.control != null) { cntrl = res.control; panel1.Controls.Add(cntrl); res.initControl(); } textBox2.Text = fi.comment; label2.Text = String.Format("{0:d} unused bytes", res.unusedBytes); } }
public PaletteInfo(XmlElement node, int mode) { if (node == null) { pal = BPalette.GrayScalePalette(); name = pal.name; fid = 0; return; } if (mode == 0) { pal = (BPalette)BResourceHelper.getResource(node); name = pal.name; fid = pal.filenum; } else { pal = new BPalette(node); name = pal.name; fid = 0; } }
private void button8_Click(object sender, EventArgs e) { openFileDialog1.Filter = "Bass Ru Script (*.xml)|*.xml"; openFileDialog1.FilterIndex = 0; openFileDialog1.Multiselect = false; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { XmlDocument doc = new XmlDocument(); doc.Load(openFileDialog1.FileName); if (doc.DocumentElement.Name != "bassru-script") { throw new ApplicationException("Bad script root node"); } int max = 0; foreach (XmlNode nd in doc.DocumentElement.ChildNodes) { if (nd.NodeType == XmlNodeType.Element) { if (nd.Name == "load" || nd.Name == "import" || nd.Name == "export" || nd.Name == "save") { max++; } } } ScriptProgressForm.get().init(max); foreach (XmlNode nd in doc.DocumentElement.ChildNodes) { if (nd.NodeType == XmlNodeType.Element) { string cd = Directory.GetCurrentDirectory(); uint id = 0; string fl = ""; Config.FileInfo fi; BResource res = null; switch (nd.Name) { case "load": path = nd.Attributes["path"].Value; if (path[path.Length - 1] != '\\') { path += "\\"; } ScriptProgressForm.get().progress("load from " + path); button1.PerformClick(); Directory.SetCurrentDirectory(cd); break; case "import": case "export": id = uint.Parse(nd.Attributes["id"].Value); fl = nd.Attributes["file"].Value; ScriptProgressForm.get().progress(nd.Name + " " + id.ToString() + (nd.Name == "import"?" from ":" to ") + fl); fi = Config.get().findFile(id); if (fi.fid == 0) { throw new ApplicationException("Unknown file type " + id.ToString()); } res = BResourceHelper.getResource(fi.node); if (nd.Name == "import") { res.import(fl); } else { res.export(fl); } break; case "save": string pth = nd.Attributes["path"].Value; if (pth[pth.Length - 1] != '\\') { pth += "\\"; } ScriptProgressForm.get().progress("save to " + pth); SkyDisk.get().saveDiskAndDinner(pth + "sky.dsk"); Directory.SetCurrentDirectory(cd); break; } } } ScriptProgressForm.get().fini(); load(); } catch (Exception ex) { ScriptProgressForm.get().fini(); MessageBox.Show("Error while script run:" + ex.Message); load(); //throw; } } }