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

Commit

Permalink
fix: show all options but disabled the ones that can't set.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 17, 2023
1 parent 9735526 commit 4cf5f81
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
8 changes: 5 additions & 3 deletions RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@
"ConfigWindow_List_HostileCastingAreaDesc": "If the target is casting the action like this, it'll defense area.",
"ConfigWindow_List_NoHostile": "No Hostile",
"ConfigWindow_List_NoHostileDesc": "Add a name of target that never be the hostile for you.",
"ActionSequencer_Load": "Load From folder.",
"ActionSequencer_Can": "Can",
"ActionSequencer_Cannot": "Cannot",
"ActionSequencer_Cannot": "Can Not",
"ActionSequencer_Is": "Is",
"ActionSequencer_Isnot": "Isnot",
"ActionSequencer_Isnot": "Is Not",
"ActionSequencer_Has": "Has",
"ActionSequencer_HasNot": "Has not",
"ActionSequencer_TimeOffset": "Time Offset",
Expand Down Expand Up @@ -478,5 +479,6 @@
"ConfigWindow_Tab_Extra": "Some features shouldn't be included by RS.",
"ConfigWindow_List_AddPosition": "Add One territory position",
"ConfigWindow_Actions_MoveUp": "Move Up",
"ConfigWindow_Actions_MoveDown": "Move Down"
"ConfigWindow_Actions_MoveDown": "Move Down",
"ConfigWindow_NotInJob": "You can't set this setting at your job!\n \nRoles or jobs needed:\n{0}"
}
1 change: 1 addition & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,4 +697,5 @@ internal partial class Strings
public string ConfigWindow_List_AddPosition { get; set; } = "Add One territory position";
public string ConfigWindow_Actions_MoveUp { get; set; } = "Move Up";
public string ConfigWindow_Actions_MoveDown { get; set; } = "Move Down";
public string ConfigWindow_NotInJob { get; set; } = "You can't set this setting at your job!\n \nRoles or jobs needed:\n{0}";
}
2 changes: 1 addition & 1 deletion RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ private void DrawBody()

foreach (var searchable in _searchResults)
{
searchable?.Draw(Job, true);
searchable?.Draw(Job);
}
}
else
Expand Down
2 changes: 1 addition & 1 deletion RotationSolver/UI/SearchableConfigs/ISearchable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ internal interface ISearchable

string SearchingKeys { get; }

void Draw(Job job, bool mustDraw = false);
void Draw(Job job);
}
51 changes: 33 additions & 18 deletions RotationSolver/UI/SearchableConfigs/Searchable.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using Dalamud.Game.ClientState.Keys;
using ECommons.DalamudServices;
using ECommons.ExcelServices;
using ECommons.ImGuiMethods;
using ECommons.ExcelServices;
using RotationSolver.Localization;
using RotationSolver.UI.SearchableSettings;
using RotationSolver.Updaters;
Expand Down Expand Up @@ -29,26 +26,44 @@ internal abstract class Searchable : ISearchable
public JobRole[] JobRoles { get; set; }
public Job[] Jobs { get; set; }

public void Draw(Job job, bool mustDraw = false)
public unsafe void Draw(Job job)
{
if (!mustDraw)
var canDraw = true;

if (JobRoles != null)
{
var canDraw = true;
if (JobRoles != null)
var role = RotationUpdater.RightNowRotation?.ClassJob?.GetJobRole();
if (role.HasValue)
{
var role = RotationUpdater.RightNowRotation?.ClassJob?.GetJobRole();
if (role.HasValue)
{
canDraw = JobRoles.Contains(role.Value);
}
canDraw = JobRoles.Contains(role.Value);
}
}

if (Jobs != null)
{
canDraw |= Jobs.Contains(DataCenter.Job);
}
if (Jobs != null)
{
canDraw |= Jobs.Contains(DataCenter.Job);
}

if (!canDraw)
{
var textColor = *ImGui.GetStyleColorVec4(ImGuiCol.Text);

ImGui.PushStyleColor(ImGuiCol.Text, *ImGui.GetStyleColorVec4(ImGuiCol.TextDisabled));

var cursor = ImGui.GetCursorPos() + ImGui.GetWindowPos();
ImGui.TextWrapped(Name);
var size = ImGui.GetItemRectSize();
cursor += new Vector2(0, size.Y / 2);
ImGui.GetWindowDrawList().AddLine(cursor, cursor + new Vector2(size.X, 0), ImGui.ColorConvertFloat4ToU32(textColor));

ImGui.PopStyleColor();

if (!canDraw) return;
var roleOrJob = string.Join(", ", JobRoles ?? Array.Empty<JobRole>());
var jobs = string.Join(", ", Jobs ?? Array.Empty<Job>());
if (string.IsNullOrEmpty(roleOrJob)) roleOrJob = jobs;
else if (string.IsNullOrEmpty(jobs)) roleOrJob +='\n' + jobs;
ImguiTooltips.HoveredTooltip(string.Format(LocalizationManager.RightLang.ConfigWindow_NotInJob, roleOrJob));
return;
}

DrawMain(job);
Expand Down

0 comments on commit 4cf5f81

Please sign in to comment.