public void openLayout() { SOverlayUtils.genericOverlay(); final SaveOpenDialog dlgOpen = new SaveOpenDialog(); final FileLocation layoutFile = Singletons.getControl().getCurrentScreen().getLayoutFile(); final File defFile = layoutFile != null ? new File(layoutFile.userPrefLoc) : null; final File loadFile = dlgOpen.OpenDialog(defFile, Filetypes.LAYOUT); if (loadFile != null) { FView.SINGLETON_INSTANCE.getPnlContent().removeAll(); // let it redraw everything first FThreads.invokeInEdtLater( new Runnable() { @Override public void run() { if (loadFile != null) { SLayoutIO.loadLayout(loadFile); SLayoutIO.saveLayout(null); } SOverlayUtils.hideOverlay(); } }); } }
public boolean setCurrentScreen(final FScreen screen, final boolean previousScreenClosed) { // TODO: Uncomment the line below if this function stops being used to refresh // the current screen in some places (such as Continue and Restart in the match screen) // if (currentScreen == screen) { return; } // give previous screen a chance to perform special switch handling and/or cancel switching away // from screen if (currentScreen != screen && !Singletons.getView().getNavigationBar().canSwitch(screen)) { return false; } if (currentScreen != null && currentScreen .isMatchScreen()) { // hide targeting overlay and reset image if was on match screen // SOverlayUtils.hideTargetingOverlay(); if (isMatchBackgroundImageVisible()) { FView.SINGLETON_INSTANCE.getPnlInsets().setForegroundImage(new ImageIcon()); } } clearChildren(JLayeredPane.DEFAULT_LAYER); SOverlayUtils.hideOverlay(); ImageCache.clear(); // reduce memory usage by clearing image cache when switching screens currentScreen = screen; // load layout for new current screen screen.getController().register(); try { SLayoutIO.loadLayout(null); } catch (final InvalidLayoutFileException ex) { SOptionPane.showMessageDialog( String.format( "Your %s layout file could not be read. It will be deleted after you press OK.\nThe game will proceed with default layout.", screen.getTabCaption()), "Warning!"); if (screen.deleteLayoutFile()) { SLayoutIO.loadLayout(null); // try again } } screen.getController().initialize(); screen.getView().populate(); if (screen.isMatchScreen()) { if (isMatchBackgroundImageVisible()) { FView.SINGLETON_INSTANCE .getPnlInsets() .setForegroundImage(FSkin.getIcon(FSkinProp.BG_MATCH)); } // SOverlayUtils.showTargetingOverlay(); } Singletons.getView().getNavigationBar().updateSelectedTab(); return true; }
public void revertLayout() { SOverlayUtils.genericOverlay(); FView.SINGLETON_INSTANCE.getPnlContent().removeAll(); FThreads.invokeInEdtLater( new Runnable() { @Override public void run() { SLayoutIO.loadLayout(null); SOverlayUtils.hideOverlay(); } }); }