Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        public bool Open()
        {
            Burntime.Platform.IO.File file = FileSystem.GetFile("burntime:gam.dat");
            if (file == null)
            {
                return(false);
            }

            return(Open(file.Stream));
        }
Ejemplo n.º 4
0
        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;
        }
Ejemplo n.º 5
0
        public SaveGame(string filename, string game, string version)
        {
            if (FileSystem.ExistsFile(filename))
            {
                FileSystem.RemoveFile(filename);
            }

            file = FileSystem.CreateFile(filename);
            if (file == null)
            {
                isValid = false;
                return;
            }

            BinaryWriter writer = new BinaryWriter(file);

            writer.Write(game);
            writer.Write(version);

            isValid = true;
        }
Ejemplo n.º 6
0
        public void Process(ResourceID id)
        {
            Burntime.Platform.IO.File file = FileSystem.GetFile(string.Format(id.File, id.Index));
            Bitmap bmp = new Bitmap(Bitmap.FromStream(file));

            buffer = new byte[bmp.Width * bmp.Height * 4];

            BitmapData data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly,
                                           PixelFormat.Format32bppArgb);

            unsafe
            {
                for (int y = 0; y < bmp.Height; y++)
                {
                    Marshal.Copy((IntPtr)((byte *)data.Scan0 + y * data.Stride), buffer, y * bmp.Width * 4, bmp.Width * 4);
                }
            }

            bmp.UnlockBits(data);

            size = new Vector2(bmp.Width, bmp.Height);
        }
Ejemplo n.º 7
0
        public SaveGame(string filename)
        {
            file = FileSystem.GetFile(filename);
            if (file == null)
            {
                isValid = false;
                return;
            }

            BinaryReader reader = new BinaryReader(file);

            try
            {
                game    = reader.ReadString();
                version = reader.ReadString();
            }
            catch
            {
                isValid = false;
                return;
            }

            isValid = true;
        }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
        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);
        }