コード例 #1
0
ファイル: Game.cs プロジェクト: marimelon/Nhaama
        public Game(Process process, bool loadRemote = true, string definitionFilePath = null)
        {
            Type    = process.MainModule.ModuleName.Contains("ffxiv_dx11") ? GameType.Dx11 : GameType.Dx9;
            Process = process.GetNhaamaProcess();

            var gameDirectory = new DirectoryInfo(process.MainModule.FileName);

            Version = File.ReadAllText(Path.Combine(gameDirectory.Parent.FullName, "ffxivgame.ver"));

            if (loadRemote)
            {
                Definitions = Definitions.Get(Process, Version, Type);
            }
            else if (definitionFilePath != null)
            {
                var definitionJson = File.ReadAllText(definitionFilePath);
                var serializer     = Process.GetSerializer();
                Definitions = serializer.DeserializeObject <Definitions>(definitionJson);
            }
            else
            {
                Definitions = new Definitions(Process);
            }

            ActorTable = new ActorTableCollection(this);
        }
コード例 #2
0
        public static Definitions Get(NhaamaProcess p, string version, Game.GameType gameType)
        {
            using (WebClient client = new WebClient())
            {
                var uri = new Uri(DefinitionStoreUrl, $"{gameType.ToString().ToLower()}/{version}.json");

                try
                {
                    var definitionJson         = client.DownloadString(uri);
                    var serializer             = p.GetSerializer();
                    var deserializedDefinition = serializer.DeserializeObject <Definitions>(definitionJson);

                    return(deserializedDefinition);
                }
                catch (WebException exc)
                {
                    throw new Exception("Could not get definitions for version: " + uri, exc);
                }
            }
        }
コード例 #3
0
        public static string GetJson(NhaamaProcess process)
        {
            var serializer = process.GetSerializer();

            return(serializer.SerializeObject(new Definitions(process), Newtonsoft.Json.Formatting.Indented));
        }