-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c84d66
commit 6f07b14
Showing
17 changed files
with
1,614 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
|
||
namespace DazXmlModifier | ||
{ | ||
class DazDsx | ||
{ | ||
String filepathfull { get; set; } | ||
XDocument xfile; | ||
public String productName { get; set; } | ||
public String globalID { get; set; } | ||
public List<String> AssetNames { get; set; } | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="filepathfull"></param> | ||
public DazDsx(String filepathfull) | ||
{ | ||
this.filepathfull = filepathfull; | ||
this.AssetNames = new List<String>(); | ||
readXmlDoc(); | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
private void readXmlDoc() | ||
{ | ||
//Load file and fill out basic variables. | ||
this.xfile = XDocument.Load(filepathfull); | ||
var xProductNode = xfile.Descendants().Where(n => n.Name == "Product").FirstOrDefault(); | ||
if ((xProductNode != null) & (xProductNode.FirstAttribute != null)) | ||
productName = xProductNode.FirstAttribute.Value; | ||
var xGlobalIDNode = xfile.Descendants().Where(n => n.Name == "GlobalID").FirstOrDefault(); | ||
if ((xGlobalIDNode != null) & (xGlobalIDNode.FirstAttribute != null)) | ||
globalID = xGlobalIDNode.FirstAttribute.Value; | ||
|
||
//This will loop through every asset to populate names. | ||
var xAssetsNode = xfile.Descendants().Where(n => n.Name == "Assets").FirstOrDefault(); | ||
foreach (XElement xasset in xAssetsNode.Descendants("Asset")) | ||
{ | ||
AssetNames.Add(xasset.FirstAttribute.Value); | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
public Boolean ProcessAssets(String assetName, String content, String cat, String comp, Boolean compBase) | ||
{ | ||
var xAssetsNode = xfile.Descendants().Where(n => n.Name == "Assets").FirstOrDefault(); | ||
//This will loop through every asset. | ||
foreach (XElement xasset in xAssetsNode.Descendants("Asset")) | ||
{ | ||
String localAssetName = xasset.FirstAttribute.Value; | ||
|
||
//Check if this is the asset we want to modify. | ||
if (assetName != localAssetName) | ||
continue; | ||
|
||
Console.WriteLine(localAssetName); | ||
|
||
//====== Content Type ====== | ||
//<ContentType VALUE="Follower/Wardrobe/Dress"/> | ||
if (content != "") | ||
{ | ||
xasset.Add(new XElement("ContentType", new XAttribute("VALUE", content))); | ||
} | ||
|
||
//====== Categories ====== | ||
//<Categories> | ||
// < Category VALUE = "/Default/Wardrobe/Dresses" /> | ||
//</Categories> | ||
if (cat != "") | ||
{ | ||
XElement xcatagories = new XElement("Categories"); | ||
xcatagories.Add(new XElement("Category", new XAttribute("VALUE", cat))); | ||
xasset.Add(xcatagories); | ||
} | ||
|
||
//====== Compatibilitybase ====== | ||
//<CompatibilityBase VALUE="/Belle Dress for Genesis 8 Females/Belle Dress"/> | ||
if (compBase) | ||
{ | ||
String baseName = localAssetName.Split('/').Last(); | ||
String info = "/" + productName + "/" + baseName.Substring(0, baseName.Length - 4); | ||
xasset.Add(new XElement("CompatibilityBase", new XAttribute("VALUE", info))); | ||
} | ||
|
||
//====== Compatibility ====== | ||
//<Compatibilities> | ||
// < Compatibility VALUE = "/Genesis 8/Female" /> | ||
//</Compatibilities> | ||
if ((comp != "") & (comp != "Null (do not add)")) | ||
{ | ||
XElement xcatagories = new XElement("Compatibilities"); | ||
xcatagories.Add(new XElement("Compatibility", new XAttribute("VALUE", cat))); | ||
xasset.Add(xcatagories); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// DO NOT USE | ||
/// </summary> | ||
/// <returns></returns> | ||
public Boolean ProcessAssets(String content, String cat, String comp, Boolean compBase) | ||
{ | ||
var xAssetsNode = xfile.Descendants().Where(n => n.Name == "Assets").FirstOrDefault(); | ||
//This will loop through every asset. | ||
foreach (XElement xasset in xAssetsNode.Descendants("Asset")) | ||
{ | ||
String assetName = xasset.FirstAttribute.Value; | ||
Console.WriteLine(assetName); | ||
//xasset.FirstAttribute.SetValue("TESTING"); | ||
|
||
//====== Content Type ====== | ||
//<ContentType VALUE="Follower/Wardrobe/Dress"/> | ||
if (content != "") | ||
{ | ||
xasset.Add(new XElement("ContentType", new XAttribute("VALUE", content))); | ||
} | ||
|
||
//====== Categories ====== | ||
//<Categories> | ||
// < Category VALUE = "/Default/Wardrobe/Dresses" /> | ||
//</Categories> | ||
if (cat != "") | ||
{ | ||
XElement xcatagories = new XElement("Categories"); | ||
xcatagories.Add(new XElement("Category", new XAttribute("VALUE", cat))); | ||
xasset.Add(xcatagories); | ||
} | ||
|
||
//====== Compatibilitybase ====== | ||
if (compBase) | ||
{ | ||
String baseName = assetName.Split('/').Last(); | ||
String info = "/" + productName + "/" + baseName.Substring(0, baseName.Length - 4); | ||
xasset.Add(new XElement("CompatibilityBase", new XAttribute("VALUE", info))); | ||
} | ||
|
||
//====== Compatibility ====== | ||
if (comp != "") | ||
{ | ||
XElement xcatagories = new XElement("Compatibilities"); | ||
xcatagories.Add(new XElement("Compatibility", new XAttribute("VALUE", cat))); | ||
xasset.Add(xcatagories); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <returns></returns> | ||
public Boolean saveChanges() | ||
{ | ||
this.xfile.Save(filepathfull); | ||
return true; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{CFF8BA34-9A14-4FF4-86D0-9D002B31B53D}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>DazXmlModifier</RootNamespace> | ||
<AssemblyName>DazXmlModifier</AssemblyName> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="DazDsx.cs" /> | ||
<Compile Include="Form1.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="Form1.Designer.cs"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<EmbeddedResource Include="Form1.resx"> | ||
<DependentUpon>Form1.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<PropertyGroup> | ||
<PreBuildEvent> | ||
</PreBuildEvent> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.28307.168 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DazXmlModifier", "DazXmlModifier.csproj", "{CFF8BA34-9A14-4FF4-86D0-9D002B31B53D}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{CFF8BA34-9A14-4FF4-86D0-9D002B31B53D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{CFF8BA34-9A14-4FF4-86D0-9D002B31B53D}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{CFF8BA34-9A14-4FF4-86D0-9D002B31B53D}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{CFF8BA34-9A14-4FF4-86D0-9D002B31B53D}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {CDAAEA4A-2BDE-4785-8BB4-82A0DC7619F0} | ||
EndGlobalSection | ||
EndGlobal |
Oops, something went wrong.