[updated] TextureLoader, added filter.
[fixed] Json bug with ignore unknown fields.
int amount = settings.padding / 2;\r
int imageWidth = image.getWidth();\r
int imageHeight = image.getHeight();\r
+ // Copy corner pixels to fill corners of the padding.\r
+ g.drawImage(image, node.left - amount, node.top - amount, node.left, node.top, 0, 0, 1, 1, null);\r
+ g.drawImage(image, node.left + imageWidth, node.top - amount, node.left + imageWidth + amount, node.top, 0, 0, 1,\r
+ 1, null);\r
+ g.drawImage(image, node.left - amount, node.top + imageHeight, node.left, node.top + imageHeight + amount, 0, 0,\r
+ 1, 1, null);\r
+ g.drawImage(image, node.left + imageWidth, node.top + imageHeight, node.left + imageWidth + amount, node.top\r
+ + imageHeight + amount, 0, 0, 1, 1, null);\r
+ // Copy edge picels into padding.\r
g.drawImage(image, node.left, node.top - amount, node.left + imageWidth, node.top, 0, 0, imageWidth, 1, null);\r
g.drawImage(image, node.left, node.top + imageHeight, node.left + imageWidth, node.top + imageHeight + amount, 0,\r
imageHeight - 1, imageWidth, imageHeight, null);\r
ObjectMap<String, String> bitmapFontMap = null;\r
if (resources != null) bitmapFontMap = resources.get(BitmapFont.class.getName());\r
\r
+ skinFile = resolve(fileName);\r
+ \r
fontPaths = new ObjectMap();\r
if (bitmapFontMap != null) {\r
- skinFile = resolve(fileName);\r
for (Entry<String, String> entry : bitmapFontMap.entries()) {\r
FileHandle fontFile = skinFile.parent().child(entry.value);\r
if (!fontFile.exists()) fontFile = Gdx.files.internal(entry.value);\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
- ******************************************************************************/
+ ******************************************************************************/\r
+\r
package com.badlogic.gdx.assets.loaders;\r
\r
-import com.badlogic.gdx.Gdx;\r
import com.badlogic.gdx.assets.AssetDescriptor;\r
import com.badlogic.gdx.assets.AssetLoaderParameters;\r
import com.badlogic.gdx.assets.AssetManager;\r
import com.badlogic.gdx.graphics.Pixmap;\r
import com.badlogic.gdx.graphics.Pixmap.Format;\r
import com.badlogic.gdx.graphics.Texture;\r
+import com.badlogic.gdx.graphics.Texture.TextureFilter;\r
import com.badlogic.gdx.graphics.TextureData;\r
import com.badlogic.gdx.graphics.glutils.ETC1TextureData;\r
import com.badlogic.gdx.graphics.glutils.FileTextureData;\r
\r
@Override\r
public void loadAsync (AssetManager manager, String fileName, TextureParameter parameter) {\r
- if(parameter == null || (parameter != null && parameter.textureData == null)) {\r
+ if (parameter == null || (parameter != null && parameter.textureData == null)) {\r
Pixmap pixmap = null;\r
Format format = null;\r
boolean genMipMaps = false;\r
genMipMaps = parameter.genMipMaps;\r
texture = parameter.texture;\r
}\r
- \r
+\r
FileHandle handle = resolve(fileName);\r
- if(!fileName.contains(".etc1")) {\r
+ if (!fileName.contains(".etc1")) {\r
pixmap = new Pixmap(handle);\r
data = new FileTextureData(handle, pixmap, format, genMipMaps);\r
} else {\r
\r
@Override\r
public Texture loadSync (AssetManager manager, String fileName, TextureParameter parameter) {\r
+ Texture texture = this.texture;\r
if (texture != null) {\r
texture.load(data);\r
- return texture;\r
} else {\r
- return new Texture(data);\r
+ texture = new Texture(data);\r
}\r
+ if (parameter != null) texture.setFilter(parameter.minFilter, parameter.magFilter);\r
+ return texture;\r
}\r
\r
@Override\r
public Texture texture = null;\r
/** TextureData for textures created on the fly, optional. When set, all format and genMipMaps are ignored */\r
public TextureData textureData = null;\r
+ public TextureFilter minFilter = TextureFilter.Nearest;\r
+ public TextureFilter magFilter = TextureFilter.Nearest;\r
}\r
-}
\ No newline at end of file
+}\r
\r
/** Returns the region's width. May be negative if the texture region is flipped horizontally. */\r
public int getRegionWidth () {\r
- return (int)(u2 * texture.getWidth()) - (int)(u * texture.getWidth());\r
+ return Math.round((u2 - u) * texture.getWidth());\r
}\r
\r
public void setRegionWidth (int width) {\r
\r
/** Returns the region's height. May be negative if the texture region is flipped horizontally. */\r
public int getRegionHeight () {\r
- return (int)(v2 * texture.getHeight()) - (int)(v * texture.getHeight());\r
+ return Math.round((v2 - v) * texture.getHeight());\r
}\r
\r
public void setRegionHeight (int height) {\r
* \r
* <h2>Layout</h2> A ComboBox's (preferred) width and height are determined by the border patches in the background\r
* {@link NinePatch} as well as the bounding box of the widest item in the list of strings. Use\r
- * {@link ComboBox#setPrefSize(int, int)} to change this size programmatically. In case the set size is to small to contain the\r
+ * to change this size programmatically. In case the set size is to small to contain the\r
* widest item, artifacts may appear.</p>\r
* \r
* The additional popup list will be positioned at the bottom edge of the ComboBox, displaying all items. The width and size is\r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newComboBox(String, String[], Stage, String)}.</li>\r
+ * .</li>\r
* <li>The <code>background</code> attribute references a {@link NinePatch} by name, to be used as the ComboBox's background</li>\r
* <li>The <code>listBackground</code> attribute references a {@link NinePatch} by name, to be used as the background for the\r
* popup list</li>\r
* registered with the list to listen to selection changes. Items have an index in the list, the top item having the index 0.\r
* \r
* <h2>Layout</h2> The (preferred) width and height of a List are derrived from the bounding box around all list items. Use\r
- * {@link #setPrefSize(int, int)} to programmatically change the size to your liking. In case the width and height you set are to\r
+ * to programmatically change the size to your liking. In case the width and height you set are to\r
* small for the contained text you will see artifacts. The patch highlighting the current selection will have the width of the\r
* List, either determined as explained above or set programmatically.\r
* \r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newList(String, String[], String)}.</li>\r
+ * .</li>\r
* <li>The <code>fontName</code> attribute references a {@link BitmapFont} by name, to be used for render the items</li>\r
* <li>The <code>fontColorUnselected</code> attribute references a {@link Color} by name, to be used for render unselected items</li>\r
* <li>The <code>fontColorSelected</code> attribute references a {@link Color} by name, to be used to render the selected item</li>\r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newScrollPane(String, Stage, Actor, int, int, String)}.</li>\r
+ * .</li>\r
* <li>The <code>background</code> attribute references a {@link NinePatch} by name, to be used as the scroll pane's background</li>\r
* <li>The <code>hScroll</code> attribute references a {@link NinePatch} by name, to be used as the scroll pane's horizontal\r
* scroll bar.</li>\r
* \r
* <h2>Layout</h2> A slider's (preferred) width and height are determined by the parameter past to its constructor as well as the\r
* maximum height of the {@link NinePatch} and {@link TextureRegion} involved in the display of the slider. Use\r
- * {@link #setPrefSize(int, int)} to programmatically change the size to your liking. In case the width and height you set are to\r
+ * to programmatically change the size to your liking. In case the width and height you set are to\r
* small you will see artifacts.</p>\r
* \r
* The slider background will only be stretched in the x-axis. The slider handle will be centered on the background vertically.\r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newSlider(String, float, float, float, float, String)}.</li>\r
+ * .</li>\r
* <li>The <code>slider</code> attribute references a {@link NinePatch} by name, to be used as the slider's background</li>\r
* <li>The <code>knob</code> attribute references a {@link TextureRegion} by name, to be used as the slider's handle</li> *\r
* </ul>\r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newSplitPane(String, Stage, Actor, Actor, boolean, int, int, String)}.</li>\r
+ * .</li>\r
* <li>The <code>handle</code> attribute references a {@link NinePatch} by name, to be used as the split pane's handle</li>\r
* </ul>\r
* @author mzechner */\r
* \r
* <h2>Layout</h2>\r
* The (preferred) width and height of a TextField are derrived from the width given at construction time as well as the\r
- * combination of the used font's height and the top and bottom border patches. Use {@link Button#setPrefSize(int, int)} to\r
+ * combination of the used font's height and the top and bottom border patches. Use to\r
* programmatically change the size to your liking. In case the width and height you set are to small for the contained text, the\r
* TextField will clip the characters based on the current cursor position.\r
* \r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newTextField(String, float, String)}.</li>\r
+ * .</li>\r
* <li>The <code>font</code> attribute references a {@link BitmapFont} by name, to be used to render the text in the text field</li>\r
* <li>The <code>fontColor</code> attribute references a {@link Color} by name, to be used to render the text on the text field</li>\r
* <li>The <code>cursorPatch</code> attribute references a {@link NinePatch} by name, to be used to render the text field's cursor\r
* \r
* <ul>\r
* <li>The <code>name</code> attribute defines the name of the style which you can later use with\r
- * {@link Skin#newWindow(String, Stage, String, int, int, String)}.</li>\r
+ * .</li>\r
* <li>The <code>titleFont</code> attribute references a {@link BitmapFont} by name, to be used to render the title string.</li>\r
* *\r
* <li>The <code>titleFontColor</code> attribute references a {@link Color} by name, to be used to render the title string.</li>\r
if (fields == null) fields = cacheFields(type);\r
for (Entry<String, Object> entry : jsonMap.entries()) {\r
FieldMetadata metadata = fields.get(entry.key);\r
- if (ignoreUnknownFields) {\r
- if (debug) System.out.println("Ignoring unknown field: " + entry.key + " (" + type.getName() + ")");\r
- } else if (metadata == null)\r
- throw new SerializationException("Field not found: " + entry.key + " (" + type.getName() + ")");\r
+ if (metadata == null) {\r
+ if (ignoreUnknownFields) {\r
+ if (debug) System.out.println("Ignoring unknown field: " + entry.key + " (" + type.getName() + ")");\r
+ continue;\r
+ } else\r
+ throw new SerializationException("Field not found: " + entry.key + " (" + type.getName() + ")");\r
+ }\r
Field field = metadata.field;\r
if (entry.value == null) continue;\r
try {\r