Skip to content

Commit

Permalink
[TEST] New Build
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
wolfcomp authored Mar 26, 2024
2 parents 76c4b32 + 34f127b commit 3788db5
Show file tree
Hide file tree
Showing 22 changed files with 604 additions and 149 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "DeepDungeonDexConsole/data"]
path = DeepDungeonDexConsole/data
url = https://github.com/wolfcomp/DeepDungeonDex.git
url = https://github.com/wolfcomp/MonsterDex.git
branch = data
13 changes: 8 additions & 5 deletions DeepDungeonDex/DeepDungeonDex.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"Author": "WildWolf",
"Name": "DeepDungeonDex",
"Punchline": "Live monster data for Deep Dungeons.",
"Description": "A live bestiary for Deep Dungeon.\nShows target mob aggro type, a subjective threat level, status vulnerabilities, and a general overview of notable mechanics.\nThreat level is meant to be taken with a grain of salt, is aimed towards solo players, and assumes a general familiarity with deep dungeon mechanics and the class being played.\nInformation is accurate to the best of my knowledge based on crowdsourced information, but I could use your help! Please open an issue on the GitHub if you'd like to correct inaccurate or untested data.\nOriginal by Strati",
"Name": "MonsterDex",
"Punchline": "Live monster data.",
"Description": "A live bestiary.\nShows target mob aggro type, a subjective threat level, status vulnerabilities, and a general overview of notable mechanics.\nThreat level is meant to be taken with a grain of salt, is aimed towards solo players, and assumes a general familiarity with deep dungeon mechanics and the class being played.\nInformation is accurate to the best of my knowledge based on crowdsourced information, but I could use your help! Please open an issue on the GitHub if you'd like to correct inaccurate or untested data.\nOriginally DeepDungeonDex",
"Tags": [
"deep dungeon",
"achievements",
"battle"
"battle",
"combat",
"monsters",
"enemies"
],
"Changelog": "",
"RepoUrl": "https://github.com/wolfcomp/DeepDungeonDex",
"RepoUrl": "https://github.com/wolfcomp/MonsterDex",
"ApplicableVersion": "any",
"LoadPriority": 0,
"AcceptsFeedback": false
Expand Down
47 changes: 34 additions & 13 deletions DeepDungeonDex/Hooks/AddonAgent.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
using FFXIVClientStructs.FFXIV.Client.Game.Event;
using System.Runtime.InteropServices;
using FFXIVClientStructs.FFXIV.Client.Game.InstanceContent;
using FFXIVClientStructs.FFXIV.Client.Graphics.Environment;

namespace DeepDungeonDex.Hooks;

public unsafe class AddonAgent : IDisposable
{
private IFramework _framework;
private IPluginLog _log;
private EventFramework* _structsFramework;
private EventFramework* _eventFramework;
private EnvManager* _envManager;
public byte Floor { get; private set; }
public bool Disabled { get; private set; }
public bool DirectorDisabled { get; private set; }
public ContentType ContentType { get; private set; }
public Action<ContentType> ContentTypeUpdated { get; set; }
public byte Weather { get; private set; }
public byte[] WeatherIds { get; private set; } = new byte[32];

public AddonAgent(IFramework framework, IPluginLog log)
{
Expand All @@ -23,13 +26,33 @@ public AddonAgent(IFramework framework, IPluginLog log)

private void OnUpdate(IFramework framework)
{
_structsFramework = EventFramework.Instance();
_eventFramework = EventFramework.Instance();
_envManager = EnvManager.Instance();
if (!DirectorDisabled)
CheckDirector();
CheckWeather();
}

private void CheckWeather()
{
if (_envManager == null)
return;

Weather = _envManager->ActiveWeather;
if(_envManager->EnvScene == null)
return;

_envManager->EnvScene->WeatherIdsSpan.CopyTo(WeatherIds);
}

private void CheckDirector()
{
try
{
if (!IsContentSafe())
return;

var activeInstance = _structsFramework->GetInstanceContentDirector();
var activeInstance = _eventFramework->GetInstanceContentDirector();

if (activeInstance != null)
{
Expand All @@ -41,7 +64,7 @@ private void OnUpdate(IFramework framework)
}
else
{
var activePublic = (PublicContentDirectorResearch*)_structsFramework->GetPublicContentDirector();
var activePublic = (PublicContentDirectorResearch*)_eventFramework->GetPublicContentDirector();
if (activePublic != null)
{
ContentType = (ContentType)(1 << (int)(activePublic->PublicContentDirectorType + 19));
Expand All @@ -51,7 +74,6 @@ private void OnUpdate(IFramework framework)
ContentType = ContentType.None;
}
}
ContentTypeUpdated?.Invoke(ContentType);
}
catch (Exception e)
{
Expand All @@ -62,7 +84,7 @@ private void OnUpdate(IFramework framework)

private bool IsContentSafe()
{
var contentDirector = _structsFramework->GetContentDirector();
var contentDirector = _eventFramework->GetContentDirector();

if ((IntPtr)contentDirector == IntPtr.Zero)
return false;
Expand All @@ -74,19 +96,18 @@ private bool IsContentSafe()

public void Restart()
{
if (!Disabled)
if (!DirectorDisabled)
return;
Disabled = false;
_framework.Update += OnUpdate;
DirectorDisabled = false;
}

public void Dispose(bool disposing)
{
_framework.Update -= OnUpdate;
Disabled = true;
DirectorDisabled = true;
if (!disposing)
return;

_framework.Update -= OnUpdate;
_framework = null!;
_log = null!;
}
Expand Down
3 changes: 3 additions & 0 deletions DeepDungeonDex/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Dalamud.Game.ClientState.Objects;
using Dalamud.IoC;
using DeepDungeonDex.Hooks;
using DeepDungeonDex.Weather;
using Microsoft.Extensions.DependencyInjection;

namespace DeepDungeonDex;
Expand Down Expand Up @@ -88,6 +89,7 @@ private static ServiceProvider BuildProvider(Main main, DalamudPluginInterface p
.AddDalamudService<IClientState>()
.AddDalamudService<IChatGui>()
.AddDalamudService<ITextureProvider>()
.AddDalamudService<IDataManager>()
.AddDalamudService<IPluginLog>()
.AddSingleton(new WindowSystem("DeepDungeonDex"))
.AddSingleton(main)
Expand All @@ -96,6 +98,7 @@ private static ServiceProvider BuildProvider(Main main, DalamudPluginInterface p
.AddSingleton(provider => ActivatorUtilities.CreateInstance<Font.Font>(provider))
.AddSingleton(provider => ActivatorUtilities.CreateInstance<CommandHandler>(provider))
.AddSingleton(provider => ActivatorUtilities.CreateInstance<AddonAgent>(provider))
.AddSingleton(provider => ActivatorUtilities.CreateInstance<WeatherManager>(provider))
.BuildServiceProvider();
}
}
Expand Down
4 changes: 3 additions & 1 deletion DeepDungeonDex/Models/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace DeepDungeonDex.Models;

public class Configuration
{
public byte Version { get; } = 2;
private const byte Version = 3;
public bool ClickThrough { get; set; }
public bool HideRed { get; set; }
public bool HideJob { get; set; }
Expand All @@ -15,6 +15,7 @@ public class Configuration
public int Locale { get; set; } = 0;
public int FontSize { get; set; } = 16;
public float Opacity { get; set; } = 1f;
public ContentType EnabledContentTypes { get; set; } = ContentType.DeepDungeon;

[JsonIgnore] public int PrevFontSize;
[JsonIgnore] public int PrevLocale;
Expand Down Expand Up @@ -50,6 +51,7 @@ public void Save(string path)
flags |= (byte)(Debug ? 1 << 4 : 0);
flags |= (byte)(LoadAll ? 1 << 5 : 0);
writer.Write(flags);
writer.Write((uint)EnabledContentTypes);
writer.Write(Locale);
writer.Write(FontSize);
writer.Write(Opacity);
Expand Down
11 changes: 10 additions & 1 deletion DeepDungeonDex/Requests/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ public partial class Requests : IDisposable
public bool RequestingData { get; private set; }
public bool RequestingLang { get; private set; }
public bool IsRequesting => RequestingData || RequestingLang;

#if RELEASE
private const bool Debug = false;
#else
private const bool Debug = true;
#endif

public Requests(StorageHandler handler, IPluginLog log)
{
Expand Down Expand Up @@ -72,6 +76,7 @@ public async Task RefreshFileList(bool continuous = true)
{
_log.Verbose($"Loading File: {file}");
var content = await Get(file);
_log.Verbose($"Content length from file: {content?.Length}");
if (string.IsNullOrWhiteSpace(content))
continue;
_log.Verbose("Creating instance");
Expand Down Expand Up @@ -107,6 +112,9 @@ public async Task RefreshFileList(bool continuous = true)

public async Task<string?> Get(string url)
{
#pragma warning disable CS0162 // Unreachable code detected
if (Debug)
return await GetFromFile(url);
try
{
_log.Verbose($"Requesting {BaseUrl}/{url}");
Expand All @@ -125,6 +133,7 @@ public async Task RefreshFileList(bool continuous = true)
_log.Error(e, "Trying to get file from precompiled data");
return !_loadedOnce ? await GetFromFile(url) : null;
}
#pragma warning restore CS0162 // Unreachable code detected
}

public void Dispose()
Expand Down
2 changes: 1 addition & 1 deletion DeepDungeonDex/Requests/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ChangeLanguage()
{
foreach (var path in files)
{
if (path == "Job.yml")
if (path == "Territories.yml")
continue;
_log.Verbose($"Loading {path}");
var mobData = Handler.GetInstance<MobData>(path);
Expand Down
21 changes: 19 additions & 2 deletions DeepDungeonDex/Storage/MobData.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using FFXIVClientStructs.FFXIV.Client.Game.Character;
using YamlDotNet.Serialization;

namespace DeepDungeonDex.Storage;
Expand Down Expand Up @@ -61,6 +62,10 @@ public string[][]? Description
public Aggro Aggro { get; set; }
public Threat Threat { get; set; }
public ContentType InstanceContentType { get; set; }
public Dictionary<uint, ElementalChangeTime> ElementalChangeTimes { get; set; } = new();
public Character.EurekaElement MutatedElementalType { get; set; }
public bool IsMutation { get; set; }
public bool IsAaptation { get; set; }

public void ProcessDescription(float width)
{
Expand All @@ -70,7 +75,7 @@ public void ProcessDescription(float width)
var s = "";
foreach (var t in t1)
{
if (ImGui.CalcTextSize(s + t).X < width)
if (ImGui.CalcTextSize(s + t + " ").X < width)
{
s += t + " ";
}
Expand Down Expand Up @@ -164,6 +169,15 @@ public enum ContentType : uint
FallGuys = 1 << 29,
}

[Flags]
public enum ElementalChangeTime : byte
{
None,
Night,
Day,
Both = Night | Day
}

public static class MobDataExtensions
{
public static Mob? GetData(this MobData data, uint key)
Expand All @@ -184,4 +198,7 @@ public static class MobDataExtensions
Threat.Vicious => 0xFFFF00FF,
_ => 0xFFFFFFFF
};
}

public static bool HasAnyFlag(this ContentType type, ContentType flag) => (type & flag) != 0;
}

Loading

0 comments on commit 3788db5

Please sign in to comment.