v0.7.3: adjusted window saving to block restoring to a different scene type
This commit is contained in:
parent
133a39026e
commit
7ca293bcc5
|
@ -136,9 +136,11 @@ public class PixelScene extends Scene {
|
||||||
|
|
||||||
//FIXME this system currently only works for a subset of windows
|
//FIXME this system currently only works for a subset of windows
|
||||||
private static ArrayList<Class<?extends Window>> savedWindows = new ArrayList<>();
|
private static ArrayList<Class<?extends Window>> savedWindows = new ArrayList<>();
|
||||||
|
private static Class<?extends PixelScene> savedClass = null;
|
||||||
|
|
||||||
public void saveWindows(){
|
public void saveWindows(){
|
||||||
savedWindows.clear();
|
savedWindows.clear();
|
||||||
|
savedClass = getClass();
|
||||||
for (Gizmo g : members){
|
for (Gizmo g : members){
|
||||||
if (g instanceof Window){
|
if (g instanceof Window){
|
||||||
savedWindows.add((Class<? extends Window>) g.getClass());
|
savedWindows.add((Class<? extends Window>) g.getClass());
|
||||||
|
@ -147,7 +149,7 @@ public class PixelScene extends Scene {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void restoreWindows(){
|
public void restoreWindows(){
|
||||||
if (!savedWindows.isEmpty()){
|
if (getClass().equals(savedClass)){
|
||||||
for (Class<?extends Window> w : savedWindows){
|
for (Class<?extends Window> w : savedWindows){
|
||||||
try{
|
try{
|
||||||
add(w.newInstance());
|
add(w.newInstance());
|
||||||
|
@ -155,8 +157,8 @@ public class PixelScene extends Scene {
|
||||||
//window has no public zero-arg constructor, just eat the exception
|
//window has no public zero-arg constructor, just eat the exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
savedWindows.clear();
|
|
||||||
}
|
}
|
||||||
|
savedWindows.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue
Block a user