diff --git a/cocos2dx/include/CCRadialTransition.h b/cocos2dx/include/CCRadialTransition.h index 0d9f20b2df..2f751e601d 100644 --- a/cocos2dx/include/CCRadialTransition.h +++ b/cocos2dx/include/CCRadialTransition.h @@ -25,28 +25,10 @@ THE SOFTWARE. #ifndef __CCRADIAL_TRANSITION_H__ #define __CCRADIAL_TRANSITION_H__ #include "CCTransition.h" -///@todo #include "CCProgressTimer.h" -///@todo #include "CCProgressTimerActions.h" +#include "misc_nodes/CCProgressTimer.h" namespace cocos2d { -typedef enum { - /// Radial Counter-Clockwise - kCCProgressTimerTypeRadialCCW, - /// Radial ClockWise - kCCProgressTimerTypeRadialCW, - /// Horizontal Left-Right - kCCProgressTimerTypeHorizontalBarLR, - /// Horizontal Right-Left - kCCProgressTimerTypeHorizontalBarRL, - /// Vertical Bottom-top - kCCProgressTimerTypeVerticalBarBT, - /// Vertical Top-Bottom - kCCProgressTimerTypeVerticalBarTB, -} CCProgressTimerType;/// @todo to be deleted - - - /// // A counter colock-wise radial transition to the next scene /// diff --git a/cocos2dx/include/CCTexture2D.h b/cocos2dx/include/CCTexture2D.h index 2616bb00dc..c87ea4334f 100644 --- a/cocos2dx/include/CCTexture2D.h +++ b/cocos2dx/include/CCTexture2D.h @@ -31,15 +31,10 @@ THE SOFTWARE. #include "Cocos2dDefine.h" #include "NSObject.h" #include "CGGeometry.h" +#include "ccTypes.h" namespace cocos2d { class UIImage; -typedef enum -{ - UITextAlignmentLeft, - UITextAlignmentCenter, - UITextAlignmentRight, -} UITextAlignment;// @todo to be deleted //CONSTANTS: @@ -142,9 +137,9 @@ public: Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). */ /** Initializes a texture from a string with dimensions, alignment, font name and font size */ - CCTexture2D * initWithString(const char *str, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize); + CCTexture2D * initWithString(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize); /** Initializes a texture from a string with font name and font size */ - CCTexture2D * initWithString(const char *str, const char *fontName, float fontSize); + CCTexture2D * initWithString(const char *text, const char *fontName, float fontSize); /** Extensions to make it easy to create a CCTexture2D object from a PVRTC file diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 478f021452..5ceec6ff68 100644 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -262,6 +262,14 @@ typedef struct _ccBlendFunc //! if you want more resolution redefine it as a double typedef float ccTime; //typedef double ccTime; + +typedef enum +{ + UITextAlignmentLeft, + UITextAlignmentCenter, + UITextAlignmentRight, +} UITextAlignment; + }//namespace cocos2d #endif //__CCTYPES_H__ diff --git a/cocos2dx/platform/platform.h b/cocos2dx/platform/platform.h index ddfac7b855..368e45da13 100644 --- a/cocos2dx/platform/platform.h +++ b/cocos2dx/platform/platform.h @@ -28,12 +28,12 @@ THE SOFTWARE. #include "config_platform.h" #ifdef CCX_PLATFORM_UPHONE - #include "uphone/CCFileUtils.h" - #include "uphone/CCTime.h" - #include "uphone/NSLock.h" + #include "uphone/CCFileUtils.h" + #include "uphone/CCTime.h" + #include "uphone/NSLock.h" #include "uphone/UIImage.h" - #include "uphone/Cocos2dTypes.h" - #include "uphone/CCXGLExtFunc.h" + #include "uphone/Cocos2dTypes.h" + #include "uphone/CCXGLExtFunc.h" #include "uphone/CCXBitmapDC.h" #else #error diff --git a/cocos2dx/platform/uphone/CCXBitmapDC.cpp b/cocos2dx/platform/uphone/CCXBitmapDC.cpp index 47511b2c21..de086c49f1 100644 --- a/cocos2dx/platform/uphone/CCXBitmapDC.cpp +++ b/cocos2dx/platform/uphone/CCXBitmapDC.cpp @@ -21,8 +21,62 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#include #include "CCXBitmapDC.h" namespace cocos2d { + CCXBitmapDC::CCXBitmapDC(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize) + { + TFont font; + int len = strlen(text) + 1; + TUChar * pText = new TUChar[len]; + TUString::StrGBToUnicode(pText, (Char*)text); + if (CGSize::CGSizeEqualToSize(dimensions, CGSizeZero)) + { + m_tTextSize.width = font.CharsWidth(pText, len); + m_tTextSize.height = font.LineHeight(); + }else + { + m_tTextSize = dimensions; + } + + int i; + int width = (int)m_tTextSize.width; + int height = (int)m_tTextSize.height; + if((width!= 1) && (width & (width - 1))) + { + i = 1; + while(i < width) + i>>=1; + width = i; + } + + if((height != 1) && (height & (height - 1))) + { + i = 1; + while(i < height) + i >>= 1; + height = i; + } + + m_tScaleSize.width = (float)width; + m_tScaleSize.height = (float)height; + + m_pBitmap = TBitmap::Create(width, height, 32); + TDC dc(NULL); + dc.DrawCharsInBitmap(pText, len, m_pBitmap, RGBA(255,0,0,255), RGBA(0,255,0,255), font, GUI_API_STYLE_ALIGNMENT_CENTER); + } + void *CCXBitmapDC::GetBuffer() + { + return m_pBitmap->GetDataPtr(); + } + CGSize CCXBitmapDC::GetSize() + { + return m_tScaleSize; + } + CGSize CCXBitmapDC::GetTextSize() + { + return m_tTextSize; + } } \ No newline at end of file diff --git a/cocos2dx/platform/uphone/CCXBitmapDC.h b/cocos2dx/platform/uphone/CCXBitmapDC.h index fd83a493b4..aaea84b061 100644 --- a/cocos2dx/platform/uphone/CCXBitmapDC.h +++ b/cocos2dx/platform/uphone/CCXBitmapDC.h @@ -23,20 +23,25 @@ THE SOFTWARE. ****************************************************************************/ #ifndef __CCXBITMAP_DC_H__ #define __CCXBITMAP_DC_H__ -#include "CCTexture2D.h" + +#include "TG3.h" +#include "ccTypes.h" + namespace cocos2d{ class CCX_DLL CCXBitmapDC { public: - CCXBitmapDC(const char *text, CGSize dimensions, const char *fontName, CGFloat fontSize, UITextAlignment alignment); - CCXBitmapDC(int nWidth, int nHeight); + CCXBitmapDC(); + CCXBitmapDC(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize); ~CCXBitmapDC(void); - void CreateBitmapDC(int nWidth, int nHeight); void* GetBuffer(void); CGSize GetSize(); CGSize GetTextSize(); protected: + TBitmap *m_pBitmap; + CGSize m_tTextSize; + CGSize m_tScaleSize; }; } diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 4cfae65242..316e4df966 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -373,13 +373,13 @@ CCTexture2D * CCTexture2D::initPremultipliedATextureWithImage(UIImage *image, un } // implementation CCTexture2D (Text) -CCTexture2D * CCTexture2D::initWithString(const char *str, const char *fontName, float fontSize) +CCTexture2D * CCTexture2D::initWithString(const char *text, const char *fontName, float fontSize) { - return initWithString(str, CGSizeMake(0,0), UITextAlignmentCenter, fontName, fontSize); + return initWithString(text, CGSizeMake(0,0), UITextAlignmentCenter, fontName, fontSize); } -CCTexture2D * CCTexture2D::initWithString(const char *str, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize) +CCTexture2D * CCTexture2D::initWithString(const char *text, CGSize dimensions, UITextAlignment alignment, const char *fontName, float fontSize) { - CCXBitmapDC *pBitmapDC = new CCXBitmapDC(str, dimensions, fontName, fontSize, alignment); + CCXBitmapDC *pBitmapDC = new CCXBitmapDC(text, dimensions, alignment, fontName, fontSize); void* pBitData = pBitmapDC->GetBuffer(); CGSize szImage = pBitmapDC->GetSize();