├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── xivModdingFramework.sln └── xivModdingFramework ├── App.config ├── Cache ├── ConsoleConfig.cs ├── FrameworkExceptions.cs ├── XivCache.cs ├── XivDependencyGraph.cs └── XivDependencyRoot.cs ├── Exd ├── Enums │ └── XivEx.cs └── FileTypes │ ├── Ex.cs │ └── ExColumnExpectations.cs ├── General ├── CMP.cs ├── DataContainers │ ├── CharaMakeParameter.cs │ └── SearchResults.cs ├── Enums │ ├── XivCategory.cs │ ├── XivDataFile.cs │ ├── XivLanguage.cs │ └── XivRace.cs ├── GameInfo.cs ├── Quad.cs └── XivModelChara.cs ├── HUD └── FileTypes │ └── Uld.cs ├── Helpers ├── BinaryReaderBE.cs ├── Constants.cs ├── DxtUtil.cs ├── HashGenerator.cs ├── IOUtil.cs ├── PenumbraAPI.cs ├── PenumbraAttachHandler.cs └── ProblemChecker.cs ├── Items ├── Categories │ ├── Character.cs │ ├── Companions.cs │ ├── Gear.cs │ ├── Housing.cs │ └── UI.cs ├── DataContainers │ ├── XivCharacter.cs │ ├── XivFurniture.cs │ ├── XivGear.cs │ ├── XivGenericItemModel.cs │ ├── XivMinion.cs │ ├── XivModelInfo.cs │ ├── XivMonsterModelInfo.cs │ ├── XivMount.cs │ ├── XivPet.cs │ └── XivUi.cs ├── Enums │ └── XivItemType.cs ├── Interfaces │ ├── IItem.cs │ └── IItemModel.cs └── ItemType.cs ├── Materials ├── DataContainers │ ├── ShaderHelpers.cs │ └── XivMtrl.cs └── FileTypes │ ├── Mtrl.cs │ └── STM.cs ├── Models ├── DataContainers │ ├── AttributeDataBlock.cs │ ├── BoneDataBlock.cs │ ├── BoneIndexMesh.cs │ ├── BoneTransformData.cs │ ├── BoundingBox.cs │ ├── ColladaData.cs │ ├── EModelingTool.cs │ ├── EquipmentParameter.cs │ ├── ExtraSkeletonEntry.cs │ ├── LevelOfDetail.cs │ ├── MaterialDataBlock.cs │ ├── MdlModelData.cs │ ├── MdlPathData.cs │ ├── MeshData.cs │ ├── MeshDataInfo.cs │ ├── MeshPart.cs │ ├── ModelTextureData.cs │ ├── NeckMorphEntry.cs │ ├── ShapeData.cs │ ├── SkeletonData.cs │ ├── TTModel.cs │ ├── TerrainShadowMeshData.cs │ ├── UnknownData0.cs │ ├── UnknownData2.cs │ ├── UnknownDataPatch72.cs │ ├── VertexData.cs │ ├── VertexDataStruct.cs │ └── XivMdl.cs ├── Enums │ ├── VertexDataType.cs │ └── VertexUsageType.cs ├── FileTypes │ ├── Eqp.cs │ ├── Est.cs │ ├── Mdl.cs │ ├── MdlVertexReader.cs │ ├── Obj.cs │ ├── PDB.cs │ └── Sklb.cs ├── Helpers │ └── ModelModifiers.cs └── ModelTextures │ └── ModelTexture.cs ├── Mods ├── DataContainers │ ├── BackupModPackData.cs │ ├── ModGroup.cs │ ├── ModList.cs │ ├── ModOption.cs │ ├── ModPackData.cs │ ├── ModPackJson.cs │ ├── OriginalModList.cs │ ├── OriginalModPackJson.cs │ ├── SimpleModPackData.cs │ └── TransactionModList.cs ├── EndwalkerUpgrade.cs ├── Enums │ └── EModState.cs ├── FileTypes │ ├── ItemMetadata.cs │ ├── ModelKit.cs │ ├── PMP.cs │ ├── PmpExtensions.cs │ ├── PmpManipulation.cs │ └── TTMP.cs ├── Interfaces │ └── IModPackData.cs ├── ModTransaction.cs ├── Modding.cs ├── ModpackUpgrader.cs ├── RootCloner.cs ├── ShrinkRay.cs ├── SmartImport.cs ├── TTMPWriter.cs ├── TxBoiler.cs └── WizardData.cs ├── Resources ├── DB │ ├── item_sets.db │ ├── shader_info.db │ └── uv_heuristics.db ├── DefaultTextures │ ├── Colorset.dat │ ├── Colorset.dds │ ├── Diffuse.dds │ ├── Multi.dds │ ├── Normal.dds │ ├── Other.dds │ ├── Specular.dds │ ├── default_material.mtrl │ └── default_material_dt.mtrl ├── GeneralStrings.Designer.cs ├── GeneralStrings.resx ├── SQL │ ├── CreateCacheDB.sql │ ├── CreateImportDB.sql │ ├── CreateRootCacheDB.sql │ ├── CreateShaderDB.sql │ └── ShrinkShaderCache.sql ├── ShaderConstants │ ├── character.json │ └── skin.json ├── ShaderKeys.json ├── XivStrings.Designer.cs ├── XivStrings.de.resx ├── XivStrings.en.resx ├── XivStrings.fr.resx ├── XivStrings.ja.resx ├── XivStrings.ko.resx ├── XivStrings.resx └── XivStrings.zh.resx ├── SqPack ├── DataContainers │ ├── IndexFile.cs │ └── TransactionIndexFile.cs └── FileTypes │ ├── Dat.cs │ ├── Index.cs │ └── TransactionDataHandler.cs ├── Textures ├── DataContainers │ ├── TexTypePath.cs │ └── XivTex.cs ├── Enums │ ├── XivTexFormat.cs │ └── XivTexType.cs ├── FileTypes │ ├── ATex.cs │ ├── DDS.cs │ └── Tex.cs └── TextureHelpers.cs ├── VFX └── FileTypes │ └── Avfx.cs ├── Variants ├── DataContainers │ └── XivImc.cs └── FileTypes │ └── Imc.cs ├── World ├── Enums.cs ├── InstanceObject.cs ├── Layer.cs └── Sgb.cs └── xivModdingFramework.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc 262 | /xivModdingFramework.xUnit 263 | /exChecker 264 | -------------------------------------------------------------------------------- /xivModdingFramework.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "xivModdingFramework", "xivModdingFramework\xivModdingFramework.csproj", "{83A720A7-A039-4FE3-BE65-95146CF5C6F3}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "xivModdingFramework.xUnit", "xivModdingFramework.xUnit\xivModdingFramework.xUnit.csproj", "{4214BC4D-2FAD-4C9A-9F60-06A3EB22820D}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "exChecker", "exChecker\exChecker.csproj", "{D174095D-1B25-471A-B443-83D69E0A3173}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Any CPU = Debug|Any CPU 15 | Release|Any CPU = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {83A720A7-A039-4FE3-BE65-95146CF5C6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 19 | {83A720A7-A039-4FE3-BE65-95146CF5C6F3}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {83A720A7-A039-4FE3-BE65-95146CF5C6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {83A720A7-A039-4FE3-BE65-95146CF5C6F3}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {4214BC4D-2FAD-4C9A-9F60-06A3EB22820D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 23 | {4214BC4D-2FAD-4C9A-9F60-06A3EB22820D}.Debug|Any CPU.Build.0 = Debug|Any CPU 24 | {4214BC4D-2FAD-4C9A-9F60-06A3EB22820D}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {4214BC4D-2FAD-4C9A-9F60-06A3EB22820D}.Release|Any CPU.Build.0 = Release|Any CPU 26 | {D174095D-1B25-471A-B443-83D69E0A3173}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 27 | {D174095D-1B25-471A-B443-83D69E0A3173}.Debug|Any CPU.Build.0 = Debug|Any CPU 28 | {D174095D-1B25-471A-B443-83D69E0A3173}.Release|Any CPU.ActiveCfg = Release|Any CPU 29 | {D174095D-1B25-471A-B443-83D69E0A3173}.Release|Any CPU.Build.0 = Release|Any CPU 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {BDFB9BEC-EE96-43CD-A227-E288399EC7E2} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /xivModdingFramework/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /xivModdingFramework/Cache/ConsoleConfig.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.IO; 4 | using System.Threading.Tasks; 5 | using xivModdingFramework.General.Enums; 6 | using xivModdingFramework.Helpers; 7 | 8 | namespace xivModdingFramework.Cache 9 | { 10 | /// 11 | /// Simple class for storing basic configuration information in the working directory. 12 | /// This is a basic way for framework applications to hook the Framework without having to manually 13 | /// supply things like game path which may already be configured by TexTools/etc. 14 | /// 15 | public class ConsoleConfig 16 | { 17 | public const string ConfigPath = "console_config.json"; 18 | 19 | public string XivPath { get; set; } = ""; 20 | 21 | public string Language { get; set; } = "en"; 22 | 23 | [JsonIgnore] 24 | public XivLanguage XivLanguage 25 | { 26 | get 27 | { 28 | try 29 | { 30 | return XivLanguages.GetXivLanguage(Language); 31 | } 32 | catch 33 | { 34 | return XivLanguage.English; 35 | } 36 | } 37 | } 38 | 39 | 40 | public static void Update(Action action) 41 | { 42 | var c = Get(); 43 | action(c); 44 | c.Save(); 45 | } 46 | 47 | public static ConsoleConfig Get() 48 | { 49 | var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); 50 | var path = Path.Combine(cwd, ConfigPath); 51 | 52 | if (!File.Exists(path)) 53 | { 54 | return new ConsoleConfig(); 55 | } 56 | 57 | try 58 | { 59 | return JsonConvert.DeserializeObject(File.ReadAllText(path)); 60 | } 61 | catch 62 | { 63 | return new ConsoleConfig(); 64 | } 65 | } 66 | 67 | public void Save() 68 | { 69 | var cwd = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); 70 | var path = Path.Combine(cwd, ConsoleConfig.ConfigPath); 71 | var text = JsonConvert.SerializeObject(this, Formatting.Indented); 72 | File.WriteAllText(path, text); 73 | } 74 | 75 | 76 | public static async Task InitCacheFromConfig(bool runWorker = false) 77 | { 78 | var c = Get(); 79 | if (string.IsNullOrWhiteSpace(c.XivPath)) 80 | { 81 | throw new ArgumentException("Console Config file does not have a valid FFXIV File path configured."); 82 | } 83 | await XivCache.SetGameInfo(new DirectoryInfo(c.XivPath), c.XivLanguage, runWorker); 84 | 85 | // Set a unique temp path. 86 | var tempDir = IOUtil.GetUniqueSubfolder(Path.GetTempPath(), "xivct"); 87 | XivCache.FrameworkSettings.TempDirectory = tempDir; 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /xivModdingFramework/Cache/FrameworkExceptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using static xivModdingFramework.Cache.FrameworkExceptions; 5 | 6 | namespace xivModdingFramework.Cache 7 | { 8 | internal class FrameworkExceptions 9 | { 10 | public class ModdingFrameworkException : Exception 11 | { 12 | public ModdingFrameworkException() 13 | { 14 | } 15 | 16 | public ModdingFrameworkException(string message) 17 | : base(message) 18 | { 19 | } 20 | 21 | public ModdingFrameworkException(string message, Exception inner) 22 | : base(message, inner) 23 | { 24 | } 25 | } 26 | 27 | public class OffsetException : ModdingFrameworkException 28 | { 29 | public OffsetException() 30 | { 31 | } 32 | 33 | public OffsetException(string message) 34 | : base(message) 35 | { 36 | } 37 | 38 | public OffsetException(string message, Exception inner) 39 | : base(message, inner) 40 | { 41 | } 42 | } 43 | public class HashCollisionException : ModdingFrameworkException 44 | { 45 | public HashCollisionException() 46 | { 47 | } 48 | 49 | public HashCollisionException(string message) 50 | : base(message) 51 | { 52 | } 53 | 54 | public HashCollisionException(string message, Exception inner) 55 | : base(message, inner) 56 | { 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /xivModdingFramework/General/DataContainers/SearchResults.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | 19 | namespace xivModdingFramework.General.DataContainers 20 | { 21 | public class SearchResults : IComparable 22 | { 23 | /// 24 | /// The slot for the item 25 | /// 26 | public string Slot { get; set; } 27 | 28 | /// 29 | /// The body for the item 30 | /// 31 | public string Body { get; set; } 32 | 33 | /// 34 | /// The variant for the item 35 | /// 36 | public int Variant { get; set; } 37 | 38 | public int CompareTo(SearchResults results) 39 | { 40 | return Variant.CompareTo(results.Variant); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /xivModdingFramework/General/Enums/XivCategory.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Resources; 6 | using xivModdingFramework.Resources; 7 | 8 | namespace xivModdingFramework.General.Enums 9 | { 10 | public static class XivCategories 11 | { 12 | static List _keys = null; 13 | static XivCategories() 14 | { 15 | _keys = typeof(XivStrings).GetProperties(BindingFlags.Static|BindingFlags.NonPublic).Select(it => it.Name).ToList(); 16 | } 17 | 18 | public static string GetDisplayName(this string value) 19 | { 20 | var rm = new ResourceManager(typeof(XivStrings)); 21 | string displayName = value; 22 | foreach(var key in _keys) 23 | { 24 | var name = rm.GetString(key,new CultureInfo("en")); 25 | if ( name== value) 26 | { 27 | displayName = rm.GetString(key); 28 | break; 29 | } 30 | } 31 | return displayName; 32 | } 33 | public static string GetEnDisplayName(this string value) 34 | { 35 | var rm = new ResourceManager(typeof(XivStrings)); 36 | string displayName = value; 37 | foreach (var key in _keys) 38 | { 39 | var name = rm.GetString(key); 40 | if (name == value) 41 | { 42 | displayName = rm.GetString(key, new CultureInfo("en")); 43 | break; 44 | } 45 | } 46 | return displayName; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /xivModdingFramework/General/Enums/XivLanguage.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.ComponentModel; 19 | using System.Linq; 20 | 21 | namespace xivModdingFramework.General.Enums 22 | { 23 | /// 24 | /// Enum containing the languages supported by the game 25 | /// 26 | /// 27 | /// May need to be updated if the game ever supports an additional language 28 | /// 29 | public enum XivLanguage 30 | { 31 | [Description("en")] English, 32 | [Description("ja")] Japanese, 33 | [Description("de")] German, 34 | [Description("fr")] French, 35 | [Description("ko")] Korean, 36 | [Description("chs")] Chinese, 37 | [Description("none")] None 38 | } 39 | 40 | /// 41 | /// Class used to get the description from the enum value 42 | /// 43 | public static class XivLanguages 44 | { 45 | /// 46 | /// Gets the description from the enum value, in this case the Language 47 | /// 48 | /// The enum value 49 | /// The Language Code 50 | public static string GetLanguageCode(this XivLanguage value) 51 | { 52 | var field = value.GetType().GetField(value.ToString()); 53 | var attribute = (DescriptionAttribute[])field.GetCustomAttributes(typeof(DescriptionAttribute), false); 54 | return attribute.Length > 0 ? attribute[0].Description : value.ToString(); 55 | } 56 | 57 | /// 58 | /// Gets the enum value from the description 59 | /// 60 | /// The language string 61 | /// The XivLanguage enum 62 | public static XivLanguage GetXivLanguage(string value) 63 | { 64 | //esrinzou for china ffxiv 65 | if (value == "zh") 66 | return XivLanguage.Chinese; 67 | //esrinzou end 68 | var languages = Enum.GetValues(typeof(XivLanguage)).Cast(); 69 | 70 | return languages.FirstOrDefault(language => language.GetLanguageCode() == value); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /xivModdingFramework/General/GameInfo.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.IO; 19 | using xivModdingFramework.General.Enums; 20 | 21 | namespace xivModdingFramework 22 | { 23 | public class GameInfo 24 | { 25 | public const string GameVersionFileName = "ffxivgame.ver"; 26 | 27 | /// 28 | /// The directory in which the game is installed. 29 | /// 30 | public DirectoryInfo GameDirectory { get; } 31 | 32 | /// 33 | /// The current version of the game. 34 | /// 35 | public Version GameVersion { get; } 36 | 37 | public string GameVersionFile { get 38 | { 39 | return GetGameVersionFile(); 40 | } 41 | } 42 | 43 | 44 | /// 45 | /// The language used when parsing the game data. 46 | /// 47 | public XivLanguage GameLanguage { get; } 48 | 49 | 50 | /// 51 | /// Constructor for GameInfo 52 | /// 53 | /// The directory in which the game is installed. 54 | /// The language to use when parsing the game data. 55 | public GameInfo(DirectoryInfo gameDirectory, XivLanguage xivLanguage) 56 | { 57 | GameDirectory = gameDirectory; 58 | GameLanguage = xivLanguage; 59 | try 60 | { 61 | GameVersion = GetGameVersion(); 62 | } catch 63 | { 64 | // Default. No version file is a non-critical bug. 65 | GameVersion = new Version("0.0.0.0"); 66 | } 67 | 68 | if (!gameDirectory.FullName.Contains(Path.Combine("game", "sqpack", "ffxiv"))) 69 | { 70 | throw new DirectoryNotFoundException("The given directory is incorrect.\n\nThe directory sould point to the \\game\\sqpack\\ffxiv folder"); 71 | } 72 | } 73 | 74 | private string GetGameVersionFile() 75 | { 76 | try 77 | { 78 | var versionBasePath = GameDirectory.FullName.Substring(0, GameDirectory.FullName.IndexOf("sqpack", StringComparison.Ordinal)); 79 | var versionFile = Path.Combine(versionBasePath, GameVersionFileName); 80 | 81 | if (!File.Exists(versionFile)) 82 | { 83 | return null; 84 | } 85 | 86 | return versionFile; 87 | } 88 | catch 89 | { 90 | return null; 91 | } 92 | 93 | } 94 | 95 | public static Version ReadVersionFile(string file) 96 | { 97 | try 98 | { 99 | if (string.IsNullOrWhiteSpace(file) || !File.Exists(file)) 100 | { 101 | return new Version(); 102 | } 103 | var versionData = File.ReadAllLines(file); 104 | return new Version(versionData[0].Substring(0, versionData[0].LastIndexOf(".", StringComparison.Ordinal))); 105 | } catch { 106 | return new Version(); 107 | } 108 | } 109 | 110 | /// 111 | /// Gets the games current version. 112 | /// 113 | /// The game version. 114 | private Version GetGameVersion() 115 | { 116 | try 117 | { 118 | var file = GetGameVersionFile(); 119 | if (string.IsNullOrWhiteSpace(file)) 120 | { 121 | return new Version(); 122 | } 123 | return ReadVersionFile(file); 124 | } 125 | catch 126 | { 127 | return new Version(); 128 | } 129 | } 130 | } 131 | } -------------------------------------------------------------------------------- /xivModdingFramework/General/Quad.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | 4 | namespace xivModdingFramework.General 5 | { 6 | [Serializable] 7 | public struct Quad 8 | { 9 | public short[] Values; 10 | 11 | public Quad(long data) 12 | { 13 | Values = new short[4]; 14 | Values[0] = (short)data; 15 | Values[1] = (short)(data >> 16); 16 | Values[2] = (short)(data >> 32); 17 | Values[3] = (short)(data >> 48); 18 | } 19 | 20 | public static Quad Read(byte[] buffer, int offset) 21 | { 22 | var data = BitConverter.ToInt64(buffer, offset); 23 | return new Quad(data); 24 | } 25 | public static Quad ReadBE(byte[] buffer, int offset) 26 | { 27 | // Assume endianness is reversed. 28 | var data = BitConverter.ToInt64(buffer.Reverse().ToArray(), offset); 29 | return new Quad(data); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /xivModdingFramework/General/XivModelChara.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SixLabors.ImageSharp.Processing; 18 | using System.Collections.Generic; 19 | using System.IO; 20 | using System.Threading.Tasks; 21 | using xivModdingFramework.Cache; 22 | using xivModdingFramework.Exd.Enums; 23 | using xivModdingFramework.Exd.FileTypes; 24 | using xivModdingFramework.Helpers; 25 | using xivModdingFramework.Items.DataContainers; 26 | using xivModdingFramework.Items.Enums; 27 | using xivModdingFramework.Mods; 28 | using static xivModdingFramework.Exd.FileTypes.Ex; 29 | 30 | namespace xivModdingFramework.General 31 | { 32 | /// 33 | /// This class contains the methods to get data from modelchara exd 34 | /// 35 | public static class XivModelChara 36 | { 37 | /// 38 | /// Shortcut accessor for reading the modelchara Ex Data 39 | /// 40 | /// 41 | /// Dictionary with modelchara data 42 | public static async Task> GetModelCharaData(ModTransaction tx = null) 43 | { 44 | var ex = new Ex(); 45 | var exData = await ex.ReadExData(XivEx.modelchara, tx); 46 | return exData; 47 | } 48 | 49 | /// 50 | /// Gets the model info from the modelchara exd file 51 | /// 52 | /// The game directory 53 | /// The index of the data 54 | /// The XivModelInfo data 55 | public static async Task GetModelInfo(int index, ModTransaction tx = null) 56 | { 57 | var ex = new Ex(); 58 | var modelCharaEx = await ex.ReadExData(XivEx.modelchara, tx); 59 | return GetModelInfo(modelCharaEx[index]); 60 | } 61 | 62 | /// 63 | /// Gets the model info from the modelchara exd data 64 | /// 65 | /// The modelchara ex data 66 | /// The index of the data 67 | /// The XivModelInfo data 68 | public static XivModelInfo GetModelInfo(ExdRow row) 69 | { 70 | var xivModelInfo = new XivMonsterModelInfo(); 71 | 72 | var type = (byte)row.GetColumnByName("Type"); 73 | xivModelInfo.PrimaryID = (ushort) row.GetColumnByName("PrimaryId"); 74 | xivModelInfo.SecondaryID = (byte)row.GetColumnByName("SecondaryId"); 75 | xivModelInfo.ImcSubsetID = (byte)row.GetColumnByName("Variant"); 76 | 77 | if (type == 2) 78 | { 79 | xivModelInfo.ModelType = XivItemType.demihuman; 80 | } 81 | else if (type == 3) 82 | { 83 | xivModelInfo.ModelType = XivItemType.monster; 84 | } 85 | else 86 | { 87 | xivModelInfo.ModelType = XivItemType.unknown; 88 | } 89 | 90 | return xivModelInfo; 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /xivModdingFramework/HUD/FileTypes/Uld.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Diagnostics; 20 | using System.IO; 21 | using System.Linq; 22 | using System.Text; 23 | using System.Threading.Tasks; 24 | using xivModdingFramework.General.Enums; 25 | using xivModdingFramework.Helpers; 26 | using xivModdingFramework.Mods; 27 | using xivModdingFramework.SqPack.FileTypes; 28 | 29 | using Index = xivModdingFramework.SqPack.FileTypes.Index; 30 | 31 | namespace xivModdingFramework.HUD.FileTypes 32 | { 33 | /// 34 | /// This class contains the methods that deal with the .uld file type 35 | /// 36 | public static class Uld 37 | { 38 | /// 39 | /// Gets the texture paths from the uld file 40 | /// 41 | /// List of texture paths from the uld file 42 | public static async Task> GetTexFromUld(ModTransaction tx = null) 43 | { 44 | var uldLock = new object(); 45 | var hashedFolder = HashGenerator.GetHash("ui/uld"); 46 | 47 | var uldStringList = new HashSet(); 48 | var uldOffsetList = await Index.GetAllFileOffsetsInFolder(hashedFolder, XivDataFile._06_Ui, tx); 49 | 50 | var tasks = new List(); 51 | foreach(var offset in uldOffsetList) 52 | { 53 | tasks.Add(Task.Run (async () => 54 | { 55 | byte[] uldData; 56 | var type = await tx.GetSqPackType(XivDataFile._06_Ui, offset, false); 57 | if (type == 2) 58 | { 59 | uldData = await tx.ReadFile(XivDataFile._06_Ui, offset); 60 | } 61 | else 62 | { 63 | return; 64 | } 65 | 66 | if (uldData.Length < 10) return; 67 | 68 | using (var br = new BinaryReader(new MemoryStream(uldData))) 69 | { 70 | var signature = br.ReadInt32(); 71 | 72 | if (signature != 1751411829) return; 73 | 74 | br.ReadBytes(56); 75 | 76 | int pathCount = br.ReadByte(); 77 | 78 | br.ReadBytes(7); 79 | 80 | for (var i = 0; i < pathCount; i++) 81 | { 82 | var pathNum = br.ReadInt32(); 83 | while (pathNum != i + 1) 84 | { 85 | pathNum = br.ReadInt32(); 86 | } 87 | 88 | var path = Encoding.UTF8.GetString(br.ReadBytes(48)).Replace("\0", ""); 89 | path = new string(path.Where(c => !char.IsControl(c)).ToArray()); 90 | 91 | if (path.Length <= 2 || !path.Contains("uld")) continue; 92 | 93 | var uldPath = path.Substring(0, path.LastIndexOf(".", StringComparison.Ordinal) + 4); 94 | 95 | lock (uldLock) 96 | { 97 | uldStringList.Add(uldPath); 98 | } 99 | } 100 | } 101 | })); 102 | } 103 | 104 | await Task.WhenAll(tasks); 105 | 106 | return uldStringList.ToList(); 107 | } 108 | } 109 | } -------------------------------------------------------------------------------- /xivModdingFramework/Helpers/BinaryReaderBE.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.IO; 19 | 20 | namespace xivModdingFramework.Helpers 21 | { 22 | /// 23 | /// This helper class is used to read files that are in Big Endian Byte Order 24 | /// 25 | public class BinaryReaderBE : BinaryReader 26 | { 27 | /// 28 | /// This helper class is used to read files that are in Big Endian Byte Order 29 | /// 30 | public BinaryReaderBE(Stream input) : base(input) 31 | { 32 | } 33 | 34 | public override short ReadInt16() 35 | { 36 | var bytes = ReadBytes(2); 37 | Array.Reverse(bytes); 38 | return BitConverter.ToInt16(bytes, 0); 39 | } 40 | 41 | public override ushort ReadUInt16() 42 | { 43 | var bytes = ReadBytes(2); 44 | Array.Reverse(bytes); 45 | return BitConverter.ToUInt16(bytes, 0); 46 | } 47 | 48 | public override int ReadInt32() 49 | { 50 | var bytes = ReadBytes(4); 51 | Array.Reverse(bytes); 52 | return BitConverter.ToInt32(bytes, 0); 53 | } 54 | 55 | public override uint ReadUInt32() 56 | { 57 | var bytes = ReadBytes(4); 58 | Array.Reverse(bytes); 59 | return BitConverter.ToUInt32(bytes, 0); 60 | } 61 | 62 | public override long ReadInt64() 63 | { 64 | var bytes = ReadBytes(8); 65 | Array.Reverse(bytes); 66 | return BitConverter.ToInt64(bytes, 0); 67 | } 68 | 69 | public override ulong ReadUInt64() 70 | { 71 | var bytes = ReadBytes(8); 72 | Array.Reverse(bytes); 73 | return BitConverter.ToUInt64(bytes, 0); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /xivModdingFramework/Helpers/Constants.cs: -------------------------------------------------------------------------------- 1 | using HelixToolkit.SharpDX.Core; 2 | using HelixToolkit.SharpDX.Core.Model.Scene2D; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using System.Text.RegularExpressions; 7 | 8 | namespace xivModdingFramework.Helpers 9 | { 10 | // I'm not sure why we didn't have a constants class to refer to before, but oh well. 11 | public static class Constants 12 | { 13 | /// 14 | /// The alphabet. Now in character array form. 15 | /// 16 | public static readonly char[] Alphabet = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; 17 | public static string BinaryOffsetMarker = "::"; 18 | 19 | public const string InternalModSourceName = "_INTERNAL_"; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /xivModdingFramework/Helpers/PenumbraAPI.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using Newtonsoft.Json.Linq; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Diagnostics; 6 | using System.IO; 7 | using System.Linq; 8 | using System.Net.Http; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace xivModdingFramework.Helpers 13 | { 14 | /// 15 | /// Simple thin static class that handles poking the Penumbra HTTP API 16 | /// Most functions just return a boolean for success status. 17 | /// 18 | public static class PenumbraAPI 19 | { 20 | 21 | /// 22 | /// Calls /redraw on the Penumbra API. 23 | /// 24 | /// 25 | public static async Task Redraw() 26 | { 27 | return await Request("/redraw"); 28 | 29 | } 30 | 31 | /// 32 | /// Calls /reloadmod on the Penumbra API. 33 | /// 34 | /// 35 | public static async Task ReloadMod(string path, string name = null) 36 | { 37 | Dictionary args = new Dictionary(); 38 | 39 | if (name != null) 40 | { 41 | args.Add("Name", name); 42 | } 43 | if (path != null) 44 | { 45 | args.Add("Path", path); 46 | } 47 | 48 | return await Request("/reloadmod", args); 49 | } 50 | 51 | private static HttpClient _Client = new HttpClient() { BaseAddress = new System.Uri("http://localhost:42069") }; 52 | 53 | private static async Task Request(string urlPath, object data = null) 54 | { 55 | data = data == null ? new object() : data; 56 | return await Task.Run(async () => { 57 | try 58 | { 59 | using StringContent jsonContent = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); 60 | using HttpResponseMessage response = await _Client.PostAsync("api/" + urlPath, jsonContent); 61 | 62 | response.EnsureSuccessStatusCode(); 63 | 64 | return true; 65 | } 66 | catch (Exception ex) 67 | { 68 | return false; 69 | //throw; 70 | } 71 | }); 72 | } 73 | 74 | 75 | public static string GetQuickLauncherGameDirectory() 76 | { 77 | var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "launcherConfigV3.json"); 78 | if (!File.Exists(path)) 79 | { 80 | return ""; 81 | } 82 | 83 | try 84 | { 85 | var obj = JObject.Parse(File.ReadAllText(path)); 86 | var st = (string)obj["GamePath"]; 87 | return st; 88 | } 89 | catch (Exception ex) 90 | { 91 | return ""; 92 | } 93 | } 94 | 95 | public static string GetPenumbraDirectory() 96 | { 97 | var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "pluginConfigs", "Penumbra.json"); 98 | if (!File.Exists(path)) 99 | { 100 | return ""; 101 | } 102 | 103 | try 104 | { 105 | var obj = JObject.Parse(File.ReadAllText(path)); 106 | var st = (string)obj["ModDirectory"]; 107 | return st; 108 | } 109 | catch (Exception ex) 110 | { 111 | return ""; 112 | } 113 | } 114 | 115 | public static bool IsPenumbraInstalled() 116 | { 117 | var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "XIVLauncher", "dalamudConfig.json"); 118 | if (!File.Exists(path)) 119 | { 120 | return false; 121 | } 122 | 123 | try 124 | { 125 | var obj = JObject.Parse(File.ReadAllText(path)); 126 | var profile = (JObject)obj["DefaultProfile"]; 127 | var plugins = (JObject)profile["Plugins"]; 128 | var pValues = (JArray)plugins["$values"]; 129 | 130 | var penumbra = pValues.FirstOrDefault(x => (string)x["InternalName"] == "Penumbra"); 131 | 132 | if(penumbra != null) 133 | { 134 | // Normally we'd stop here. But while Penumbra is in testing we need to check that part. 135 | var optIns = (JObject)obj["PluginTestingOptIns"]; 136 | var oValues = (JArray)optIns["$values"]; 137 | var pTesting = oValues.FirstOrDefault(x => (string)x["InternalName"] == "Penumbra"); 138 | if ((string)pTesting["Branch"] == "testing-live") 139 | { 140 | return true; 141 | } 142 | 143 | return false; 144 | } else 145 | { 146 | return false; 147 | } 148 | } 149 | catch (Exception ex) 150 | { 151 | return false; 152 | } 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivCharacter.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Linq; 20 | using System.Threading.Tasks; 21 | using xivModdingFramework.Cache; 22 | using xivModdingFramework.General.Enums; 23 | using xivModdingFramework.Items.Categories; 24 | using xivModdingFramework.Items.Interfaces; 25 | using xivModdingFramework.Models.FileTypes; 26 | using xivModdingFramework.Mods; 27 | using xivModdingFramework.Resources; 28 | 29 | namespace xivModdingFramework.Items.DataContainers 30 | { 31 | /// 32 | /// This class holds information for Items in the Character Category 33 | /// 34 | public class XivCharacter : IItemModel 35 | { 36 | /// 37 | /// The name of the character item 38 | /// 39 | public string Name { get; set; } 40 | 41 | /// 42 | /// The Main Category 43 | /// 44 | /// 45 | /// For character items, the category is "Character" 46 | /// 47 | public string PrimaryCategory { get; set; } 48 | 49 | /// 50 | /// The item Category 51 | /// 52 | /// 53 | /// This would be a category such as Hair, Face, Body, Tail 54 | /// 55 | public string SecondaryCategory { get; set; } 56 | 57 | /// 58 | /// The item SubCategory 59 | /// 60 | /// 61 | /// This is currently not used for the Character Category, but may be used in the future 62 | /// 63 | public string TertiaryCategory { get; set; } 64 | 65 | /// 66 | /// The data file the item belongs to 67 | /// 68 | /// 69 | /// Character items are always in 040000 70 | /// 71 | public XivDataFile DataFile { get; set; } = XivDataFile._04_Chara; 72 | 73 | public uint IconId { get; set; } 74 | 75 | /// 76 | /// The Primary Model Information of the Character Item 77 | /// 78 | public XivModelInfo ModelInfo { get; set; } 79 | internal static IItemModel FromDependencyRoot(XivDependencyRoot root) 80 | { 81 | var item = new XivCharacter(); 82 | item.ModelInfo = new XivModelInfo(); 83 | item.ModelInfo.PrimaryID = root.Info.PrimaryId; 84 | item.ModelInfo.SecondaryID = (int)root.Info.SecondaryId; 85 | item.PrimaryCategory = XivStrings.Character; 86 | 87 | if (root.Info.Slot != null) 88 | { 89 | item.SecondaryCategory = Mdl.SlotAbbreviationDictionary.FirstOrDefault(x => x.Value == root.Info.Slot).Key; 90 | 91 | //var race = XivRaces.GetXivRace(root.Info.PrimaryId.ToString().PadLeft(4, '0')).GetDisplayName(); 92 | item.Name = item.SecondaryCategory + " - " + root.Info.GetBaseFileName(); 93 | } else 94 | { 95 | item.Name = root.Info.GetBaseFileName(); 96 | item.SecondaryCategory = XivStrings.Body; 97 | } 98 | 99 | 100 | return item; 101 | } 102 | 103 | public async Task> GetDecalTextures(ModTransaction tx = null) 104 | { 105 | if(tx == null) 106 | { 107 | // Readonly TX if we don't have one. 108 | tx = ModTransaction.BeginReadonlyTransaction(); 109 | } 110 | 111 | if(SecondaryCategory == XivStrings.Face_Paint) 112 | { 113 | return await Character.GetDecalPaths(Character.XivDecalType.FacePaint, tx); 114 | } 115 | else if(SecondaryCategory == XivStrings.Equipment_Decals) 116 | { 117 | return await Character.GetDecalPaths(Character.XivDecalType.Equipment, tx); 118 | } 119 | else 120 | { 121 | return new List(); 122 | } 123 | } 124 | 125 | /// 126 | /// Gets the item's name as it should be written to the modlist/modpack files. 127 | /// 128 | /// 129 | public string GetModlistItemName() 130 | { 131 | return SecondaryCategory != null ? SecondaryCategory : "Unknown"; 132 | } 133 | 134 | /// 135 | /// Gets the item's category as it should be written to the modlist/modpack files. 136 | /// 137 | /// 138 | public string GetModlistItemCategory() 139 | { 140 | return XivStrings.Character; 141 | } 142 | 143 | public int CompareTo(object obj) 144 | { 145 | return string.Compare(Name, ((XivCharacter)obj).Name, StringComparison.Ordinal); 146 | } 147 | public object Clone() 148 | { 149 | var copy = (XivCharacter)this.MemberwiseClone(); 150 | copy.ModelInfo = (XivModelInfo) ModelInfo?.Clone(); 151 | return copy; 152 | } 153 | } 154 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivGenericItemModel.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using xivModdingFramework.Cache; 19 | using xivModdingFramework.General.Enums; 20 | using xivModdingFramework.Items.Interfaces; 21 | using xivModdingFramework.Resources; 22 | 23 | namespace xivModdingFramework.Items.DataContainers 24 | { 25 | /// 26 | /// This class holds information for Generic Items with models 27 | /// 28 | public class XivGenericItemModel : IItemModel 29 | { 30 | /// 31 | /// The name of the item 32 | /// 33 | public string Name { get; set; } 34 | 35 | /// 36 | /// The Main Category 37 | /// 38 | public string PrimaryCategory { get; set; } 39 | 40 | /// 41 | /// The item Category 42 | /// 43 | public string SecondaryCategory { get; set; } 44 | 45 | /// 46 | /// The item SubCategory 47 | /// 48 | public string TertiaryCategory { get; set; } 49 | 50 | /// 51 | /// The data file the item belongs to 52 | /// 53 | public XivDataFile DataFile { get; set; } 54 | 55 | /// 56 | /// The Model Information for the gear item 57 | /// 58 | public XivModelInfo ModelInfo { get; set; } 59 | public uint IconId { get; set; } 60 | 61 | /// 62 | /// Gets the item's name as it should be written to the modlist/modpack files. 63 | /// 64 | /// 65 | public string GetModlistItemName() 66 | { 67 | return Name != null ? Name : "Unknown Item"; 68 | } 69 | 70 | /// 71 | /// Gets the item's category as it should be written to the modlist/modpack files. 72 | /// 73 | /// 74 | public string GetModlistItemCategory() 75 | { 76 | return SecondaryCategory != null ? SecondaryCategory : "Unknown"; 77 | } 78 | internal static IItemModel FromDependencyRoot(XivDependencyRoot root, int imcSubset) 79 | { 80 | var item = new XivGenericItemModel(); 81 | item.ModelInfo = new XivModelInfo(); 82 | item.ModelInfo.ImcSubsetID = imcSubset; 83 | item.ModelInfo.PrimaryID = root.Info.PrimaryId; 84 | item.ModelInfo.SecondaryID = (int)root.Info.SecondaryId; 85 | item.Name = root.Info.GetBaseFileName() + "_v" + imcSubset.ToString(); 86 | item.PrimaryCategory = XivStrings.Gear; 87 | 88 | return item; 89 | } 90 | 91 | public int CompareTo(object obj) 92 | { 93 | return string.Compare(Name, ((XivGenericItemModel)obj).Name, StringComparison.Ordinal); 94 | } 95 | 96 | public object Clone() 97 | { 98 | var copy = (XivGenericItemModel)this.MemberwiseClone(); 99 | copy.ModelInfo = (XivModelInfo)ModelInfo.Clone(); 100 | return copy; 101 | } 102 | } 103 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivMinion.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using xivModdingFramework.General.Enums; 19 | using xivModdingFramework.Items.Interfaces; 20 | using xivModdingFramework.Resources; 21 | 22 | namespace xivModdingFramework.Items.DataContainers 23 | { 24 | /// 25 | /// This class contains information for items in the Minion Category 26 | /// 27 | public class XivMinion : IItemModel 28 | { 29 | /// 30 | /// The name of the minion 31 | /// 32 | public string Name { get; set; } 33 | 34 | /// 35 | /// The Main Category 36 | /// 37 | /// 38 | /// For Minions the main category is "Companions" 39 | /// 40 | public string PrimaryCategory { get; set; } 41 | 42 | /// 43 | /// The item Category 44 | /// 45 | /// 46 | /// For minions the item category is "Minions" 47 | /// 48 | public string SecondaryCategory { get; set; } 49 | 50 | /// 51 | /// The item SubCategory 52 | /// 53 | /// 54 | /// This is currently not used for the Minion Category, but may be used in the future 55 | /// 56 | public string TertiaryCategory { get; set; } 57 | 58 | /// 59 | /// The data file the item belongs to 60 | /// 61 | /// 62 | /// Minion items are always in 040000 63 | /// 64 | public XivDataFile DataFile { get; set; } = XivDataFile._04_Chara; 65 | 66 | public uint IconId { get; set; } 67 | 68 | /// 69 | /// The Primary Model Information of the Minion Item 70 | /// 71 | public XivModelInfo ModelInfo { get; set; } 72 | 73 | /// 74 | /// Gets the item's name as it should be written to the modlist/modpack files. 75 | /// 76 | /// 77 | public string GetModlistItemName() 78 | { 79 | return Name != null ? Name : "Unknown Minion"; 80 | } 81 | 82 | /// 83 | /// Gets the item's category as it should be written to the modlist/modpack files. 84 | /// 85 | /// 86 | public string GetModlistItemCategory() 87 | { 88 | return SecondaryCategory != null ? SecondaryCategory : XivStrings.Minions; 89 | } 90 | public int CompareTo(object obj) 91 | { 92 | return string.Compare(Name, ((XivMinion)obj).Name, StringComparison.Ordinal); 93 | } 94 | 95 | public object Clone() 96 | { 97 | var copy = (XivMinion)this.MemberwiseClone(); 98 | copy.ModelInfo = (XivModelInfo)ModelInfo.Clone(); 99 | return copy; 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivModelInfo.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using xivModdingFramework.General; 19 | using xivModdingFramework.Items.Enums; 20 | 21 | namespace xivModdingFramework.Items.DataContainers 22 | { 23 | /// 24 | /// This class contains Model Information for an Item 25 | /// Note - This is a partial class effectively, and 26 | /// cannot actually be resolved into a full model without 27 | /// it's parent IIitem, as it lacks a slot identifier (top, dwn, glv, ...) 28 | /// 29 | public class XivModelInfo : ICloneable 30 | { 31 | 32 | /// 33 | /// The Item's primary ID. This is one of: 34 | /// - (e)quipment number 35 | /// - (a)ccessory number 36 | /// - (w)eapon number 37 | /// - (d)emihuman number 38 | /// - (m)onster number 39 | /// - bg/furniture number 40 | /// - ui/icon number 41 | /// 42 | public int PrimaryID { get; set; } 43 | 44 | /// 45 | /// The Item's secondary ID. This is one of 46 | /// - (b)ody number (Monster/Companion/Weapon) 47 | /// - (e)quipment number (Demihuman) 48 | /// - (z)ear number (Human) 49 | /// - (f)ace number (Human) 50 | /// - (t)ail number (Human) 51 | /// - (h)air number (Human) 52 | /// - None 53 | /// 54 | public int SecondaryID { get; set; } 55 | 56 | /// 57 | /// The item's Model SubSet ID - This can be resolved to 58 | /// Material Set ID/Variant via use of IMC->GetImcInfo() 59 | /// Only available for equipment items. 60 | /// 61 | public int ImcSubsetID { get; set; } 62 | 63 | public object Clone() 64 | { 65 | return MemberwiseClone(); 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivMonsterModelInfo.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using xivModdingFramework.General; 19 | using xivModdingFramework.Items.Enums; 20 | 21 | namespace xivModdingFramework.Items.DataContainers 22 | { 23 | /// 24 | /// This class contains Model Information for an Item 25 | /// Note - This is a partial class effectively, and 26 | /// cannot actually be resolved into a full model without 27 | /// it's parent IIitem, as it lacks a slot identifier (top, dwn, glv, ...) 28 | /// 29 | public class XivMonsterModelInfo: XivModelInfo 30 | { 31 | 32 | /// 33 | /// Model type as pulled from the ModelChara EXD. 34 | /// 35 | public XivItemType ModelType; 36 | } 37 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivMount.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Linq; 19 | using xivModdingFramework.Cache; 20 | using xivModdingFramework.General.Enums; 21 | using xivModdingFramework.Items.Interfaces; 22 | using xivModdingFramework.Models.FileTypes; 23 | using xivModdingFramework.Resources; 24 | 25 | namespace xivModdingFramework.Items.DataContainers 26 | { 27 | /// 28 | /// This class holds information for items in the Mount Category 29 | /// 30 | public class XivMount : IItemModel 31 | { 32 | /// 33 | /// The mount name 34 | /// 35 | public string Name { get; set; } 36 | 37 | /// 38 | /// The Main Category 39 | /// 40 | /// 41 | /// For Mounts the Main Category is "Companions" 42 | /// 43 | public string PrimaryCategory { get; set; } 44 | 45 | /// 46 | /// The item Category 47 | /// 48 | /// 49 | /// For Mounts the item Category is "Mounts" 50 | /// 51 | public string SecondaryCategory { get; set; } 52 | 53 | /// 54 | /// The item SubCategory 55 | /// 56 | /// 57 | /// This is currently not used for the Mount Category, but may be used in the future 58 | /// 59 | public string TertiaryCategory { get; set; } 60 | 61 | public uint IconId { get; set; } 62 | 63 | /// 64 | /// The data file the item belongs to 65 | /// 66 | /// 67 | /// Mount items are always in 040000 68 | /// 69 | public XivDataFile DataFile { get; set; } = XivDataFile._04_Chara; 70 | 71 | /// 72 | /// The Primary Model Information of the Mount Item 73 | /// 74 | public XivModelInfo ModelInfo { get; set; } 75 | 76 | /// 77 | /// Gets the item's name as it should be written to the modlist/modpack files. 78 | /// 79 | /// 80 | public string GetModlistItemName() 81 | { 82 | return Name != null ? Name : "Unknown Mount"; 83 | } 84 | 85 | /// 86 | /// Gets the item's category as it should be written to the modlist/modpack files. 87 | /// 88 | /// 89 | public string GetModlistItemCategory() 90 | { 91 | return SecondaryCategory != null ? SecondaryCategory : XivStrings.Mounts; 92 | } 93 | internal static IItemModel FromDependencyRoot(XivDependencyRoot root, int imcSubset) 94 | { 95 | var item = new XivMount(); 96 | var mi = new XivMonsterModelInfo(); 97 | mi.ModelType = root.Info.PrimaryType; 98 | mi.PrimaryID = root.Info.PrimaryId; 99 | mi.SecondaryID = (int)root.Info.SecondaryId; 100 | mi.ImcSubsetID = imcSubset; 101 | 102 | item.ModelInfo = mi; 103 | item.Name = root.Info.GetBaseFileName() + "_v" + imcSubset.ToString(); 104 | item.PrimaryCategory = XivStrings.Companions; 105 | item.SecondaryCategory = XivStrings.Mounts; 106 | 107 | if(root.Info.Slot != null) 108 | { 109 | item.TertiaryCategory = Mdl.SlotAbbreviationDictionary.First(x => x.Value == root.Info.Slot).Key; 110 | } 111 | 112 | return item; 113 | } 114 | 115 | public int CompareTo(object obj) 116 | { 117 | return string.Compare(Name, ((XivMount)obj).Name, StringComparison.Ordinal); 118 | } 119 | 120 | public object Clone() 121 | { 122 | var copy = (XivMount)this.MemberwiseClone(); 123 | copy.ModelInfo = (XivModelInfo)ModelInfo.Clone(); 124 | return copy; 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/DataContainers/XivPet.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using xivModdingFramework.General.Enums; 19 | using xivModdingFramework.Items.Interfaces; 20 | using xivModdingFramework.Resources; 21 | 22 | namespace xivModdingFramework.Items.DataContainers 23 | { 24 | /// 25 | /// This class contains information for Items in the Pet Category 26 | /// 27 | public class XivPet : IItemModel 28 | { 29 | /// 30 | /// The name of the Pet 31 | /// 32 | public string Name { get; set; } 33 | 34 | /// 35 | /// The Main Category 36 | /// 37 | /// 38 | /// For Pets the Main Category is "Companions" 39 | /// 40 | public string PrimaryCategory { get; set; } 41 | 42 | /// 43 | /// The item category 44 | /// 45 | /// 46 | /// For Pets the item Category is "Pets" 47 | /// 48 | public string SecondaryCategory { get; set; } 49 | 50 | /// 51 | /// The item SubCategory 52 | /// 53 | /// 54 | /// This is currently not used for the Pet Category, but may be used in the future 55 | /// 56 | public string TertiaryCategory { get; set; } 57 | public uint IconId { get; set; } 58 | 59 | /// 60 | /// The data file the item belongs to 61 | /// 62 | /// 63 | /// Mount items are always in 040000 64 | /// 65 | public XivDataFile DataFile { get; set; } = XivDataFile._04_Chara; 66 | 67 | /// 68 | /// The Primary Model Information of the Pet Item 69 | /// 70 | public XivModelInfo ModelInfo { get; set; } 71 | 72 | /// 73 | /// Gets the item's name as it should be written to the modlist/modpack files. 74 | /// 75 | /// 76 | public string GetModlistItemName() 77 | { 78 | return Name != null ? Name : "Unknown Pet"; 79 | } 80 | 81 | /// 82 | /// Gets the item's category as it should be written to the modlist/modpack files. 83 | /// 84 | /// 85 | public string GetModlistItemCategory() 86 | { 87 | return SecondaryCategory != null ? SecondaryCategory : XivStrings.Pets; 88 | } 89 | public int CompareTo(object obj) 90 | { 91 | return string.Compare(Name, ((XivPet)obj).Name, StringComparison.Ordinal); 92 | } 93 | 94 | public object Clone() 95 | { 96 | var copy = (XivPet)this.MemberwiseClone(); 97 | copy.ModelInfo = (XivModelInfo)ModelInfo.Clone(); 98 | return copy; 99 | } 100 | } 101 | } -------------------------------------------------------------------------------- /xivModdingFramework/Items/Interfaces/IItem.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using HelixToolkit.SharpDX.Core.Utilities.ImagePacker; 18 | using System; 19 | using System.Collections.Generic; 20 | using xivModdingFramework.General.Enums; 21 | 22 | namespace xivModdingFramework.Items.Interfaces 23 | { 24 | /// 25 | /// Interface for Item details 26 | /// 27 | public interface IItem : IComparable 28 | { 29 | /// 30 | /// The item Name 31 | /// 32 | string Name { get; set; } 33 | 34 | /// 35 | /// The top level category 36 | /// -- This has no relevance in actual game file structure. This is purely a 37 | /// -- custom generated Human Readable convention for the sake of TexTools sorting. 38 | /// 39 | /// 40 | /// This would be a category such as Gear, Character, Companion, and UI 41 | /// 42 | string PrimaryCategory { get; set; } 43 | 44 | /// 45 | /// The second level category. 46 | /// 47 | /// 48 | /// This would be a category such as Body, Legs, Ears, Hair, Minions, Maps 49 | /// 50 | string SecondaryCategory { get; set; } 51 | 52 | /// 53 | /// The third level category. 54 | /// 55 | /// 56 | /// This would be a category such as La Noscea within Maps, Marker within Actions, Detrimental within Status 57 | /// This is mostly used in the UI main category 58 | /// 59 | string TertiaryCategory { get; } 60 | 61 | /// 62 | /// The data file the item belongs to 63 | /// 64 | /// 65 | /// This would change depending on the data file the data is to be pulled from 66 | /// 67 | XivDataFile DataFile { get; } 68 | 69 | /// 70 | /// Gets the item's name as it should be written to the modlist/modpack files. 71 | /// 72 | /// 73 | public string GetModlistItemName(); 74 | 75 | /// 76 | /// Gets the item's category as it should be written to the modlist/modpack files. 77 | /// 78 | /// 79 | public string GetModlistItemCategory(); 80 | } 81 | 82 | /// 83 | /// Simple shell IItem that can be used as a filler when writing mods. 84 | /// 85 | public class SimpleIItem : IItem 86 | { 87 | public string Name { get; set; } = ""; 88 | 89 | public string PrimaryCategory { get; set; } = ""; 90 | 91 | public string SecondaryCategory { get; set; } = ""; 92 | 93 | public string TertiaryCategory { get; set; } = ""; 94 | 95 | public XivDataFile DataFile => XivDataFile._04_Chara; 96 | public SimpleIItem(string name, string category) 97 | { 98 | Name = name; 99 | SecondaryCategory = category; 100 | } 101 | 102 | public int CompareTo(object obj) 103 | { 104 | return 0; 105 | } 106 | 107 | public string GetModlistItemName() 108 | { 109 | return Name; 110 | } 111 | 112 | public string GetModlistItemCategory() 113 | { 114 | return SecondaryCategory; 115 | } 116 | } 117 | 118 | 119 | /// 120 | /// Custom item name comparator. 121 | /// [Human Readable Names] => [NPC Names] => [Nulls/Invalids] 122 | /// 123 | public class ItemNameComparer : IComparer 124 | { 125 | public ItemNameComparer() 126 | { 127 | } 128 | 129 | public int Compare(string x, string y) 130 | { 131 | // Nulls 132 | var xNull = String.IsNullOrEmpty(x); 133 | var yNull = String.IsNullOrEmpty(y); 134 | if ( xNull && yNull ) 135 | { 136 | return 0; 137 | } else if(xNull) 138 | { 139 | return 1; 140 | } else if(yNull) 141 | { 142 | return -1; 143 | } 144 | 145 | // Both NPC Items. 146 | var xNpc = x.Contains("_v"); 147 | var yNpc = y.Contains("_v"); 148 | if (xNpc && yNpc) 149 | { 150 | return String.Compare(x, y, StringComparison.InvariantCultureIgnoreCase); 151 | } else if(xNpc) 152 | { 153 | return 1; 154 | } else if (yNpc) 155 | { 156 | return -1; 157 | } 158 | 159 | 160 | return String.Compare(x, y, StringComparison.InvariantCultureIgnoreCase); 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /xivModdingFramework/Items/Interfaces/IItemModel.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.IO; 19 | using System.Threading.Tasks; 20 | using xivModdingFramework.Cache; 21 | using xivModdingFramework.General.Enums; 22 | using xivModdingFramework.Helpers; 23 | using xivModdingFramework.Items.DataContainers; 24 | using xivModdingFramework.Resources; 25 | 26 | namespace xivModdingFramework.Items.Interfaces 27 | { 28 | /// 29 | /// Interface for Items that have model data 30 | /// 31 | public interface IItemModel : IItem, ICloneable 32 | { 33 | /// 34 | /// The Primary Model Information of the Item 35 | /// 36 | public XivModelInfo ModelInfo { get; set; } 37 | 38 | public uint IconId { get; set; } 39 | } 40 | 41 | public class SimpleItemModel : IItemModel, ICloneable 42 | { 43 | public SimpleItemModel(string path) : base() { 44 | ModelPath = path; 45 | ModelInfo = new XivModelInfo(); 46 | } 47 | 48 | public XivModelInfo ModelInfo { get; set; } 49 | public uint IconId { get; set; } 50 | public string Name 51 | { 52 | get 53 | { 54 | if (string.IsNullOrWhiteSpace(ModelPath)) 55 | { 56 | return "Unknown"; 57 | 58 | } 59 | return Path.GetFileName(ModelPath); 60 | } 61 | set 62 | { 63 | // No-Op. 64 | } 65 | } 66 | public string PrimaryCategory { get; set; } = "Unknown"; 67 | public string SecondaryCategory 68 | { 69 | get 70 | { 71 | if (string.IsNullOrWhiteSpace(ModelPath)) 72 | { 73 | return "Unknown"; 74 | 75 | } 76 | return Path.GetFileName(ModelPath); 77 | } 78 | set 79 | { 80 | // No-Op. 81 | } 82 | } 83 | public string TertiaryCategory { get; set; } 84 | public XivDataFile DataFile { 85 | get { 86 | return IOUtil.GetDataFileFromPath(ModelPath); 87 | } 88 | } 89 | 90 | 91 | public string ModelPath { get; set; } 92 | 93 | public object Clone() 94 | { 95 | var im = (SimpleItemModel)MemberwiseClone(); 96 | im.ModelInfo = (XivModelInfo) ModelInfo.Clone(); 97 | return im; 98 | } 99 | 100 | public int CompareTo(object obj) 101 | { 102 | var sm = obj as SimpleItemModel; 103 | if (sm == null) return -1; 104 | return ModelPath.CompareTo(sm.ModelPath); 105 | } 106 | 107 | public string GetModlistItemCategory() 108 | { 109 | return PrimaryCategory; 110 | } 111 | 112 | public string GetModlistItemName() 113 | { 114 | return SecondaryCategory; 115 | } 116 | } 117 | 118 | public static class IItemModelExtensions 119 | { 120 | public static bool HasRealModel(this IItemModel item) 121 | { 122 | // Catch for paintings being dumb. 123 | if(item.ModelInfo != null && item.SecondaryCategory != XivStrings.Paintings) 124 | { 125 | return true; 126 | } 127 | return false; 128 | } 129 | } 130 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/AttributeDataBlock.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | public class AttributeDataBlock 22 | { 23 | /// 24 | /// This data block contains the offsets to each attribute path within the data block 25 | /// 26 | /// 27 | /// The data block consists of offsets with an int data type (4 bytes each) 28 | /// 29 | public List AttributePathOffsetList { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/BoneDataBlock.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | public class BoneDataBlock 22 | { 23 | /// 24 | /// This data block contains the offsets to each bone path within the data block 25 | /// 26 | /// 27 | /// The data block consists of offsets with an int data type (4 bytes each) 28 | /// 29 | public List BonePathOffsetList { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/BoneIndexMesh.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | /// 22 | /// This class contains the properties of the Bone Index Data 23 | /// 24 | /// 25 | /// This references the specific bones that are used by the mesh by their index in the bone string list 26 | /// 27 | public class BoneSet 28 | { 29 | /// 30 | /// The list of Bone Indices 31 | /// 32 | /// 33 | /// This list contains the indices to the bones in MdlPathData.BoneList 34 | /// 35 | public List BoneIndices { get; set; } 36 | 37 | /// 38 | /// The number of indices in the Bone Index Data 39 | /// 40 | public int BoneIndexCount { get; set; } 41 | } 42 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/BoneTransformData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SharpDX; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | /// 22 | /// Data for some sort of transform on bones 23 | /// 24 | /// 25 | /// The number of transforms is [ Bone Count ] 26 | /// 27 | public class BoneTransformData 28 | { 29 | /// 30 | /// The first Transform value 31 | /// 32 | public Vector4 Transform0 { get; set; } 33 | 34 | /// 35 | /// The second transform value 36 | /// 37 | public Vector4 Transform1 { get; set; } 38 | 39 | } 40 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/BoundingBox.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SharpDX; 18 | using System.Collections.Generic; 19 | 20 | namespace xivModdingFramework.Models.DataContainers 21 | { 22 | /// 23 | /// This class contains the properties for the Bounding Box of the model 24 | /// 25 | public class BoundingBox 26 | { 27 | /// 28 | /// The list of point floats used by the bounding box 29 | /// 30 | public List PointList { get; set; } 31 | } 32 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/ColladaData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | public class ColladaData 22 | { 23 | /// 24 | /// The bone strings as they appear in the collada file 25 | /// 26 | public string[] Bones { get; set; } 27 | 28 | /// 29 | /// The list of bones and their associated number 30 | /// 31 | public Dictionary BoneNumDictionary { get; set; } = new Dictionary(); 32 | 33 | /// 34 | /// The bone names for the mesh 35 | /// 36 | public List MeshBoneNames { get; set; } = new List(); 37 | 38 | /// 39 | /// The Vertex Positions 40 | /// 41 | public List Positions { get; set; } = new List(); 42 | 43 | /// 44 | /// The Vertex Normals 45 | /// 46 | public List Normals { get; set; } = new List(); 47 | 48 | /// 49 | /// The Vertex Colors 50 | /// 51 | public List VertexColors { get; set; } = new List(); 52 | 53 | /// 54 | /// The Vertex Primary Texture Coordinates 55 | /// 56 | public List TextureCoordinates0 { get; set; } = new List(); 57 | 58 | /// 59 | /// The Vertex Secondary Texture Coordinates 60 | /// 61 | public List TextureCoordinates1 { get; set; } = new List(); 62 | 63 | /// 64 | /// The Vertex Alphas 65 | /// 66 | public List VertexAlphas { get; set; } = new List(); 67 | 68 | /// 69 | /// The Vertex Bone Weights 70 | /// 71 | public List BoneWeights { get; set; } = new List(); 72 | 73 | /// 74 | /// The Vertex BiNormals 75 | /// 76 | public List BiNormals { get; set; } = new List(); 77 | 78 | /// 79 | /// The Vertex Tangents 80 | /// 81 | public List Tangents { get; set; } = new List(); 82 | 83 | /// 84 | /// The Indices 85 | /// 86 | public List Indices { get; set; } = new List(); 87 | 88 | /// 89 | /// Dictionary containing the location of vertex type indices 90 | /// 91 | public Dictionary IndexLocDictionary { get; set; } 92 | 93 | /// 94 | /// The Vertex Bone Indices 95 | /// 96 | public List BoneIndices { get; set; } = new List(); 97 | 98 | /// 99 | /// The V count 100 | /// 101 | /// 102 | /// This list contains the number of bone weights per vertex 103 | /// 104 | public List Vcounts { get; set; } = new List(); 105 | 106 | /// 107 | /// THe Position Indices 108 | /// 109 | public List PositionIndices { get; set; } = new List(); 110 | 111 | /// 112 | /// The Normal Indices 113 | /// 114 | public List NormalIndices { get; set; } = new List(); 115 | 116 | /// 117 | /// The BiNormal Indices 118 | /// 119 | public List BiNormalIndices { get; set; } = new List(); 120 | 121 | /// 122 | /// The Primary Texture Coordinate Indices 123 | /// 124 | public List TextureCoordinate0Indices { get; set; } = new List(); 125 | 126 | /// 127 | /// The Secondary Texture Coordinate Indices 128 | /// 129 | public List TextureCoordinate1Indices { get; set; } = new List(); 130 | 131 | /// 132 | /// The Secondary Texture Coordinate Indices 133 | /// 134 | public List VertexColorIndices { get; set; } = new List(); 135 | 136 | /// 137 | /// The Secondary Texture Coordinate Indices 138 | /// 139 | public List VertexAlphaIndices { get; set; } = new List(); 140 | 141 | /// 142 | /// The Parts Dictionary 143 | /// 144 | public Dictionary PartsDictionary = new Dictionary(); 145 | 146 | /// 147 | /// The stride for Index values 148 | /// 149 | public int IndexStride { get; set; } 150 | 151 | /// 152 | /// The stride for Texture Coordinate values 153 | /// 154 | public int TextureCoordinateStride { get; set; } 155 | 156 | /// 157 | /// The stride for Vertex Color values 158 | /// 159 | public int VertexColorStride { get; set; } 160 | 161 | /// 162 | /// A flag to determine if the import is from Blender 163 | /// 164 | public bool IsBlender { get; set; } 165 | } 166 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/EModelingTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace xivModdingFramework.Models.DataContainers 6 | { 7 | public enum EModelingTool 8 | { 9 | Blender, 10 | Max, 11 | Maya, 12 | Unreal, 13 | Unity, 14 | }; 15 | 16 | public static class ModelingToolExtensions 17 | { 18 | public static bool UsesDirectXNormals(this EModelingTool modelingTool) 19 | { 20 | if(modelingTool == EModelingTool.Max || modelingTool == EModelingTool.Unreal) 21 | { 22 | return true; 23 | } 24 | return false; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/ExtraSkeletonEntry.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using xivModdingFramework.General.Enums; 5 | using xivModdingFramework.Helpers; 6 | 7 | namespace xivModdingFramework.Models.DataContainers 8 | { 9 | /// 10 | /// Class Representing a Extra Skeletons Table Entry for a Equipment Set. 11 | /// 12 | public class ExtraSkeletonEntry 13 | { 14 | 15 | public ExtraSkeletonEntry(XivRace race, ushort setId) 16 | { 17 | Race = race; 18 | SetId = setId; 19 | SkelId = 0; 20 | } 21 | public ExtraSkeletonEntry(XivRace race, ushort setId, ushort skelId) 22 | { 23 | SetId = setId; 24 | Race = race; 25 | SkelId = skelId; 26 | } 27 | 28 | public static void Write(byte[] data, ExtraSkeletonEntry entry, int count, int index) 29 | { 30 | int offset = (int)(4 + (index * 4)); 31 | short raceId = Int16.Parse(XivRaces.GetRaceCode(entry.Race)); 32 | IOUtil.ReplaceBytesAt(data, BitConverter.GetBytes(entry.SetId), offset); 33 | IOUtil.ReplaceBytesAt(data, BitConverter.GetBytes(raceId), offset + 2); 34 | 35 | var baseOffset = 4 + (count * 4); 36 | offset = (int)(baseOffset + (index * 2)); 37 | IOUtil.ReplaceBytesAt(data, BitConverter.GetBytes(entry.SkelId), offset); 38 | } 39 | public static ExtraSkeletonEntry Read(byte[] data, uint count, uint index) 40 | { 41 | 42 | int offset = (int)(4 + (index * 4)); 43 | 44 | var setId = BitConverter.ToUInt16(data, offset); 45 | var raceId = BitConverter.ToUInt16(data, offset + 2); 46 | var race = XivRaces.GetXivRace(raceId.ToString().PadLeft(4, '0')); 47 | 48 | 49 | var baseOffset = 4 + (count * 4); 50 | offset = (int)(baseOffset + (index * 2)); 51 | 52 | var skelId = BitConverter.ToUInt16(data, offset); 53 | 54 | var ret = new ExtraSkeletonEntry(race, setId, skelId); 55 | return ret; 56 | } 57 | 58 | public ushort SetId; 59 | public XivRace Race; 60 | public ushort SkelId; 61 | 62 | 63 | 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/LevelOfDetail.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using System.Linq; 20 | using xivModdingFramework.Materials.DataContainers; 21 | 22 | namespace xivModdingFramework.Models.DataContainers 23 | { 24 | /// 25 | /// This class contains properties for the Level of Detail data 26 | /// 27 | public class LevelOfDetail 28 | { 29 | public int TotalMeshCount 30 | { 31 | get 32 | { 33 | return MeshTypes.Sum(x => x.Key == EMeshType.TerrainShadow ? 0 : x.Value.Count); 34 | } 35 | } 36 | 37 | public bool HasExtraMeshes 38 | { 39 | get { 40 | var extraStart = (int)EMeshType.LightShaft; 41 | var extraMeshCount = 10; 42 | 43 | for(int i = extraStart; i < extraStart + extraMeshCount; i++) 44 | { 45 | var e = (EMeshType)i; 46 | if (MeshTypes.ContainsKey(e)) 47 | { 48 | if (MeshTypes[e].Count > 0) 49 | { 50 | return true; 51 | } 52 | } 53 | } 54 | return false; 55 | } 56 | } 57 | 58 | public EMeshType GetMeshType(int offset) 59 | { 60 | foreach (var kv in MeshTypes) 61 | { 62 | if (offset >= kv.Value.Offset && offset < kv.Value.Offset + kv.Value.Count) 63 | { 64 | return kv.Key; 65 | } 66 | } 67 | throw new Exception("Unknown Mesh Type."); 68 | 69 | } 70 | 71 | public Dictionary MeshTypes = new Dictionary(); 72 | 73 | /// 74 | /// Unknown Usage 75 | /// 76 | public float ModelLoDRange { get; set; } 77 | 78 | /// 79 | /// Unknown Usage 80 | /// 81 | public float TextureLoDRange { get; set; } 82 | 83 | /// 84 | /// Unknown Usage 85 | /// 86 | public int EdgeGeometrySize { get; set; } 87 | 88 | /// 89 | /// The offset at which the index data begins 90 | /// 91 | public int EdgeGeometryOffset { get; set; } 92 | 93 | /// 94 | /// Unknown Usage 95 | /// 96 | public int Unknown6 { get; set; } 97 | 98 | /// 99 | /// Unknown Usage 100 | /// This appears to be multiple individual byte values, with the first 2 being related to neck morph data 101 | /// 102 | public int Unknown7 { get; set; } 103 | 104 | /// 105 | /// The size of the Vertex Data Block 106 | /// 107 | public int VertexDataSize { get; set; } 108 | 109 | /// 110 | /// The size of the Index Data Block 111 | /// 112 | public int IndexDataSize { get; set; } 113 | 114 | /// 115 | /// The offset to the Vertex Data Block 116 | /// 117 | public int VertexDataOffset { get; set; } 118 | 119 | /// 120 | /// The offset to the Index Data Block 121 | /// 122 | public int IndexDataOffset { get; set; } 123 | 124 | /// 125 | /// The list of MeshData for the LoD 126 | /// 127 | public List MeshDataList { get; set; } 128 | } 129 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/MaterialDataBlock.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | public class MaterialDataBlock 22 | { 23 | /// 24 | /// This data block contains the offsets to each material path within the data block 25 | /// 26 | /// 27 | /// The data block consists of offsets with an int data type (4 bytes each) 28 | /// 29 | public List MaterialPathOffsetList { get; set; } 30 | } 31 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/MdlPathData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | /// 22 | /// This class contains the properties for the MDL files path data 23 | /// 24 | public class MdlPathData 25 | { 26 | /// 27 | /// The number of paths contained in the Path Data Block 28 | /// 29 | public int PathCount { get; set; } 30 | 31 | /// 32 | /// The size of the Path Data Block 33 | /// 34 | public int PathBlockSize { get; set; } 35 | 36 | /// 37 | /// The list of attribute strings 38 | /// 39 | /// 40 | /// These will usually begin with 'atr_' 41 | /// 42 | public List AttributeList { get; set; } 43 | 44 | /// 45 | /// The list of bone strings 46 | /// 47 | /// 48 | /// These will usually begin with 'j_' 49 | /// 50 | public List BoneList { get; set; } 51 | 52 | /// 53 | /// The list of material strings 54 | /// 55 | /// 56 | /// These are references to the MTRL files used by the model 57 | /// 58 | public List MaterialList { get; set; } 59 | 60 | /// 61 | /// The list of shape strings 62 | /// 63 | /// 64 | /// These will usually begin with shp_ 65 | /// 66 | public List ShapeList { get; set; } 67 | 68 | /// 69 | /// The list of extra path strings 70 | /// 71 | /// 72 | /// These are extra paths contained in the mdl path data 73 | /// 74 | public List ExtraPathList { get; set; } 75 | } 76 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/MeshData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SharpDX; 18 | using System.Collections.Generic; 19 | 20 | namespace xivModdingFramework.Models.DataContainers 21 | { 22 | public class MeshData 23 | { 24 | public int VertexBoneArraySize { get; set; } 25 | 26 | /// 27 | /// The information for the mesh data 28 | /// 29 | public MeshDataInfo MeshInfo { get; set; } 30 | 31 | /// 32 | /// The list of parts for the mesh 33 | /// 34 | public List MeshPartList { get; set; } 35 | 36 | /// 37 | /// The list of vertex data structures for the mesh 38 | /// 39 | public List VertexDataStructList { get; set; } 40 | 41 | /// 42 | /// The vertex data for the mesh 43 | /// 44 | public VertexData VertexData { get; set; } 45 | 46 | /// 47 | /// Determines whether this mesh contains a body material 48 | /// 49 | public bool IsBody { get; set; } 50 | 51 | 52 | /// 53 | /// A list of the shape paths associated with this mesh 54 | /// 55 | public List ShapePathList { get; set; } 56 | } 57 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/MeshDataInfo.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.DataContainers 18 | { 19 | /// 20 | /// This class contains the properties of the Mesh Data Information 21 | /// 22 | public class MeshDataInfo 23 | { 24 | /// 25 | /// The number of vertices the mesh contains 26 | /// 27 | public int VertexCount { get; set; } 28 | 29 | /// 30 | /// The number of indcies the mesh contains 31 | /// 32 | public int IndexCount { get; set; } 33 | 34 | /// 35 | /// The index of the material used by the mesh 36 | /// 37 | /// 38 | /// This is the index of the material in the MaterialList from MdlPathData 39 | /// 40 | public short MaterialIndex { get; set; } 41 | 42 | /// 43 | /// The index of the Mesh Part to start at 44 | /// 45 | public short MeshPartIndex { get; set; } 46 | 47 | /// 48 | /// The number of Parts the mesh contains 49 | /// 50 | public short MeshPartCount { get; set; } 51 | 52 | /// 53 | /// The index of the Bone List to use for the mesh 54 | /// 55 | /// 56 | /// This is the index of the bone list in the BoneDataList 57 | /// 58 | public short BoneSetIndex { get; set; } 59 | 60 | /// 61 | /// The offset to the Index Data Block 62 | /// 63 | public int IndexDataOffset { get; set; } 64 | 65 | /// 66 | /// The offset to the first Vertex Data Block 67 | /// 68 | public int VertexDataOffset0 { get; set; } 69 | 70 | /// 71 | /// The offset to the second Vertex Data Block 72 | /// 73 | public int VertexDataOffset1 { get; set; } 74 | 75 | /// 76 | /// The offset to the Third Vertex Data Block 77 | /// 78 | /// 79 | /// This value is usually blank 80 | /// 81 | public int VertexDataOffset2 { get; set; } 82 | 83 | /// 84 | /// The size of each individual Vertex Data Entry in the first Vertex Data Block 85 | /// 86 | public byte VertexDataEntrySize0 { get; set; } 87 | 88 | /// 89 | /// The size of each individual Vertex Data Entry in the second Vertex Data Block 90 | /// 91 | public byte VertexDataEntrySize1 { get; set; } 92 | 93 | /// 94 | /// The size of each individual Vertex Data Entry in the third Vertex Data Block 95 | /// 96 | /// 97 | /// This value is usually blank 98 | /// 99 | public byte VertexDataEntrySize2 { get; set; } 100 | 101 | /// 102 | /// The number of vertex data blocks for the mesh 103 | /// 104 | public byte VertexStreamCountUnknown { get; set; } 105 | } 106 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/MeshPart.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.DataContainers 18 | { 19 | /// 20 | /// This class contins the properties for the Parts for a Mesh 21 | /// 22 | public class MeshPart 23 | { 24 | /// 25 | /// The offset to the start index in the Index Data Block 26 | /// 27 | public int IndexOffset { get; set; } 28 | 29 | /// 30 | /// The number of indices the mesh part contains 31 | /// 32 | public int IndexCount { get; set; } 33 | 34 | /// 35 | /// The index to the attribute used by the mesh part 36 | /// 37 | /// 38 | /// This is the index to the value in MdlPathData.AttributeList 39 | /// 40 | public uint AttributeBitmask { get; set; } 41 | 42 | /// 43 | /// The offset to the starting bone in the BoneList 44 | /// 45 | public short BoneStartOffset { get; set; } 46 | 47 | /// 48 | /// The number of bones to use from the bone list beginning at the BoneStartOffset 49 | /// 50 | public short BoneCount { get; set; } 51 | } 52 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/ModelTextureData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using xivModdingFramework.Helpers; 18 | using xivModdingFramework.Materials.DataContainers; 19 | using xivModdingFramework.Materials.FileTypes; 20 | using xivModdingFramework.Models.Helpers; 21 | 22 | namespace xivModdingFramework.Models.DataContainers 23 | { 24 | /// 25 | /// This class holds the data for the textures to be used on the 3D Model 26 | /// 27 | public class ModelTextureData 28 | { 29 | public int Width { get; set; } 30 | 31 | public int Height { get; set; } 32 | 33 | 34 | //Color Data 35 | public byte[] Diffuse { get; set; } 36 | public byte[] Specular { get; set; } 37 | public byte[] Emissive { get; set; } 38 | 39 | // Other Common Data 40 | public byte[] Normal { get; set; } 41 | public byte[] Alpha { get; set; } 42 | 43 | // PBR Data 44 | public byte[] Occlusion { get; set; } 45 | public byte[] Roughness { get; set; } 46 | public byte[] Metalness { get; set; } 47 | public byte[] Subsurface { get; set; } 48 | 49 | 50 | public string MaterialPath { get; set; } 51 | 52 | public bool IsSkin { 53 | get 54 | { 55 | return ModelModifiers.IsSkinMaterial(MaterialPath); 56 | } 57 | } 58 | 59 | public bool RenderBackfaces { get; set; } 60 | public TextureSampler.ETilingMode UTilingMode { get; set; } 61 | public TextureSampler.ETilingMode VTilingMode { get; set; } 62 | } 63 | /// 64 | /// This class holds the data for the textures to be used on the 3D Model 65 | /// 66 | public class PbrModelTextureData 67 | { 68 | public int Width { get; set; } 69 | 70 | public int Height { get; set; } 71 | 72 | public byte[] Diffuse { get; set; } 73 | 74 | public byte[] Specular { get; set; } 75 | 76 | public byte[] Normal { get; set; } 77 | 78 | public byte[] Alpha { get; set; } 79 | 80 | public byte[] Emissive { get; set; } 81 | 82 | public byte[] Metalness { get; set; } 83 | 84 | public byte[] Roughness{ get; set; } 85 | 86 | public string MaterialPath { get; set; } 87 | 88 | public bool IsSkin 89 | { 90 | get 91 | { 92 | return ModelModifiers.IsSkinMaterial(MaterialPath); 93 | } 94 | } 95 | 96 | public bool RenderBackfaces { get; set; } 97 | } 98 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/NeckMorphEntry.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SharpDX; 18 | using System.Collections.Generic; 19 | 20 | namespace xivModdingFramework.Models.DataContainers 21 | { 22 | /// 23 | /// Class representing a neck morph table entry in a model, which modifies a vertex on the neck seam of a character's body when active. 24 | /// Typically 10 of these entries exist on a head mesh. 25 | /// It is unclear how each entry relates to individual vertex on the body mesh. 26 | /// 27 | public class NeckMorphEntry 28 | { 29 | /// 30 | /// Relative adjustment of the Position of the vertex. 31 | /// Its unclear how this is applied, but it seems affected by the referenced bones. 32 | /// 33 | public Vector3 PositionAdjust { get; set; } 34 | 35 | /// 36 | /// This value is unclear but preserving it is important. 37 | /// If it is incorrect, the vertex adjustments disappear when viewed from certain camera angles. 38 | /// For all known working examples, it just has the value 0x00006699. 39 | /// 40 | public uint Unknown { get; set; } 41 | 42 | /// 43 | /// Relative adjustment of the Normal of the vertex. 44 | /// Its unclear how this is applied. 45 | /// 46 | public Vector3 NormalAdjust { get; set; } 47 | 48 | /// 49 | /// A list of bones, stored as indexes in to MdlPathData.BoneList. 50 | /// For all known working examples, the referenced bones are ["j_kubi", "j_sebo_c"]. 51 | /// If the incorrect bones are referenced, the neck behavior becomes erratic. 52 | /// NOTE: In the model file these are actually stored as indexes in to BoneSet 0. 53 | /// 54 | public List Bones { get; set; } 55 | } 56 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/SkeletonData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | /// 22 | /// This class contains properties for the model skeleton 23 | /// 24 | /// 25 | /// The model skeleton is kept separate from the mdl file and is usually in 26 | /// the chara/human/[raceID]/skeleton/base/[bodyID] folder, it is a Havok file. 27 | /// 28 | public class SkeletonData : ICloneable 29 | { 30 | /// 31 | /// The Name of the bone 32 | /// 33 | public string BoneName { get; set; } 34 | 35 | /// 36 | /// The bone number 37 | /// 38 | public int BoneNumber { get; set; } 39 | 40 | /// 41 | /// The bone parent 42 | /// 43 | /// 44 | /// The base bone that has no parent will have a value of -1 45 | /// 46 | public int BoneParent { get; set; } 47 | 48 | /// 49 | /// The Pose Matrix for the bone 50 | /// 51 | public float[] PoseMatrix { get; set; } 52 | 53 | /// 54 | /// The Inverse Pose Matrix for the bone 55 | /// 56 | public float[] InversePoseMatrix { get; set; } 57 | 58 | public object Clone() 59 | { 60 | var c = (SkeletonData) MemberwiseClone(); 61 | 62 | c.PoseMatrix = (float[]) PoseMatrix.Clone(); 63 | c.InversePoseMatrix = (float[])InversePoseMatrix.Clone(); 64 | return c; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/TerrainShadowMeshData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.DataContainers 18 | { 19 | public class TerrainShadowMeshData 20 | { 21 | /// 22 | /// This data block is currently unknown 23 | /// 24 | /// 25 | /// The size of this unknown data block is [ MdlModelData.Unknown3 * 20 ] 26 | /// 27 | public byte[] TerrainShadowMeshHeader { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/UnknownData0.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.DataContainers 18 | { 19 | public class UnknownData0 20 | { 21 | /// 22 | /// This data block is currently unknown 23 | /// 24 | /// 25 | /// The size of this unknown data block is [ MdlModelData.Unknown2 * 32 ] 26 | /// 27 | public byte[] Unknown { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/UnknownData2.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.DataContainers 18 | { 19 | public class UnknownData2 20 | { 21 | /// 22 | /// This data block is currently unknown 23 | /// 24 | /// 25 | /// The size of this unknown data block is [ MdlModelData.Unknown9 * 12 ] 26 | /// 27 | public byte[] Unknown { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/UnknownDataPatch72.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.DataContainers 18 | { 19 | public class UnknownDataPatch72 20 | { 21 | /// 22 | /// This data block is currently unknown 23 | /// 24 | /// 25 | /// The size of this unknown data block is [ MdlModelData.Patch72TableSize * 16 ] 26 | /// 27 | public byte[] Unknown { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/VertexData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SharpDX; 18 | using System.Collections.Generic; 19 | using HelixToolkit.SharpDX.Core; 20 | 21 | namespace xivModdingFramework.Models.DataContainers 22 | { 23 | /// 24 | /// This class contains the properties for the Vertex Data 25 | /// 26 | public class VertexData 27 | { 28 | /// 29 | /// The vertex position data in Vector3 format (X, Y, Z) 30 | /// 31 | public Vector3Collection Positions { get; set; } = new Vector3Collection(); 32 | 33 | /// 34 | /// The bone weight array per vertex 35 | /// 36 | /// 37 | /// Each vertex can hold a maximum of 4 bone weights 38 | /// 39 | public List BoneWeights { get; set; } = new List(); 40 | 41 | /// 42 | /// The bone index array per vertex 43 | /// 44 | /// 45 | /// Each vertex can hold a maximum of 4 bone indices 46 | /// 47 | public List BoneIndices { get; set; } = new List(); 48 | 49 | /// 50 | /// The vertex normal data in Vector4 format (X, Y, Z, W) 51 | /// 52 | /// 53 | /// The W coordinate is present but has never been noticed to be anything other than 0 54 | /// 55 | public Vector3Collection Normals { get; set; } = new Vector3Collection(); 56 | 57 | /// 58 | /// The vertex BiNormal data in Vector3 format (X, Y, Z) 59 | /// 60 | public Vector3Collection BiNormals { get; set; } = new Vector3Collection(); 61 | 62 | /// 63 | /// The vertex BiNormal Handedness data in bytes 64 | /// 65 | public List BiNormalHandedness { get; set; } = new List(); 66 | 67 | /// 68 | /// The vertex Tangent data in Vector3 format (X, Y, Z) 69 | /// 70 | public Vector3Collection FlowDirections { get; set; } = new Vector3Collection(); 71 | 72 | /// 73 | /// The vertex BiNormal Handedness data in bytes 74 | /// 75 | public List FlowHandedness { get; set; } = new List(); 76 | 77 | /// 78 | /// The vertex color data in Byte4 format (R, G, B, A) 79 | /// 80 | public List Colors { get; set; } = new List(); 81 | 82 | /// 83 | /// Second Vertex Color Channel 84 | /// 85 | public List Colors2 { get; set; } = new List(); 86 | 87 | 88 | /// 89 | /// The primary texture coordinates for the mesh in Vector2 format (X, Y) 90 | /// 91 | public Vector2Collection TextureCoordinates0 { get; set; } = new Vector2Collection(); 92 | 93 | /// 94 | /// The secondary texture coordinates for the mesh in Vector2 format (X, Y) 95 | /// 96 | public Vector2Collection TextureCoordinates1 { get; set; } = new Vector2Collection(); 97 | public Vector2Collection TextureCoordinates2 { get; set; } = new Vector2Collection(); 98 | 99 | /// 100 | /// The index data for the mesh 101 | /// 102 | public IntCollection Indices { get; set; } = new IntCollection(); 103 | } 104 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/VertexDataStruct.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using xivModdingFramework.Models.Enums; 18 | 19 | namespace xivModdingFramework.Models.DataContainers 20 | { 21 | /// 22 | /// This class contains the properties for the Vertex Data Structures 23 | /// 24 | public class VertexDataStruct 25 | { 26 | 27 | /// 28 | /// The vertex data block the data belongs to 29 | /// 30 | /// 31 | /// There are usually 2 data blocks and usually contain the following data 32 | /// Block 0: Positions, Blend Weights, Blend indices 33 | /// Block 1: Normal, Tangent, Color, Texture Coordinates 34 | /// 35 | public byte DataBlock { get; set; } 36 | 37 | /// 38 | /// The offset to the data within the Data Block 39 | /// 40 | public byte DataOffset { get; set; } 41 | 42 | /// 43 | /// The type of the data 44 | /// 45 | public VertexDataType DataType { get; set; } 46 | 47 | /// 48 | /// What the data will be used for 49 | /// 50 | public VertexUsageType DataUsage { get; set; } 51 | 52 | public byte Count { get; set; } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /xivModdingFramework/Models/DataContainers/XivMdl.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SharpDX; 18 | using System.Collections.Generic; 19 | 20 | namespace xivModdingFramework.Models.DataContainers 21 | { 22 | /// 23 | /// This class is an internal representation of the entire sum of an uncompressed .mdl file. 24 | /// It is not used in any high-level APIs, but is often used as a storage of the many bits of data that 25 | /// either we don't know what they do, or that users have no interaction with, but are still parts of the 26 | /// final .mdl file. 27 | /// 28 | public class XivMdl 29 | { 30 | 31 | /// 32 | /// The path to this mdl file 33 | /// 34 | public string MdlPath { get; set; } 35 | 36 | public ushort MdlVersion { get; set; } 37 | 38 | /// 39 | /// The path data contained in the mdl file 40 | /// 41 | public MdlPathData PathData { get; set; } 42 | 43 | /// 44 | /// The model data contained in the mdl file 45 | /// 46 | public MdlModelData ModelData { get; set; } 47 | 48 | /// 49 | /// Currently unknown data 50 | /// 51 | public UnknownData0 UnkData0 { get; set; } 52 | 53 | /// 54 | /// The list containing the info for each Level of Detail of the model 55 | /// 56 | public List LoDList { get; set; } 57 | 58 | /// 59 | /// The data block containing attribute information 60 | /// 61 | public AttributeDataBlock AttrDataBlock { get; set; } 62 | 63 | /// 64 | /// Currently unknown data 65 | /// 66 | public TerrainShadowMeshData UnkData1 { get; set; } 67 | 68 | /// 69 | /// Currently unknown data 70 | /// 71 | public UnknownData2 UnkData2 { get; set; } 72 | 73 | /// 74 | /// The data block containing material information 75 | /// 76 | public MaterialDataBlock MatDataBlock { get; set; } 77 | 78 | /// 79 | /// The data block containing bone information 80 | /// 81 | public BoneDataBlock BoneDataBlock { get; set; } 82 | 83 | /// 84 | /// The list continaing each of the Bone Index Lists for each LoD 85 | /// 86 | public List MeshBoneSets { get; set; } 87 | 88 | /// 89 | /// The data containing the information for mesh shapes 90 | /// 91 | public ShapeData MeshShapeData { get; set; } 92 | 93 | /// 94 | /// The data containing the information for the bone indices used by mesh parts 95 | /// 96 | public BoneSet PartBoneSets { get; set; } 97 | 98 | /// 99 | /// The size of the padded bytes immediately following 100 | /// 101 | public byte PaddingSize { get; set; } 102 | 103 | /// 104 | /// The padded bytes 105 | /// 106 | public byte[] PaddedBytes { get; set; } 107 | 108 | /// 109 | // Bounding Boxes for the model 110 | /// 111 | public List> BoundingBoxes { get; set; } 112 | 113 | /// 114 | /// Bone Bounding Boxes 115 | /// 116 | public List> BoneBoundingBoxes { get; set; } 117 | 118 | /// 119 | /// Bone Bounding Boxes 120 | /// 121 | public List> BonelessPartBoundingBoxes { get; set; } 122 | 123 | /// 124 | /// Flag set when the model has shape data 125 | /// 126 | public bool HasShapeData { get; set; } 127 | 128 | /// 129 | /// The list containing the info for each etra Level of Detail of the model 130 | /// 131 | /// 132 | /// This happens when the sum of all LoD mesh counts is less than the model data mesh count. 133 | /// The number of extra LoDs seems to be the value of Unknown10 134 | /// 135 | public List ExtraLoDList { get; set; } 136 | 137 | /// 138 | /// The list of extra MeshData for the Model 139 | /// 140 | /// 141 | /// This happens when the sum of all LoD mesh counts is less than the model data mesh count 142 | /// 143 | public List ExtraMeshData { get; set; } 144 | 145 | /// 146 | /// This data is present on heads and seems to affect the shape of the neck on the body mesh 147 | /// 148 | public List NeckMorphTable { get; set; } 149 | 150 | /// 151 | /// Currently unknown data 152 | /// 153 | public UnknownDataPatch72 UnkDataPatch72 { get; set; } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /xivModdingFramework/Models/Enums/VertexDataType.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Models.Enums 20 | { 21 | /// 22 | /// Enum containing the Data Type for data entries in the Vertex Data Blocks 23 | /// 24 | public enum VertexDataType 25 | { 26 | Float1 = 0x0, 27 | Float2 = 0x1, 28 | Float3 = 0x2, 29 | Float4 = 0x3, 30 | Ubyte4 = 0x5, 31 | Short2 = 0x6, 32 | Short4 = 0x7, 33 | Ubyte4n = 0x8, 34 | Short2n = 0x9, 35 | Short4n = 0xA, 36 | Ushort2n = 0xB, 37 | Ushort4n = 0xC, 38 | Half2 = 0x0D, 39 | Half4 = 0x0E, 40 | //Half2D = 0x0D, 41 | //Half4E = 0x0E, 42 | UByte8 = 0x11 43 | } 44 | 45 | public static class VertexDataTypeInfo 46 | { 47 | public static Dictionary Sizes = new Dictionary() { 48 | { VertexDataType.Float1, 4 }, 49 | { VertexDataType.Float2, 8 }, 50 | { VertexDataType.Float3, 12 }, 51 | { VertexDataType.Float4, 16 }, 52 | { VertexDataType.Ubyte4, 4 }, 53 | { VertexDataType.Short2, 4 }, 54 | { VertexDataType.Short4, 8 }, 55 | { VertexDataType.Ubyte4n, 4 }, 56 | { VertexDataType.Short2n, 4 }, 57 | { VertexDataType.Short4n, 8 }, 58 | { VertexDataType.Ushort2n, 4 }, 59 | { VertexDataType.Ushort4n, 8 }, 60 | { VertexDataType.Half2, 4 }, 61 | { VertexDataType.Half4, 8 }, 62 | { VertexDataType.UByte8, 8 }, 63 | }; 64 | 65 | } 66 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/Enums/VertexUsageType.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Models.Enums 18 | { 19 | /// 20 | /// Enum containing the what the data entries in the Vertex Data Block will be used for 21 | /// 22 | public enum VertexUsageType 23 | { 24 | Position = 0x0, 25 | BoneWeight = 0x1, 26 | BoneIndex = 0x2, 27 | Normal = 0x3, 28 | TextureCoordinate = 0x4, 29 | Flow = 0x5, 30 | Binormal = 0x6, 31 | Color = 0x7 32 | } 33 | } -------------------------------------------------------------------------------- /xivModdingFramework/Models/FileTypes/Obj.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using System.IO; 20 | using System.Text; 21 | using xivModdingFramework.General.Enums; 22 | using xivModdingFramework.Helpers; 23 | using xivModdingFramework.Items.Interfaces; 24 | using xivModdingFramework.Models.DataContainers; 25 | 26 | namespace xivModdingFramework.Models.FileTypes 27 | { 28 | /// 29 | /// This class handles Obj files 30 | /// 31 | public class Obj 32 | { 33 | private readonly DirectoryInfo _gameDirectory; 34 | 35 | public Obj(DirectoryInfo gameDirectory) 36 | { 37 | _gameDirectory = gameDirectory; 38 | } 39 | 40 | /// 41 | /// Exports each mesh as an obj file 42 | /// 43 | public void ExportObj(TTModel model, string path) 44 | { 45 | var meshGroups = model.MeshGroups; 46 | 47 | Directory.CreateDirectory(Path.GetDirectoryName(path)); 48 | 49 | try 50 | { 51 | var meshNum = 0; 52 | foreach (var mesh in meshGroups) 53 | { 54 | var modelName = $"{Path.GetFileNameWithoutExtension(path)}_{meshNum}.obj"; 55 | var savePath = Path.GetDirectoryName(path) + "\\" + modelName; 56 | 57 | meshNum++; 58 | File.WriteAllText(savePath, ExportObj(mesh)); 59 | } 60 | } catch(Exception ex) 61 | { 62 | throw ex; 63 | } 64 | } 65 | 66 | public string ExportObj(TTMeshGroup mesh) 67 | { 68 | var sb = new StringBuilder(); 69 | 70 | 71 | // Merge the index and vertex lists. 72 | var vertices = new List((int)mesh.VertexCount); 73 | var indices = new List((int)mesh.IndexCount); 74 | foreach (var p in mesh.Parts) 75 | { 76 | var preVertexCount = vertices.Count; 77 | vertices.AddRange(p.Vertices); 78 | foreach (var i in p.TriangleIndices) 79 | { 80 | indices.Add(i + preVertexCount); 81 | } 82 | } 83 | 84 | foreach (var v in vertices) 85 | { 86 | sb.AppendLine($"v {v.Position.X:N5} {v.Position.Y:N5} {v.Position.Z:N5}"); 87 | } 88 | 89 | foreach (var v in vertices) 90 | { 91 | var ox = v.UV1.X - Math.Truncate(v.UV1.X); 92 | var oy = v.UV1.Y - Math.Truncate(v.UV1.Y); 93 | sb.AppendLine($"vt {ox:N5} {(1 - oy):N5}"); 94 | } 95 | 96 | foreach (var v in vertices) 97 | { 98 | sb.AppendLine($"vn {v.Normal.X:N5} {v.Normal.Y:N5} {v.Normal.Z:N5}"); 99 | } 100 | 101 | for (var i = 0; i < indices.Count; i += 3) 102 | { 103 | var index1 = indices[i] + 1; 104 | var index2 = indices[i + 1] + 1; 105 | var index3 = indices[i + 2] + 1; 106 | sb.AppendLine($"f {index1}/{index1}/{index1} {index2}/{index2}/{index2} {index3}/{index3}/{index3}"); 107 | } 108 | 109 | 110 | return sb.ToString(); 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/BackupModPackData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using xivModdingFramework.Mods.Interfaces; 4 | 5 | namespace xivModdingFramework.Mods.DataContainers 6 | { 7 | public class BackupModPackData : IModPackData 8 | { 9 | /// 10 | /// The name of the mod pack 11 | /// 12 | public string Name { get; set; } 13 | 14 | /// 15 | /// The mod pack author 16 | /// 17 | public string Author { get; set; } = "TexTools"; 18 | 19 | /// 20 | /// The mod pack version 21 | /// 22 | public Version Version { get; set; } = new Version("1.0.0"); 23 | 24 | /// 25 | /// The modpack Url 26 | /// 27 | public string Url { get; set; } = ""; 28 | 29 | /// 30 | /// The description for the mod pack 31 | /// 32 | public string Description { get; set; } = ""; 33 | 34 | /// 35 | /// The list of mods to back up 36 | /// 37 | public List ModsToBackup { get; set; } 38 | } 39 | 40 | public class BackupModData 41 | { 42 | /// 43 | /// Simple mod data 44 | /// 45 | public SimpleModData SimpleModData { get; set; } 46 | 47 | /// 48 | /// Mod pack that the mod is a part of 49 | /// 50 | public ModPack? ModPack { get; set; } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/ModGroup.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | 19 | namespace xivModdingFramework.Mods.DataContainers 20 | { 21 | public class ModGroup 22 | { 23 | /// 24 | /// The name of the mod options group 25 | /// 26 | public string GroupName { get; set; } 27 | 28 | /// 29 | /// The type of selection for the options in the group 30 | /// 31 | /// 32 | /// This is either Single Selection or Multi Selection 33 | /// 34 | public string SelectionType { get; set; } 35 | 36 | /// 37 | /// The list of options in the group 38 | /// 39 | public List OptionList { get; set; } 40 | } 41 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/ModOption.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using SixLabors.ImageSharp; 18 | using System.Collections.Generic; 19 | 20 | namespace xivModdingFramework.Mods.DataContainers 21 | { 22 | public class ModOption 23 | { 24 | /// 25 | /// The name of the option 26 | /// 27 | public string Name { get; set; } 28 | 29 | /// 30 | /// The option description 31 | /// 32 | public string Description { get; set; } 33 | 34 | /// 35 | /// The preview image for the option 36 | /// 37 | public Image Image { get; set; } 38 | 39 | /// 40 | /// This is the path for the Image 41 | /// 42 | public string ImageFileName { get; set; } 43 | 44 | /// 45 | /// A dictionary containing the (key)mod path and (value)mod data 46 | /// 47 | public Dictionary Mods { get; } = new Dictionary(); 48 | 49 | /// 50 | /// The name of the group this mod option belongs to 51 | /// 52 | public string GroupName { get; set; } 53 | 54 | /// 55 | /// The selection type for this mod option 56 | /// 57 | public string SelectionType { get; set; } 58 | 59 | /// 60 | /// The status of the radio or checkbox 61 | /// 62 | public bool IsChecked { get; set; } 63 | } 64 | 65 | public class ModData 66 | { 67 | /// 68 | /// The name of the item 69 | /// 70 | public string Name { get; set; } 71 | 72 | /// 73 | /// The category of the item 74 | /// 75 | public string Category { get; set; } 76 | 77 | /// 78 | /// The full path of the item 79 | /// 80 | public string FullPath { get; set; } 81 | 82 | /// 83 | /// Whether or not this item is a default SE file. 84 | /// These files are still included in full, for the sake 85 | /// of backwards compatability, but in the future may have 86 | /// handling to simply disable existing mods, rather than copy over. 87 | /// 88 | public bool IsDefault = false; 89 | 90 | /// 91 | /// The raw mod data 92 | /// 93 | public byte[] ModDataBytes { get; set; } 94 | 95 | } 96 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/ModPackData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using xivModdingFramework.Mods.Interfaces; 20 | 21 | namespace xivModdingFramework.Mods.DataContainers 22 | { 23 | public class ModPackData : IModPackData 24 | { 25 | /// 26 | /// The name of the mod pack 27 | /// 28 | public string Name { get; set; } 29 | 30 | /// 31 | /// The mod pack author 32 | /// 33 | public string Author { get; set; } 34 | 35 | /// 36 | /// The mod pack version 37 | /// 38 | public Version Version { get; set; } 39 | 40 | /// 41 | /// The description for the mod pack 42 | /// 43 | public string Description { get; set; } 44 | 45 | /// 46 | /// Author's supplied URL for the modpack. 47 | /// 48 | public string Url { get; set; } 49 | 50 | /// 51 | /// A list of pages containing a list of mod groups for that particular page 52 | /// 53 | public List ModPackPages { get; set; } 54 | 55 | public class ModPackPage 56 | { 57 | /// 58 | /// The page index 59 | /// 60 | public int PageIndex { get; set; } 61 | 62 | /// 63 | /// The list of mod groups contained in the mod pack 64 | /// 65 | public List ModGroups { get; set; } 66 | 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/OriginalModList.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2019 Rafael Gonzalez - All Rights Reserved 2 | // 3 | // This program is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU General Public License as published by 5 | // the Free Software Foundation, either version 3 of the License, or 6 | // (at your option) any later version. 7 | // 8 | // This program is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU General Public License 14 | // along with this program. If not, see . 15 | 16 | namespace xivModdingFramework.Mods.DataContainers 17 | { 18 | class OriginalModList 19 | { 20 | /// 21 | /// The modified items category 22 | /// 23 | public string category { get; set; } 24 | 25 | /// 26 | /// The modified items name 27 | /// 28 | public string name { get; set; } 29 | 30 | /// 31 | /// The internal path of the modified item 32 | /// 33 | public string fullPath { get; set; } 34 | 35 | /// 36 | /// The oringial offset of the modified item 37 | /// 38 | /// 39 | /// Used to revert to the items original texture 40 | /// 41 | public int originalOffset { get; set; } 42 | 43 | /// 44 | /// The modified offset of the modified item 45 | /// 46 | public int modOffset { get; set; } 47 | 48 | /// 49 | /// The size of the modified items data 50 | /// 51 | /// 52 | /// When importing a previously modified texture, this value is used to determine whether the modified data will be overwritten 53 | /// 54 | public int modSize { get; set; } 55 | 56 | /// 57 | /// The dat file where the modified item is located 58 | /// 59 | public string datFile { get; set; } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/OriginalModPackJson.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | 18 | namespace xivModdingFramework.Mods.DataContainers 19 | { 20 | public class OriginalModPackJson 21 | { 22 | /// 23 | /// The name of the item 24 | /// 25 | public string Name { get; set; } 26 | 27 | /// 28 | /// The item category 29 | /// 30 | public string Category { get; set; } 31 | 32 | /// 33 | /// The full path of the item data for the game 34 | /// 35 | public string FullPath { get; set; } 36 | 37 | /// 38 | /// The offset to where the mod data is located 39 | /// 40 | public long ModOffset { get; set; } 41 | 42 | /// 43 | /// The size of the mod data 44 | /// 45 | public int ModSize { get; set; } 46 | 47 | /// 48 | /// The dat file associated with the item 49 | /// 50 | public string DatFile { get; set; } 51 | } 52 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/SimpleModPackData.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.Collections.Generic; 19 | using xivModdingFramework.Mods.Interfaces; 20 | 21 | namespace xivModdingFramework.Mods.DataContainers 22 | { 23 | public class SimpleModPackData : IModPackData 24 | { 25 | /// 26 | /// The name of the mod pack 27 | /// 28 | public string Name { get; set; } 29 | 30 | /// 31 | /// The mod pack author 32 | /// 33 | public string Author { get; set; } 34 | 35 | /// 36 | /// The mod pack version 37 | /// 38 | public Version Version { get; set; } 39 | 40 | /// 41 | /// The modpack Url 42 | /// 43 | public string Url { get; set; } = ""; 44 | 45 | /// 46 | /// The description for the mod pack 47 | /// 48 | public string Description { get; set; } 49 | 50 | /// 51 | /// List of simple mod data 52 | /// 53 | public List SimpleModDataList { get; set; } 54 | 55 | } 56 | 57 | public class SimpleModData 58 | { 59 | /// 60 | /// The name of the item 61 | /// 62 | public string Name { get; set; } 63 | 64 | /// 65 | /// The category of the item 66 | /// 67 | public string Category { get; set; } 68 | 69 | /// 70 | /// The full path of the item data for the game 71 | /// 72 | public string FullPath { get; set; } 73 | 74 | /// 75 | /// The offset to where the mod data is located 76 | /// 77 | public long ModOffset { get; set; } 78 | 79 | /// 80 | /// If the entry is SE Default data or not. 81 | /// 82 | public bool IsDefault = false; 83 | 84 | /// 85 | /// The size of the mod data 86 | /// 87 | public int ModSize { get; set; } 88 | 89 | /// 90 | /// The dat file associated with the item 91 | /// 92 | public string DatFile { get; set; } 93 | } 94 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/DataContainers/TransactionModList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | 6 | namespace xivModdingFramework.Mods.DataContainers 7 | { 8 | /// 9 | /// Wrapped ModList handler that reports to the active transaction when changes are made. 10 | /// 11 | internal class TransactionModList : ModList 12 | { 13 | protected override void INTERNAL_AddOrUpdateMod(Mod mod) 14 | { 15 | // Loop back to notify the Transaction of our changes. 16 | var tx = ModTransaction.ActiveTransaction; 17 | if (tx != null) 18 | { 19 | var originalMod = GetMod(mod.FilePath); 20 | tx.INTERNAL_OnModUpdate(mod.FilePath, originalMod, mod); 21 | } 22 | base.INTERNAL_AddOrUpdateMod(mod); 23 | } 24 | 25 | protected override void INTERNAL_RemoveMod(string path) 26 | { 27 | // Loop back to notify the Transaction of our changes. 28 | var tx = ModTransaction.ActiveTransaction; 29 | if (tx != null) 30 | { 31 | var originalMod = GetMod(path); 32 | tx.INTERNAL_OnModUpdate(path, originalMod, null); 33 | } 34 | base.INTERNAL_RemoveMod(path); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /xivModdingFramework/Mods/Enums/EModState.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Mods.Enums 18 | { 19 | public enum EModState 20 | { 21 | // The file is modded, but points to an offset that is neither the modded or original file. 22 | Invalid, 23 | 24 | // The file has not been modded at all, and exists only in its default game state. 25 | UnModded, 26 | 27 | // The file is modded, and enabled. 28 | Enabled, 29 | 30 | // The file is modded, but the mod is disabled. 31 | Disabled 32 | } 33 | } -------------------------------------------------------------------------------- /xivModdingFramework/Mods/FileTypes/ModelKit.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using xivModdingFramework.General.Enums; 5 | using xivModdingFramework.Materials.DataContainers; 6 | using xivModdingFramework.Models.DataContainers; 7 | 8 | namespace xivModdingFramework.Mods.FileTypes 9 | { 10 | /// 11 | /// The high-level representation of a model kit. 12 | /// 13 | public class ModelKit 14 | { 15 | public string Name; 16 | public string Author; 17 | public string Version; 18 | public string Url; 19 | public string Description; 20 | 21 | public string Image; 22 | 23 | 24 | public TTModel Model; 25 | public XivMtrl Material; 26 | public XivRace OriginalRace; 27 | 28 | } 29 | 30 | 31 | 32 | /// 33 | /// The base Low-Level JSON representation for a model kit. 34 | /// 35 | public class ModelKitJson 36 | { 37 | public string Name; 38 | public string Author; 39 | public string Version; 40 | public string Url; 41 | public string Description; 42 | 43 | 44 | /// 45 | /// Path to the preview image within the Zip file. 46 | /// 47 | public string Image; 48 | 49 | /// 50 | /// The original Race identifier if there was one for the model. 51 | /// Should be NULL or Empty String if the model should not be racially scaled. 52 | /// 53 | public string OriginalRace; 54 | 55 | /// 56 | /// Model file path within the zip file. 57 | /// 58 | public string Model; 59 | 60 | /// 61 | /// Model-listed Material Name => Zip Path for Materials. 62 | /// 63 | public Dictionary Materials; 64 | 65 | /// 66 | /// FFXIV Internal Path => Zip Path for textures. 67 | /// Textures should only be imported by default if they do not exist. 68 | /// 69 | public Dictionary Textures; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /xivModdingFramework/Mods/Interfaces/IModPackData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace xivModdingFramework.Mods.Interfaces 4 | { 5 | public interface IModPackData 6 | { 7 | /// 8 | /// The name of the mod pack 9 | /// 10 | public string Name { get; set; } 11 | 12 | /// 13 | /// The mod pack author 14 | /// 15 | public string Author { get; set; } 16 | 17 | /// 18 | /// The mod pack version 19 | /// 20 | public Version Version { get; set; } 21 | 22 | /// 23 | /// The description for the mod pack 24 | /// 25 | public string Description { get; set; } 26 | 27 | /// 28 | /// Author's supplied URL for the modpack. 29 | /// 30 | public string Url { get; set; } 31 | } 32 | 33 | /// 34 | /// Baseline modpack data, just used for handling metadata. 35 | /// Only used in PMP creation currently. 36 | /// 37 | public class BaseModpackData : IModPackData 38 | { 39 | public string Name { get; set; } 40 | public string Author { get; set; } 41 | public Version Version { get; set; } 42 | public string Description { get; set; } 43 | public string Url { get; set; } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /xivModdingFramework/Mods/ShrinkRay.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using xivModdingFramework.Helpers; 8 | using xivModdingFramework.Models.DataContainers; 9 | using xivModdingFramework.Models.FileTypes; 10 | using xivModdingFramework.Mods.DataContainers; 11 | using xivModdingFramework.SqPack.FileTypes; 12 | using xivModdingFramework.Textures.DataContainers; 13 | using xivModdingFramework.Textures.FileTypes; 14 | 15 | namespace xivModdingFramework.Mods 16 | { 17 | public static class ShrinkRay 18 | { 19 | public class ShrinkRaySettings 20 | { 21 | public bool ResaveModels = true; 22 | public bool RemoveExtraFiles = true; 23 | public int MaxTextureSize = 2048; 24 | } 25 | 26 | public static async Task ShrinkModpack(string modpackPath, ShrinkRaySettings settings = null) 27 | { 28 | var data = await WizardData.FromModpack(modpackPath); 29 | if (data == null) 30 | { 31 | throw new ArgumentException("The given modpack does not exist or is invalid."); 32 | } 33 | 34 | return await ShrinkModpack(data); 35 | } 36 | public static async Task ShrinkModpack(WizardData modpack, ShrinkRaySettings settings = null) 37 | { 38 | if(settings == null) 39 | { 40 | settings = new ShrinkRaySettings(); 41 | } 42 | 43 | modpack.ClearNulls(); 44 | 45 | await Task.Run(async () => 46 | { 47 | var rtx = ModTransaction.BeginReadonlyTransaction(); 48 | await ForEachOptionParalell(modpack, async (opt) => 49 | { 50 | var newKeys = new Dictionary(opt.Files.Count); 51 | foreach (var kv in opt.Files) 52 | { 53 | var path = kv.Key; 54 | var file = kv.Value; 55 | var ext = Path.GetExtension(path); 56 | 57 | if (settings.ResaveModels && ext == ".mdl") 58 | { 59 | file = await ResaveModel(path, file); 60 | } 61 | else if (ext == ".tex" || ext == ".atex") 62 | { 63 | file = await ResaveTexture(path, file, settings.MaxTextureSize); 64 | } 65 | 66 | newKeys.Add(path, file); 67 | } 68 | 69 | opt.Files = newKeys; 70 | }); 71 | 72 | if (settings.RemoveExtraFiles) 73 | { 74 | modpack.ExtraFiles = new Dictionary(); 75 | } 76 | }); 77 | 78 | return modpack; 79 | } 80 | 81 | private static async Task ForEachOptionParalell(WizardData data, Func act) 82 | { 83 | var tasks = new List(); 84 | foreach (var p in data.DataPages) 85 | { 86 | foreach (var g in p.Groups) 87 | { 88 | foreach (var o in g.Options) 89 | { 90 | var sData = o.StandardData; 91 | if (sData == null) continue; 92 | 93 | tasks.Add(Task.Run(async () => await act(sData))); 94 | } 95 | } 96 | } 97 | await Task.WhenAll(tasks); 98 | } 99 | 100 | private static async Task ResaveModel(string path, FileStorageInformation model) 101 | { 102 | var file = model; 103 | try 104 | { 105 | var data = await TransactionDataHandler.GetUncompressedFile(model); 106 | var raw = Mdl.GetXivMdl(data, path); 107 | var ttm = await TTModel.FromRaw(raw); 108 | ttm.MdlVersion = 6; 109 | 110 | var res = Mdl.MakeUncompressedMdlFile(ttm, raw); 111 | var tempPath = IOUtil.GetFrameworkTempFile(); 112 | File.WriteAllBytes(tempPath, res); 113 | 114 | file = new FileStorageInformation() 115 | { 116 | FileSize = res.Length, 117 | RealOffset = 0, 118 | RealPath = tempPath, 119 | StorageType = EFileStorageType.UncompressedIndividual, 120 | }; 121 | } catch(Exception ex) 122 | { 123 | Trace.WriteLine(ex); 124 | } 125 | return file; 126 | } 127 | 128 | 129 | private static async Task ResaveTexture(string path, FileStorageInformation texture, int maxSize = -1) 130 | { 131 | var file = texture; 132 | try 133 | { 134 | var data = await TransactionDataHandler.GetUncompressedFile(texture); 135 | var xTex = XivTex.FromUncompressedTex(data); 136 | 137 | await Tex.EnsureValidSize(xTex, maxSize); 138 | var res = xTex.ToUncompressedTex(); 139 | var tempPath = IOUtil.GetFrameworkTempFile(); 140 | File.WriteAllBytes(tempPath, res); 141 | 142 | file = new FileStorageInformation() 143 | { 144 | FileSize = res.Length, 145 | RealOffset = 0, 146 | RealPath = tempPath, 147 | StorageType = EFileStorageType.UncompressedIndividual, 148 | }; 149 | } 150 | catch (Exception ex) 151 | { 152 | Trace.WriteLine(ex); 153 | } 154 | return file; 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DB/item_sets.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DB/item_sets.db -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DB/shader_info.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DB/shader_info.db -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DB/uv_heuristics.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DB/uv_heuristics.db -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Colorset.dat: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Colorset.dds: -------------------------------------------------------------------------------- 1 | DDS | q<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL<<<<<<<M LL -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Diffuse.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/Diffuse.dds -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Multi.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/Multi.dds -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Normal.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/Normal.dds -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Other.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/Other.dds -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/Specular.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/Specular.dds -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/default_material.mtrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/default_material.mtrl -------------------------------------------------------------------------------- /xivModdingFramework/Resources/DefaultTextures/default_material_dt.mtrl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TexTools/xivModdingFramework/4e6bd716228c8820738e7cbd1315f1a685bc1f80/xivModdingFramework/Resources/DefaultTextures/default_material_dt.mtrl -------------------------------------------------------------------------------- /xivModdingFramework/Resources/GeneralStrings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace xivModdingFramework.Resources { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class GeneralStrings { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal GeneralStrings() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("xivModdingFramework.Resources.GeneralStrings", typeof(GeneralStrings).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized string similar to Creating TTMP File.... 65 | /// 66 | internal static string TTMP_Creating { 67 | get { 68 | return ResourceManager.GetString("TTMP_Creating", resourceCulture); 69 | } 70 | } 71 | 72 | /// 73 | /// Looks up a localized string similar to Reading TTMP Content.... 74 | /// 75 | internal static string TTMP_ReadingContent { 76 | get { 77 | return ResourceManager.GetString("TTMP_ReadingContent", resourceCulture); 78 | } 79 | } 80 | 81 | /// 82 | /// Looks up a localized string similar to Starting Import.... 83 | /// 84 | internal static string TTMP_StartImport { 85 | get { 86 | return ResourceManager.GetString("TTMP_StartImport", resourceCulture); 87 | } 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /xivModdingFramework/Resources/SQL/CreateCacheDB.sql: -------------------------------------------------------------------------------- 1 | -- Meta table for storing framework values, 2 | -- Such as Cache version. 3 | CREATE TABLE "meta" ( 4 | "key" TEXT NOT NULL UNIQUE, 5 | "value" TEXT, 6 | PRIMARY KEY("key") 7 | ); 8 | 9 | -- All Equipment, Accessory, and Human type entries. 10 | CREATE TABLE "characters" ( 11 | "name" TEXT NOT NULL, 12 | "primary_id" INTEGER NOT NULL, 13 | "slot" TEXT, 14 | "slot_full" TEXT NOT NULL, 15 | "root" TEXT, 16 | "race" TEXT, 17 | "secondary_id" INTEGER 18 | ); 19 | 20 | -- All Equipment, Accessory, and Human type entries. 21 | CREATE TABLE "items" ( 22 | "exd_id" INTEGER NOT NULL, 23 | "name" TEXT NOT NULL, 24 | "primary_id" INTEGER NOT NULL, 25 | "secondary_id" INTEGER NOT NULL, 26 | "slot" TEXT, 27 | "slot_full" TEXT NOT NULL, 28 | "imc_variant" INTEGER NOT NULL, 29 | "icon_id" INTEGER NOT NULL, 30 | "root" TEXT, 31 | PRIMARY KEY("name", "exd_id") 32 | ); 33 | 34 | -- All Dat 06000 stuff. 35 | CREATE TABLE "ui" ( 36 | "name" TEXT NOT NULL, 37 | "category" TEXT NOT NULL, 38 | "subcategory" TEXT, 39 | "mapzonecategory" TEXT, 40 | "path" TEXT, 41 | "icon_id" INTEGER NOT NULL, 42 | "root" TEXT, 43 | 44 | PRIMARY KEY("name", "path", "icon_id") 45 | ); 46 | 47 | -- All /bgcommon/ stuff. 48 | CREATE TABLE "furniture" ( 49 | "name" TEXT NOT NULL, 50 | "category" TEXT NOT NULL, 51 | "subcategory" TEXT, 52 | "primary_id" INTEGER NOT NULL, 53 | "secondary_id" INTEGER, 54 | "icon_id" INTEGER NOT NULL, 55 | "root" TEXT, 56 | 57 | PRIMARY KEY("category", "name", "primary_id") 58 | ); 59 | 60 | 61 | -- Includes both known monster and demihuman types. 62 | CREATE TABLE "monsters" ( 63 | "name" TEXT NOT NULL, 64 | "category" TEXT NOT NULL, 65 | "primary_id" INTEGER NOT NULL, 66 | "icon" INTEGER NOT NULL, 67 | "secondary_id" INTEGER NOT NULL, 68 | "imc_variant" INTEGER NOT NULL, 69 | "model_type" TEXT NOT NULL, 70 | "root" TEXT, 71 | 72 | PRIMARY KEY("category", "name", "primary_id", "secondary_id", "imc_variant") 73 | ); 74 | 75 | -- Human-readable names for roots. Cached for snappy access. 76 | CREATE TABLE "nice_root_names" ( 77 | "root" TEXT NOT NULL, 78 | "nice_name" TEXT NOT NULL, 79 | 80 | PRIMARY KEY("root") 81 | ); 82 | 83 | -- File children. Only guaranteed populated for mod files. 84 | CREATE TABLE "dependencies_children" ( 85 | "parent" TEXT NOT NULL, 86 | "child" TEXT, 87 | 88 | PRIMARY KEY("parent", "child") 89 | ); 90 | 91 | -- File parents. Only guaranteed populated for mod files when the cache queue length is 0. 92 | CREATE TABLE "dependencies_parents" ( 93 | "child" TEXT NOT NULL, 94 | "parent" TEXT, 95 | 96 | PRIMARY KEY("child", "parent") 97 | ); 98 | 99 | -- Cache worker queues 100 | CREATE TABLE "dependencies_children_queue" ( 101 | "position" INTEGER PRIMARY KEY AUTOINCREMENT, 102 | "file" TEXT UNIQUE NOT NULL 103 | ); 104 | 105 | CREATE TABLE "dependencies_parents_queue" ( 106 | "position" INTEGER PRIMARY KEY AUTOINCREMENT, 107 | "file" TEXT UNIQUE NOT NULL 108 | ); -------------------------------------------------------------------------------- /xivModdingFramework/Resources/SQL/CreateImportDB.sql: -------------------------------------------------------------------------------- 1 | -- Meta table for storing any meta level information not already obviously handled by the table structure. 2 | -- Ex. Author, path to original file, etc. 3 | CREATE TABLE "meta" ( 4 | "key" TEXT NOT NULL UNIQUE, 5 | "value" TEXT, 6 | PRIMARY KEY("key") 7 | ); 8 | 9 | -- Warnings that should be proc'd by TexTools. 10 | CREATE TABLE "warnings" ( 11 | "text" TEXT NOT NULL 12 | ); 13 | 14 | -- The Triangle Indices 15 | CREATE TABLE "indices" ( 16 | "mesh" INTEGER NOT NULL, 17 | "part" INTEGER NOT NULL, 18 | "index_id" INTEGER NOT NULL, 19 | "vertex_id" INTEGER NOT NULL, 20 | 21 | 22 | PRIMARY KEY("mesh","part","index_id") 23 | ); 24 | 25 | 26 | -- Vertex Data 27 | CREATE TABLE "vertices" ( 28 | "mesh" INTEGER NOT NULL, 29 | "part" INTEGER NOT NULL, 30 | "vertex_id" INTEGER NOT NULL, 31 | 32 | -- Position 33 | "position_x" REAL NOT NULL, 34 | "position_y" REAL NOT NULL, 35 | "position_z" REAL NOT NULL, 36 | 37 | -- Normal 38 | "normal_x" REAL NOT NULL, 39 | "normal_y" REAL NOT NULL, 40 | "normal_z" REAL NOT NULL, 41 | 42 | -- Binormal 43 | "binormal_x" REAL, 44 | "binormal_y" REAL, 45 | "binormal_z" REAL, 46 | 47 | -- Tangent 48 | "tangent_x" REAL, 49 | "tangent_y" REAL, 50 | "tangent_z" REAL, 51 | 52 | -- Vertex Color 53 | "color_r" REAL NOT NULL, 54 | "color_g" REAL NOT NULL, 55 | "color_b" REAL NOT NULL, 56 | "color_a" REAL NOT NULL, 57 | 58 | -- Vertex Color 2 59 | "color2_r" REAL NOT NULL, 60 | "color2_g" REAL NOT NULL, 61 | "color2_b" REAL NOT NULL, 62 | "color2_a" REAL NOT NULL, 63 | 64 | -- UV Coordinates 65 | "uv_1_u" REAL NOT NULL, 66 | "uv_1_v" REAL NOT NULL, 67 | "uv_2_u" REAL NOT NULL, 68 | "uv_2_v" REAL NOT NULL, 69 | "uv_3_u" REAL NOT NULL, 70 | "uv_3_v" REAL NOT NULL, 71 | 72 | -- Bone Weights 73 | "bone_1_id" INTEGER, 74 | "bone_1_weight" REAL, 75 | "bone_2_id" INTEGER, 76 | "bone_2_weight" REAL, 77 | "bone_3_id" INTEGER, 78 | "bone_3_weight" REAL, 79 | "bone_4_id" INTEGER, 80 | "bone_4_weight" REAL, 81 | "bone_5_id" INTEGER, 82 | "bone_5_weight" REAL, 83 | "bone_6_id" INTEGER, 84 | "bone_6_weight" REAL, 85 | "bone_7_id" INTEGER, 86 | "bone_7_weight" REAL, 87 | "bone_8_id" INTEGER, 88 | "bone_8_weight" REAL, 89 | 90 | -- Flow Info 91 | "flow_u" REAL NOT NULL, 92 | "flow_v" REAL NOT NULL, 93 | 94 | PRIMARY KEY("mesh","part","vertex_id") 95 | ); 96 | 97 | CREATE TABLE "shape_vertices" ( 98 | "shape" TEXT NOT NULL, 99 | "mesh" INTEGER NOT NULL, 100 | "part" INTEGER NOT NULL, 101 | "vertex_id" INTEGER NOT NULL, 102 | 103 | -- Position 104 | "position_x" REAL NOT NULL, 105 | "position_y" REAL NOT NULL, 106 | "position_z" REAL NOT NULL, 107 | 108 | PRIMARY KEY("shape", "mesh", "part", "vertex_id") 109 | ); 110 | 111 | -- Models 112 | CREATE TABLE "models" ( 113 | "model" INTEGER NOT NULL, 114 | "name" TEXT, 115 | 116 | Primary KEY("model") 117 | ); 118 | 119 | -- Meshes 120 | CREATE TABLE "meshes" ( 121 | "mesh" INTEGER NOT NULL, 122 | "model" INTEGER NOT NULL, 123 | "material_id" INTEGER, 124 | "name" TEXT, 125 | "type" TEXT, 126 | 127 | Primary KEY("mesh") 128 | ); 129 | 130 | 131 | -- Parts 132 | CREATE TABLE "parts" ( 133 | "mesh" INTEGER NOT NULL, 134 | "part" INTEGER NOT NULL, 135 | "name" TEXT, 136 | "attributes" TEXT, 137 | 138 | Primary KEY("mesh", "part") 139 | ); 140 | 141 | -- Bones 142 | CREATE TABLE "bones" ( 143 | "mesh" INTEGER NOT NULL, 144 | "bone_id" INTEGER NOT NULL, 145 | "name" TEXT NOT NULL, 146 | 147 | Primary KEY("mesh","bone_id") 148 | ); 149 | 150 | -- The actual skeleton/bind pose. 151 | CREATE TABLE "skeleton" ( 152 | "name" TEXT NOT NULL, 153 | "parent" TEXT, 154 | 155 | "matrix_0" REAL, 156 | "matrix_1" REAL, 157 | "matrix_2" REAL, 158 | "matrix_3" REAL, 159 | "matrix_4" REAL, 160 | "matrix_5" REAL, 161 | "matrix_6" REAL, 162 | "matrix_7" REAL, 163 | "matrix_8" REAL, 164 | "matrix_9" REAL, 165 | "matrix_10" REAL, 166 | "matrix_11" REAL, 167 | "matrix_12" REAL, 168 | "matrix_13" REAL, 169 | "matrix_14" REAL, 170 | "matrix_15" REAL, 171 | 172 | Primary KEY("name") 173 | ); 174 | 175 | -- Materials 176 | CREATE TABLE "materials" ( 177 | "material_id" INTEGER NOT NULL, 178 | "name" TEXT, 179 | "diffuse" TEXT, 180 | "normal" TEXT, 181 | "specular" TEXT, 182 | "opacity" TEXT, 183 | "emissive" TEXT, 184 | 185 | Primary KEY("material_id") 186 | ); -------------------------------------------------------------------------------- /xivModdingFramework/Resources/SQL/CreateRootCacheDB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE "roots" ( 2 | "primary_type" TEXT NOT NULL, 3 | "primary_id" INT NOT NULL, 4 | "secondary_type" TEXT, 5 | "secondary_id" INT, 6 | "slot" TEXT, 7 | "root_path" TEXT NOT NULL, 8 | 9 | PRIMARY KEY("root_path") 10 | ); -------------------------------------------------------------------------------- /xivModdingFramework/Resources/SQL/CreateShaderDB.sql: -------------------------------------------------------------------------------- 1 | -- Meta table for storing any meta level information not already obviously handled by the table structure. 2 | -- Ex. Author, path to original file, etc. 3 | CREATE TABLE "meta" ( 4 | "key" TEXT NOT NULL UNIQUE, 5 | "value" TEXT, 6 | PRIMARY KEY("key") 7 | ); 8 | 9 | CREATE TABLE materials ( 10 | -- Simple combined identifier of data_fule-file_offset 11 | "db_key" TEXT NOT NULL UNIQUE, 12 | 13 | "data_file" INTEGER NOT NULL, 14 | "file_offset" INTEGER NOT NULL, 15 | "file_hash" INTEGER, 16 | "folder_hash" INTEGER, 17 | "full_hash" INTEGER, 18 | "file_path" TEXT, 19 | "shader_pack" TEXT, 20 | 21 | PRIMARY KEY("db_key") 22 | ); 23 | 24 | 25 | CREATE TABLE shader_keys ( 26 | "db_key" TEXT NOT NULL, 27 | "key_id" INTEGER NOT NULL, 28 | "value" INTEGER NOT NULL, 29 | "name" TEXT 30 | ); 31 | 32 | CREATE TABLE shader_constants ( 33 | "db_key" TEXT NOT NULL, 34 | "constant_id" INTEGER NOT NULL, 35 | "length" INTEGER NOT NULL, 36 | "value0" REAL, 37 | "value1" REAL, 38 | "value2" REAL, 39 | "value3" REAL, 40 | "name" TEXT 41 | ); 42 | 43 | CREATE TABLE textures ( 44 | "db_key" TEXT NOT NULL, 45 | "texture_path" STRING NOT NULL, 46 | "sampler_id" INTEGER NOT NULL, 47 | "sampler_settings" INTEGER NOT NULL, 48 | "name" STRING 49 | ); 50 | 51 | create view view_shader_keys_reference as 52 | select distinct shader_pack, key_id, value, name from materials m left 53 | join shader_keys sk on sk.db_key = m.db_key 54 | where sk.db_key is not null 55 | order by shader_pack asc, key_id asc, value asc; 56 | 57 | create view view_shader_key_counts as 58 | select row_number() over (order by shader_pack asc, key_id asc, ct desc) as id, * from (select shader_pack, key_id, name, value, count(*) as ct from materials m left 59 | join shader_keys sc on sc.db_key = m.db_key 60 | where sc.db_key is not null 61 | group by shader_pack, key_id, sc.value 62 | order by shader_pack asc, key_id asc, ct desc); 63 | 64 | create view view_shader_key_defaults as 65 | select * from 66 | view_shader_key_counts a 67 | inner join ( 68 | select id, max(ct) 69 | from view_shader_key_counts 70 | group by shader_pack, key_id 71 | ) b on a.id = b.id; 72 | 73 | create view view_shader_constant_counts as 74 | select row_number() over (order by shader_pack asc, constant_id asc, ct desc) as id, * from (select shader_pack, constant_id, name, sc.length, sc.value0, sc.value1, sc.value2, sc.value3, count(*) as ct from materials m left 75 | join shader_constants sc on sc.db_key = m.db_key 76 | where sc.db_key is not null 77 | group by shader_pack, constant_id, sc.value0, sc.value1, sc.value2, sc.value3 78 | order by shader_pack asc, constant_id asc, ct desc); 79 | 80 | create view view_shader_constant_defaults as 81 | select * from 82 | view_shader_constant_counts a 83 | inner join ( 84 | select id, max(ct) 85 | from view_shader_constant_counts 86 | group by shader_pack, constant_id 87 | ) b on a.id = b.id; -------------------------------------------------------------------------------- /xivModdingFramework/Resources/SQL/ShrinkShaderCache.sql: -------------------------------------------------------------------------------- 1 | -- Create hard table clones 2 | CREATE TABLE view_shader_constant_defaults2 AS 3 | SELECT * 4 | FROM view_shader_constant_defaults; 5 | 6 | CREATE TABLE view_shader_keys_reference2 AS 7 | SELECT * 8 | FROM view_shader_keys_reference; 9 | 10 | CREATE TABLE view_shader_key_defaults2 AS 11 | SELECT * 12 | FROM view_shader_key_defaults; 13 | 14 | 15 | -- Drop views and data tables 16 | DROP VIEW view_shader_constant_defaults; 17 | DROP VIEW view_shader_keys_reference; 18 | DROP VIEW view_shader_key_defaults; 19 | DROP VIEW view_shader_constant_counts; 20 | DROP VIEW view_shader_key_counts; 21 | DROP TABLE materials; 22 | DROP TABLE textures; 23 | DROP TABLE shader_constants; 24 | DROP TABLE shader_keys; 25 | 26 | -- Rename 27 | ALTER TABLE view_shader_constant_defaults2 RENAME TO view_shader_constant_defaults; 28 | ALTER TABLE view_shader_keys_reference2 RENAME TO view_shader_keys_reference; 29 | ALTER TABLE view_shader_key_defaults2 RENAME TO view_shader_key_defaults; 30 | 31 | -------------------------------------------------------------------------------- /xivModdingFramework/Resources/ShaderKeys.json: -------------------------------------------------------------------------------- 1 | { 2 | "bg": { 3 | "1330578998": [ 4 | 2087690331, 5 | 2087690331, 6 | 3180618906 7 | ], 8 | "3054951514": [ 9 | 1721386267, 10 | 1721386267, 11 | 502437980, 12 | 2484609214 13 | ], 14 | "2846092837": [ 15 | 1561618979, 16 | 1561618979, 17 | 1923787182 18 | ] 19 | }, 20 | "character": { 21 | "3054951514": [ 22 | 1556481461, 23 | 1556481461, 24 | 1611594207, 25 | 581216959 26 | ], 27 | "4113354501": [ 28 | 3756477356, 29 | 3756477356, 30 | 2815623008 31 | ], 32 | "3531043187": [ 33 | 1111668802, 34 | 1111668802, 35 | 4083110193, 36 | 1480746461 37 | ], 38 | "3367837167": [ 39 | 428675533, 40 | 428675533, 41 | 2687453224 42 | ] 43 | }, 44 | "bguvscroll": { 45 | "3054951514": [ 46 | 1721386267, 47 | 1721386267, 48 | 3835352875 49 | ], 50 | "2846092837": [ 51 | 1561618979, 52 | 1561618979, 53 | 1923787182 54 | ] 55 | }, 56 | "iris": { 57 | "4113354501": [ 58 | 3756477356, 59 | 3756477356 60 | ] 61 | }, 62 | "skin": { 63 | "4113354501": [ 64 | 3756477356, 65 | 2815623008 66 | ], 67 | "940355280": [ 68 | 4117181732, 69 | 4117181732, 70 | 735790577, 71 | 1476344676 72 | ] 73 | }, 74 | "characterglass": { 75 | "4113354501": [ 76 | 3756477356, 77 | 3756477356 78 | ] 79 | }, 80 | "hair": { 81 | "4113354501": [ 82 | 3756477356, 83 | 3756477356 84 | ], 85 | "612525193": [ 86 | 4156069230, 87 | 4156069230, 88 | 1851494160 89 | ] 90 | }, 91 | "lightshaft": { 92 | "229123851": [ 93 | 2969977091, 94 | 2969977091, 95 | 3321983381 96 | ] 97 | }, 98 | "river": { 99 | "3762391338": [ 100 | 854610787, 101 | 854610787, 102 | 652478584 103 | ], 104 | "4176438622": [ 105 | 2259818435, 106 | 2259818435, 107 | 138432195, 108 | 3869682983 109 | ] 110 | }, 111 | "water": { 112 | "4176438622": [ 113 | 2259818435, 114 | 2259818435, 115 | 138432195, 116 | 3869682983 117 | ], 118 | "681055795": [ 119 | 684799985, 120 | 684799985, 121 | 3713329004 122 | ], 123 | "4219131364": [ 124 | 247731022, 125 | 247731022, 126 | 289469532 127 | ], 128 | "3048326218": [ 129 | 1265896194, 130 | 1265896194, 131 | 2186107714 132 | ] 133 | } 134 | } -------------------------------------------------------------------------------- /xivModdingFramework/SqPack/DataContainers/TransactionIndexFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using xivModdingFramework.General.Enums; 6 | using xivModdingFramework.Mods; 7 | 8 | namespace xivModdingFramework.SqPack.DataContainers 9 | { 10 | /// 11 | /// Wrapped Index File class that notifies the active global transaction whenever the index is updated. 12 | /// 13 | internal class TransactionIndexFile : IndexFile 14 | { 15 | public TransactionIndexFile(XivDataFile dataFile, BinaryReader index1Stream, BinaryReader index2Stream, bool readOnly = true) : base(dataFile, index1Stream, index2Stream, readOnly) 16 | { 17 | } 18 | 19 | protected override uint INTERNAL_SetDataOffset(string filePath, uint newRawOffsetWithDatNumEmbed, bool allowRepair = false) 20 | { 21 | // Loop back to notify the Transaction of our changes. 22 | var tx = ModTransaction.ActiveTransaction; 23 | if(tx != null && tx.State == ETransactionState.Closed) 24 | { 25 | throw new AccessViolationException("Cannot read data from a closed transaction."); 26 | } 27 | 28 | 29 | var originalOffset = Get8xDataOffset(filePath); 30 | if(tx != null && originalOffset != newRawOffsetWithDatNumEmbed) 31 | { 32 | tx.INTERNAL_OnIndexUpdate(DataFile, filePath, originalOffset, newRawOffsetWithDatNumEmbed * 8L); 33 | } 34 | 35 | var ret = base.INTERNAL_SetDataOffset(filePath, newRawOffsetWithDatNumEmbed, allowRepair); 36 | if (tx != null && originalOffset != newRawOffsetWithDatNumEmbed) 37 | { 38 | tx.INTERNAL_OnFileChanged(filePath, newRawOffsetWithDatNumEmbed * 8L, true); 39 | } 40 | return ret; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /xivModdingFramework/Textures/DataContainers/TexTypePath.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using xivModdingFramework.General.Enums; 18 | using xivModdingFramework.Textures.Enums; 19 | 20 | namespace xivModdingFramework.Textures.DataContainers 21 | { 22 | /// 23 | /// This class contains a textures Type, Path, and DataFile it is contained in 24 | /// 25 | public class TexTypePath 26 | { 27 | /// 28 | /// The Type of a Texture 29 | /// 30 | public XivTexType Type { get; set; } 31 | 32 | /// 33 | /// The Textures internal path 34 | /// 35 | public string Path { get; set; } 36 | 37 | /// 38 | /// The data file in which the texture is contained 39 | /// 40 | public XivDataFile DataFile { get; set; } 41 | 42 | /// 43 | /// The name of the texture if different from XivTexType 44 | /// 45 | public string Name { get; set; } 46 | } 47 | } -------------------------------------------------------------------------------- /xivModdingFramework/Textures/Enums/XivTexFormat.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System; 18 | using System.ComponentModel; 19 | 20 | namespace xivModdingFramework.Textures.Enums 21 | { 22 | /// 23 | /// Enum containing the known Texture Formats and their associated code 24 | /// 25 | public enum XivTexFormat 26 | { 27 | // WHY ARE THESE STRINGS? 28 | [XivTexFormatDescription("4400", "8L")] L8 = 4400, 29 | [XivTexFormatDescription("4401", "8A")] A8 = 4401, 30 | [XivTexFormatDescription("5184", "4.4.4.4 RGB")] A4R4G4B4 = 5184, 31 | [XivTexFormatDescription("5185", "1.5.5.5 ARGB")] A1R5G5B5 = 5185, 32 | [XivTexFormatDescription("5200", "8.8.8.8 ARGB")] A8R8G8B8 = 5200, 33 | [XivTexFormatDescription("5201", "X.8.8.8 XRGB")] X8R8G8B8 = 5201, 34 | [XivTexFormatDescription("8528", "32f R")] R32F = 8528, 35 | [XivTexFormatDescription("8784", "16.16f GR")] G16R16F = 8784, 36 | [XivTexFormatDescription("8800", "32.32f GR")] G32R32F = 8800, 37 | [XivTexFormatDescription("9312", "16.16.16.16f ABGR")] A16B16G16R16F = 9312, 38 | [XivTexFormatDescription("9328", "32.32.32.32f ABGR")] A32B32G32R32F = 9328, 39 | [XivTexFormatDescription("13344", "DXT1 RGB")] DXT1 = 13344, 40 | [XivTexFormatDescription("13360", "DXT3 ARGB")] DXT3 = 13360, 41 | [XivTexFormatDescription("13361", "DXT5 ARGB")] DXT5 = 13361, 42 | [XivTexFormatDescription("16704", "D16")] D16 = 16704, 43 | [XivTexFormatDescription("24864", "BC4")] BC4 = 24864, 44 | [XivTexFormatDescription("25136", "BC5")] BC5 = 25136, 45 | [XivTexFormatDescription("25650", "BC7")] BC7 = 25650, 46 | [XivTexFormatDescription("0", "INVALID")] INVALID = 0, 47 | } 48 | 49 | /// 50 | /// Class used to get the description from the enum value 51 | /// 52 | public static class XivTexFormats 53 | { 54 | /// 55 | /// Gets the description from the enum value, in this case the Texture Code 56 | /// 57 | /// The enum value 58 | /// The Texture Code 59 | public static string GetTexFormatCode(this XivTexFormat value) 60 | { 61 | var field = value.GetType().GetField(value.ToString()); 62 | var attribute = (XivTexFormatDescriptionAttribute[])field.GetCustomAttributes(typeof(XivTexFormatDescriptionAttribute), false); 63 | return attribute.Length > 0 ? attribute[0].TexCode : value.ToString(); 64 | } 65 | 66 | /// 67 | /// Gets the description from the enum value, in this case the Texture Code 68 | /// 69 | /// The enum value 70 | /// The Texture Code 71 | public static string GetTexDisplayName(this XivTexFormat value) 72 | { 73 | var field = value.GetType().GetField(value.ToString()); 74 | var attribute = (XivTexFormatDescriptionAttribute[])field.GetCustomAttributes(typeof(XivTexFormatDescriptionAttribute), false); 75 | return attribute.Length > 0 ? attribute[0].DisplayName : value.ToString(); 76 | } 77 | } 78 | 79 | [AttributeUsage(AttributeTargets.All)] 80 | public class XivTexFormatDescriptionAttribute : DescriptionAttribute 81 | { 82 | public XivTexFormatDescriptionAttribute(string texCode, string displayName) 83 | { 84 | this.TexCode = texCode; 85 | this.DisplayName = displayName; 86 | } 87 | 88 | public string TexCode { get; set; } 89 | public string DisplayName { get; set; } 90 | } 91 | } -------------------------------------------------------------------------------- /xivModdingFramework/Textures/Enums/XivTexType.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | namespace xivModdingFramework.Textures.Enums 18 | { 19 | /// 20 | /// Enum containing the Types of Textures 21 | /// 22 | public enum XivTexType 23 | { 24 | Diffuse, 25 | Specular, 26 | Normal, 27 | Mask, 28 | Reflection, 29 | Skin, 30 | ColorSet, 31 | Index, 32 | Map, 33 | Icon, 34 | Vfx, 35 | UI, 36 | Decal, 37 | 38 | // Legacy Unused DX9 Textures 39 | DX9, 40 | 41 | Other 42 | } 43 | } -------------------------------------------------------------------------------- /xivModdingFramework/VFX/FileTypes/Avfx.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using System.Collections.Generic; 18 | using System.IO; 19 | using System.Text; 20 | using System.Threading.Tasks; 21 | using xivModdingFramework.General.Enums; 22 | using xivModdingFramework.Mods; 23 | using xivModdingFramework.SqPack.FileTypes; 24 | 25 | namespace xivModdingFramework.VFX.FileTypes 26 | { 27 | public static class Avfx 28 | { 29 | 30 | /// 31 | /// Gets the .atex paths that are within the .avfx file 32 | /// 33 | /// The offset to the avfx file 34 | /// A list of atex paths 35 | public static async Task> GetATexPaths(string path, bool forceOriginal = false, ModTransaction tx = null) 36 | { 37 | var atexList = new List(); 38 | 39 | 40 | var avfxData = await Dat.ReadFile(path, forceOriginal, tx); 41 | 42 | await Task.Run(() => 43 | { 44 | using (var br = new BinaryReader(new MemoryStream(avfxData))) 45 | { 46 | var data = br.ReadInt32(); 47 | 48 | // Advance to the path data header 49 | while (data != 5531000) 50 | { 51 | try 52 | { 53 | data = br.ReadInt32(); 54 | } 55 | catch (EndOfStreamException) 56 | { 57 | return; 58 | } 59 | } 60 | 61 | // While the data is a path data header 62 | while (data == 5531000) 63 | { 64 | var pathLength = br.ReadInt32(); 65 | 66 | atexList.Add(Encoding.UTF8.GetString(br.ReadBytes(pathLength)).Replace("\0", "")); 67 | 68 | try 69 | { 70 | byte ch = 0; 71 | 72 | // Read until a byte of 120 or end of stream...? 73 | var read = 0; 74 | while(ch != 120) 75 | { 76 | if(br.BaseStream.Length == br.BaseStream.Position + 1) 77 | { 78 | // End of Stream. 79 | break; 80 | } 81 | 82 | if(ch != 0) 83 | { 84 | // End of block. 85 | break; 86 | } 87 | read++; 88 | ch = br.ReadByte(); 89 | } 90 | br.BaseStream.Seek(-1, SeekOrigin.Current); 91 | data = br.ReadInt32(); 92 | } 93 | catch 94 | { 95 | break; 96 | } 97 | 98 | } 99 | } 100 | }); 101 | 102 | return atexList; 103 | } 104 | } 105 | } -------------------------------------------------------------------------------- /xivModdingFramework/Variants/DataContainers/XivImc.cs: -------------------------------------------------------------------------------- 1 | // xivModdingFramework 2 | // Copyright © 2018 Rafael Gonzalez - All Rights Reserved 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | using HelixToolkit.SharpDX.Core; 18 | using System; 19 | using System.Collections.Generic; 20 | using System.Linq; 21 | using xivModdingFramework.Helpers; 22 | using xivModdingFramework.Variants.FileTypes; 23 | 24 | namespace xivModdingFramework.Variants.DataContainers 25 | { 26 | /// 27 | /// The IMC information for a Specific Variant of a Specific Slot in a Gear Set. 28 | /// 29 | public class XivImc : ICloneable 30 | { 31 | /// 32 | /// The Material Set / Variant # 33 | /// 34 | public byte MaterialSet { get; set; } 35 | 36 | /// 37 | /// Unknown byte next to the Variant 38 | /// 39 | public byte Decal { get; set; } 40 | 41 | /// 42 | /// The IMC mask data 43 | /// 44 | /// 45 | /// This is used with a models mesh part mask data 46 | /// It is used to determine what parts of the mesh are hidden 47 | /// 48 | public ushort Mask { get; set; } 49 | 50 | public ushort AttributeMask 51 | { 52 | get 53 | { 54 | return (ushort)(Mask & (ushort)0x3FF); 55 | } 56 | set 57 | { 58 | value &= (ushort)0x3FF; 59 | int mask = ~0x3FF; 60 | Mask &= (ushort)mask; 61 | Mask |= value; 62 | } 63 | } 64 | 65 | public byte SoundId 66 | { 67 | get 68 | { 69 | var val = Mask >> 10; 70 | return (byte)val; 71 | } 72 | set 73 | { 74 | var val = value << 10; 75 | var mask = ~(0x3F << 10); 76 | Mask &= (ushort)mask; 77 | Mask |= (ushort)val; 78 | } 79 | } 80 | 81 | /// 82 | /// The IMC VFX data 83 | /// 84 | /// 85 | /// Only a few items have VFX data associated with them 86 | /// Some examples would be any of the Lux weapons 87 | /// 88 | public byte Vfx { get; set; } 89 | 90 | /// 91 | /// Material animation byte 92 | /// 93 | public byte Animation { get; set; } 94 | 95 | /// 96 | /// Returns the raw bytes that make up this IMC entry. 97 | /// 98 | /// 99 | public byte[] GetBytes(ImcType type) 100 | { 101 | var bytes = new List(); 102 | bytes.Add(MaterialSet); 103 | bytes.Add(Decal); 104 | bytes.AddRange(BitConverter.GetBytes(Mask)); 105 | bytes.Add(Vfx); 106 | bytes.Add(Animation); 107 | return bytes.ToArray(); 108 | } 109 | 110 | /// 111 | /// Shows a given attribute part 112 | /// 113 | /// 114 | public void ShowPart(char part) 115 | { 116 | var index = Helpers.Constants.Alphabet.ToList().IndexOf(part); 117 | if(index < 0 || index > 9) 118 | { 119 | throw new NotSupportedException("Invalid IMC Part Letter."); 120 | } 121 | 122 | var bit = 1; 123 | for(var i = 0; i < index; i++) 124 | { 125 | bit = bit << 1; 126 | } 127 | 128 | Mask = (ushort)(Mask | bit); 129 | } 130 | 131 | /// 132 | /// Hides a given attribute part 133 | /// 134 | /// 135 | public void HidePart(char part) 136 | { 137 | var index = Helpers.Constants.Alphabet.ToList().IndexOf(part); 138 | if (index < 0 || index > 9) 139 | { 140 | throw new NotSupportedException("Invalid IMC Part Letter."); 141 | } 142 | 143 | var bit = 1; 144 | for (var i = 0; i < index; i++) 145 | { 146 | bit = bit << 1; 147 | } 148 | 149 | Mask = (ushort)(Mask & (~bit)); 150 | 151 | } 152 | 153 | public object Clone() 154 | { 155 | return this.MemberwiseClone(); 156 | } 157 | 158 | } 159 | } 160 | --------------------------------------------------------------------------------