migrate to GameConfig & cleanup warnings

This commit is contained in:
2023-09-24 17:13:41 +02:00
parent cc1bdc7e08
commit 30794201f0
10 changed files with 19 additions and 43 deletions

View File

@@ -26,6 +26,7 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
RESX_ShowErrorsInErrorList = False
SolutionGuid = {B17E85B1-5F60-4440-9F9A-3DDE877E8CDF}
EndGlobalSection
EndGlobal

View File

@@ -30,45 +30,19 @@ namespace PlayerTags.Configuration.GameConfig
}
}
private int? GetIntValue(ConfigOption option)
private uint? GetIntValue(ConfigOption option)
{
int? value = null;
unsafe
{
var index = configModule->GetIndex(option);
if (index.HasValue)
value = configModule->GetIntValue(index.Value);
}
return value;
if (PluginServices.GameConfig.UiConfig.TryGetUInt(nameof(ConfigOption.LogNameType), out var value))
return value;
return null;
}
public LogNameType? GetLogNameType()
{
LogNameType? logNameType = null;
int? value = GetIntValue(ConfigOption.LogNameType);
if (value.HasValue)
{
switch (value)
{
case 0:
logNameType = LogNameType.FullName;
break;
case 1:
logNameType = LogNameType.LastNameShorted;
break;
case 2:
logNameType = LogNameType.FirstNameShorted;
break;
case 3:
logNameType = LogNameType.Initials;
break;
}
}
return logNameType;
uint? value = GetIntValue(ConfigOption.LogNameType);
if (value != null)
return (LogNameType)value;
return null;
}
}
}

View File

@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace PlayerTags.Configuration.GameConfig
{
public enum LogNameType
public enum LogNameType : uint
{
FullName,
LastNameShorted,

View File

@@ -803,7 +803,7 @@ namespace PlayerTags.Configuration
}
else
{
PluginLog.Warning($"Rendering for inheritable option not implemented: {selectedInheritable.Inheritable.Key}");
PluginServices.PluginLog.Warning($"Rendering for inheritable option not implemented: {selectedInheritable.Inheritable.Key}");
}
}
}

View File

@@ -58,7 +58,7 @@ namespace PlayerTags.GameInterface.Nameplates
}
catch (Exception ex)
{
PluginLog.Error(ex, $"SetPlayerNameplateDetour");
PluginServices.PluginLog.Error(ex, $"SetPlayerNameplateDetour");
}
}
}

View File

@@ -68,7 +68,7 @@ namespace PlayerTags.Inheritables
else if (inheritableData.Value == null)
{
// This should never happen
PluginLog.Error($"Expected value of type {Value.GetType()} but received null");
PluginServices.PluginLog.Error($"Expected value of type {Value.GetType()} but received null");
}
else if (typeof(T) == typeof(Guid) && inheritableData.Value is string strValue)
{
@@ -81,7 +81,7 @@ namespace PlayerTags.Inheritables
}
catch (Exception ex)
{
PluginLog.Error(ex, $"Failed to convert {inheritableData.Value.GetType()} value '{inheritableData.Value}' to {Value.GetType()}");
PluginServices.PluginLog.Error(ex, $"Failed to convert {inheritableData.Value.GetType()} value '{inheritableData.Value}' to {Value.GetType()}");
}
}

View File

@@ -55,7 +55,7 @@ namespace PlayerTags
if (value != null)
return value;
PluginLog.Error($"Failed to get localized string for id {localizedStringId}");
PluginServices.PluginLog.Error($"Failed to get localized string for id {localizedStringId}");
return localizedStringId;
}
}

View File

@@ -26,7 +26,6 @@ namespace PlayerTags
private PluginConfiguration pluginConfiguration = null;
private PluginData pluginData = null;
private PluginConfigurationUI pluginConfigurationUI = null;
private DalamudPluginInterface pluginInterface = null;
private CustomTagsContextMenuFeature customTagsContextMenuFeature;
private NameplateTagTargetFeature nameplatesTagTargetFeature;

View File

@@ -14,6 +14,8 @@ namespace PlayerTags
public class PluginServices
{
[PluginService] public static DalamudPluginInterface DalamudPluginInterface { get; set; } = null!;
[PluginService] public static IPluginLog PluginLog { get; set; } = null;
[PluginService] public static IGameConfig GameConfig { get; set; } = null;
[PluginService] public static IChatGui ChatGui { get; set; } = null!;
[PluginService] public static IClientState ClientState { get; set; } = null!;
[PluginService] public static ICommandManager CommandManager { get; set; } = null!;

View File

@@ -24,7 +24,7 @@ namespace PlayerTags
}
catch (Exception ex)
{
PluginLog.Error(ex, $"RandomNameGenerator failed to read adjectives");
PluginServices.PluginLog.Error(ex, $"RandomNameGenerator failed to read adjectives");
}
}
@@ -50,7 +50,7 @@ namespace PlayerTags
}
catch (Exception ex)
{
PluginLog.Error(ex, $"RandomNameGenerator failed to read nouns");
PluginServices.PluginLog.Error(ex, $"RandomNameGenerator failed to read nouns");
}
}