axmol/cocos/base/CCProtocols.h

274 lines
7.3 KiB
C
Raw Normal View History

/****************************************************************************
Copyright (c) 2008-2010 Ricardo Quesada
Copyright (c) 2010-2012 cocos2d-x.org
2015-03-24 20:23:51 +08:00
Copyright (c) 2013-2015 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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.
****************************************************************************/
Squashed commit of the following: commit a794d107ad85667e3d754f0b6251fc864dfbf288 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 14:33:49 2014 -0700 Yeah... everything compiles on win32 and wp8 commit 4740be6e4a0d16f742c27996e7ab2c100adc76af Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:58:38 2014 -0700 CCIME moved to base and compiles on Android commit ff3e1bf1eb27a01019f4e1b56d1aebbe2d385f72 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:02:57 2014 -0700 compiles Ok for Windows Phone 8 commit 8160a4eb2ecdc61b5bd1cf56b90d2da6f11e3ebd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 12:25:31 2014 -0700 fixes for Windows Phone 8 commit 418197649efc93032aee0adc205e502101cdb53d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 11:15:13 2014 -0700 Compiles on Win32 commit 08813ed7cf8ac1079ffadeb1ce78ea9e833e1a33 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 10:08:31 2014 -0700 Compiles on linux! commit 118896521e5b335a5257090b6863f1fb2a2002fe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 09:30:42 2014 -0700 moves cocos/2d/platform -> cocos/platform commit 4fe9319d7717b0c1bccb2db0156eeb86255a89e0 Merge: bd68ec2 511295e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 08:24:41 2014 -0700 Merge remote-tracking branch 'cocos2d/v3' into files commit bd68ec2f0e3a826d8b2f4b60564ba65ce766bc56 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu May 15 19:36:23 2014 -0700 files in the correct directory
2014-05-17 05:36:00 +08:00
#ifndef __BASE_CCPROTOCOLS_H__
#define __BASE_CCPROTOCOLS_H__
2015-03-24 20:23:51 +08:00
/// @cond DO_NOT_SHOW
#include <string>
Squashed commit of the following: commit a794d107ad85667e3d754f0b6251fc864dfbf288 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 14:33:49 2014 -0700 Yeah... everything compiles on win32 and wp8 commit 4740be6e4a0d16f742c27996e7ab2c100adc76af Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:58:38 2014 -0700 CCIME moved to base and compiles on Android commit ff3e1bf1eb27a01019f4e1b56d1aebbe2d385f72 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:02:57 2014 -0700 compiles Ok for Windows Phone 8 commit 8160a4eb2ecdc61b5bd1cf56b90d2da6f11e3ebd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 12:25:31 2014 -0700 fixes for Windows Phone 8 commit 418197649efc93032aee0adc205e502101cdb53d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 11:15:13 2014 -0700 Compiles on Win32 commit 08813ed7cf8ac1079ffadeb1ce78ea9e833e1a33 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 10:08:31 2014 -0700 Compiles on linux! commit 118896521e5b335a5257090b6863f1fb2a2002fe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 09:30:42 2014 -0700 moves cocos/2d/platform -> cocos/platform commit 4fe9319d7717b0c1bccb2db0156eeb86255a89e0 Merge: bd68ec2 511295e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 08:24:41 2014 -0700 Merge remote-tracking branch 'cocos2d/v3' into files commit bd68ec2f0e3a826d8b2f4b60564ba65ce766bc56 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu May 15 19:36:23 2014 -0700 files in the correct directory
2014-05-17 05:36:00 +08:00
#include "base/ccTypes.h"
#include "renderer/CCTexture2D.h"
NS_CC_BEGIN
/**
* RGBA protocol that affects Node's color and opacity
*/
class CC_DLL __RGBAProtocol
{
public:
virtual ~__RGBAProtocol() {}
/**
* Changes the color with R,G,B bytes
*
* @param color Example: Color3B(255,100,0) means R=255, G=100, B=0
* @js NA
* @lua NA
*/
virtual void setColor(const Color3B& color) = 0;
/**
* Returns color that is currently used.
*
* @return The Color3B contains R,G,B bytes.
* @js NA
* @lua NA
*/
virtual const Color3B& getColor() const = 0;
/**
* Returns the displayed color.
*
* @return The Color3B contains R,G,B bytes.
* @js NA
* @lua NA
*/
virtual const Color3B& getDisplayedColor() const = 0;
/**
* Returns the displayed opacity.
*
* @return The opacity of sprite, from 0 ~ 255
* @js NA
* @lua NA
*/
virtual GLubyte getDisplayedOpacity() const = 0;
/**
* Returns the opacity.
*
* The opacity which indicates how transparent or opaque this node is.
* 0 indicates fully transparent and 255 is fully opaque.
*
* @return The opacity of sprite, from 0 ~ 255
* @js NA
* @lua NA
*/
virtual GLubyte getOpacity() const = 0;
/**
* Changes the opacity.
*
* @param opacity Goes from 0 to 255, where 255 means fully opaque and 0 means fully transparent.
* @js NA
* @lua NA
*/
virtual void setOpacity(GLubyte opacity) = 0;
// optional
/**
* Changes the OpacityModifyRGB property.
* If thie property is set to true, then the rendered color will be affected by opacity.
* Normally, r = r * opacity/255, g = g * opacity/255, b = b * opacity/255.
*
* @param value If true, then the opacity will be applied as: glColor(R,G,B,opacity);
* If false, then the opacity will be applied as: glColor(opacity, opacity, opacity, opacity);
* @js NA
* @lua NA
*/
virtual void setOpacityModifyRGB(bool value) = 0;
/**
* Returns whether or not the opacity will be applied using glColor(R,G,B,opacity)
* or glColor(opacity, opacity, opacity, opacity)
*
* @return Returns opacity modify flag.
* @js NA
* @lua NA
*/
virtual bool isOpacityModifyRGB() const = 0;
/**
* whether or not color should be propagated to its children.
* @js NA
* @lua NA
*/
virtual bool isCascadeColorEnabled() const = 0;
/**
* @js NA
* @lua NA
*/
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) = 0;
/**
* recursive method that updates display color
* @js NA
* @lua NA
*/
virtual void updateDisplayedColor(const Color3B& color) = 0;
/**
* whether or not opacity should be propagated to its children.
* @js NA
* @lua NA
*/
virtual bool isCascadeOpacityEnabled() const = 0;
/**
* @js NA
* @lua NA
*/
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) = 0;
/**
* recursive method that updates the displayed opacity.
* @js NA
* @lua NA
*/
virtual void updateDisplayedOpacity(GLubyte opacity) = 0;
};
/**
* Specify the blending function according glBlendFunc
* Please refer to glBlendFunc in OpenGL ES Manual
* http://www.khronos.org/opengles/sdk/docs/man/xhtml/glBlendFunc.xml for more details.
*/
class CC_DLL BlendProtocol
{
public:
virtual ~BlendProtocol() {}
/**
* Sets the source blending function.
*
* @param blendFunc A structure with source and destination factor to specify pixel arithmetic,
* e.g. {GL_ONE, GL_ONE}, {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}.
* @js NA
* @lua NA
*/
virtual void setBlendFunc(const BlendFunc &blendFunc) = 0;
/**
* Returns the blending function that is currently being used.
*
* @return A BlendFunc structure with source and destination factor which specified pixel arithmetic.
* @js NA
* @lua NA
*/
virtual const BlendFunc &getBlendFunc() const = 0;
};
/**
* Node objects that uses a Texture2D to render the images.
* The texture can have a blending function.
* If the texture has alpha premultiplied the default blending function is:
* src=GL_ONE dst= GL_ONE_MINUS_SRC_ALPHA
* else
* src=GL_SRC_ALPHA dst= GL_ONE_MINUS_SRC_ALPHA
* But you can change the blending function at any time.
*/
class CC_DLL TextureProtocol : public BlendProtocol
{
public:
virtual ~TextureProtocol() {}
/**
* Returns the currently used texture
*
* @return The texture that is currenlty being used.
* @js NA
* @lua NA
*/
virtual Texture2D* getTexture() const = 0;
/**
* Sets a new texuture. It will be retained.
*
* @param texture A valid Texture2D object, which will be applied to this sprite object.
* @js NA
* @lua NA
*/
virtual void setTexture(Texture2D *texture) = 0;
};
/**
* Common interface for Labels
*/
class CC_DLL LabelProtocol
{
public:
virtual ~LabelProtocol() {}
/**
2013-09-23 02:39:42 +08:00
* Sets a new label using a string
*
* @param label A null terminated string
* @js NA
* @lua NA
*/
virtual void setString(const std::string &label) = 0;
/**
* Returns the string that is currently being used in this label
*
* @return The string that is currently being used in this label
* @js NA
* @lua NA
*/
virtual const std::string& getString() const = 0;
};
/**
* OpenGL projection protocol
*/
class CC_DLL DirectorDelegate
{
public:
virtual ~DirectorDelegate() {}
/**
* Will be called by Director when the projection is updated, and "custom" projection is used
* @js NA
* @lua NA
*/
virtual void updateProjection() = 0;
};
NS_CC_END
2015-03-24 20:23:51 +08:00
/// @endcond
Squashed commit of the following: commit a794d107ad85667e3d754f0b6251fc864dfbf288 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 14:33:49 2014 -0700 Yeah... everything compiles on win32 and wp8 commit 4740be6e4a0d16f742c27996e7ab2c100adc76af Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:58:38 2014 -0700 CCIME moved to base and compiles on Android commit ff3e1bf1eb27a01019f4e1b56d1aebbe2d385f72 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 13:02:57 2014 -0700 compiles Ok for Windows Phone 8 commit 8160a4eb2ecdc61b5bd1cf56b90d2da6f11e3ebd Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 12:25:31 2014 -0700 fixes for Windows Phone 8 commit 418197649efc93032aee0adc205e502101cdb53d Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 11:15:13 2014 -0700 Compiles on Win32 commit 08813ed7cf8ac1079ffadeb1ce78ea9e833e1a33 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 10:08:31 2014 -0700 Compiles on linux! commit 118896521e5b335a5257090b6863f1fb2a2002fe Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 09:30:42 2014 -0700 moves cocos/2d/platform -> cocos/platform commit 4fe9319d7717b0c1bccb2db0156eeb86255a89e0 Merge: bd68ec2 511295e Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Fri May 16 08:24:41 2014 -0700 Merge remote-tracking branch 'cocos2d/v3' into files commit bd68ec2f0e3a826d8b2f4b60564ba65ce766bc56 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Thu May 15 19:36:23 2014 -0700 files in the correct directory
2014-05-17 05:36:00 +08:00
#endif // __BASE_CCPROTOCOLS_H__