private void writeObject(ObjectOutputStream aOutputStream) throws Exception { transmitting = true; aOutputStream.defaultWriteObject(); transmitting = false; }
public static boolean save() { if (registry.isSaving) { return false; } boolean status = true; registry.isSaving = true; resolutions.add("800x600"); resolutions.add("1024x768"); resolutions.add("1152x864"); resolutions.add("1280x720"); resolutions.add("1280x768"); resolutions.add("1280x800"); resolutions.add("1280x960"); resolutions.add("1280x1024"); resolutions.add("1360x768"); resolutions.add("1366x768"); resolutions.add("1440x900"); resolutions.add("1600x900"); resolutions.add("1600x1024"); resolutions.add("1680x1050"); resolutions.add("1920x1080"); resolutions.add("1920x1200"); // resolutions.add("Full Screen"); // try to save the settings file try { FileOutputStream settingsFile = new FileOutputStream("SettingsTemp.dat"); ObjectOutputStream settings = new ObjectOutputStream(settingsFile); settings.writeObject(new Integer(1)); // settings file version settings.writeObject(new Integer(resolution)); if (volumeMusic == 0) { settings.writeObject(new Integer(-1)); } else { settings.writeObject(new Integer(volumeMusic)); } if (volumeFX == 0) { settings.writeObject(new Integer(-1)); } else { settings.writeObject(new Integer(volumeFX)); } settings.writeObject(new Integer(buttonMoveRight)); settings.writeObject(new Integer(buttonMoveLeft)); settings.writeObject(new Integer(buttonJump)); settings.writeObject(new Integer(buttonAction)); settings.writeObject(new Integer(buttonRobot)); settings.writeObject(new Integer(buttonInventory)); settings.writeObject(new Integer(buttonPause)); settings.close(); moveFile("SettingsTemp.dat", "Settings.dat"); EIError.debugMsg("Saved Settings", EIError.ErrorLevel.Notice); } catch (Exception e) { status = false; EIError.debugMsg("Couldn't save settings " + e.getMessage(), EIError.ErrorLevel.Error); } // try to save the players for (int i = 1; i <= NUMBER_OF_PLAYER_SLOTS; i++) { try { if (player == i - 1) { FileOutputStream playerFile = new FileOutputStream("PlayerTemp.dat"); ObjectOutputStream playerInfo = new ObjectOutputStream(playerFile); playerInfo.writeObject(new Integer(2)); // settings file version playerInfo.writeObject(players.get(i - 1)); if (registry.getGameController().multiplayerMode != GameController.MultiplayerMode.CLIENT && player == i - 1) { blockManagers.set(i - 1, registry.getBlockManager()); placeableManagers.set(i - 1, registry.getPlaceableManager()); monsterManagers.set(i - 1, registry.getMonsterManager()); } playerInfo.writeObject(blockManagers.get(i - 1)); playerInfo.writeObject(placeableManagers.get(i - 1)); playerInfo.writeObject(monsterManagers.get(i - 1)); playerInfo.close(); moveFile("PlayerTemp.dat", "Player" + i + ".dat"); EIError.debugMsg("Saved Player " + i, EIError.ErrorLevel.Notice); } } catch (Exception e) { status = false; EIError.debugMsg( "Couldn't save Player " + i + " " + e.getMessage(), EIError.ErrorLevel.Error); } } registry.isSaving = false; return status; }
private void writeObject(ObjectOutputStream aOutputStream) throws Exception { aOutputStream.defaultWriteObject(); }