Skip to content

Commit

Permalink
Adding setting to nested rings to keep the previous ring's center
Browse files Browse the repository at this point in the history
  • Loading branch information
Tischel committed Jan 11, 2022
1 parent a305583 commit 7827ce3
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 9 deletions.
4 changes: 3 additions & 1 deletion TPie/Config/NestedRingElementWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public override void Draw()
ImGui.DragFloat("Activation Time ##NestedRing", ref NestedRingElement.ActivationTime, 0.1f, 0.2f, 5f);
DrawHelper.SetTooltip("Determines how many seconds the element needs to be hovered on to activate the nested ring.");

ImGui.NewLine();
// keep center
ImGui.Checkbox("Keep Previous Ring Center", ref NestedRingElement.KeepCenter);

ImGui.NewLine();

// icon id
Expand Down
6 changes: 4 additions & 2 deletions TPie/Models/Elements/NestedRingElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ public class NestedRingElement : RingElement
public string RingName;
public float ActivationTime;
public bool DrawText;
public bool KeepCenter;

public NestedRingElement(string ringName, float activationTime, bool drawText, uint iconId)
public NestedRingElement(string ringName, float activationTime, bool drawText, bool keepCenter, uint iconId)
{
RingName = ringName;
ActivationTime = activationTime;
DrawText = drawText;
KeepCenter = keepCenter;
IconID = iconId;
}

public NestedRingElement() : this("Ring Name", 0.5f, true, 66319) { }
public NestedRingElement() : this("Ring Name", 0.5f, true, true, 66319) { }

public override string Description()
{
Expand Down
3 changes: 2 additions & 1 deletion TPie/Models/Elements/RingElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object? exis
float activationTime = jo.Value<float>("ActivationTime");
activationTime = activationTime == 0 ? 1 : activationTime;
bool drawText = jo.GetValue("DrawText") != null ? jo.Value<bool>("DrawText") : true;
bool keepCenter = jo.GetValue("KeepCenter") != null ? jo.Value<bool>("KeepCenter") : true;
uint iconId = jo.Value<uint>("IconID");

NestedRingElement element = new NestedRingElement(ringName, activationTime, drawText, iconId);
NestedRingElement element = new NestedRingElement(ringName, activationTime, drawText, keepCenter, iconId);
element.Border = border;
return element;
}
Expand Down
10 changes: 10 additions & 0 deletions TPie/Models/Ring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using TPie.Config;
using TPie.Models.Elements;

Expand Down Expand Up @@ -367,11 +368,20 @@ private bool CheckNestedRingSelection()
ring.SetTemporalKeybind(CurrentKeybind());
Plugin.RingsManager?.ForceRing(ring);
_selectionStartTime = -1;

if (nestedRing.KeepCenter && _center.HasValue)
{
SetCursorPos((int)_center.Value.X, (int)_center.Value.Y);
}
}

return true;
}

[DllImport("user32.dll")]
private static extern bool SetCursorPos(int x, int y);


#region keybind
public void SetTemporalKeybind(KeyBind? keybind)
{
Expand Down
2 changes: 1 addition & 1 deletion TPie/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ KeyState keyState
AssemblyLocation = Assembly.GetExecutingAssembly().Location;
}

Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.2.0.3";
Version = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "1.2.1.0";

Framework.Update += Update;
UiBuilder.Draw += Draw;
Expand Down
6 changes: 3 additions & 3 deletions TPie/TPie.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<!-- Assembly Configuration -->
<PropertyGroup>
<AssemblyName>TPie</AssemblyName>
<AssemblyVersion>1.2.0.3</AssemblyVersion>
<FileVersion>1.2.0.3</FileVersion>
<InformationalVersion>1.2.0.3</InformationalVersion>
<AssemblyVersion>1.2.1.0</AssemblyVersion>
<FileVersion>1.2.1.0</FileVersion>
<InformationalVersion>1.2.1.0</InformationalVersion>
</PropertyGroup>

<!-- Build Configuration -->
Expand Down
2 changes: 1 addition & 1 deletion TPie/TPie.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"Description": "Highly configurable hotbars that can be toggled with a keybind. They can be filled with Actions, Items, Gear Sets or Macros.",
"RepoUrl": "https://github.com/Tischel/TPie",
"Tags": ["UI"],
"Changelog": "1.2.0.3\n- Fixed quick actions executing when they shouldn't.\n- Fixed ring settings window freezing when for rings with toggle mode activated."
"Changelog": "1.2.1.0\n- Added setting for nested rings to keep it centered with the previous ring.\n\t+ This will move your cursor to the center automatically after activating a nested ring.\n\t+ Enabled by default."
}
5 changes: 5 additions & 0 deletions TPie/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.2.1.0
- Added setting for nested rings to keep it centered with the previous ring.
+ This will move your cursor to the center automatically after activating a nested ring.
+ Enabled by default.

# 1.2.0.3
- Fixed quick actions executing when they shouldn't.
- Fixed ring settings window freezing when for rings with toggle mode activated.
Expand Down

0 comments on commit 7827ce3

Please sign in to comment.