This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build-129: Save settings, API changes, removed unused files and fixes.
- Loading branch information
Showing
30 changed files
with
176 additions
and
441 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/main/java/net/guerra24/voxel/client/core/GameSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package net.guerra24.voxel.client.core; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
public class GameSettings { | ||
|
||
private Properties prop; | ||
private File settings; | ||
|
||
public GameSettings() { | ||
settings = new File(VoxelVariables.settings); | ||
prop = new Properties(); | ||
if (settings.exists()) { | ||
try { | ||
prop.load(new FileInputStream(settings)); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
VoxelVariables.useShadows = Boolean.parseBoolean(getValue("useShadows")); | ||
VoxelVariables.useVolumetricLight = Boolean.parseBoolean(getValue("useVolumetricLight")); | ||
VoxelVariables.useHQWater = Boolean.parseBoolean(getValue("useHQWater")); | ||
VoxelVariables.useFXAA = Boolean.parseBoolean(getValue("useFXAA")); | ||
} else { | ||
updateSetting(); | ||
save(); | ||
} | ||
} | ||
|
||
public void registerValue(String key, String data) { | ||
prop.setProperty(key, data); | ||
} | ||
|
||
public String getValue(String key) { | ||
return prop.getProperty(key); | ||
} | ||
|
||
public void save() { | ||
try { | ||
prop.store(new FileOutputStream(settings), "Voxel Settings"); | ||
} catch (FileNotFoundException e) { | ||
e.printStackTrace(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void updateSetting() { | ||
registerValue("useShadows", Boolean.toString(VoxelVariables.useShadows)); | ||
registerValue("useVolumetricLight", Boolean.toString(VoxelVariables.useVolumetricLight)); | ||
registerValue("useHQWater", Boolean.toString(VoxelVariables.useHQWater)); | ||
registerValue("useFXAA", Boolean.toString(VoxelVariables.useFXAA)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.