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

Commit

Permalink
fix: changed some ui.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Jul 30, 2023
1 parent 5f79092 commit 3955323
Show file tree
Hide file tree
Showing 10 changed files with 240 additions and 19 deletions.
1 change: 1 addition & 0 deletions Images/Repository.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="https://github-readme-stats.vercel.app/api/pin/?username=ArchiDog1998&repo=RotationSolver&theme=dark">
Binary file added Images/Repository.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ Then, it will highlight the best action on the hot bar, or help you to click on

It is designed for `general combat`, not for savage or ultimate. Use it carefully.

## Concept

I have to admit, I'm not a good RPG player. But I enjoy the experience of FFXIV. So I want to design a plugin that can improve my gaming experience without affecting other players' gaming experience. So there goes to `Rotation Solver`.

I have to admit, it does have an automatic component, which might not be good for some players. But it can NOT affect any other player's game experience. pvp is absolutely NOT allowed in this plugin.

## Compatibility

literally, `Rotation Solver` helps you to choose the target and then click the action. So any plugin that changes these will affect its decision.
Expand Down
8 changes: 7 additions & 1 deletion Resources/AnimationLockTime.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
"7510": 0.1,
"7511": 0.1,
"7513": 0.6,
"7514": 0.1,
"7514": 0.6,
"7517": 0.6,
"7518": 0.6,
"7519": 0.6,
Expand Down Expand Up @@ -551,6 +551,9 @@
"25838": 0.6,
"25839": 0.6,
"25840": 0.6,
"25855": 0.6,
"25856": 0.6,
"25857": 0.6,
"25859": 0.1,
"25860": 0.1,
"25861": 0.6,
Expand Down Expand Up @@ -592,6 +595,9 @@
"30800": 0.1,
"31323": 2.1,
"31338": 2.1,
"31929": 0.1,
"31930": 0.1,
"31931": 0.1,
"33041": 2.1,
"33336": 0.1,
"33337": 0.1,
Expand Down
4 changes: 3 additions & 1 deletion Resources/HostileCastingArea.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,5 +336,7 @@
30450,
30955,
30447,
30798
30798,
5150,
25147
]
2 changes: 2 additions & 0 deletions RotationSolver.Basic/Actions/BaseAction_BasicInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ public BaseAction(ActionID actionID, ActionOption option = ActionOption.None)
_option = option;

CoolDownGroup = _action.GetCoolDownGroup();

if (IsFriendly) AOECount = 2;
}

/// <summary>
Expand Down
8 changes: 7 additions & 1 deletion RotationSolver/Localization/Localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,5 +427,11 @@
},
"HighEndWarning": "Please separately keybind damage reduction / shield cooldowns in case RS fails at a crucial moment in {0}!",
"TextToTalkWarning": "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!",
"ClickingMistakeMessage": "OOOps! RS clicked the wrong action ({0})!"
"ClickingMistakeMessage": "OOOps! RS clicked the wrong action ({0})!",
"ConfigWindow_About_Punchline": "Analyses PvE combat information every frame and finds the best action.",
"ConfigWindow_About_Description": "This means almost all the information available in one frame in combat, including the status of all players in the party, the status of any hostile targets, skill cooldowns, the MP and HP of characters, the location of characters, casting status of the hostile target, combo, combat duration, player level, etc.\n\nThen, it will highlight the best action on the hot bar, or help you to click on it.",
"ConfigWindow_About_Warning": "It is designed for GENERAL COMBAT, not for savage or ultimate. Use it carefully.",
"ConfigWindow_About_Macros": "Macros",
"ConfigWindow_About_Links": "Links",
"ConfigWindow_About_Compatibility": "Compatibility"
}
11 changes: 11 additions & 0 deletions RotationSolver/Localization/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,15 @@ internal partial class Strings
public string TextToTalkWarning { get; set; } = "You didn't install TextToTalk, please install it to make Rotation Solver say something for you!";

public string ClickingMistakeMessage { get; set; } = "OOOps! RS clicked the wrong action ({0})!";


public string ConfigWindow_About_Punchline { get; set; } = "Analyses PvE combat information every frame and finds the best action.";
public string ConfigWindow_About_Description { get; set; } = "This means almost all the information available in one frame in combat, including the status of all players in the party, the status of any hostile targets, skill cooldowns, the MP and HP of characters, the location of characters, casting status of the hostile target, combo, combat duration, player level, etc.\n\nThen, it will highlight the best action on the hot bar, or help you to click on it.";

public string ConfigWindow_About_Warning { get; set; } = "It is designed for GENERAL COMBAT, not for savage or ultimate. Use it carefully.";

public string ConfigWindow_About_Macros { get; set; } = "Macros";
public string ConfigWindow_About_Links { get; set; } = "Links";
public string ConfigWindow_About_Compatibility { get; set; } = "Compatibility";

}
75 changes: 75 additions & 0 deletions RotationSolver/UI/CollapsingHeaderGroup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using Dalamud.Logging;

namespace RotationSolver.UI;

internal class CollapsingHeaderGroup
{
private Dictionary<Func<string>, Action> _headers = new Dictionary<Func<string>, Action>();
private int _openedIndex = -1;

public CollapsingHeaderGroup()
{

}

public CollapsingHeaderGroup(Dictionary<Func<string>, Action> headers)
{
_headers = headers;
}

public void AddCollapsingHeader(Func<string> name, Action action)
{
_headers.Add(name, action);
}

public void RemoveCollapsingHeader(Func<string> name)
{
_headers.Remove(name);
}

public void ClearCollapsingHeader()
{
_headers.Clear();
}

public void Draw()
{
var index = -1;
foreach (var header in _headers)
{
index++;

if (header.Key == null) continue;
if (header.Value == null) continue;

var name = header.Key();
if(string.IsNullOrEmpty(name)) continue;

try
{
ImGui.Separator();
var selected = index == _openedIndex;
ImGui.PushFont(ImGuiHelper.GetFont(24));
var changed = ImGui.Selectable(name, selected);
ImGui.PopFont();
if (ImGui.IsItemHovered())
{
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
}
if (changed)
{
_openedIndex = selected ? -1 : index;
}
if (selected)
{
header.Value();
}
}
catch (Exception ex)
{
PluginLog.Warning(ex, "Something wrong with header drawing.");
}

}
}
}
144 changes: 134 additions & 10 deletions RotationSolver/UI/RotationConfigWindowNew.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using Dalamud.Interface.Windowing;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Windowing;
using Dalamud.Utility;
using ECommons.ExcelServices;
using ECommons.GameHelpers;
using ImGuiScene;
using RotationSolver.Helpers;
using RotationSolver.Localization;
using RotationSolver.Updaters;
Expand All @@ -17,6 +19,8 @@ public class RotationConfigWindowNew : Window
private const float MIN_COLUMN_WIDTH = 24;
private const float JOB_ICON_WIDTH = 50;

private string _searchText = string.Empty;

public RotationConfigWindowNew()
: base(nameof(RotationConfigWindowNew), ImGuiWindowFlags.NoScrollbar, false)
{
Expand All @@ -25,15 +29,27 @@ public RotationConfigWindowNew()
RespectCloseHotkey = true;
}

public override void PreDraw()
{
ImGui.PushStyleVar(ImGuiStyleVar.SelectableTextAlign, new Vector2(0.5f, 0.5f));
base.PreDraw();
}

public override void PostDraw()
{
ImGui.PopStyleVar();
base.PostDraw();
}

public override void Draw()
{
if(ImGui.BeginTable("Rotation Config Table", 2, ImGuiTableFlags.Resizable))
{
ImGui.TableSetupColumn("Rotation Config Side Bar", ImGuiTableColumnFlags.WidthFixed, 100 * _scale);
ImGui.TableNextColumn();
DrawSideBar();
ImGui.TableNextColumn();

ImGui.TableNextColumn();
DrawBody();

ImGui.EndTable();
Expand All @@ -52,7 +68,12 @@ private void DrawSideBar()
ImGui.Separator();
ImGui.Spacing();

ImGui.PushStyleVar(ImGuiStyleVar.SelectableTextAlign, new Vector2(0.5f, 0.5f));
if(wholeWidth > JOB_ICON_WIDTH * _scale)
{
ImGui.SetNextItemWidth(wholeWidth);
ImGui.InputTextWithHint("##Rotation Solver Search Box", "Searching is not available", ref _searchText, 128, ImGuiInputTextFlags.AutoSelectAll);
}

foreach (var item in Enum.GetValues<RotationConfigWindowTab>())
{
if (item.GetAttribute<TabSkipAttribute>() != null) continue;
Expand All @@ -78,9 +99,39 @@ private void DrawSideBar()
{
_activeTab = item;
}
if (ImGui.IsItemHovered())
{
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
}
}
}
ImGui.PopStyleVar();

var texture = wholeWidth <= 60 * _scale
? IconSet.GetTexture("https://storage.ko-fi.com/cdn/brandasset/kofi_s_logo_nolabel.png")
: IconSet.GetTexture("https://storage.ko-fi.com/cdn/brandasset/kofi_bg_tag_dark.png");

if (texture != null)
{
var width = Math.Min(150 * _scale, Math.Max(_scale * MIN_COLUMN_WIDTH, Math.Min(wholeWidth, texture.Width)));
var size = new Vector2(width, width * texture.Height / texture.Width);
size *= MathF.Max(_scale * MIN_COLUMN_WIDTH / size.Y, 1);
var result = false;
DrawItemMiddle(() =>
{
ImGui.SetCursorPosY(ImGui.GetWindowSize().Y - size.Y);
ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0);
ImGui.PushStyleColor(ImGuiCol.Button, 0);
result = NoPaddingImageButton(texture.ImGuiHandle, size);
ImGui.PopStyleColor(3);
}, wholeWidth, size.X);

if (result)
{
Util.OpenLink("https://ko-fi.com/B0B0IN5DX");
}
}

ImGui.EndChild();
}
}
Expand All @@ -100,6 +151,7 @@ private void DrawHeader(float wholeWidth)
{
_activeTab = RotationConfigWindowTab.About;
}
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ConfigWindow_About_Punchline);
}, wholeWidth, size);

ImGui.Spacing();
Expand Down Expand Up @@ -186,14 +238,42 @@ private unsafe static bool SilenceImageButton(IntPtr handle, Vector2 size, bool
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ImGui.ColorConvertFloat4ToU32(*ImGui.GetStyleColorVec4(ImGuiCol.HeaderHovered)));
ImGui.PushStyleColor(ImGuiCol.Button, selected ? ImGui.ColorConvertFloat4ToU32(*ImGui.GetStyleColorVec4(ImGuiCol.Header)) : 0);

var result = NoPaddingImageButton(handle, size);
ImGui.PopStyleColor(3);

return result;
}

private static bool NoPaddingImageButton(IntPtr handle, Vector2 size)
{
var padding = ImGui.GetStyle().FramePadding;
ImGui.GetStyle().FramePadding = Vector2.Zero;

var result = ImGui.ImageButton(handle, size);
if (ImGui.IsItemHovered())
{
ImGui.SetMouseCursor(ImGuiMouseCursor.Hand);
}

ImGui.GetStyle().FramePadding = padding;
ImGui.PopStyleColor(3);
return result;
}

private static bool TextureButton(TextureWrap texture, float wholeWidth)
{
if (texture == null) return false;

var size = new Vector2(texture.Width, texture.Height) * MathF.Min(1, wholeWidth / texture.Width);

var result = false;
DrawItemMiddle(() =>
{
ImGui.PushStyleColor(ImGuiCol.ButtonActive, 0);
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, 0);
ImGui.PushStyleColor(ImGuiCol.Button, 0);
result = NoPaddingImageButton(texture.ImGuiHandle, size);
ImGui.PopStyleColor(3);
}, wholeWidth, size.X);
return result;
}

Expand Down Expand Up @@ -224,13 +304,12 @@ private void DrawBody()
}
ImGui.EndChild();
}
//ImGui.PopStyleVar();
}

private void DrawAbout()
private static readonly CollapsingHeaderGroup _aboutHeaders = new (new ()
{
ImGui.Text("About Tab");

{ () => LocalizationManager.RightLang.ConfigWindow_About_Macros, () =>
{
ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0f, 5f));

StateCommandType.Auto.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp);
Expand Down Expand Up @@ -268,10 +347,55 @@ private void DrawAbout()
SpecialCommandType.Burst.DisplayCommandHelp(getHelp: EnumTranslations.ToHelp);

ImGui.PopStyleVar();
} },

{ () => LocalizationManager.RightLang.ConfigWindow_About_Compatibility, () =>
{
} },

{ () => LocalizationManager.RightLang.ConfigWindow_About_Links, () =>
{
var width = ImGui.GetWindowWidth();
if(TextureButton(IconSet.GetTexture("https://streak-stats.demolab.com?user=ArchiDog1998&type=png"), width))
{
Util.OpenLink("https://github.com/ArchiDog1998/RotationSolver");
}

if(TextureButton(IconSet.GetTexture("https://discordapp.com/api/guilds/1064448004498653245/embed.png?style=banner2"), width))
{
Util.OpenLink("https://discord.gg/4fECHunam9");
}

if(TextureButton(IconSet.GetTexture("https://badges.crowdin.net/badge/light/crowdin-on-dark.png"), width))
{
Util.OpenLink("https://crowdin.com/project/rotationsolver");
}
} },
});
private static void DrawAbout()
{
ImGui.PushFont(ImGuiHelper.GetFont(18));
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_About_Punchline);
ImGui.PopFont();
ImGui.Spacing();

ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_About_Description);

ImGui.Spacing();
ImGui.PushStyleColor(ImGuiCol.Text, ImGui.ColorConvertFloat4ToU32(ImGuiColors.DalamudOrange));
ImGui.TextWrapped(LocalizationManager.RightLang.ConfigWindow_About_Warning);
ImGui.PopStyleColor();

ImGui.NewLine();
_aboutHeaders.Draw();
}

private static readonly CollapsingHeaderGroup _rotationHeader = new(new()
{

});
private void DrawRotation()
{
ImGui.Text("Rotation Tab");
_rotationHeader.Draw();
}
}

0 comments on commit 3955323

Please sign in to comment.