/** After view and model have been initialized, control can start. */ public void initialize() { // Preloads skin components (using progress bar). FSkin.loadFull(true); display = FView.SINGLETON_INSTANCE.getLpnDocument(); final ForgePreferences prefs = FModel.getPreferences(); closeAction = CloseAction.valueOf(prefs.getPref(FPref.UI_CLOSE_ACTION)); FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Loading quest..."); // Preload quest data if present final File dirQuests = new File(ForgeConstants.QUEST_SAVE_DIR); final String questname = FModel.getQuestPreferences().getPref(QPref.CURRENT_QUEST); final File data = new File(dirQuests.getPath(), questname); if (data.exists()) { FModel.getQuest().load(QuestDataIO.loadData(data)); } // Handles resizing in null layouts of layers in JLayeredPane as well as saving window layout final FFrame window = Singletons.getView().getFrame(); window.addComponentListener( new ComponentAdapter() { @Override public void componentResized(final ComponentEvent e) { sizeChildren(); window.updateNormalBounds(); SLayoutIO.saveWindowLayout(); } @Override public void componentMoved(final ComponentEvent e) { window.updateNormalBounds(); SLayoutIO.saveWindowLayout(); } }); FView.SINGLETON_INSTANCE .getLpnDocument() .addMouseListener(SOverflowUtil.getHideOverflowListener()); FView.SINGLETON_INSTANCE .getLpnDocument() .addComponentListener(SResizingUtil.getWindowResizeListener()); setGlobalKeyboardHandler(); FView.SINGLETON_INSTANCE.setSplashProgessBarMessage("Opening main window..."); SwingUtilities.invokeLater( new Runnable() { @Override public void run() { Singletons.getView().initialize(); } }); }
/** * Rename this quest. * * @param newName the new name to set */ public void rename(final String newName) { File newpath = new File(ForgeConstants.QUEST_SAVE_DIR, newName + ".dat"); File oldpath = new File(ForgeConstants.QUEST_SAVE_DIR, this.name + ".dat"); oldpath.renameTo(newpath); newpath = new File(ForgeConstants.QUEST_SAVE_DIR, newName + ".dat.bak"); oldpath = new File(ForgeConstants.QUEST_SAVE_DIR, this.name + ".dat.bak"); oldpath.renameTo(newpath); this.name = newName; QuestDataIO.saveData(this); }
/** Save data. */ public void saveData() { QuestDataIO.saveData(this); }