Skip to content

Commit

Permalink
fix Tutorial on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
Sesu8642 committed Jan 7, 2025
1 parent f4f30cd commit 00b92c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -97,14 +95,11 @@ public FeudalTacticsDialog addTable(List<List<String>> 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;
}

}

0 comments on commit 00b92c3

Please sign in to comment.