Beispiel #1
0
  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;
  }
Beispiel #2
0
 public void saveLayout() {
   final SaveOpenDialog dlgSave = new SaveOpenDialog();
   final FileLocation layoutFile = Singletons.getControl().getCurrentScreen().getLayoutFile();
   final File defFile = layoutFile != null ? new File(layoutFile.userPrefLoc) : null;
   final File saveFile = dlgSave.SaveDialog(defFile, Filetypes.LAYOUT);
   if (saveFile != null) {
     SLayoutIO.saveLayout(saveFile);
   }
 }