cleaned up folder organization, music selection ui cleaned up for lower resolutions
This commit is contained in:
66
core/src/zero1hd/polyjet/util/RoundingResolutionHandler.java
Executable file
66
core/src/zero1hd/polyjet/util/RoundingResolutionHandler.java
Executable file
@@ -0,0 +1,66 @@
|
||||
package zero1hd.polyjet.util;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.assets.loaders.FileHandleResolver;
|
||||
import com.badlogic.gdx.assets.loaders.resolvers.ResolutionFileResolver.Resolution;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
|
||||
public class RoundingResolutionHandler implements FileHandleResolver {
|
||||
private final Resolution[] descriptors;
|
||||
private final FileHandleResolver resolver;
|
||||
|
||||
public RoundingResolutionHandler(FileHandleResolver fileResolver, Resolution... descriptors) {
|
||||
if (descriptors.length == 0) throw new IllegalArgumentException("At least one Resolution needs to be supplied.");
|
||||
this.descriptors = descriptors;
|
||||
this.resolver = fileResolver;
|
||||
}
|
||||
|
||||
|
||||
public Resolution chooseRounded(Resolution... descriptors) {
|
||||
Resolution best = descriptors[0];
|
||||
|
||||
int leastDifference = -1;
|
||||
|
||||
int w = MathUtils.round(Gdx.graphics.getWidth()*Gdx.graphics.getDensity()), h = MathUtils.round(Gdx.graphics.getHeight()*Gdx.graphics.getDensity());
|
||||
|
||||
if (w < h) {
|
||||
for (int i = 0; i < descriptors.length; i++) {
|
||||
int currentDiff = h - descriptors[i].portraitHeight;
|
||||
|
||||
if (currentDiff < 0) {
|
||||
currentDiff = currentDiff*-1;
|
||||
}
|
||||
|
||||
if (currentDiff < leastDifference || leastDifference == -1) {
|
||||
best = descriptors[i];
|
||||
leastDifference = currentDiff;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < descriptors.length; i++) {
|
||||
int currentDiff = w - descriptors[i].portraitWidth;
|
||||
|
||||
if (currentDiff < 0) {
|
||||
currentDiff = currentDiff*-1;
|
||||
}
|
||||
|
||||
if (currentDiff < leastDifference || leastDifference == -1) {
|
||||
best = descriptors[i];
|
||||
leastDifference = currentDiff;
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileHandle resolve(String fileName) {
|
||||
Resolution bestRes = chooseRounded(descriptors);
|
||||
FileHandle initialHandle = new FileHandle(fileName);
|
||||
|
||||
FileHandle resSpecificFile = resolver.resolve(bestRes.folder + "/" + initialHandle.name());
|
||||
if (!resSpecificFile.exists()) resSpecificFile = resolver.resolve(fileName);
|
||||
return resSpecificFile;
|
||||
}
|
||||
}
|
5
core/src/zero1hd/polyjet/util/TransitionAdapter.java
Executable file
5
core/src/zero1hd/polyjet/util/TransitionAdapter.java
Executable file
@@ -0,0 +1,5 @@
|
||||
package zero1hd.polyjet.util;
|
||||
|
||||
public interface TransitionAdapter {
|
||||
public void postTransition();
|
||||
}
|
Reference in New Issue
Block a user