[#2126] Apply freeform conversion to config listeners
This commit is contained in:
parent
98fb726c4b
commit
2822e0ec27
@ -45,15 +45,16 @@ public class FreeformFinSet extends FinSet {
|
|||||||
* The specified fin set should not be used after the call!
|
* The specified fin set should not be used after the call!
|
||||||
*
|
*
|
||||||
* @param finset the fin set to convert.
|
* @param finset the fin set to convert.
|
||||||
|
* @param freezeRocket whether to freeze the rocket before conversion.
|
||||||
* @return the new freeform fin set.
|
* @return the new freeform fin set.
|
||||||
*/
|
*/
|
||||||
public static FreeformFinSet convertFinSet(FinSet finset) {
|
public static FreeformFinSet convertFinSet(FinSet finset, boolean freezeRocket) {
|
||||||
final RocketComponent root = finset.getRoot();
|
final RocketComponent root = finset.getRoot();
|
||||||
FreeformFinSet freeform;
|
FreeformFinSet freeform;
|
||||||
List<RocketComponent> toInvalidate = new ArrayList<>();
|
List<RocketComponent> toInvalidate = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (root instanceof Rocket) {
|
if (freezeRocket && root instanceof Rocket) {
|
||||||
((Rocket) root).freeze();
|
((Rocket) root).freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +93,17 @@ public class FreeformFinSet extends FinSet {
|
|||||||
parent.addChild(freeform, position);
|
parent.addChild(freeform, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Convert config listeners
|
||||||
|
for (RocketComponent listener : finset.configListeners) {
|
||||||
|
if (listener instanceof FinSet) {
|
||||||
|
FreeformFinSet listenerSet = FreeformFinSet.convertFinSet((FinSet) listener, false);
|
||||||
|
freeform.addConfigListener(listenerSet);
|
||||||
|
finset.removeConfigListener(listener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (root instanceof Rocket) {
|
if (freezeRocket && root instanceof Rocket) {
|
||||||
((Rocket) root).thaw();
|
((Rocket) root).thaw();
|
||||||
}
|
}
|
||||||
// Invalidate components after events have been fired
|
// Invalidate components after events have been fired
|
||||||
@ -101,9 +111,24 @@ public class FreeformFinSet extends FinSet {
|
|||||||
c.invalidate();
|
c.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return freeform;
|
return freeform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert an existing fin set into a freeform fin set. The specified
|
||||||
|
* fin set is taken out of the rocket tree (if any) and the new component
|
||||||
|
* inserted in its stead.
|
||||||
|
* <p>
|
||||||
|
* The specified fin set should not be used after the call!
|
||||||
|
*
|
||||||
|
* @param finset the fin set to convert.
|
||||||
|
* @return the new freeform fin set.
|
||||||
|
*/
|
||||||
|
public static FreeformFinSet convertFinSet(FinSet finset) {
|
||||||
|
return convertFinSet(finset, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a point of this fin set to edit into a point for a config listener to edit.
|
* Converts a point of this fin set to edit into a point for a config listener to edit.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user