コード例 #1
0
        private static void GetArchiveChildren(string filePath, XmlNode node, ref OIVArchive root)
        {
            foreach (XmlNode subNode in node.ChildNodes)
            {
                if (subNode.Name == "add")
                {
                    root?.Add(filePath + "content\\" + subNode.Attributes.GetNamedItem("source").Value,
                              subNode.InnerText);
                }

                else if (subNode.Name == "archive")
                {
                    var archive = new OIVArchive();

                    archive.Path = subNode.Attributes.GetNamedItem("path").Value;

                    archive.CreateIfNotExist = Convert.ToBoolean(subNode.Attributes.GetNamedItem("createIfNotExist").Value);

                    archive.Version = (RageArchiveType)Enum.Parse(typeof(RageArchiveType), subNode.Attributes.GetNamedItem("type").Value);

                    root.NestedArchives.Add(archive);

                    GetArchiveChildren(filePath, subNode, ref archive);
                }
            }
        }
コード例 #2
0
        private void FinishButtonClick(object sender, CancelEventArgs e)
        {
            string fullPath = textBox1.Text.Trim();

            SaveCommonPath(fullPath);

            fullPath = fullPath.Replace('/', '\\');

            if (fullPath.Length <= 0 || !fullPath.Contains(".rpf"))
            {
                MessageBox.Show("Invalid archive path.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (files.Count <= 0)
            {
                MessageBox.Show("No files were selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int startIndex = 0;
            int endIndex   = 0;

            startIndex = fullPath.IndexOf(".rpf") + 4;

            var initialPath = fullPath.Substring(0, startIndex);

            archive.Path = initialPath;

            string subStr = fullPath;

            OIVArchive currentNode = archive;

            for (int i = 1; i < Regex.Matches(fullPath, ".rpf").Count; i++)
            {
                subStr   = subStr.Substring(startIndex, subStr.Length - startIndex);
                endIndex = subStr.IndexOf(".rpf") + 4;
                var subArchivePath = subStr.Substring(0, endIndex).TrimStart('\\');
                startIndex = endIndex;
                var subArchive = new OIVArchive(archive.Version, new List <OIVArchiveFile>(), subArchivePath, false);
                currentNode.NestedArchives.Add(subArchive);
                currentNode = subArchive;
            }

            foreach (var file in files)
            {
                var innerPath = fullPath.Substring(fullPath.LastIndexOf(".rpf") + 4);
                if (innerPath.Length > 0 && !innerPath.EndsWith("\\"))
                {
                    innerPath += "\\";
                }
                currentNode.Add(file, innerPath + file.Substring(file.LastIndexOf("\\") + 1));
            }

            Finished?.Invoke(this, archive);
            Close();
        }
コード例 #3
0
ファイル: Util.cs プロジェクト: CamxxCore/OIVPackageCreator
        public static IEnumerable <OIVArchive> GetNodes(this OIVArchive a)
        {
            if (a == null)
            {
                yield break;
            }

            yield return(a);

            foreach (var n in a.NestedArchives)
            {
                foreach (var innerN in GetNodes(n))
                {
                    yield return(innerN);
                }
            }
        }
コード例 #4
0
ファイル: Util.cs プロジェクト: CamxxCore/OIVPackageCreator
        public static IEnumerable <OIVArchiveFile> GetNestedFiles(this OIVArchive a)
        {
            foreach (var file in a.SourceFiles)
            {
                yield return(file);
            }

            foreach (var n in a.NestedArchives)
            {
                foreach (var innerN in GetNodes(a))
                {
                    foreach (var file in innerN.SourceFiles)
                    {
                        yield return(file);
                    }
                }
            }
        }
コード例 #5
0
        private void ArchiveContentWz_Finished(object sender, OIVArchive archive)
        {
            foreach (var ar in archive.GetNodes())
            {
                if (ar.SourceFiles == null)
                {
                    continue;
                }

                foreach (var f in ar.SourceFiles)
                {
                    listBox1.Items.Add(string.Format("{0} -> {1}",
                                                     f.Source.Substring(f.Source.LastIndexOf('\\') + 1),
                                                     f.FullPath).Replace("\\\\", "\\"));
                }
            }

            info = info ?? new OIVPackageInfo();
            info.Archives.Add(archive);

            wizardActive = false;
        }
コード例 #6
0
        private void ReadXMLMetadata(string filePath, out OIVPackageInfo data)
        {
            OIVPackageInfo info = new OIVPackageInfo();

            var xmlDoc = new XmlDocument();

            xmlDoc.Load(filePath + "assembly.xml");

            var packageRoot = xmlDoc.SelectSingleNode("/package");

            info.Version = Convert.ToSingle(packageRoot.Attributes.GetNamedItem("version").Value);

            info.ID = packageRoot.Attributes.GetNamedItem("id").Value;

            info.Target = packageRoot.Attributes.GetNamedItem("target").Value;

            var element = packageRoot.SelectSingleNode("metadata");

            info.Name = element.SelectSingleNode("name").InnerText;

            var element1 = element.SelectSingleNode("version");

            info.MajorVersion = Convert.ToInt32(element1.SelectSingleNode("major").InnerText);

            info.MinorVersion = Convert.ToInt32(element1.SelectSingleNode("minor").InnerText);

            info.Tag = element1.SelectSingleNode("tag")?.InnerText;

            element1 = element.SelectSingleNode("author");

            info.DisplayName = element1.SelectSingleNode("displayName").InnerText;

            info.ActionLink = element1.SelectSingleNode("actionLink")?.InnerText;

            info.Web = element1.SelectSingleNode("web")?.InnerText;

            info.Facebook = element1.SelectSingleNode("facebook")?.InnerText;

            info.Twitter = element1.SelectSingleNode("twitter")?.InnerText;

            info.Youtube = element1.SelectSingleNode("youtube")?.InnerText;

            element1 = element.SelectSingleNode("description");

            info.FooterLink = element1.Attributes.GetNamedItem("footerLink")?.Value;

            info.FooterLinkTitle = element1.Attributes.GetNamedItem("footerLinkTitle")?.Value;

            var cData = (XmlCDataSection)(element1.ChildNodes[0]);

            info.Description = cData.Data;

            element1 = element.SelectSingleNode("largeDescription");

            if (element1 != null)
            {
                info.LDDisplayName = element1.Attributes.GetNamedItem("displayName")?.Value;

                info.LDFooterLink = element1.Attributes.GetNamedItem("footerLink")?.Value;

                info.LDFooterLinkTitle = element1.Attributes.GetNamedItem("footerLinkTitle")?.Value;

                cData = (XmlCDataSection)(element1.ChildNodes[0]);

                info.LDDescription = cData.Data;
            }

            element1 = element.SelectSingleNode("license");

            if (element1 != null)
            {
                info.LFooterLink = element1.Attributes.GetNamedItem("footerLink")?.Value;

                info.LFooterLinkTitle = element1.Attributes.GetNamedItem("footerLinkTitle")?.Value;

                cData = (XmlCDataSection)(element1.ChildNodes[0]);

                info.License = cData.Data;
            }

            element = packageRoot.SelectSingleNode("colors");

            element1 = element.SelectSingleNode("headerBackground");

            info.BlackTextEnabled = Convert.ToBoolean(element1.Attributes.GetNamedItem("useBlackTextColor").Value);

            info.HeaderBackground = ColorTranslator.FromHtml(element1.InnerText.Replace('$', '#'));

            element1 = element.SelectSingleNode("iconBackground");

            info.IconBackground = ColorTranslator.FromHtml(element1.InnerText.Replace('$', '#'));

            element1 = packageRoot.SelectSingleNode("content");

            foreach (XmlNode node in element1.ChildNodes)
            {
                if (node.Name == "add")
                {
                    var source = node.Attributes.GetNamedItem("source");

                    info.GenericFiles.Add(new OIVGenericFile(filePath + "content\\" + source.Value, node.InnerText));
                }

                else if (node.Name == "archive")
                {
                    var archive = new OIVArchive();

                    archive.Path = node.Attributes.GetNamedItem("path").Value;

                    archive.CreateIfNotExist = Convert.ToBoolean(node.Attributes.GetNamedItem("createIfNotExist").Value);

                    archive.Version = (RageArchiveType)Enum.Parse(typeof(RageArchiveType), node.Attributes.GetNamedItem("type").Value);

                    GetArchiveChildren(filePath, node, ref archive);

                    info.Archives.Add(archive);
                }
            }

            data = info;
        }