Update API 9 and add data to items.

This commit is contained in:
Ottermandias 2023-10-02 16:56:24 +02:00
parent c98ed04bf3
commit cb0da11529
62 changed files with 524 additions and 268 deletions

View file

@ -20,7 +20,7 @@ internal class CmpFile
public bool Valid
=> _file != null;
public CmpFile(IDataManager gameData)
public CmpFile(IDataManager gameData, IPluginLog log)
{
try
{
@ -36,7 +36,7 @@ internal class CmpFile
}
catch (Exception e)
{
PluginLog.Error("READ THIS\n======== Could not obtain the human.cmp file which is necessary for color sets.\n"
log.Error("READ THIS\n======== Could not obtain the human.cmp file which is necessary for color sets.\n"
+ "======== This usually indicates an error with your index files caused by TexTools modifications.\n"
+ "======== If you have used TexTools before, you will probably need to start over in it to use Glamourer.", e);
_file = null;

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Dalamud.Interface.Internal;
using Dalamud.Plugin.Services;
using Penumbra.GameData.Enums;
@ -11,9 +12,9 @@ public class CustomizationManager : ICustomizationManager
private CustomizationManager()
{ }
public static ICustomizationManager Create(ITextureProvider textures, IDataManager gameData)
public static ICustomizationManager Create(ITextureProvider textures, IDataManager gameData, IPluginLog log)
{
_options ??= new CustomizationOptions(textures, gameData);
_options ??= new CustomizationOptions(textures, gameData, log);
return new CustomizationManager();
}
@ -29,7 +30,7 @@ public class CustomizationManager : ICustomizationManager
public CustomizationSet GetList(SubRace clan, Gender gender)
=> _options!.GetList(clan, gender);
public ImGuiScene.TextureWrap GetIcon(uint iconId)
public IDalamudTextureWrap GetIcon(uint iconId)
=> _options!.GetIcon(iconId);
public string GetName(CustomName name)

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Dalamud;
using Dalamud.Interface.Internal;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Lumina.Excel;
@ -34,7 +35,7 @@ public partial class CustomizationOptions
=> _customizationSets[ToIndex(race, gender)];
// Get specific icons.
internal ImGuiScene.TextureWrap GetIcon(uint id)
internal IDalamudTextureWrap GetIcon(uint id)
=> _icons.LoadIcon(id)!;
private readonly IconStorage _icons;
@ -61,9 +62,9 @@ public partial class CustomizationOptions
public string GetName(CustomName name)
=> _names[(int)name];
internal CustomizationOptions(ITextureProvider textures, IDataManager gameData)
internal CustomizationOptions(ITextureProvider textures, IDataManager gameData, IPluginLog log)
{
var tmp = new TemporaryData(gameData, this);
var tmp = new TemporaryData(gameData, this, log);
_icons = new IconStorage(textures, gameData);
SetNames(gameData, tmp);
foreach (var race in Clans)
@ -179,10 +180,10 @@ public partial class CustomizationOptions
}
public TemporaryData(IDataManager gameData, CustomizationOptions options)
public TemporaryData(IDataManager gameData, CustomizationOptions options, IPluginLog log)
{
_options = options;
_cmpFile = new CmpFile(gameData);
_cmpFile = new CmpFile(gameData, log);
_customizeSheet = gameData.GetExcelSheet<CharaMakeCustomize>()!;
_bnpcCustomize = gameData.GetExcelSheet<BNpcCustomize>()!;
_enpcBase = gameData.GetExcelSheet<ENpcBase>()!;

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Dalamud.Interface.Internal;
using Penumbra.GameData.Enums;
namespace Glamourer.Customization;
@ -11,6 +12,6 @@ public interface ICustomizationManager
public CustomizationSet GetList(SubRace race, Gender gender);
public ImGuiScene.TextureWrap GetIcon(uint iconId);
public string GetName(CustomName name);
public IDalamudTextureWrap GetIcon(uint iconId);
public string GetName(CustomName name);
}

View file

@ -9,8 +9,9 @@ namespace Glamourer;
public static class GameData
{
private static Dictionary<byte, Job>? _jobs;
private static Dictionary<ushort, JobGroup>? _jobGroups;
private static Dictionary<byte, Job>? _jobs;
private static Dictionary<ushort, JobGroup>? _jobGroups;
private static JobGroup[]? _allJobGroups;
public static IReadOnlyDictionary<byte, Job> Jobs(IDataManager dataManager)
{
@ -22,14 +23,22 @@ public static class GameData
return _jobs;
}
public static IReadOnlyList<JobGroup> AllJobGroups(IDataManager dataManager)
{
if (_allJobGroups != null)
return _allJobGroups;
var sheet = dataManager.GetExcelSheet<ClassJobCategory>()!;
var jobs = dataManager.GetExcelSheet<ClassJob>(ClientLanguage.English)!;
_allJobGroups = sheet.Select(j => new JobGroup(j, jobs)).ToArray();
return _allJobGroups;
}
public static IReadOnlyDictionary<ushort, JobGroup> JobGroups(IDataManager dataManager)
{
if (_jobGroups != null)
return _jobGroups;
var sheet = dataManager.GetExcelSheet<ClassJobCategory>()!;
var jobs = dataManager.GetExcelSheet<ClassJob>(ClientLanguage.English)!;
static bool ValidIndex(uint idx)
{
if (idx is > 0 and < 36)
@ -68,12 +77,12 @@ public static class GameData
69 => true,
68 => true,
93 => true,
_ => false,
_ => false,
};
}
_jobGroups = sheet.Where(j => ValidIndex(j.RowId))
.ToDictionary(j => (ushort)j.RowId, j => new JobGroup(j, jobs));
_jobGroups = AllJobGroups(dataManager).Where(j => ValidIndex(j.Id))
.ToDictionary(j => (ushort) j.Id, j => j);
return _jobGroups;
}
}

View file

@ -7,17 +7,20 @@ namespace Glamourer.Structs;
// Also contains the jobs Name and Abbreviation as strings.
public readonly struct Job
{
public readonly string Name;
public readonly string Abbreviation;
public readonly string Name;
public readonly string Abbreviation;
public readonly ClassJob Base;
public uint Id
=> Base.RowId;
public JobFlag Flag
=> (JobFlag)(1u << (int)Base.RowId);
public Job(ClassJob job)
{
Base = job;
Name = job.Name.ToDalamudString().ToString();
Base = job;
Name = job.Name.ToDalamudString().ToString();
Abbreviation = job.Abbreviation.ToDalamudString().ToString();
}

View file

@ -1,16 +1,21 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using Lumina.Excel;
using Lumina.Excel.GeneratedSheets;
namespace Glamourer.Structs;
[Flags]
public enum JobFlag : ulong
{ }
// The game specifies different job groups that can contain specific jobs or not.
public readonly struct JobGroup
{
public readonly string Name;
public readonly int Count;
public readonly uint Id;
private readonly ulong _flags;
public readonly string Name;
public readonly int Count;
public readonly uint Id;
private readonly JobFlag _flags;
// Create a job group from a given category and the ClassJob sheet.
// It looks up the different jobs contained in the category and sets the flags appropriately.
@ -35,18 +40,22 @@ public readonly struct JobGroup
continue;
++Count;
_flags |= 1ul << (int)job.RowId;
_flags |= (JobFlag)(1ul << (int)job.RowId);
}
}
// Check if a job is contained inside this group.
public bool Fits(Job job)
=> Fits(job.Id);
=> _flags.HasFlag(job.Flag);
// Check if any of the jobs in the given flags fit this group.
public bool Fits(JobFlag flag)
=> (_flags & flag) != 0;
// Check if a job is contained inside this group.
public bool Fits(uint jobId)
{
var flag = 1ul << (int)jobId;
return (flag & _flags) != 0;
var flag = (JobFlag)(1ul << (int)jobId);
return _flags.HasFlag(flag);
}
}