inventory wallet view

This commit is contained in:
minjaesong
2019-02-11 18:02:52 +09:00
parent 97d0b9de64
commit 07b801ace5
6 changed files with 72 additions and 10 deletions

View File

@@ -183,6 +183,13 @@ public class AppLoader implements ApplicationListener {
public static TerrarumController gamepad = null;
public static float gamepadDeadzone = 0.2f;
public static boolean inDeadzone(TerrarumController controller, int axis) {
float ax = controller.getAxis(axis);
float zero = (axis < 4) ? getConfigFloatArray("gamepadaxiszeropoints")[axis] : 0f;
return Math.abs(ax - zero) < gamepadDeadzone;
}
/**
* For the events depends on rendering frame (e.g. flicker on post-hit invincibility)
*/
@@ -752,6 +759,21 @@ public class AppLoader implements ApplicationListener {
return ((int[]) cfg);
}
public static float[] getConfigFloatArray(String key) {
Object cfg = getConfigMaster(key);
if (cfg instanceof JsonArray) {
JsonArray jsonArray = ((JsonArray) cfg).getAsJsonArray();
//return IntArray(jsonArray.size(), { i -> jsonArray[i].asInt })
float[] floatArray = new float[jsonArray.size()];
for (int i = 0; i < jsonArray.size(); i++) {
floatArray[i] = jsonArray.get(i).getAsInt();
}
return floatArray;
}
else
return ((float[]) cfg);
}
/**
* Get config from config file. If the entry does not exist, get from defaults; if the entry is not in the default, NullPointerException will be thrown
*/