feat(housing): add submenu and add to bookmarks function

This commit is contained in:
Anna 2021-06-27 19:49:22 -04:00
parent 857f2fca59
commit d0ac69697e
3 changed files with 28 additions and 9 deletions

View File

@ -55,6 +55,6 @@
<PackageReference Include="F23.StringSimilarity" Version="4.1.0"/>
<PackageReference Include="Fody" Version="6.5.1" PrivateAssets="all"/>
<PackageReference Include="ILMerge.Fody" Version="1.16.0" PrivateAssets="all"/>
<PackageReference Include="XivCommon" Version="2.1.1"/>
<PackageReference Include="XivCommon" Version="2.2.0-alpha.1"/>
</ItemGroup>
</Project>

View File

@ -9,7 +9,7 @@ namespace RoleplayersToolbox.Tools.Housing {
private Plugin Plugin { get; }
private HousingTool Tool { get; }
private HousingConfig Config { get; }
private (Bookmark editing, int index)? _editing;
internal (Bookmark editing, int index)? Editing;
internal bool ShouldDraw;
@ -32,7 +32,7 @@ namespace RoleplayersToolbox.Tools.Housing {
}
if (Util.IconButton(FontAwesomeIcon.Plus)) {
this._editing = (new Bookmark(string.Empty), -1);
this.Editing = (new Bookmark(string.Empty), -1);
}
var toDelete = -1;
@ -69,7 +69,7 @@ namespace RoleplayersToolbox.Tools.Housing {
ImGui.SameLine();
if (Util.IconButton(FontAwesomeIcon.PencilAlt, hash)) {
this._editing = (bookmark.Clone(), i);
this.Editing = (bookmark.Clone(), i);
}
Util.Tooltip("Edit");
@ -100,7 +100,7 @@ namespace RoleplayersToolbox.Tools.Housing {
}
private void AddEditWindow() {
if (this._editing == null) {
if (this.Editing == null) {
return;
}
@ -109,7 +109,7 @@ namespace RoleplayersToolbox.Tools.Housing {
return;
}
var (bookmark, index) = this._editing.Value;
var (bookmark, index) = this.Editing.Value;
ImGui.InputText("Name", ref bookmark.Name, 255);
@ -165,13 +165,13 @@ namespace RoleplayersToolbox.Tools.Housing {
}
this.Plugin.SaveConfig();
this._editing = null;
this.Editing = null;
}
ImGui.SameLine();
if (ImGui.Button("Cancel")) {
this._editing = null;
this.Editing = null;
}
ImGui.End();

View File

@ -224,7 +224,10 @@ namespace RoleplayersToolbox.Tools.Housing {
return;
}
args.Items.Add(new NormalContextMenuItem("Select as Destination", this.SelectDestination));
args.Items.Add(new NormalContextSubMenuItem("Roleplayer's Toolbox", args => {
args.Items.Add(new NormalContextMenuItem("Select as Destination", this.SelectDestination));
args.Items.Add(new NormalContextMenuItem("Add Bookmark", this.AddBookmark));
}));
}
private void SelectDestination(ContextMenuItemSelectedArgs args) {
@ -237,6 +240,22 @@ namespace RoleplayersToolbox.Tools.Housing {
this.Destination = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.Interface.Data, this.Info);
}
private void AddBookmark(ContextMenuItemSelectedArgs args) {
var listing = this.Plugin.Common.Functions.PartyFinder.CurrentListings.Values.FirstOrDefault(listing => listing.ContentIdLower == args.ContentIdLower);
if (listing == null) {
return;
}
var dest = InfoExtractor.Extract(listing.Description.TextValue, listing.World.Value.DataCenter.Row, this.Plugin.Interface.Data, this.Info);
this.BookmarksUi.Editing = (new Bookmark(string.Empty) {
WorldId = dest.World?.RowId ?? 0,
Area = dest.Area ?? 0,
Ward = dest.Ward ?? 0,
Plot = dest.Plot ?? 0,
}, -1);
this.BookmarksUi.ShouldDraw = true;
}
private void OnFramework(Framework framework) {
this.ClearIfNear();
this.HighlightSelectString();