Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: rotation condition comparation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 7, 2023
1 parent a932dcc commit c266442
Show file tree
Hide file tree
Showing 9 changed files with 266 additions and 28 deletions.
21 changes: 21 additions & 0 deletions RotationSolver.Basic/Configuration/Configs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ public float GetValue(PluginConfigFloat config)
public Vector4 GetValue(PluginConfigVector4 config)
=> GlobalConfig.Vectors.GetValue(config);

public string GetDefault(Job job, JobConfigString config)
=> GetJobConfig(job).Strings.GetDefault(config);

public int GetDefault(Job job, JobConfigInt config)
=> GetJobConfig(job).Ints.GetDefault(config);

public float GetDefault(Job job, JobConfigFloat config)
=> GetJobConfig(job).Floats.GetDefault(config);

public int GetDefault(PluginConfigInt config)
=> GlobalConfig.Ints.GetDefault(config);

public bool GetDefault(PluginConfigBool config)
=> GlobalConfig.Bools.GetDefault(config);

public float GetDefault(PluginConfigFloat config)
=> GlobalConfig.Floats.GetDefault(config);

public Vector4 GetDefault(PluginConfigVector4 config)
=> GlobalConfig.Vectors.GetDefault(config);

public void SetValue(Job job, JobConfigString config, string value)
=> GetJobConfig(job).Strings.SetValue(config, value);

Expand Down
26 changes: 13 additions & 13 deletions RotationSolver.Basic/Data/IconSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,41 +74,41 @@ public enum IconType : byte
/// </summary>
public static class IconSet
{
/// <summary>
/// Drat Texture.
/// </summary>
/// <param name="text"></param>
/// <param name="size"></param>
public static void DrawTexture(this ITexture text, Vector2 size)
{
var texture = text.GetTexture();
if (texture == null) return;
ImGui.Image(texture.ImGuiHandle, size);
}

/// <summary>
/// Get Texture form texture.
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
[Obsolete]
public static TextureWrap GetTexture(this ITexture text) => GetTexture(text?.IconID ?? 0);
public static void GetTexture(this ITexture text, out TextureWrap texture) => GetTexture(text?.IconID ?? 0, out texture);

/// <summary>
/// Get Texture from id.
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[Obsolete]

public static TextureWrap GetTexture(uint id)
=> ThreadLoadImageHandler.TryGetIconTextureWrap(id, false, out var texture) ? texture :
ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out texture) ? texture : null;

public static bool GetTexture(uint id, out TextureWrap texture)
=> ThreadLoadImageHandler.TryGetIconTextureWrap(id, false, out texture)
|| ThreadLoadImageHandler.TryGetIconTextureWrap(0, false, out texture);

/// <summary>
/// Get Texture from path.
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
[Obsolete]
public static TextureWrap GetTexture(string path)
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out var texture) ? texture : null;
=> GetTexture(path, out var texture) ? texture : null;

public static bool GetTexture(string path, out TextureWrap texture)
=> ThreadLoadImageHandler.TryGetTextureWrap(path, out texture);

static readonly Dictionary<uint, uint> _actionIcons = new();

Expand Down
4 changes: 2 additions & 2 deletions RotationSolver/ActionSequencer/RotationCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public bool IsTrue(ICustomRotation rotation)
case 0:
return by > Param1;
case 1:
return by == Param1;
case 2:
return by < Param1;
case 2:
return by == Param1;
}
}
return false;
Expand Down
70 changes: 70 additions & 0 deletions RotationSolver/Localization/ConfigTranslation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,74 @@ internal static class ConfigTranslation
{
_ => string.Empty,
};

public static string ToCommand(this JobConfigString config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this JobConfigInt config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this JobConfigFloat config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigInt config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigBool config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigFloat config) => config switch
{
_ => string.Empty,
};

public static string ToCommand(this PluginConfigVector4 config) => config switch
{
_ => string.Empty,
};

public static Action ToAction(this JobConfigString config) => config switch
{
_ => null,
};

public static Action ToAction(this JobConfigInt config) => config switch
{
_ => null,
};

public static Action ToAction(this JobConfigFloat config) => config switch
{
_ => null,
};

public static Action ToAction(this PluginConfigInt config) => config switch
{
_ => null,
};

public static Action ToAction(this PluginConfigBool config) => config switch
{
_ => null,
};

public static Action ToAction(this PluginConfigFloat config) => config switch
{
_ => null,
};

public static Action ToAction(this PluginConfigVector4 config) => config switch
{
_ => null,
};
}
15 changes: 9 additions & 6 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private void DrawHeader(float wholeWidth)
{
var size = MathF.Max(MathF.Min(wholeWidth, _scale * 120), _scale * MIN_COLUMN_WIDTH);

var logo = IconSet.GetTexture("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/Logo.png");
var logo = IconSet.GetTexture("https://raw.githubusercontent.com/ArchiDog1998/RotationSolver/main/Images/Logo.png") ?? IconSet.GetTexture(0);

if (logo != null)
{
Expand Down Expand Up @@ -545,7 +545,7 @@ private static void DrawRotation()
if (!string.IsNullOrEmpty(desc))
{
ImGui.PushFont(ImGuiHelper.GetFont(15));
ImGui.TextWrapped(desc);
ImGuiEx.TextWrappedCopy(desc);
ImGui.PopFont();
}

Expand Down Expand Up @@ -765,11 +765,14 @@ private static void DrawActions()
ImguiTooltips.HoveredTooltip(item.Name);
DrawActionOverlay(cursor, size, _activeAction == item ? 1 : 0);

var texture = IconSet.GetTexture("https://raw.githubusercontent.com/goatcorp/DalamudAssets/master/UIRes/installedIcon.png");
if(texture != null && item.IsEnabled)
var texture = IconSet.GetTexture("ui/uld/readycheck_hr1.tex");
if(texture != null)
{
ImGui.SetCursorPos(cursor);
ImGui.Image(texture.ImGuiHandle, Vector2.One * size);
var offset = new Vector2(1 / 12f, 1 / 6f);
ImGui.SetCursorPos(cursor + new Vector2(0.6f, 0.7f) * size);
ImGui.Image(texture.ImGuiHandle, Vector2.One * size * 0.5f,
new Vector2(item.IsEnabled ? 0 : 0.5f, 0) + offset,
new Vector2(item.IsEnabled ? 0.5f : 1, 1) - offset);
}
ImGui.EndGroup();
}
Expand Down
24 changes: 20 additions & 4 deletions RotationSolver/UI/SearchableConfigs/CheckBoxSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ internal class CheckBoxSearchPlugin : CheckBoxSearch

public override string Description => _config.ToDescription();

public override Action DrawTooltip => _config.ToAction();

public override string Command => _config.ToCommand();

public CheckBoxSearchPlugin(PluginConfigBool config, params ISearchable[] children)
:base(children)
{
_config = config;
Children = children;
}

protected override bool GetValue(Job job)
Expand All @@ -29,14 +33,26 @@ protected override void SetValue(Job job, bool value)
{
Service.ConfigNew.SetValue(_config, value);
}

public override void ResetToDefault()
{
Service.ConfigNew.SetValue(_config, Service.ConfigNew.GetDefault(_config));
}
}

internal abstract class CheckBoxSearch : Searchable
{
public abstract string ID { get; }

public ISearchable[] Children { get; protected set; }

public CheckBoxSearch(params ISearchable[] children)
{
Children = children;
foreach (var child in Children)
{
child.Parent = this;
}
}

protected abstract bool GetValue(Job job);
protected abstract void SetValue(Job job, bool value);

Expand All @@ -47,7 +63,7 @@ public override void Draw(Job job)
{
SetValue(job, enable);
}
if(ImGui.IsItemHovered()) ShowTooltip();
if (ImGui.IsItemHovered()) ShowTooltip();

var name = $"{Name}##Config_{ID}";
if (enable)
Expand Down
59 changes: 59 additions & 0 deletions RotationSolver/UI/SearchableConfigs/DragIntSearch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using ECommons.ExcelServices;
using Newtonsoft.Json.Linq;
using RotationSolver.Basic.Configuration;
using RotationSolver.Localization;

namespace RotationSolver.UI.SearchableConfigs;

internal class DragIntSearchPlugin : DragIntSearch
{
private PluginConfigInt _config;

public override string ID => _config.ToString();

public override string Name => _config.ToName();

public override string Description => _config.ToDescription();

public override Action DrawTooltip => _config.ToAction();

public override string Command => _config.ToCommand();

public DragIntSearchPlugin(PluginConfigInt config)
{
_config = config;
}

public override void ResetToDefault()
{
Service.ConfigNew.SetValue(_config, Service.ConfigNew.GetDefault(_config));
}

protected override int GetValue(Job job)
{
return Service.ConfigNew.GetValue(_config);
}

protected override void SetValue(Job job, int value)
{
Service.ConfigNew.SetValue(_config, value);
}
}

internal abstract class DragIntSearch : Searchable
{
public int Min { get; }
public int Max { get; }
public float Speed { get; }
protected abstract int GetValue(Job job);
protected abstract void SetValue(Job job, int value);
public override void Draw(Job job)
{
var value = GetValue(job);
if(ImGui.DragInt($"{Name}##Config_{ID}", ref value, Speed, Min, Max))
{
SetValue(job, value);
}
if (ImGui.IsItemHovered()) ShowTooltip();
}
}
4 changes: 3 additions & 1 deletion RotationSolver/UI/SearchableConfigs/ISearchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

namespace RotationSolver.UI.SearchableSettings;

public interface ISearchable
internal interface ISearchable
{
CheckBoxSearch Parent { get; set; }

string SearchingKey { get; }

void Draw(Job job);
Expand Down
Loading

0 comments on commit c266442

Please sign in to comment.