feat: add achievement info
This commit is contained in:
parent
23e40520d9
commit
383b3e66ce
|
@ -12,4 +12,6 @@ internal class Configuration : IPluginConfiguration {
|
||||||
internal enum SortOrder {
|
internal enum SortOrder {
|
||||||
Default,
|
Default,
|
||||||
Alphabetical,
|
Alphabetical,
|
||||||
|
Achievement,
|
||||||
|
Category,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,22 @@ namespace TheHeartOfTheParty;
|
||||||
internal class PluginUi : IDisposable {
|
internal class PluginUi : IDisposable {
|
||||||
private Plugin Plugin { get; }
|
private Plugin Plugin { get; }
|
||||||
|
|
||||||
|
private Dictionary<uint, Achievement> Achievements { get; } = new();
|
||||||
|
|
||||||
private bool _visible;
|
private bool _visible;
|
||||||
private string _searchText = string.Empty;
|
private string _searchText = string.Empty;
|
||||||
|
|
||||||
internal PluginUi(Plugin plugin) {
|
internal PluginUi(Plugin plugin) {
|
||||||
this.Plugin = plugin;
|
this.Plugin = plugin;
|
||||||
|
|
||||||
|
foreach (var achievement in this.Plugin.DataManager.GetExcelSheet<Achievement>()!) {
|
||||||
|
if (achievement.Title.Row == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Achievements[achievement.Title.Row] = achievement;
|
||||||
|
}
|
||||||
|
|
||||||
this.Plugin.Interface.UiBuilder.Draw += this.OnDraw;
|
this.Plugin.Interface.UiBuilder.Draw += this.OnDraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,14 +76,35 @@ internal class PluginUi : IDisposable {
|
||||||
ImGui.InputTextWithHint("##search", hint, ref this._searchText, 64);
|
ImGui.InputTextWithHint("##search", hint, ref this._searchText, 64);
|
||||||
|
|
||||||
if (ImGui.BeginChild("##titles")) {
|
if (ImGui.BeginChild("##titles")) {
|
||||||
|
if (ImGui.BeginTable("##titles-table", 3)) {
|
||||||
|
ImGui.TableSetupColumn("Title", ImGuiTableColumnFlags.WidthFixed);
|
||||||
|
ImGui.TableSetupColumn("Achievement", ImGuiTableColumnFlags.WidthFixed);
|
||||||
|
ImGui.TableSetupColumn("Category", ImGuiTableColumnFlags.WidthStretch);
|
||||||
|
|
||||||
|
ImGui.TableHeadersRow();
|
||||||
|
|
||||||
foreach (var title in titles) {
|
foreach (var title in titles) {
|
||||||
|
ImGui.TableNextRow();
|
||||||
|
|
||||||
if (title.Unlocked) {
|
if (title.Unlocked) {
|
||||||
if (ImGui.Selectable(title.Text)) {
|
const ImGuiSelectableFlags flags = ImGuiSelectableFlags.SpanAllColumns
|
||||||
|
| ImGuiSelectableFlags.AllowItemOverlap;
|
||||||
|
// TODO: detect current title?
|
||||||
|
if (ImGui.Selectable(title.Text, false, flags)) {
|
||||||
this.Plugin.Functions.SetTitle(title.Row.RowId);
|
this.Plugin.Functions.SetTitle(title.Row.RowId);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ImGui.TextDisabled(title.Text);
|
ImGui.TextDisabled(title.Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(title.Achievement?.Name?.RawString ?? "???");
|
||||||
|
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
ImGui.TextUnformatted(title.Achievement?.AchievementCategory.Value?.Name?.RawString ?? "???");
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui.EndTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
|
@ -89,6 +120,7 @@ internal class PluginUi : IDisposable {
|
||||||
Row = row,
|
Row = row,
|
||||||
Unlocked = this.Plugin.Functions.IsTitleUnlocked(row.RowId),
|
Unlocked = this.Plugin.Functions.IsTitleUnlocked(row.RowId),
|
||||||
Text = fem ? row.Feminine : row.Masculine,
|
Text = fem ? row.Feminine : row.Masculine,
|
||||||
|
Achievement = this.Achievements.TryGetValue(row.RowId, out var achievement) ? achievement : null,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (this.Plugin.Config.OnlyUnlocked) {
|
if (this.Plugin.Config.OnlyUnlocked) {
|
||||||
|
@ -103,6 +135,8 @@ internal class PluginUi : IDisposable {
|
||||||
titles = this.Plugin.Config.SortOrder switch {
|
titles = this.Plugin.Config.SortOrder switch {
|
||||||
SortOrder.Default => titles.OrderBy(t => t.Row.Order),
|
SortOrder.Default => titles.OrderBy(t => t.Row.Order),
|
||||||
SortOrder.Alphabetical => titles.OrderBy(t => t.Text.RawString),
|
SortOrder.Alphabetical => titles.OrderBy(t => t.Text.RawString),
|
||||||
|
SortOrder.Achievement => titles.OrderBy(t => t.Achievement?.Name?.RawString ?? "???"),
|
||||||
|
SortOrder.Category => titles.OrderBy(t => t.Achievement?.AchievementCategory.Value?.Name?.RawString ?? "???"),
|
||||||
_ => titles,
|
_ => titles,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -114,4 +148,5 @@ internal class TitleInfo {
|
||||||
internal Title Row { get; init; } = null!;
|
internal Title Row { get; init; } = null!;
|
||||||
internal bool Unlocked { get; init; }
|
internal bool Unlocked { get; init; }
|
||||||
internal SeString Text { get; init; } = null!;
|
internal SeString Text { get; init; } = null!;
|
||||||
|
internal Achievement? Achievement { get; init; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user