implement UI for default plugin data template

This commit is contained in:
2022-11-10 12:34:18 +01:00
parent 1d69893890
commit c8a3f752f4
4 changed files with 160 additions and 10 deletions

View File

@@ -107,6 +107,11 @@ namespace PlayerTags.Configuration
{
ImGui.Spacing();
ImGui.Spacing();
DrawComboBox(true, true, false, ref m_PluginConfiguration.DefaultPluginDataTemplate, () =>
{
m_PluginData.ReloadDefault();
SaveSettings();
}, true, true);
DrawCheckbox(nameof(m_PluginConfiguration.IsShowInheritedPropertiesEnabled), true, ref m_PluginConfiguration.IsShowInheritedPropertiesEnabled, () => SaveSettings());
ImGui.BeginGroup();
ImGui.Columns(2);
@@ -272,7 +277,7 @@ namespace PlayerTags.Configuration
m_PluginConfiguration.StatusIconPriorizerSettings.ResetToDefault();
SaveSettings();
}
else if (ImGui.IsItemHovered())
if (ImGui.IsItemHovered())
ImGui.SetTooltip(Strings.Loc_StatusIconPriorizer_ResetToDefault_Description);
ImGui.SameLine();
@@ -282,7 +287,7 @@ namespace PlayerTags.Configuration
m_PluginConfiguration.StatusIconPriorizerSettings.ResetToEmpty();
SaveSettings();
}
else if (ImGui.IsItemHovered())
if (ImGui.IsItemHovered())
ImGui.SetTooltip(Strings.Loc_StatusIconPriorizer_ResetToEmpty_Description);
ImGui.Spacing();
@@ -294,9 +299,6 @@ namespace PlayerTags.Configuration
{
var conditionSet = m_PluginConfiguration.StatusIconPriorizerSettings.GetConditionSet(conditionSetName);
if (ImGui.IsItemHovered())
ImGui.SetTooltip(Localizer.GetString(conditionSetName, true));
foreach (var statusIcon in statusIcons)
{
var isChecked = conditionSet.Contains(statusIcon);
@@ -314,6 +316,9 @@ namespace PlayerTags.Configuration
}
}
if (ImGui.IsItemHovered())
ImGui.SetTooltip(Localizer.GetString(conditionSetName, true));
ImGui.Spacing();
}
}
@@ -1207,12 +1212,14 @@ namespace PlayerTags.Configuration
ImGui.PopStyleVar();
}
private void DrawComboBox<TEnum>(bool isLabelVisible, bool shouldLocalizeNames, bool shouldOrderNames, ref TEnum currentValue, System.Action changed)
private void DrawComboBox<TEnum>(bool isLabelVisible, bool shouldLocalizeNames, bool shouldOrderNames, ref TEnum currentValue, System.Action changed, bool showToolTipToLabel = false, bool showLabelInSameLine = false)
where TEnum : Enum
{
if (isLabelVisible)
{
ImGui.Text(Localizer.GetString<TEnum>(false));
if (showLabelInSameLine)
ImGui.SameLine();
}
var currentDisplayName = shouldLocalizeNames ? Localizer.GetString(currentValue, false) : currentValue.ToString();
@@ -1253,7 +1260,10 @@ namespace PlayerTags.Configuration
if (ImGui.IsItemHovered() && shouldLocalizeNames)
{
ImGui.SetTooltip(Localizer.GetString(currentValue, true));
if (showToolTipToLabel)
ImGui.SetTooltip(Localizer.GetString(typeof(TEnum).Name, true));
else
ImGui.SetTooltip(Localizer.GetString(currentValue, true));
}
}

View File

@@ -25,12 +25,16 @@ namespace PlayerTags.Data
public List<Tag> CustomTags;
public List<Identity> Identities;
private PluginConfiguration m_PluginConfiguration;
private PluginConfiguration pluginConfiguration;
public PluginData(PluginConfiguration pluginConfiguration)
{
m_PluginConfiguration = pluginConfiguration;
this.pluginConfiguration = pluginConfiguration;
ReloadDefault();
}
public void ReloadDefault()
{
Default = new DefaultPluginData(pluginConfiguration.DefaultPluginDataTemplate);
// Set the default changes and saved changes
@@ -261,7 +265,7 @@ namespace PlayerTags.Data
if (identity.WorldId == null && worldId != null)
{
identity.WorldId = worldId;
m_PluginConfiguration.Save(this);
pluginConfiguration.Save(this);
return identity;
}

View File

@@ -204,6 +204,104 @@ namespace PlayerTags.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Template ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Basic ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Basic {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Basic", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Same as Empty, but includes a very basic pre-confiuration for formatting and coloring.
///Can also be used if you want to make your own cofiguration but want basic formatting. ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Basic_Description {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Basic_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Here you can choose the template for all the settings below.
///The template is used as basic set of properties. Every change you are making is what get saved. But all options from this template will not be saved.
///This helpes you by not needing to overwrite so much properties - or by doing your completely own configuration without a template.
///
///Warning:
///Changing this can cause properties to be resetted. You may loose a part of your configuration.
///After you changed this, ensure everything is setted up how [Rest der Zeichenfolge wurde abgeschnitten]&quot;; ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Description {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Full ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Full {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Full", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Show the job tag with color and also color the player name element. ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Full_Description {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Full_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Empty ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_None {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_None", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die No single configuration made. This is an completley empty template.
///Use this if you want to to have every option under your control or just want to make only a few configurations. ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_None_Description {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_None_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Simple ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Simple {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Simple", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Shows the job tag with color and the role icon by replacing the title. ähnelt.
/// </summary>
public static string Loc_DefaultPluginDataTemplate_Simple_Description {
get {
return ResourceManager.GetString("Loc_DefaultPluginDataTemplate_Simple_Description", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Melee ähnelt.
/// </summary>

View File

@@ -754,4 +754,42 @@ When disabled, only the disconnected status icon is priorized.</value>
<data name="Loc_StatusIcons_ViewingCutscene" xml:space="preserve">
<value>Viewing Cutscene</value>
</data>
<data name="Loc_DefaultPluginDataTemplate" xml:space="preserve">
<value>Template</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Basic" xml:space="preserve">
<value>Basic</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Basic_Description" xml:space="preserve">
<value>Same as Empty, but includes a very basic pre-confiuration for formatting and coloring.
Can also be used if you want to make your own cofiguration but want basic formatting.</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Description" xml:space="preserve">
<value>Here you can choose the template for all the settings below.
The template is used as basic set of properties. Every change you are making is what get saved. But all options from this template will not be saved.
This helpes you by not needing to overwrite so much properties - or by doing your completely own configuration without a template.
Warning:
Changing this can cause properties to be resetted. You may loose a part of your configuration.
After you changed this, ensure everything is setted up how you like it.</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Full" xml:space="preserve">
<value>Full</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Full_Description" xml:space="preserve">
<value>Show the job tag with color and also color the player name element.</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_None" xml:space="preserve">
<value>Empty</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_None_Description" xml:space="preserve">
<value>No single configuration made. This is an completley empty template.
Use this if you want to to have every option under your control or just want to make only a few configurations.</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Simple" xml:space="preserve">
<value>Simple</value>
</data>
<data name="Loc_DefaultPluginDataTemplate_Simple_Description" xml:space="preserve">
<value>Shows the job tag with color and the role icon by replacing the title.</value>
</data>
</root>