Example #1
0
        public TitanfallMod(string Directory)
        {
            string modDocumentPath = Path.Combine(Directory, ModDocumentFile);

            if (File.Exists(modDocumentPath))
            {
                StreamReader reader   = new StreamReader(modDocumentPath);
                string       Contents = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();

                try
                {
                    Definition = JsonConvert.DeserializeObject <TitanfallModDefinition>(Contents);
                }
                catch
                {
                }
            }
            this.Directory = Directory;

            // Load custom image for this mod if it exists
            string modImagePath = Path.Combine(Directory, ModImage);

            if (File.Exists(modImagePath))
            {
                ImagePath = modImagePath;
            }

            string disabledFilePath = Path.Combine(Directory, DisabledFile);

            Enabled = !File.Exists(disabledFilePath);
        }
        public TitanfallMod(string Directory)
        {
            string modDocumentPath = Path.Combine(Directory, ModDocumentFile);

            if (File.Exists(modDocumentPath))
            {
                StreamReader reader   = new StreamReader(modDocumentPath);
                string       Contents = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();

                if (Contents.StartsWith("disabled"))
                {
                    Enabled  = false;
                    Contents = Contents.Substring("disabled".Length);
                }

                Definition = JsonConvert.DeserializeObject <TitanfallModDefinition>(Contents);
            }
            this.Directory = Directory;

            // Load custom image for this mod if it exists
            string modImagePath = Path.Combine(Directory, ModImage);

            if (File.Exists(modImagePath))
            {
                ImagePath = modImagePath;
            }

            // Get the release id of the mod so we can check it for updates
            string modReleasePath = Path.Combine(Directory, ReleaseFile);

            if (File.Exists(modReleasePath))
            {
                StreamReader reader = new StreamReader(modReleasePath);
                CurrentReleaseId = reader.ReadToEnd();
                reader.Close();
                reader.Dispose();
            }

            if (OnStatusUpdated != null)
            {
                OnStatusUpdated();
            }
        }