Browse Source

Add TextEffect in Text3D class.

Aster Jian 12 years ago
parent
commit
902300e2e5

+ 4 - 0
Source/Engine/Script/UIAPI.cpp

@@ -371,6 +371,10 @@ static void RegisterText3D(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Text3D", "float get_rowSpacing() const", asMETHOD(Text3D, GetRowSpacing), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text3D", "void set_wordwrap(bool)", asMETHOD(Text3D, SetWordwrap), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text3D", "bool get_wordwrap() const", asMETHOD(Text3D, GetWordwrap), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Text3D", "void set_textEffect(TextEffect)", asMETHOD(Text3D, SetTextEffect), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Text3D", "TextEffect get_textEffect() const", asMETHOD(Text3D, GetTextEffect), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Text3D", "void set_effectColor(const Color&in)", asMETHOD(Text3D, SetEffectColor), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Text3D", "const Color& get_effectColor() const", asMETHOD(Text3D, GetEffectColor), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text3D", "void set_width(int)", asMETHOD(Text3D, SetWidth), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text3D", "int get_width() const", asMETHOD(Text3D, GetWidth), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text3D", "void set_color(const Color&in)", asMETHODPR(Text3D, SetColor, (const Color&), void), asCALL_THISCALL);

+ 23 - 0
Source/Engine/UI/Text3D.cpp

@@ -39,6 +39,7 @@ namespace Urho3D
 
 extern const char* horizontalAlignments[];
 extern const char* verticalAlignments[];
+extern const char* textEffects[];
 extern const char* GEOMETRY_CATEGORY;
 
 static const float TEXT_SCALING = 1.0f / 128.0f;
@@ -70,6 +71,8 @@ void Text3D::RegisterObject(Context* context)
     ENUM_ATTRIBUTE(Text3D, "Text Alignment", text_.textAlignment_, horizontalAlignments, HA_LEFT, AM_DEFAULT);
     ATTRIBUTE(Text3D, VAR_FLOAT, "Row Spacing", text_.rowSpacing_, 1.0f, AM_DEFAULT);
     ATTRIBUTE(Text3D, VAR_BOOL, "Word Wrap", text_.wordWrap_, false, AM_DEFAULT);
+    ENUM_ATTRIBUTE(Text3D, "Text Effect", text_.textEffect_, textEffects, TE_NONE, AM_FILE);
+    REF_ACCESSOR_ATTRIBUTE(Text3D, VAR_COLOR, "Effect Color", GetEffectColor, SetEffectColor, Color, Color::TRANSPARENT, AM_FILE);
     ACCESSOR_ATTRIBUTE(Text3D, VAR_INT, "Width", GetWidth, SetWidth, int, 0, AM_DEFAULT);
     ENUM_ACCESSOR_ATTRIBUTE(Text3D, "Horiz Alignment", GetHorizontalAlignment, SetHorizontalAlignment, HorizontalAlignment, horizontalAlignments, HA_LEFT, AM_DEFAULT);
     ENUM_ACCESSOR_ATTRIBUTE(Text3D, "Vert Alignment", GetVerticalAlignment, SetVerticalAlignment, VerticalAlignment, verticalAlignments, VA_TOP, AM_DEFAULT);
@@ -224,6 +227,16 @@ void Text3D::SetWordwrap(bool enable)
     MarkTextDirty();
 }
 
+void Text3D::SetTextEffect(TextEffect textEffect)
+{
+    text_.SetTextEffect(textEffect);
+}
+
+void Text3D::SetEffectColor(const Color& effectColor)
+{
+    text_.SetEffectColor(effectColor);
+}
+
 void Text3D::SetWidth(int width)
 {
     text_.SetMinWidth(width);
@@ -309,6 +322,16 @@ bool Text3D::GetWordwrap() const
     return text_.GetWordwrap();
 }
 
+TextEffect Text3D::GetTextEffect() const
+{
+    return text_.GetTextEffect();
+}
+
+const Color& Text3D::GetEffectColor() const
+{
+    return text_.GetEffectColor();
+}
+
 int Text3D::GetWidth() const
 {
     return text_.GetWidth();

+ 8 - 0
Source/Engine/UI/Text3D.h

@@ -74,6 +74,10 @@ public:
     void SetRowSpacing(float spacing);
     /// Set wordwrap. In wordwrap mode the text element will respect its current width. Otherwise it resizes itself freely.
     void SetWordwrap(bool enable);
+    /// Set text effect.
+    void SetTextEffect(TextEffect textEffect);
+    /// Set effect color.
+    void SetEffectColor(const Color& effectColor);
     /// Set text width. Only has effect in word wrap mode.
     void SetWidth(int width);
     /// Set color on all corners.
@@ -103,6 +107,10 @@ public:
     float GetRowSpacing() const;
     /// Return wordwrap mode.
     bool GetWordwrap() const;
+    /// Return text effect.
+    TextEffect GetTextEffect() const;
+    /// Return effect color.
+    const Color& GetEffectColor() const;
     /// Return text width.
     int GetWidth() const;
     /// Return row height.

+ 6 - 0
Source/Extras/LuaScript/pkgs/UI/Text3D.pkg

@@ -19,6 +19,8 @@ class Text3D : public Drawable
     void SetTextAlignment(HorizontalAlignment align);
     void SetRowSpacing(float spacing);
     void SetWordwrap(bool enable);
+    void SetTextEffect(TextEffect textEffect);
+    void SetEffectColor(const Color& effectColor);
     void SetWidth(int width);
     void SetColor(const Color& color);
     void SetColor(Corner corner, const Color& color);
@@ -34,6 +36,8 @@ class Text3D : public Drawable
     VerticalAlignment GetVerticalAlignment() const;
     float GetRowSpacing() const;
     bool GetWordwrap() const;
+    TextEffect GetTextEffect() const;
+    const Color& GetEffectColor() const;
     int GetWidth() const;
     int GetRowHeight() const;
     unsigned GetNumRows() const;
@@ -56,6 +60,8 @@ class Text3D : public Drawable
     tolua_property__get_set VerticalAlignment verticalAlignment;
     tolua_property__get_set float rowSpacing;
     tolua_property__get_set bool wordwrap;
+    tolua_property__get_set TextEffect textEffect;
+    tolua_property__get_set Color& effectColor;
     tolua_property__get_set int width;
     tolua_property__get_set Color& color; // Write only property.
     tolua_readonly tolua_property__get_set int rowHeight;