Skip to content

Commit

Permalink
Parsing 3k anims project
Browse files Browse the repository at this point in the history
  • Loading branch information
donkeyProgramming committed May 25, 2022
1 parent 89001c7 commit 009abdf
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 1 deletion.
8 changes: 8 additions & 0 deletions AnimationSlotAnal/AnimationSlotAnal.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
119 changes: 119 additions & 0 deletions AnimationSlotAnal/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Serialization;

namespace AnimationSlotAnal
{
class Program
{
static void Main(string[] args)
{
var catagories = LoadXmlFile<Dataroot_Categories>(@"C:\Users\ole_k\Downloads\animation_categories.xml").Animation_categories;
var slots = LoadXmlFile<Dataroot_Slots>(@"C:\Users\ole_k\Downloads\animation_slot_categories.xml").Animation_slot_categories;

var orderedCatagories = catagories
.OrderBy(x => x.Order)
.ToDictionary(x => x.Name, x => x.Order);

var orderedCatagoriesCount = orderedCatagories
.Select(x => $"{x.Key}_{x.Value}")
.ToList();

var slotsOrderedByGroup = slots
.OrderBy(x => orderedCatagories[x.Category])
.GroupBy(x => x.Category);

var slotsOrderedByGroupWithCount = slotsOrderedByGroup
.Select(x => $"{x.Key}_{x.Count()}")
.ToList();

var slotsOrderedByGroupList = slotsOrderedByGroup.ToList();
}

static T LoadXmlFile<T>(string path) where T : class
{
var ser = new XmlSerializer(typeof(T));
using var fileStream = new FileStream(path, FileMode.Open);
var data = ser.Deserialize(fileStream) as T;
return data;
}
}

[XmlRoot(ElementName = "animation_categories")]
public class Animation_categories
{
[XmlElement(ElementName = "name")]
public string Name { get; set; }
[XmlElement(ElementName = "order")]
public int Order { get; set; }
[XmlAttribute(AttributeName = "record_uuid")]
public string Record_uuid { get; set; }
[XmlAttribute(AttributeName = "record_timestamp")]
public string Record_timestamp { get; set; }
[XmlAttribute(AttributeName = "record_key")]
public string Record_key { get; set; }
}

[XmlRoot(ElementName = "dataroot")]
public class Dataroot_Categories
{
[XmlElement(ElementName = "edit_uuid")]
public string Edit_uuid { get; set; }
[XmlElement(ElementName = "animation_categories")]
public List<Animation_categories> Animation_categories { get; set; }
[XmlAttribute(AttributeName = "od", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Od { get; set; }
[XmlAttribute(AttributeName = "xsi", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Xsi { get; set; }
[XmlAttribute(AttributeName = "noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
public string NoNamespaceSchemaLocation { get; set; }
[XmlAttribute(AttributeName = "export_time")]
public string Export_time { get; set; }
[XmlAttribute(AttributeName = "revision")]
public string Revision { get; set; }
[XmlAttribute(AttributeName = "export_branch")]
public string Export_branch { get; set; }
[XmlAttribute(AttributeName = "export_user")]
public string Export_user { get; set; }
}

[XmlRoot(ElementName = "animation_slot_categories")]
public class Animation_slot_categories
{
[XmlElement(ElementName = "category")]
public string Category { get; set; }
[XmlElement(ElementName = "slot")]
public string Slot { get; set; }
[XmlAttribute(AttributeName = "record_uuid")]
public string Record_uuid { get; set; }
[XmlAttribute(AttributeName = "record_timestamp")]
public string Record_timestamp { get; set; }
[XmlAttribute(AttributeName = "record_key")]
public string Record_key { get; set; }
}

[XmlRoot(ElementName = "dataroot")]
public class Dataroot_Slots
{
[XmlElement(ElementName = "edit_uuid")]
public string Edit_uuid { get; set; }
[XmlElement(ElementName = "animation_slot_categories")]
public List<Animation_slot_categories> Animation_slot_categories { get; set; }
[XmlAttribute(AttributeName = "od", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Od { get; set; }
[XmlAttribute(AttributeName = "xsi", Namespace = "http://www.w3.org/2000/xmlns/")]
public string Xsi { get; set; }
[XmlAttribute(AttributeName = "noNamespaceSchemaLocation", Namespace = "http://www.w3.org/2001/XMLSchema-instance")]
public string NoNamespaceSchemaLocation { get; set; }
[XmlAttribute(AttributeName = "export_time")]
public string Export_time { get; set; }
[XmlAttribute(AttributeName = "revision")]
public string Revision { get; set; }
[XmlAttribute(AttributeName = "export_branch")]
public string Export_branch { get; set; }
[XmlAttribute(AttributeName = "export_user")]
public string Export_user { get; set; }
}
}
9 changes: 8 additions & 1 deletion AssetEditor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AnimationEditor", "Animatio
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Experiments", "Experiments", "{FF70C4FA-A9A7-4DEC-87A3-4BF5F23EF336}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wh3AnimPackCreator", "Wh3AnimPackCreator\Wh3AnimPackCreator.csproj", "{3A205F23-1862-4F06-B9D8-DF82810515B3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Wh3AnimPackCreator", "Wh3AnimPackCreator\Wh3AnimPackCreator.csproj", "{3A205F23-1862-4F06-B9D8-DF82810515B3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnimationSlotAnal", "AnimationSlotAnal\AnimationSlotAnal.csproj", "{59AE0CFC-9721-44E6-927C-0611556259EA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -88,6 +90,10 @@ Global
{3A205F23-1862-4F06-B9D8-DF82810515B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A205F23-1862-4F06-B9D8-DF82810515B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A205F23-1862-4F06-B9D8-DF82810515B3}.Release|Any CPU.Build.0 = Release|Any CPU
{59AE0CFC-9721-44E6-927C-0611556259EA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{59AE0CFC-9721-44E6-927C-0611556259EA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{59AE0CFC-9721-44E6-927C-0611556259EA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{59AE0CFC-9721-44E6-927C-0611556259EA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -101,6 +107,7 @@ Global
{70708A4D-A71A-487A-87DE-47E526F2E142} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{0FCB6133-32A4-4115-BD53-474C703E7B34} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{3A205F23-1862-4F06-B9D8-DF82810515B3} = {FF70C4FA-A9A7-4DEC-87A3-4BF5F23EF336}
{59AE0CFC-9721-44E6-927C-0611556259EA} = {FF70C4FA-A9A7-4DEC-87A3-4BF5F23EF336}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB5968F3-98ED-4AFF-98EA-0DBEDCACADF2}
Expand Down

0 comments on commit 009abdf

Please sign in to comment.