OSDN Git Service

[updated] Revert back to int->float alpha mask.
authornathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 2 Nov 2011 23:36:42 +0000 (23:36 +0000)
committernathan.sweet <nathan.sweet@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Wed, 2 Nov 2011 23:36:42 +0000 (23:36 +0000)
[updated] Json, pretty print sorts.
[updated] Misc changes.

gdx/src/com/badlogic/gdx/graphics/g2d/NinePatch.java
gdx/src/com/badlogic/gdx/math/Interpolation.java
gdx/src/com/badlogic/gdx/scenes/scene2d/Stage.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Button.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Image.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Label.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Stack.java
gdx/src/com/badlogic/gdx/scenes/scene2d/ui/tablelayout/TableLayout.java
gdx/src/com/badlogic/gdx/utils/Json.java
gdx/src/com/badlogic/gdx/utils/NumberUtils.java

index 82135af..ecfcb09 100644 (file)
@@ -80,6 +80,10 @@ public class NinePatch {
                }\r
        }\r
 \r
+       public NinePatch (Texture texture) {\r
+               this(new TextureRegion(texture));\r
+       }\r
+\r
        public NinePatch (TextureRegion region) {\r
                this.patches = new TextureRegion[] {\r
                        //\r
index 4396db7..8c38572 100644 (file)
@@ -5,6 +5,10 @@ package com.badlogic.gdx.math;
 public abstract class Interpolation {\r
        abstract public float apply (float a);\r
 \r
+       public float apply (float start, float end, float a) {\r
+               return start + (end - start) * apply(a);\r
+       }\r
+\r
        static public final Interpolation linear = new Interpolation() {\r
                public float apply (float a) {\r
                        return a;\r
@@ -253,7 +257,7 @@ public abstract class Interpolation {
                        case 2:\r
                                widths[0] = 0.6f;\r
                                widths[1] = 0.4f;\r
-                               heights[1] = 0.1f;\r
+                               heights[1] = 0.33f;\r
                                break;\r
                        case 3:\r
                                widths[0] = 0.4f;\r
index 677b045..3c69e2e 100644 (file)
@@ -28,6 +28,8 @@ import com.badlogic.gdx.math.Vector2;
 import com.badlogic.gdx.math.Vector3;\r
 import com.badlogic.gdx.utils.Disposable;\r
 \r
+// BOZO - Set culling area on root group?\r
+\r
 /** A stage is a container for {@link Actor}s and handles distributing touch events, animating actors and asking them to render\r
  * themselves. A stage is 2D scenegraph with hierarchies of Actors.\r
  * <p>\r
index 6de4e77..57a987d 100644 (file)
@@ -63,10 +63,8 @@ public class Button extends Table {
                super(null, null, null, name);
                if (style == null) throw new IllegalArgumentException("style cannot be null.");
                setStyle(style);
-               initialize();
-       }
+               pack();
 
-       private void initialize () {
                super.setClickListener(new ClickListener() {
                        public void click (Actor actor) {
                                boolean newChecked = !isChecked;
index c27ac3b..8b300ac 100644 (file)
@@ -41,6 +41,7 @@ public class Image extends Widget {
 \r
        /** @param region May be null. */\r
        public Image (TextureRegion region, Scaling scaling, int align, String name) {\r
+               super(name);\r
                setRegion(region);\r
                this.scaling = scaling;\r
                this.align = align;\r
@@ -66,6 +67,7 @@ public class Image extends Widget {
 \r
        /** @param patch May be null. */\r
        public Image (NinePatch patch, Scaling scaling, int align, String name) {\r
+               super(name);\r
                setPatch(patch);\r
                this.scaling = scaling;\r
                this.align = align;\r
index 8e06f92..e9d96aa 100644 (file)
@@ -46,6 +46,11 @@ public class Label extends Widget {
                this(text, skin.getStyle(LabelStyle.class), null);\r
        }\r
 \r
+       /** Creates a label, using a {@link LabelStyle} that has a BitmapFont with the specified name and the specified color. */\r
+       public Label (String text, String fontName, Color color, Skin skin) {\r
+               this(text, new LabelStyle(skin.getResource(fontName, BitmapFont.class), color), null);\r
+       }\r
+\r
        public Label (String text, LabelStyle style) {\r
                this(text, style, null);\r
        }\r
@@ -63,7 +68,11 @@ public class Label extends Widget {
                if (style.font == null) throw new IllegalArgumentException("Missing LabelStyle font.");\r
                this.style = style;\r
                cache = new BitmapFontCache(style.font);\r
-               if (style.fontColor != null) cache.setColor(style.fontColor);\r
+               if (style.fontColor != null) {\r
+                       if (style.fontColor.r == 0.51f)\r
+                               System.out.println();\r
+                       cache.setColor(style.fontColor);\r
+               }\r
                invalidateHierarchy();\r
        }\r
 \r
index 7866bc7..e7cb9ef 100644 (file)
@@ -50,12 +50,16 @@ public class Stack extends WidgetGroup {
 \r
        public void layout () {\r
                for (int i = 0, n = children.size(); i < n; i++) {\r
-                       Actor actor = children.get(i);\r
-                       actor.x = 0;\r
-                       actor.y = 0;\r
-                       actor.width = width;\r
-                       actor.height = height;\r
-                       if (actor instanceof Layout) ((Layout)actor).invalidate();\r
+                       Actor child = children.get(i);\r
+                       child.x = 0;\r
+                       child.y = 0;\r
+                       child.width = width;\r
+                       child.height = height;\r
+                       if (child instanceof Layout) {\r
+                               Layout layout = (Layout)child;\r
+                               layout.invalidate();\r
+                               layout.validate();\r
+                       }\r
                }\r
        }\r
 \r
index bf3d069..1376cc8 100644 (file)
@@ -93,7 +93,15 @@ public class TableLayout extends BaseTableLayout<Actor, Table, TableLayout, Libg
                        actor.y = table.height - c.getWidgetY() - widgetHeight;\r
                        actor.width = c.getWidgetWidth();\r
                        actor.height = widgetHeight;\r
-                       if (actor instanceof Layout) ((Layout)actor).invalidate();\r
+               }\r
+               List<Actor> children = table.getActors();\r
+               for (int i = 0, n = children.size(); i < n; i++) {\r
+                       Actor child = children.get(i);\r
+                       if (child instanceof Layout) {\r
+                               Layout layout = (Layout)child;\r
+                               layout.invalidate();\r
+                               layout.validate();\r
+                       }\r
                }\r
        }\r
 \r
index 264d75c..a54decb 100644 (file)
@@ -828,18 +828,20 @@ public class Json {
 \r
        private void prettyPrint (Object object, StringBuilder buffer, int indent, boolean fieldsOnSameLine) {\r
                if (object instanceof ObjectMap) {\r
-                       ObjectMap<?, ?> map = (ObjectMap)object;\r
+                       ObjectMap map = (ObjectMap)object;\r
                        if (map.size == 0) {\r
                                buffer.append("{}");\r
                        } else {\r
                                boolean newLines = !fieldsOnSameLine || !isFlat(map) || map.size > 4;\r
                                buffer.append(newLines ? "{\n" : "{ ");\r
+                               Array<String> keys = (Array)map.keys().toArray();\r
+                               keys.sort();\r
                                int i = 0;\r
-                               for (Entry entry : map.entries()) {\r
+                               for (String key : keys) {\r
                                        if (newLines) indent(indent, buffer);\r
-                                       buffer.append(outputType.quoteName((String)entry.key));\r
+                                       buffer.append(outputType.quoteName(key));\r
                                        buffer.append(": ");\r
-                                       prettyPrint(entry.value, buffer, indent + 1, fieldsOnSameLine);\r
+                                       prettyPrint(map.get(key), buffer, indent + 1, fieldsOnSameLine);\r
                                        if (i++ < map.size - 1) buffer.append(",");\r
                                        buffer.append(newLines ? '\n' : ' ');\r
                                }\r
index d762644..7fa4136 100644 (file)
@@ -24,13 +24,15 @@ public class NumberUtils {
        public static int floatToRawIntBits (float value) {\r
                return Float.floatToRawIntBits(value);\r
        }\r
-       \r
+\r
        public static int floatToIntColor (float value) {\r
                return Float.floatToRawIntBits(value);\r
        }\r
-       \r
-       public static float intToFloatColor(int value) {\r
-               return Float.intBitsToFloat(value);\r
+\r
+       public static float intToFloatColor (int value) {\r
+               // This mask avoids using bits in the NaN range. See Float.intBitsToFloat javadocs.\r
+               // This unfortunately means we don't get the full range of alpha.\r
+               return Float.intBitsToFloat(value & 0xfeffffff);\r
        }\r
 \r
        public static float intBitsToFloat (int value) {\r