コード例 #1
0
        public void Apply(ICollection <Command> commands, SifInfo sif)
        {
            var dict = sif.KeyValues;

            if (dict.ContainsKey(SifKeys.Dir))
            {
                var name = dict[SifKeys.Dir];
                _smMetadataChanger.SetBannerImage(commands, $"{name}_th.png");
                _smMetadataChanger.SetBackgroundImage(commands, $"{name}_bk.png");
            }

            if (dict.ContainsKey(SifKeys.Title))
            {
                _smMetadataChanger.SetTitle(commands, dict[SifKeys.Title]);
            }
            if (dict.ContainsKey(SifKeys.Mix))
            {
                _smMetadataChanger.SetSubtitle(commands, dict[SifKeys.Mix]);
            }
            if (dict.ContainsKey(SifKeys.Artist))
            {
                _smMetadataChanger.SetArtist(commands, dict[SifKeys.Artist]);
            }
            if (dict.ContainsKey(SifKeys.Extra))
            {
                _smMetadataChanger.SetSubartist(commands, dict[SifKeys.Extra]);
            }
            if (dict.ContainsKey(SifKeys.BpmMin) && dict.ContainsKey(SifKeys.BpmMax))
            {
                _smMetadataChanger.SetBpm(commands, dict[SifKeys.BpmMin], dict[SifKeys.BpmMax]);
            }

            if (dict.ContainsKey(SifKeys.FootSingle))
            {
                var values = dict[SifKeys.FootSingle].Split(',');
                _smMetadataChanger.SetDifficulty(commands, SmGameTypes.DanceSingle, SmNotesDifficulties.Easy,
                                                 values[0]);
                _smMetadataChanger.SetDifficulty(commands, SmGameTypes.DanceSingle, SmNotesDifficulties.Medium,
                                                 values[1]);
                _smMetadataChanger.SetDifficulty(commands, SmGameTypes.DanceSingle, SmNotesDifficulties.Hard,
                                                 values[2]);
            }

            if (dict.ContainsKey(SifKeys.FootDouble))
            {
                var values = dict[SifKeys.FootDouble].Split(',');
                _smMetadataChanger.SetDifficulty(commands, SmGameTypes.DanceDouble, SmNotesDifficulties.Easy,
                                                 values[0]);
                _smMetadataChanger.SetDifficulty(commands, SmGameTypes.DanceDouble, SmNotesDifficulties.Medium,
                                                 values[1]);
                _smMetadataChanger.SetDifficulty(commands, SmGameTypes.DanceDouble, SmNotesDifficulties.Hard,
                                                 values[2]);
            }
        }
コード例 #2
0
        public SifInfo Decode(IEnumerable <string> lines)
        {
            var result = new SifInfo
            {
                KeyValues = new Dictionary <string, string>()
            };

            foreach (var line in lines)
            {
                if (!line.Contains("="))
                {
                    continue;
                }

                var splits = line.Split('=');
                var key    = splits[0].Trim();
                var val    = string.Join(string.Empty, splits.Skip(1)).Trim();
                result.KeyValues[key] = val;
            }

            return(result);
        }
コード例 #3
0
        public SifInfo Decode(ReadOnlyMemory <byte> bytes)
        {
            var result = new SifInfo
            {
                KeyValues = new Dictionary <string, string>()
            };

            result.KeyValues[SifKeys.Version] = "0";

            var text     = new string[5];
            var chunkMem = new ReadOnlyMemoryStream(bytes);
            var reader   = new BinaryReader(chunkMem, Encodings.CP1252);
            var builder  = new StringBuilder();

            chunkMem.Position = 0x001;

            for (var i = 0; i < text.Length; i++)
            {
                while (true)
                {
                    var c = reader.ReadChar();
                    if (c == 0)
                    {
                        break;
                    }
                    builder.Append(c);
                }

                text[i] = builder.ToString();
                builder.Clear();
            }

            result.KeyValues[SifKeys.Dir]    = text[0];
            result.KeyValues[SifKeys.Title]  = text[1];
            result.KeyValues[SifKeys.Mix]    = text[2];
            result.KeyValues[SifKeys.Artist] = text[3];
            result.KeyValues[SifKeys.Extra]  = text[4];

            chunkMem.Position = 0x200;
            result.KeyValues[SifKeys.GrooveChartSingleLight] =
                $"{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()}";
            result.KeyValues[SifKeys.GrooveChartSingleStandard] =
                $"{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()}";
            result.KeyValues[SifKeys.GrooveChartSingleHeavy] =
                $"{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()}";
            result.KeyValues[SifKeys.GrooveChartDoubleLight] =
                $"{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()}";
            result.KeyValues[SifKeys.GrooveChartDoubleStandard] =
                $"{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()}";
            result.KeyValues[SifKeys.GrooveChartDoubleHeavy] =
                $"{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()},{reader.ReadInt16()}";
            result.KeyValues[SifKeys.FootSingle] =
                $"{reader.ReadByte()},{reader.ReadByte()},{reader.ReadByte()}";
            result.KeyValues[SifKeys.FootDouble] =
                $"{reader.ReadByte()},{reader.ReadByte()},{reader.ReadByte()}";
            result.KeyValues[SifKeys.BpmMin] =
                $"{reader.ReadInt16()}";
            result.KeyValues[SifKeys.BpmMax] =
                $"{reader.ReadInt16()}";
            result.KeyValues[SifKeys.EndBar] =
                $"{reader.ReadInt16()}";

            return(result);
        }