diff --git a/core/src/main/java/de/sesu8642/feudaltactics/lib/gamestate/ScenarioGameStateLoader.java b/core/src/main/java/de/sesu8642/feudaltactics/lib/gamestate/ScenarioGameStateLoader.java index 88da575..21508f6 100644 --- a/core/src/main/java/de/sesu8642/feudaltactics/lib/gamestate/ScenarioGameStateLoader.java +++ b/core/src/main/java/de/sesu8642/feudaltactics/lib/gamestate/ScenarioGameStateLoader.java @@ -1,14 +1,12 @@ package de.sesu8642.feudaltactics.lib.gamestate; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.Json; import com.badlogic.gdx.utils.JsonReader; import com.badlogic.gdx.utils.JsonValue; import com.badlogic.gdx.utils.JsonWriter.OutputType; -import com.google.common.io.Resources; -import de.sesu8642.feudaltactics.exceptions.FatalErrorException; -import java.io.IOException; -import java.net.URL; import java.nio.charset.StandardCharsets; /** @@ -30,13 +28,9 @@ public ScenarioGameStateLoader() { * @return loaded gameState */ public GameState loadScenarioGameState(ScenarioMap scenarioMap) { - URL url = Resources.getResource(scenarioMap.mapPath); - String loadedString = null; - try { - loadedString = Resources.toString(url, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new FatalErrorException("Unable to load scenario map from " + scenarioMap.mapPath); - } + FileHandle assetsFileHandle = Gdx.files.internal(scenarioMap.mapPath); + String loadedString = assetsFileHandle.readString(StandardCharsets.UTF_8.name()); + JsonValue loadedStateJsonValue = jsonReader.parse(loadedString); return json.readValue(GameState.class, loadedStateJsonValue); } diff --git a/core/src/main/java/de/sesu8642/feudaltactics/menu/common/ui/FeudalTacticsDialog.java b/core/src/main/java/de/sesu8642/feudaltactics/menu/common/ui/FeudalTacticsDialog.java index fb8aec2..7a55a6d 100644 --- a/core/src/main/java/de/sesu8642/feudaltactics/menu/common/ui/FeudalTacticsDialog.java +++ b/core/src/main/java/de/sesu8642/feudaltactics/menu/common/ui/FeudalTacticsDialog.java @@ -18,8 +18,6 @@ public class FeudalTacticsDialog extends Dialog { public static final float DIALOG_PADDING = 20; public static final float DIALOG_LABEL_MAX_WIDTH = 600; - private static final float MAX_RESPONSIVE_SMALL_IMAGE_WIDTH = Gdx.graphics.getDensity() * 150F; - private final Skin skin; /** @@ -97,14 +95,11 @@ public FeudalTacticsDialog addTable(List> data) { */ public FeudalTacticsDialog addButtonImage(String spriteName) { Sprite sprite = skin.getSprite(spriteName); - float aspectRatio = sprite.getHeight() / sprite.getWidth(); Image image = new Image(sprite); image.setColor(skin.getColor(SkinConstants.COLOR_HIGHLIGHT2)); - this.getContentTable().add(image).prefWidth(0).maxWidth(MAX_RESPONSIVE_SMALL_IMAGE_WIDTH) - .height(Value.percentWidth(aspectRatio)) - .expand().fill(); + this.getContentTable().add(image).size(Value.percentWidth(0.2F, this.getContentTable())); this.getContentTable().row(); return this; } - + }