Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intuitive Maneuvers fix #16

Merged
merged 2 commits into from
Apr 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion GameData/PreciseNode/Localization/en-us.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#PN_Peri = Peri
#PN_DN = DN
#PN_MinusOrb = -Orb
#PN_PlusOrb = - +Orb
#PN_PlusOrb = +Orb
#PN_Minus1K = -1K
#PN_Plus1K = +1K
#PN_AN = AN
Expand Down
2 changes: 1 addition & 1 deletion GameData/PreciseNode/Localization/es-es.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Localization
#PN_Peri = Peri
#PN_DN = ND
#PN_MinusOrb = -Orb
#PN_PlusOrb =- +Orb
#PN_PlusOrb = +Orb
#PN_Minus1K = -1K
#PN_Plus1K = +1K
#PN_AN = NA
Expand Down
2 changes: 1 addition & 1 deletion GameData/PreciseNode/Localization/ru.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#PN_Peri = Пе
#PN_DN = DN
#PN_MinusOrb = -Orb
#PN_PlusOrb =- +Orb
#PN_PlusOrb = +Orb
#PN_Minus1K = -1K
#PN_Plus1K = +1K
#PN_AN = AN
Expand Down
4 changes: 3 additions & 1 deletion PreciseNode/Internal/IntuitiveNodeGizmoHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ internal class IntuitiveNodeGizmoHandler {

public void DeleteHandler() {
DetachHandleHandlers();
this.maneuverNode.attachedGizmo.OnDelete -= this.DeleteHandler;

if(this.maneuverNode.attachedGizmo != null)
this.maneuverNode.attachedGizmo.OnDelete -= this.DeleteHandler;

// remove this handler from the addin's list
this.intuitiveManeuvers.RemoveIntuitiveManeuverHandler(this);
Expand Down
34 changes: 21 additions & 13 deletions PreciseNode/Internal/IntuitiveNodeGizmosManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,40 @@ internal class IntuitiveNodeGizmosManager {
}

internal void OnDestroy() {
while (this.maneuverGizmoHandlers.Count > 0)
this.maneuverGizmoHandlers[0].DeleteHandler();
ClearHandlers();
}

PatchedConicSolver curSolver = null;
private void UpdateIntuitiveManeuverHandlersList() {
PatchedConicSolver solver = NodeTools.getSolver();

if (solver != curSolver)
{
this.maneuverGizmoHandlers.Clear();
ClearHandlers();
curSolver = solver;
if (solver != null)
}

if (solver != null)
{
List<ManeuverNode> nodes = solver.maneuverNodes;

for (int i = 0; i < nodes.Count; i++)
{
List<ManeuverNode> nodes = solver.maneuverNodes;
for (int i = 0; i < nodes.Count; i++)
{
ManeuverNode node = nodes[i];
if ((node.attachedGizmo != null) && !isHandled(node))
{
this.maneuverGizmoHandlers.Add(new IntuitiveNodeGizmoHandler(this, node, options));
}
}
ManeuverNode node = nodes[i];
if (node.attachedGizmo != null && !isHandled(node))
this.maneuverGizmoHandlers.Add(new IntuitiveNodeGizmoHandler(this, node, options));
}

if (nodes.Count == 0 && this.maneuverGizmoHandlers.Count > 0)
ClearHandlers();
}
}

private void ClearHandlers() {
while (this.maneuverGizmoHandlers.Count > 0)
this.maneuverGizmoHandlers[0].DeleteHandler();
}

private bool isHandled(ManeuverNode node) {
for (int i = 0; i < maneuverGizmoHandlers.Count; i++) {
if (node == maneuverGizmoHandlers[i].ManeuverNode) {
Expand Down