private void btnLanguage_Click(object sender, EventArgs e) { language.CurrentID = (sender as Button).Tag as String; FileSystem.LocalizationCode = language.CurrentID; Burntime.Platform.IO.File file = FileSystem.GetFile(launcher); txt = new TextResourceFile(file); Text = txt.Data[0]; btnSingle.Text = txt.Data[5]; btnMulti.Text = txt.Data[6]; btnOptions.Text = txt.Data[7]; btnExit.Text = txt.Data[8]; bugReport.Text = txt.Data[9]; // set user folder to systems settings.txt FileSystem.SetUserFolder("Burntime"); ConfigFile config = new ConfigFile(); file = FileSystem.GetFile("system:settings.txt"); config.Open(file); config["game"].Set("language", language.CurrentID); file.Close(); file = FileSystem.CreateFile("user:settings.txt"); config.Save(file); file.Close(); }
private void btnOK_Click(object sender, EventArgs e) { path.Save(); ConfigFile config = new ConfigFile(); Burntime.Platform.IO.File file = file = FileSystem.GetFile(settings); config.Open(file); file.Close(); if (cmbPresentation.SelectedIndex == 0) { config["system"].Set("windowmode", false); } else { config["system"].Set("windowmode", true); if (cmbPresentation.SelectedIndex == 2) { config["system"].Set("resolution", new Vector2(960, 600)); } else { config["system"].Set("resolution", new Vector2(640, 400)); } } FileSystem.RemoveFile(settings); file = FileSystem.CreateFile(settings); config.Save(file); file.Close(); Close(); }
public ClassicSettings(BurntimePath path, TextResourceFile txt) { InitializeComponent(); this.path = path; this.txt = txt; // set user folder to systems settings.txt FileSystem.SetUserFolder("Burntime"); ConfigFile config = new ConfigFile(); Burntime.Platform.IO.File file = FileSystem.GetFile("system:settings.txt"); config.Open(file); lang = config["game"].GetString("language"); file.Close(); // set user folder to game specific location FileSystem.SetUserFolder("Burntime/Classic"); file = FileSystem.GetFile(settings); config.Open(file); file.Close(); Text = txt.Data[0]; grpSettings.Text = txt.Data[10]; lblPresentation.Text = txt.Data[11]; cmbPresentation.Items.Add(txt.Data[12]); cmbPresentation.Items.Add(txt.Data[13]); cmbPresentation.Items.Add(txt.Data[14]); lblBurntimePath.Text = txt.Data[15]; btnChoose.Text = txt.Data[16]; lblPorted.Text = txt.Data[17]; lblMail.Text = txt.Data[18]; btnOK.Text = txt.Data[3]; btnCancel.Text = txt.Data[4]; if (config["system"].GetBool("windowmode")) { Vector2 res = config["system"].GetVector2("resolution"); cmbPresentation.SelectedIndex = (res.x == 960 && res.y == 600) ? 2 : 1; } else { cmbPresentation.SelectedIndex = 0; } UpdatePathInfo(); txtPath.Text = path.Path; }
public void Close() { if (file == null) { return; } file.Close(); }
public void InitializeLanguageButtons() { int buttonSize = 30; int buttonHeight = 21; int buttonMargin = 4; int buttonTop = 5; int buttonCount = Program.Languages.Length; int buttonOffset = (ClientSize.Width - (buttonSize * buttonCount + buttonMargin * (buttonCount - 1))) - 15; SuspendLayout(); Controls.Remove(tabControl); if (buttons.Count != 0) { foreach (RadioButton b in buttons) { Controls.Remove(b); } buttons.Clear(); } // disable localization as we need images for all languages Program.VFS.Localized = false; RadioButton button; for (int i = 0; i < buttonCount; i++) { // load image Burntime.Platform.IO.File bitmapFile = Program.VFS.GetFile("flagg-" + Program.Languages[i] + ".png", FileOpenMode.Read); Bitmap bitmap = new Bitmap(bitmapFile.Stream); bitmapFile.Close(); // create button button = new RadioButton(); button.Left = buttonOffset + i * (buttonSize + buttonMargin); button.Top = buttonTop; button.Width = buttonSize; button.Height = buttonHeight; button.Tag = Program.Languages[i]; button.Image = bitmap; button.Click += new EventHandler(btnLanguage_Click); button.Appearance = Appearance.Button; Controls.Add(button); // select the language button if its the current language if (Program.Languages[i].Equals(Program.Settings["game"].Get("language"), StringComparison.InvariantCultureIgnoreCase)) { button.Checked = true; } buttons.Add(button); } // enable localization Program.VFS.Localized = true; Controls.Add(tabControl); ResumeLayout(); }
public ClassicLauncher(bool debugMode) { this.debugMode = debugMode; InitializeComponent(); FileSystem.UseLocalization = false; FileSystem.BasePath = debugMode ? "../" : ""; FileSystem.AddPackage("system", "system"); FileSystem.AddPackage("classic", gamepath); FileSystem.SetUserFolder("Burntime"); language = new Language("launcher/"); ConfigFile config = new ConfigFile(); Burntime.Platform.IO.File file = FileSystem.GetFile("system:settings.txt"); config.Open(file); language.CurrentID = config["game"].GetString("language"); file.Close(); FileSystem.UseLocalization = true; FileSystem.LocalizationCode = language.CurrentID; file = FileSystem.GetFile(launcher); txt = new TextResourceFile(new Burntime.Platform.IO.File(file)); Text = txt.Data[0]; btnSingle.Text = txt.Data[5]; btnMulti.Text = txt.Data[6]; btnOptions.Text = txt.Data[7]; btnExit.Text = txt.Data[8]; bugReport.Text = txt.Data[9]; path = new BurntimePath(FileSystem.BasePath + "system"); btnSingle.Enabled = path.IsValid; btnMulti.Enabled = path.IsValid & enableMulti; int buttonSize = 30; int buttonHeight = 19; int buttonMargin = 4; int buttonTop = 110; int buttonCount = language.Languages.Length; int buttonOffset = (ClientSize.Width - (buttonSize * buttonCount + buttonMargin * (buttonCount - 1))) / 2; Button button; for (int i = 0; i < buttonCount; i++) { button = new Button(); button.Left = buttonOffset + i * (buttonSize + buttonMargin); button.Top = buttonTop; button.Width = buttonSize; button.Height = buttonHeight; button.Tag = language.Languages[i].ID; button.Image = language.Languages[i].Icon; button.Click += new EventHandler(btnLanguage_Click); Controls.Add(button); } }
public DataObject Process(ResourceID id, ResourceManager ResourceManager) { int map = 0; if (id.Custom != null) { map = int.Parse(id.Custom); } IDataProcessor processor = ResourceManager.GetDataProcessor("burngfxmap"); MapData raw = null; if (FileSystem.ExistsFile(System.IO.Path.GetFileNameWithoutExtension(id.File) + ".raw")) { raw = processor.Process(System.IO.Path.GetFileNameWithoutExtension(id.File) + ".raw??" + map, ResourceManager) as MapData; } MapData data = new MapData(); Burntime.Platform.IO.File file = Burntime.Platform.IO.FileSystem.GetFile(id.File); BinaryReader reader = new BinaryReader(file); if (reader.ReadString() != "Burntime Map") { return(null); } String ver = reader.ReadString(); if (ver != "0.2") { return(null); } // header data.Width = reader.ReadInt32(); data.Height = reader.ReadInt32(); data.TileSize = Vector2.One * reader.ReadInt32(); data.Tiles = new Burntime.Data.BurnGfx.MapTile[data.Width * data.Height]; data.Mask = new Burntime.Data.BurnGfx.PathMask(data.Width * 4, data.Height * 4, 8); // set indices List <String> indices = new List <string>(); int count = reader.ReadInt32(); for (int i = 0; i < count; i++) { indices.Add(reader.ReadString()); } ConfigFile settings = new ConfigFile(); if (FileSystem.ExistsFile(id.File.Replace(".burnmap", ".txt"))) { settings.Open(FileSystem.GetFile(id.File.Replace(".burnmap", ".txt"))); } else { settings = null; } //Dictionary<String, int> indices2 = new Dictionary<string, int>(); //for (int i = 0; i < TileSets.Count; i++) // indices2.Add(TileSets[i].Name, i); // tiles for (int y = 0; y < data.Height; y++) { for (int x = 0; x < data.Width; x++) { byte _id = reader.ReadByte(); byte subset = reader.ReadByte(); byte set = reader.ReadByte(); if (subset == 0) { } else { Burntime.Data.BurnGfx.MapTile tile = new Burntime.Data.BurnGfx.MapTile(); tile.Item = _id; tile.Section = subset; data.Tiles[x + y * data.Width] = tile; String maskFile = "gfx/tiles/" + subset.ToString("D3") + "_" + _id.ToString("D2") + ".txt"; if (Burntime.Platform.IO.FileSystem.ExistsFile(maskFile)) { Burntime.Platform.IO.File maskfile = Burntime.Platform.IO.FileSystem.GetFile(maskFile); TextReader maskreader = new StreamReader(maskfile); for (int k = 0; k < 4; k++) { String line = maskreader.ReadLine(); if (line.Length < 4) { continue; } char[] chrs = line.ToCharArray(); data.Mask[4 * x + 0, 4 * y + k] = (chrs[0] != '1'); data.Mask[4 * x + 1, 4 * y + k] = (chrs[1] != '1'); data.Mask[4 * x + 2, 4 * y + k] = (chrs[2] != '1'); data.Mask[4 * x + 3, 4 * y + k] = (chrs[3] != '1'); } maskreader.Close(); maskfile.Close(); } else { for (int k = 0; k < 4; k++) { data.Mask[4 * x + 0, 4 * y + k] = true; data.Mask[4 * x + 1, 4 * y + k] = true; data.Mask[4 * x + 2, 4 * y + k] = true; data.Mask[4 * x + 3, 4 * y + k] = true; } } } } } foreach (Vector2 pos in new Rect(0, 0, data.Width, data.Height)) { if (data[pos].Section >= 90) { foreach (Vector2 sub in new Rect(0, 0, 4, 4)) { data.Mask[pos * 4 + sub] &= !(pos.x == 0 && sub.x == 0 || pos.y == 0 && sub.y == 0 || (pos.x == data.Width - 1 && sub.x == 3) || (pos.y == data.Height - 1 && sub.y == 3)); } } else { String res = "burngfxtilemask@zei_" + data[pos].Section.ToString("D3") + ".raw?" + data[pos].Item; IDataProcessor p = ResourceManager.GetDataProcessor("burngfxtilemask"); TileMaskData tile = p.Process(res, ResourceManager) as TileMaskData; foreach (Vector2 sub in new Rect(0, 0, 4, 4)) { data.Mask[pos * 4 + sub] = !(pos.x == 0 && sub.x == 0 || pos.y == 0 && sub.y == 0 || (pos.x == data.Width - 1 && sub.x == 3) || (pos.y == data.Height - 1 && sub.y == 3)); data.Mask[pos * 4 + sub] &= tile[sub]; } } } // fixed items //string[] items = settings[""].GetStrings("fixed_item"); //bool[] items_room = settings[""].GetBools("fixed_item_room"); //Vector2[] items_pos = settings[""].GetVector2s("fixed_item_pos"); //data.FixedItems = new FixedItem[items.Length]; //for (int i = 0; i < items.Length; i++) //{ // data.FixedItems[i].Item = items[i]; // data.FixedItems[i].Room = items_room[i] ? items_pos[i].x : -1; // data.FixedItems[i].Position = items_room[i] ? Vector2.Zero : items_pos[i]; //} // entrances count = reader.ReadByte(); data.Entrances = new MapEntrance[count]; for (int i = 0; i < count; i++) { MapEntrance e = new MapEntrance(); // take data from original Burntime as default #warning // TODO this should be only temporary if (raw != null && raw.Entrances.Length > i) { e = raw.Entrances[i]; } // e.RoomType = Burntime.Data.BurnGfx.RoomType.Normal; e.Area.Left = reader.ReadInt32(); e.Area.Top = reader.ReadInt32(); e.Area.Width = reader.ReadInt32(); e.Area.Height = reader.ReadInt32(); //#warning TODO insert proper images and titles // e.Background = 0;// settings["room" + i].GetString("image"); if (settings != null) { e.TitleId = settings["room" + i].GetString("title"); } // //e.Key = settings["room" + i].GetString("key"); data.Entrances[i] = e; } //if (ver == "0.2") //{ // count = reader.ReadInt32(); // for (int i = 0; i < count; i++) // { // Way way = new Way(); // way.Days = reader.ReadByte(); // way.Entrance[0] = reader.ReadByte(); // way.Entrance[1] = reader.ReadByte(); // int wpc = reader.ReadByte(); // for (int j = 0; j < wpc; j++) // { // Point pt = new Point(); // pt.X = reader.ReadInt32(); // pt.Y = reader.ReadInt32(); // way.Points.Add(pt); // } // } //} file.Close(); for (int i = 0; i < data.Tiles.Length; i++) { if (data.Tiles[i].Section >= 90) { data.Tiles[i].Image = ResourceManager.GetImage("gfx/tiles/" + data.Tiles[i].Section.ToString("D3") + "_" + data.Tiles[i].Item.ToString("D2") + ".png", ResourceLoadType.Delayed); } else { data.Tiles[i].Image = ResourceManager.GetImage("burngfxtile@zei_" + data.Tiles[i].Section.ToString("D3") + ".raw?" + data.Tiles[i].Item.ToString() + "?" + map, ResourceLoadType.Delayed); } } return(data); }
static public void ConvertFolderToPak(string path, ConvertFeedback feedback) { if (feedback != null) { feedback(0); } IPackage package = new PackageFolder("test", path, ""); string outputPath = path + ".pak"; System.IO.FileStream stream = new System.IO.FileStream(outputPath, System.IO.FileMode.Create); stream.SetLength(0); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); // calculate positions int position = 0; List <PakFileInfo> infos = new List <PakFileInfo>(); foreach (string fileName in package.Files) { // exclude pdb files and files starting with . if (fileName.StartsWith(".") || fileName.EndsWith(".pdb", StringComparison.InvariantCultureIgnoreCase)) { continue; } File file = package.GetFile(fileName, FileOpenMode.Read); PakFileInfo info = new PakFileInfo(); info.Name = fileName; info.Position = position; info.Length = (int)file.Stream.Length; position += info.Length; file.Close(); infos.Add(info); } PakHeader header = new PakHeader(); header.FileCount = infos.Count; header.Version = 00010; //0.00.10 header.Type = PackageType.Main; // write header writer.Write(header.FileCount); writer.Write(header.Version); writer.Write((int)header.Type); foreach (PakFileInfo info in infos) { writer.Write(info.Position); writer.Write(info.Length); writer.Write(info.Name); } int written = 0; // write files foreach (PakFileInfo info in infos) { File file = package.GetFile(info.Name, FileOpenMode.Read); int remaining = (int)file.Stream.Length; byte[] buf = new byte[1024 * 1024 * 4]; while (remaining > 0) { int copy = System.Math.Min(buf.Length, remaining); file.Stream.Read(buf, 0, copy); stream.Write(buf, 0, copy); remaining -= copy; } written += (int)file.Stream.Length; file.Close(); if (feedback != null) { feedback(written / (float)position); } } // finish writer.Flush(); writer.Close(); stream.Close(); }