using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; using JD.Core; namespace JDSongConverter { /// /// TODO : Refactor mechanism strange use MEF maybe /// public class JDDefinitions : ConstantDefinitions { public JDDefinitions() { Settings settings = new Settings(); _definitions["dataRoot"] = DataRoot.Value; _definitions["worldRoot"] = DataRoot.World; InternalAddConstants(settings.Declarations.Constants); } #region Public Properties public static JDDefinitions Instance { get; } = new JDDefinitions(); #endregion private string EvaluateWithMapNameMode(string key, string mapNameWithoutMode, string mapMode, string projectVersion, string platform = "") { var definitions = CloneDefinitions(); definitions["mapNameWithoutMode"] = mapNameWithoutMode; definitions["mapMode"] = mapMode; if (!string.IsNullOrEmpty(projectVersion)) { definitions["projectVersion"] = projectVersion; } if (!string.IsNullOrEmpty(platform)) { definitions["platform"] = platform; } return EvaluateExpression(_definitions[key], definitions); } public string MapPath(MapPathType type, string mapNameWithoutMode, string mapMode, string projectVersion, string platform = "") { var keyName = ""; switch (type) { case MapPathType.PictosDir: keyName = "pictosDirInMapRelative"; break; case MapPathType.WavFile: keyName = "wavInMapRelative"; break; case MapPathType.TrkFile: keyName = "trkInMapRelative"; break; case MapPathType.TimelineTml: keyName = "timelineTmlInMapRelative"; break; case MapPathType.TimelineTpl: keyName = "timelineTplInMapRelative"; break; case MapPathType.DanceTapeFile: keyName = "danceTapeInMapRelative"; break; case MapPathType.KaraokeTapeFile: keyName = "karaokeTapeInMapRelative"; break; case MapPathType.SignatureTapeFile: keyName = "signatureTapeInMapRelative"; break; case MapPathType.BlockTapeFile: keyName = "blockTapeInMapRelative"; break; case MapPathType.MoveClassifierDir: keyName = "moveClassifierDir"; break; case MapPathType.MoveRecordingDir: keyName = "moveRecordingDir"; break; case MapPathType.MoveSnippingDir: keyName = "moveSnippingDir"; break; case MapPathType.AmbiantDir: keyName = "ambiantDir"; break; case MapPathType.MainTape: keyName = "mainTapeInMapRelative"; break; case MapPathType.TimelineIsc: keyName = "timelineSceneInMapRelative"; break; case MapPathType.LyricsFile: keyName = "lyricsFileInMapRelative"; break; case MapPathType.VideoDir: keyName = "videoDirInMapRelative"; break; case MapPathType.VideoFile: keyName = "videoFileInMapRelative"; break; case MapPathType.SongDescFile: keyName = "songDescFileInMapRelative"; break; case MapPathType.CoverAndCoachLobby: keyName = "coverAndCoachDirInMapRelative"; break; case MapPathType.NasScoringDir: keyName = "nasScoringDir"; break; } return EvaluateWithMapNameMode(keyName, mapNameWithoutMode, mapMode, projectVersion, platform.ToUpper()); } public string MapPath(MapPathType type, string mapName, string projectVersion) { return MapPath(type, mapName, "", projectVersion); } } public enum MapPathType { PictosDir, WavFile, TrkFile, TimelineTml, TimelineTpl, TimelineIsc, DanceTapeFile, KaraokeTapeFile, SignatureTapeFile, BlockTapeFile, MoveClassifierDir, MoveRecordingDir, MoveSnippingDir, AmbiantDir, MainTape, LyricsFile, VideoDir, VideoFile, SongDescFile, CoverAndCoachLobby, NasScoringDir } }