示例#1
0
        public void Generate()
        {
            var folder = GetSongFolder();
            var maps   = new List <Map>();

            DeclareMaps(maps);

            foreach (var map in maps)
            {
                ParseMapDetails(folder, map);
                GenerateMapStoryboard(map);
                WriteMapStoryboard(folder, map);
                SB.Clear();
            }

            GenerateStoryboard();
            WriteStoryboard(folder);
        }
示例#2
0
        private void WriteMapStoryboard(string folder, Map map)
        {
            var code = SB.GenerateCode();

            Trace.Write(code);

            var diffContents = "";

            using (var streamReader = new StreamReader(Path.Combine(folder, map.Path))) {
                diffContents = streamReader.ReadToEnd();
            }

            var beginning = "//Storyboard Layer 0 (Background)";
            var end       = "//Storyboard Sound Samples";

            var contentsBeginning = diffContents.IndexOf(beginning);
            var contentsEnd       = diffContents.IndexOf(end);

            var codeBeginning = code.IndexOf(beginning);
            var codeEnd       = code.IndexOf(end);

            var updatedDiffContents = diffContents.Substring(0, contentsBeginning);

            updatedDiffContents += code.Substring(codeBeginning, codeEnd - codeBeginning);
            updatedDiffContents += diffContents.Substring(contentsEnd, diffContents.Length - contentsEnd);
            if (IsWidescreen())
            {
                updatedDiffContents = updatedDiffContents.Replace("WidescreenStoryboard: 0", "WidescreenStoryboard: 1");
            }
            else
            {
                updatedDiffContents = updatedDiffContents.Replace("WidescreenStoryboard: 1", "WidescreenStoryboard: 0");
            }

            using (TextWriter tw = new StreamWriter(Path.Combine(folder, map.Path))) {
                tw.Write(updatedDiffContents);
            }
        }