Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added checks to prevent crash when style not present #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
### Gradle template
.gradle
build/
preview/war/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
22 changes: 22 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/copyright/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/modules/libgdx-skins.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/modules/preview/preview.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions local.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Fri Jan 13 15:45:11 CET 2017
sdk.dir=/Users/julienvillegas/Library/Android/sdk
119 changes: 62 additions & 57 deletions preview/src/com/badlogicgames/gdxskins/client/SkinTest.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package com.badlogicgames.gdxskins.client;

import com.badlogic.gdx.Application;
Expand All @@ -16,74 +17,78 @@
import com.badlogicgames.gdxskins.client.skins.info.SkinMeta;
import com.google.gwt.user.client.Window;

/**
* @author Tom-Ski
*/
/** @author Tom-Ski */
public class SkinTest extends ApplicationAdapter {

public static Array<SkinContainer> skins = new Array<SkinContainer>();
private SkinPreviewer skinPreviewer;
private Stage stage;
public static Array<SkinContainer> skins = new Array<SkinContainer>();
private SkinPreviewer skinPreviewer;
private Stage stage;
private static final String initialSkinFolderName = "testskin";

@Override
public void create () {
Gdx.app.setLogLevel(Application.LOG_INFO);
@Override
public void create () {
Gdx.app.setLogLevel(Application.LOG_INFO);

String masterListString = Gdx.files.internal("masterlist").readString();
String[] masterSplit = masterListString.split("\r\n");
String masterListString = Gdx.files.internal("masterlist").readString();
String[] masterSplit = masterListString.split("\r\n");

Json json = new Json();
for (int i = 0; i < masterSplit.length; i++) {
String skinString = masterSplit[i];
String skinjson = Gdx.files.internal(skinString + "/info.json").readString();
SkinMeta meta = json.fromJson(SkinMeta.class, skinjson);
Skin skin = new Skin(Gdx.files.internal(skinString + "/assets/" + meta.filename));
skins.add(new SkinContainer(meta, skin));
}
Json json = new Json();
for (int i = 0; i < masterSplit.length; i++) {
String skinString = masterSplit[i];
String skinjson = Gdx.files.internal(skinString + "/info.json").readString();
SkinMeta meta = json.fromJson(SkinMeta.class, skinjson);
Skin skin = new Skin(Gdx.files.internal(skinString + "/assets/" + meta.filename));
skins.add(new SkinContainer(meta, skin));
}

stage = new Stage();
stage = new Stage();

String debug = Window.Location.getParameter("debug");
if (debug != null && debug.equalsIgnoreCase("true")) {
stage.setDebugAll(true);
}
Gdx.input.setInputProcessor(stage);
String debug = Window.Location.getParameter("debug");
if (debug != null && debug.equalsIgnoreCase("true")) {
stage.setDebugAll(true);
}
Gdx.input.setInputProcessor(stage);
SkinContainer initialSkin = skins.first();
for (int i = 0; i < skins.size; i++){
if (skins.get(i).skinMeta.foldername.equalsIgnoreCase(initialSkinFolderName)) {
initialSkin = skins.get(i);
}
}

SkinContainer initialSkin = skins.first();
String defaultSkin = Window.Location.getParameter("skin");
if (defaultSkin != null) {
for (SkinContainer skinContainer : skins) {
if (skinContainer.skinMeta.foldername.equals(defaultSkin)) {
initialSkin = skinContainer;
break;
}
}
}
String defaultSkin = Window.Location.getParameter("skin");
if (defaultSkin != null) {
for (SkinContainer skinContainer : skins) {
if (skinContainer.skinMeta.foldername.equals(defaultSkin)) {
initialSkin = skinContainer;
break;
}
}
}

SkinChangerListener changerListener = new SkinChangerListener();
skinPreviewer = new SkinPreviewer(initialSkin, changerListener);
changerListener.setPreviewer(skinPreviewer);
skinPreviewer.addTab(new RpgGuiTab(initialSkin));
skinPreviewer.addTab(new PreviewGui(initialSkin));
skinPreviewer.initiate();
SkinChangerListener changerListener = new SkinChangerListener();
skinPreviewer = new SkinPreviewer(initialSkin, changerListener);
changerListener.setPreviewer(skinPreviewer);
skinPreviewer.addTab(new RpgGuiTab(initialSkin));
skinPreviewer.addTab(new PreviewGui(initialSkin));
skinPreviewer.initiate();

stage.addActor(skinPreviewer);
}
stage.addActor(skinPreviewer);
}

@Override
public void render () {
Gdx.gl.glClearColor(0, 0, 0, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
@Override
public void render () {
Gdx.gl.glClearColor(0, 0, 0, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

stage.act();
stage.draw();
}
stage.act();
stage.draw();
}

@Override
public void dispose () {
stage.dispose();
for (SkinContainer skinContainer : skins) {
skinContainer.dispose();
}
}
@Override
public void dispose () {
stage.dispose();
for (SkinContainer skinContainer : skins) {
skinContainer.dispose();
}
}
}
Loading