public PlayerProfile(ProfileLoader loader, string playerpath, string stagepath) { if (playerpath == null) { throw new ArgumentNullException(nameof(playerpath)); } if (loader == null) { throw new ArgumentNullException(nameof(loader)); } m_loader = loader; //May be null m_playerstagepath = stagepath; var textfile = m_loader.SubSystems.GetSubSystem <FileSystem>().OpenTextFile(playerpath); var infosection = textfile.GetSection("info"); if (infosection == null) { throw new InvalidOperationException("No 'info' section in .def file"); } var filesection = textfile.GetSection("files"); if (filesection == null) { throw new InvalidOperationException("No 'files' section in .def file"); } m_defpath = playerpath; m_basepath = Path.GetDirectoryName(textfile.Filepath); m_playername = infosection.GetAttribute("name", string.Empty); m_displayname = infosection.GetAttribute("displayname", m_playername); m_author = infosection.GetAttribute("author", string.Empty); m_version = infosection.GetAttribute("versiondate", string.Empty); m_mugenversion = infosection.GetAttribute("mugenversion", string.Empty); m_paletteorder = BuildPaletteOrder(infosection.GetAttribute <string>("pal.defaults", null)); m_commandfile = FilterPath(filesection.GetAttribute("cmd", string.Empty)); m_constantsfile = FilterPath(filesection.GetAttribute("cns", string.Empty)); m_commonstatefile = GetCommonStateFile(filesection.GetAttribute <string>("stcommon")); m_statesfiles = BuildStateFiles(filesection); m_spritesfile = FilterPath(filesection.GetAttribute("sprite", string.Empty)); m_animationfile = FilterPath(filesection.GetAttribute("anim", string.Empty)); m_soundfile = FilterPath(filesection.GetAttribute("sound", string.Empty)); m_palettefiles = BuildPaletteFiles(filesection); m_spritemanager = m_loader.SubSystems.GetSubSystem <Drawing.SpriteSystem>().CreateManager(SpritePath); SpriteManager.GetSprite(SpriteId.LargePortrait); SpriteManager.GetSprite(SpriteId.SmallPortrait); }
public PlayerProfile(ProfileLoader loader, String playerpath, String stagepath) { if (playerpath == null) throw new ArgumentNullException("playerpath"); if (loader == null) throw new ArgumentNullException("loader"); m_loader = loader; //May be null m_playerstagepath = stagepath; IO.TextFile textfile = m_loader.SubSystems.GetSubSystem<IO.FileSystem>().OpenTextFile(playerpath); TextSection infosection = textfile.GetSection("info"); if (infosection == null) throw new InvalidOperationException("No 'info' section in .def file"); TextSection filesection = textfile.GetSection("files"); if (filesection == null) throw new InvalidOperationException("No 'files' section in .def file"); m_defpath = playerpath; m_basepath = Path.GetDirectoryName(textfile.Filepath); m_playername = infosection.GetAttribute<String>("name", String.Empty); m_displayname = infosection.GetAttribute<String>("displayname", m_playername); m_author = infosection.GetAttribute<String>("author", String.Empty); m_version = infosection.GetAttribute<String>("versiondate", String.Empty); m_mugenversion = infosection.GetAttribute<String>("mugenversion", String.Empty); m_paletteorder = BuildPaletteOrder(infosection.GetAttribute<String>("pal.defaults", null)); m_commandfile = FilterPath(filesection.GetAttribute<String>("cmd", String.Empty)); m_constantsfile = FilterPath(filesection.GetAttribute<String>("cns", String.Empty)); m_commonstatefile = GetCommonStateFile(filesection.GetAttribute<String>("stcommon")); m_statesfiles = BuildStateFiles(filesection); m_spritesfile = FilterPath(filesection.GetAttribute<String>("sprite", String.Empty)); m_animationfile = FilterPath(filesection.GetAttribute<String>("anim", String.Empty)); m_soundfile = FilterPath(filesection.GetAttribute<String>("sound", String.Empty)); m_palettefiles = BuildPaletteFiles(filesection); m_spritemanager = m_loader.SubSystems.GetSubSystem<Drawing.SpriteSystem>().CreateManager(SpritePath); SpriteManager.GetSprite(SpriteId.LargePortrait); SpriteManager.GetSprite(SpriteId.SmallPortrait); }
Replay.Recording BuildRecording(String filepath) { if (filepath == null) { throw new ArgumentNullException("filepath"); } ProfileLoader profiles = m_subsystems.GetSubSystem <ProfileLoader>(); if (m_subsystems.GetSubSystem <IO.FileSystem>().DoesFileExist(filepath) == false) { return(null); } IO.TextFile text = m_subsystems.GetSubSystem <IO.FileSystem>().OpenTextFile(filepath); IO.TextSection header = text.GetSection("xnaMugen Replay Header"); IO.TextSection data = text.GetSection("xnaMugen Replay Data"); if (header == null || data == null) { return(null); } Int32 version = header.GetAttribute <Int32>("Version", 0); CombatMode mode = header.GetAttribute <CombatMode>("Combat Mode", CombatMode.None); String p1name = header.GetAttribute <String>("Player 1 Name", null); String p1version = header.GetAttribute <String>("Player 1 Version", null); Int32 p1palette = header.GetAttribute <Int32>("Player 1 Palette", Int32.MinValue); String p2name = header.GetAttribute <String>("Player 2 Name", null); String p2version = header.GetAttribute <String>("Player 2 Version", null); Int32 p2palette = header.GetAttribute <Int32>("Player 2 Palette", Int32.MinValue); String stagepath = header.GetAttribute <String>("Stage Path", null); Int32 seed = header.GetAttribute <Int32>("Seed", Int32.MinValue); if (version != 1 || mode == CombatMode.None || stagepath == null || seed == Int32.MinValue) { return(null); } if (p1name == null || p1version == null || p1palette == Int32.MinValue) { return(null); } PlayerProfile p1profile = profiles.FindPlayerProfile(p1name, p1version); PlayerProfile p2profile = profiles.FindPlayerProfile(p2name, p2version); StageProfile stageprofile = profiles.FindStageProfile(stagepath); if (p1profile == null || p2profile == null || stageprofile == null) { return(null); } Combat.EngineInitialization initsettings = new Combat.EngineInitialization(mode, p1profile, p1palette, p2profile, p2palette, stageprofile, seed); List <Replay.RecordingData> replaydata = new List <Replay.RecordingData>(); Regex line_regex = new Regex(@"^(\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)$", RegexOptions.IgnoreCase); StringConverter converter = profiles.GetSubSystem <StringConverter>(); foreach (String dataline in data.Lines) { Match match = line_regex.Match(dataline); if (match.Success == false) { continue; } Replay.RecordingData inputdata = new Replay.RecordingData( converter.Convert <Int32>(match.Groups[1].Value), converter.Convert <Int32>(match.Groups[2].Value), converter.Convert <Int32>(match.Groups[3].Value), converter.Convert <Int32>(match.Groups[4].Value), converter.Convert <Int32>(match.Groups[5].Value) ); replaydata.Add(inputdata); } return(new Replay.Recording(initsettings, replaydata)); }