Skip to content

Commit

Permalink
Using correct API to find options files. (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaskelly authored Nov 27, 2020
1 parent 88cc1df commit 15645f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.interrupt.dungeoneer.editor;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import com.interrupt.dungeoneer.game.Game;
import com.interrupt.utils.JsonUtil;

/** Editor options container class. */
Expand All @@ -14,7 +14,7 @@ public EditorOptions() {
}

public static EditorOptions fromLocalFiles() {
FileHandle file = Gdx.files.local(getEditorOptionsFilePath());
FileHandle file = Game.getFile(getEditorOptionsFilePath());

return JsonUtil.fromJson(EditorOptions.class, file, ()-> {
EditorOptions eo = new EditorOptions();
Expand All @@ -24,7 +24,8 @@ public static EditorOptions fromLocalFiles() {
}

public static void toLocalFiles(EditorOptions instance) {
JsonUtil.toJson(instance, getEditorOptionsFilePath());
FileHandle file = Game.getFile(getEditorOptionsFilePath());
JsonUtil.toJson(instance, file);
}

public void save() {
Expand All @@ -36,7 +37,7 @@ public void dispose() {
}

public static String getEditorOptionsFilePath() {
return "/save/editor.txt";
return "save/editor.txt";
}

public void removeRecentlyOpenedFile(String path) {
Expand Down
5 changes: 3 additions & 2 deletions Dungeoneer/src/com/interrupt/dungeoneer/game/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static String getOptionsFilePath() {

/** Load options from file and update instance. */
public static void loadOptions() {
FileHandle file = Gdx.files.local(getOptionsFilePath());
FileHandle file = Game.getFile(getOptionsFilePath());

instance = JsonUtil.fromJson(Options.class, file, () -> {
Options o = new Options(Gdx.app.getType());
Expand All @@ -183,7 +183,8 @@ public static void saveOptions() {
}

try {
JsonUtil.toJson(instance, getOptionsFilePath());
FileHandle file = Game.getFile(getOptionsFilePath());
JsonUtil.toJson(instance, file);
}
catch (Exception e) {
Gdx.app.log("Delver", "Failed to save options file.");
Expand Down
6 changes: 0 additions & 6 deletions Dungeoneer/src/com/interrupt/utils/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

/** Helper class for working with JSON. */
public class JsonUtil {
/** Serializes the given object to the specified path. */
public static void toJson(Object object, String path) {
FileHandle file = Gdx.files.local(path);
toJson(object, file);
}

/** Serializes the given object to the given file. */
public static void toJson(Object object, FileHandle file) {
if (file == null) {
Expand Down

0 comments on commit 15645f9

Please sign in to comment.