Exemplo n.º 1
0
        public ClipboardLevelSource(string loadFileName)
        {
            BinaryReader br;

            if (loadFileName == "")
            {
                string leveltxt = Clipboard.GetText();
                if (!(leveltxt.StartsWith(clipboardHeader) && leveltxt.EndsWith(clipboardFooter)))
                {
                    throw new Exception();
                }
                leveltxt = leveltxt.Substring(11, leveltxt.Length - 12);
                byte[] leveldata          = ROM.LZ77_Decompress(Convert.FromBase64String(leveltxt), false);
                ByteArrayInputStream strm = new ByteArrayInputStream(leveldata);
                br = new BinaryReader(strm);
            }
            else
            {
                FileStream fs = new FileStream(loadFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
                br = new BinaryReader(fs);
            }
            level = new ExportedLevel(br);
            br.Close();
        }