Inheritance: IDisposable
Ejemplo n.º 1
0
        public ModuleFile(Module module, string alias, string filePath)
        {
            mModule = module;
            mAlias = alias;
            mOriginalFilePath = filePath;
            mRootFile = JsonHelper.GetFileFromFileJson(filePath, module.Path);
            int lastColon = Name.LastIndexOf(':');
            mShortName = lastColon > -1 ? Name.Substring(lastColon + 1) : Name;
            if (mShortName.Equals("fine"))
            {
                string oneBefore = Name.Substring(0, lastColon);
                int secondToLastColon = oneBefore.LastIndexOf(':');
                oneBefore = secondToLastColon > -1 ? oneBefore.Substring(secondToLastColon + 1) : oneBefore;
                mShortName = oneBefore;
                mIsFineVersion = true;
            }

            DetermineFileType();
        }
Ejemplo n.º 2
0
#pragma warning disable SA1202 // Elements must be ordered by access
        public void Dispose()
#pragma warning restore SA1202 // Elements must be ordered by access
        {
            mModule = null;
            mReferencesCache.Clear();
            if (mFileData != null)
            {
                FileData data = mFileData;
                mFileData = null;
                data.Dispose();
            }
        }
        public void Load()
        {
            // Parse Manifests
            string[] modFolders = Directory.GetDirectories(mModsDirectoryPath);
            if (modFolders == null)
            {
                return;
            }

            foreach (string modPath in modFolders)
            {
                string formatted = JsonHelper.NormalizeSystemPath(modPath);
                Module module = new Module(formatted);
                module.InitializeFromManifest();
                mModules.Add(module.Name, module);
            }

            foreach (Module module in mModules.Values)
            {
                module.LoadFiles();
            }

            foreach (Module module in mModules.Values)
            {
                module.PostLoadFixup();
            }
        }
Ejemplo n.º 4
0
        private void selectJsonFileDialog_FileOk(object sender, CancelEventArgs e)
        {
            string filePath = selectJsonFileDialog.FileName;

            if (filePath == null)
            {
                return;
            }

            filePath = JsonHelper.NormalizeSystemPath(filePath);
            Module selectedMod = selectJsonFileDialog.Tag as Module;

            if (!filePath.Contains(selectedMod.Path))
            {
                MessageBox.Show("The file must be under the directory " + selectedMod.Path);
                return;
            }

            mLastModuleLocations[selectedMod.Name] = filePath;
            string shortPath = filePath.Replace(selectedMod.Path + "/", "");

            string[] pathSplit  = shortPath.Split('/');
            string   samplePath = string.Empty;

            for (int i = 1; i < (pathSplit.Length - 1); ++i)
            {
                if (string.IsNullOrEmpty(samplePath))
                {
                    samplePath = pathSplit[i];
                }
                else
                {
                    samplePath = samplePath + ':' + pathSplit[i];
                }
            }

            if (pathSplit.Length > 2)
            {
                // Make the file path not contain the .json part if it doesn't have to
                string fileName  = pathSplit[pathSplit.Length - 1];
                string extension = System.IO.Path.GetExtension(fileName);
                if (extension == ".json")
                {
                    string folder = pathSplit[pathSplit.Length - 2];
                    if (folder.Equals(System.IO.Path.GetFileNameWithoutExtension(fileName)))
                    {
                        shortPath = shortPath.Replace("/" + fileName, "");
                    }
                }
                else if (extension == ".lua")
                {
                    string nameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fileName);
                    if (nameWithoutExtension.EndsWith("_action"))
                    {
                        nameWithoutExtension = nameWithoutExtension.Substring(0, nameWithoutExtension.Length - 7);
                        samplePath           = samplePath + ':' + nameWithoutExtension;
                    }
                }
            }

            NewAliasCallback callback = new NewAliasCallback(this, selectedMod, shortPath);
            InputDialog      dialog   = new InputDialog("Add New Alias", "Type the name of the alias for " + filePath, samplePath, "Add!");

            dialog.SetCallback(callback);
            dialog.ShowDialog();
        }
Ejemplo n.º 5
0
 public NewAliasCallback(ManifestView owner, Module module, string filePath)
 {
     mOwner    = owner;
     mModule   = module;
     mFilePath = filePath;
 }
Ejemplo n.º 6
0
 public NewAliasCallback(ManifestView owner, Module module, string filePath)
 {
     mOwner = owner;
     mModule = module;
     mFilePath = filePath;
 }