Fix themes not being shown on desktop
This commit is contained in:
parent
43483cc950
commit
f1b05d4c79
2 changed files with 17 additions and 6 deletions
2
android/assets/themes/theme.list
Normal file
2
android/assets/themes/theme.list
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
default
|
||||||
|
dark
|
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.graphics.Texture;
|
||||||
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
import com.badlogic.gdx.graphics.g2d.NinePatch;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
|
||||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||||
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.JsonReader;
|
import com.badlogic.gdx.utils.JsonReader;
|
||||||
import com.badlogic.gdx.utils.JsonValue;
|
import com.badlogic.gdx.utils.JsonValue;
|
||||||
|
|
||||||
|
@ -52,17 +53,25 @@ public class Theme {
|
||||||
|
|
||||||
//region Static methods
|
//region Static methods
|
||||||
|
|
||||||
public static boolean exists(final String name) {
|
static boolean exists(final String name) {
|
||||||
return Gdx.files.internal("themes/"+name+".theme").exists();
|
return Gdx.files.internal("themes/"+name+".theme").exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets all the available themes on the available on the internal game storage
|
// Gets all the available themes on the available on the internal game storage
|
||||||
public static Theme[] getThemes() {
|
public static Array<Theme> getThemes() {
|
||||||
FileHandle[] handles = Gdx.files.internal("themes").list();
|
String[] themes = Gdx.files.internal("themes/theme.list").readString().split("\n");
|
||||||
|
|
||||||
Theme[] result = new Theme[handles.length];
|
Array<Theme> result = new Array<Theme>(themes.length);
|
||||||
for (int i = 0; i < handles.length; ++i)
|
for (int i = 0; i < themes.length; ++i) {
|
||||||
result[i] = Theme.fromFile(handles[i]);
|
FileHandle file = Gdx.files.internal("themes/" + themes[i] + ".theme");
|
||||||
|
if (file.exists())
|
||||||
|
result.add(Theme.fromFile(file));
|
||||||
|
else {
|
||||||
|
Gdx.app.log(
|
||||||
|
"Theme/Info", "Non-existing theme '" + themes[i] +
|
||||||
|
"' found on theme.list (line " + (i + 1) + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue