List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Skin getAll
public <T> ObjectMap<String, T> getAll(Class<T> type)
From source file:com.bladecoder.engine.ui.TextManagerUI.java
License:Apache License
public TextManagerUI(Skin skin) { setTouchable(Touchable.disabled);//from w w w . j ava 2 s .c om styles = skin.getAll(TextManagerUIStyle.class); for (TextManagerUIStyle style : styles.values()) { style.font.getData().markupEnabled = true; } setVisible(false); }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
/** ?? */ public static <T> boolean isStyleInUse(Skin skin, String targetStyleName, Class<T> targetStyleClazz) { if (skin == null || targetStyleName == null || targetStyleName.trim().length() == 0 || targetStyleClazz == null) { throw new IllegalArgumentException("skin?targetStyleName and targetStyleClazz can not null"); }/*from w w w .j a v a 2 s. c om*/ try { for (String widget : widgets) { Class<?> resType = Class .forName("com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style"); // ? if (resType == targetStyleClazz) { continue; } ObjectMap<String, ?> typeResources = skin.getAll(resType); if (emptyMap(typeResources)) { continue; } // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { Object objStyle = typeResources.get(styleName); Field[] fields = ClassReflection.getFields(objStyle.getClass()); for (Field field : fields) { // field if (field.isFinal() || field.isStatic() || field.isTransient()) { continue; } if (field.getType() == targetStyleClazz) { @SuppressWarnings("unchecked") T fieldObj = (T) field.get(objStyle); String fieldObjStyleName = skin.find(fieldObj); if (targetStyleName.equals(fieldObjStyleName)) { return true; } } } } } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:com.libgdx.skin.editor.utils.scene2d.CustomSkin.java
License:Apache License
/** ?? */ public static <T> boolean isResInUse(Skin skin, T target) { if (skin == null || target == null) { throw new IllegalArgumentException("skin and target can not null"); }/* ww w . j av a 2 s .c o m*/ try { Class<?> clazzTarget = target.getClass(); for (String widget : widgets) { Class<?> resType = Class .forName("com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style"); // ? if (resType == clazzTarget) { continue; } ObjectMap<String, ?> typeResources = skin.getAll(resType); if (emptyMap(typeResources)) { continue; } // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { Object objStyle = typeResources.get(styleName); Field[] fields = ClassReflection.getFields(objStyle.getClass()); for (Field field : fields) { // field if (field.isFinal() || field.isStatic() || field.isTransient()) { continue; } if (field.getType() == clazzTarget) { @SuppressWarnings("unchecked") T f = (T) field.get(objStyle); if (target.equals(f)) { return true; } } } } } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:org.shadebob.skineditor.utils.scenes.scene2d.ui.CustomSkin.java
License:Apache License
/** ?? */ public static <T> boolean isStyleInUse(Skin skin, String targetStyleName, Class<T> targetStyleClazz) { if (skin == null || targetStyleName == null || targetStyleName.trim().length() == 0 || targetStyleClazz == null) { throw new IllegalArgumentException("skin?targetStyleName and targetStyleClazz can not null"); }//from ww w. j a v a 2 s . co m try { for (String widget : SkinEditorGame.widgets) { Class<?> resType = Class .forName("com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style"); // ? if (resType == targetStyleClazz) { continue; } ObjectMap<String, ?> typeResources = skin.getAll(resType); if (emptyMap(typeResources)) { continue; } // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { Object objStyle = typeResources.get(styleName); Field[] fields = ClassReflection.getFields(objStyle.getClass()); for (Field field : fields) { // field if (field.isFinal() || field.isStatic() || field.isTransient()) { continue; } if (field.getType() == targetStyleClazz) { @SuppressWarnings("unchecked") T fieldObj = (T) field.get(objStyle); String fieldObjStyleName = skin.find(fieldObj); if (targetStyleName.equals(fieldObjStyleName)) { return true; } } } } } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:org.shadebob.skineditor.utils.scenes.scene2d.ui.CustomSkin.java
License:Apache License
/** ?? */ public static <T> boolean isResInUse(Skin skin, T target) { if (skin == null || target == null) { throw new IllegalArgumentException("skin and target can not null"); }//from ww w .jav a 2 s . c o m try { Class<?> clazzTarget = target.getClass(); for (String widget : SkinEditorGame.widgets) { Class<?> resType = Class .forName("com.badlogic.gdx.scenes.scene2d.ui." + widget + "$" + widget + "Style"); // ? if (resType == clazzTarget) { continue; } ObjectMap<String, ?> typeResources = skin.getAll(resType); if (emptyMap(typeResources)) { continue; } // styleName ?.??? Array<String> styleNames = typeResources.keys().toArray(); // ??? resType ? ? for (String styleName : styleNames) { Object objStyle = typeResources.get(styleName); Field[] fields = ClassReflection.getFields(objStyle.getClass()); for (Field field : fields) { // field if (field.isFinal() || field.isStatic() || field.isTransient()) { continue; } if (field.getType() == clazzTarget) { @SuppressWarnings("unchecked") T f = (T) field.get(objStyle); if (target.equals(f)) { return true; } } } } } } catch (Exception e) { e.printStackTrace(); } return false; }