Skip to content

Commit

Permalink
Add native preset save button and preview, import, and clear to the p…
Browse files Browse the repository at this point in the history
…reset pane
  • Loading branch information
sourpuh committed Dec 3, 2024
1 parent 1aac106 commit f2eca17
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
4 changes: 3 additions & 1 deletion WaymarkStudio/WaymarkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ internal class WaymarkManager
private unsafe delegate byte PlacePreset(MarkingController* markingController, MarkerPresetPlacement* placement);
private readonly PlacePreset? placePresetFn;

internal WaymarkPreset Preset { get { return new(mapName, territoryId, contentFinderId, new Dictionary<Waymark, Vector3>(placeholders)); } }
internal WaymarkPreset DraftPreset { get { return new(mapName, territoryId, contentFinderId, new Dictionary<Waymark, Vector3>(placeholders)); } }
internal WaymarkPreset WaymarkPreset { get { return new(mapName, territoryId, contentFinderId, new Dictionary<Waymark, Vector3>(Waymarks)); } }

internal IReadOnlyDictionary<Waymark, Vector3> Placeholders => placeholders;
internal IReadOnlyDictionary<Waymark, Vector3> HoverPreviews => hoverPreviews;
internal unsafe IReadOnlyDictionary<Waymark, Vector3> Waymarks => MarkingController.Instance()->ActiveMarkers();
Expand Down
41 changes: 28 additions & 13 deletions WaymarkStudio/Windows/StudioWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal class StudioWindow : Window, IDisposable
internal StudioWindow()
: base("Waymark Studio", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
{
Size = new(560, 505);
Size = new(575, 480);
SizeCondition = ImGuiCond.Once;
SizeConstraints = new WindowSizeConstraints
{
Expand Down Expand Up @@ -140,7 +140,7 @@ internal void DrawDraftSection()
{
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.Save, "Save Draft"))
{
var preset = Plugin.WaymarkManager.Preset;
var preset = Plugin.WaymarkManager.DraftPreset;
preset.Name += $" {Plugin.Storage.CountPresetsForTerritoryId(Plugin.WaymarkManager.territoryId) + 1}";
Plugin.Config.SavedPresets.Add(preset);
Plugin.Config.Save();
Expand All @@ -152,20 +152,10 @@ internal void DrawDraftSection()
{
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.MapMarkedAlt, "Place Draft"))
{
Plugin.WaymarkManager.SafePlacePreset(Plugin.WaymarkManager.Preset);
Plugin.WaymarkManager.SafePlacePreset(Plugin.WaymarkManager.DraftPreset);
}
HoverTooltip("Replace draft markers with real markers\nTBD how existing waymarks should be treated");
}
using (ImRaii.Disabled(Plugin.WaymarkManager.Waymarks.Count == 0))
{
if (ImGuiComponents.IconButtonWithText(FontAwesomeIcon.MapMarkerAlt, "Import markers"))
{
foreach ((Waymark w, Vector3 p) in Plugin.WaymarkManager.Waymarks)
Plugin.WaymarkManager.PlaceWaymarkPlaceholder(w, p);
Plugin.WaymarkManager.NativeClearWaymarks();
}
HoverTooltip("Replace real markers with draft markers");
}
}

internal void DrawGuideSection()
Expand Down Expand Up @@ -235,6 +225,31 @@ internal void DrawSavedPresets()
ImGui.TableNextRow();
ImGui.TableNextColumn();
ImGui.Text($"{Plugin.WaymarkManager.mapName}");
var currentMarkers = Plugin.WaymarkManager.WaymarkPreset;
if (currentMarkers.MarkerPositions.Count > 0)
{
if (ImGuiComponents.IconButton(FontAwesomeIcon.Save))
{
Plugin.Config.SavedPresets.Add(currentMarkers);
Plugin.Config.Save();
}
HoverTooltip("Save markers to presets");
ImGui.SameLine();
TextActiveWaymarks(currentMarkers);
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.MapMarkerAlt))
{
foreach ((Waymark w, Vector3 p) in Plugin.WaymarkManager.Waymarks)
Plugin.WaymarkManager.PlaceWaymarkPlaceholder(w, p);
}
HoverTooltip("Import markers as draft");
ImGui.SameLine();
if (ImGuiComponents.IconButton(FontAwesomeIcon.Times))
{
Plugin.WaymarkManager.NativeClearWaymarks();
}
HoverTooltip("Clear Waymarks");
}
ImGui.Text("Saved Presets");

var presets = Plugin.Config.SavedPresets;
Expand Down

0 comments on commit f2eca17

Please sign in to comment.