Beispiel #1
0
void cxActionReadAttr(cxReaderAttrInfo *info)
{
    cxAction this = info->object;
    //
    cxActionSetStepHide(this, cxXMLReadBoolAttr(info, "cxAction.stepHide", this->stepHide));
    //delay
    cxActionSetDelay(this, cxXMLReadFloatAttr(info, "cxAction.delay", this->delay));
    //time
    cxActionSetDuration(this, cxXMLReadFloatAttr(info, "cxAction.time", this->duration));
    //init time
    cxActionSetDurationInit(this, cxXMLReadFloatAttr(info, "cxAction.initTime", this->durationInit));
    //curve
    cxConstChars scurve = cxXMLAttr(info->reader, "cxAction.curve");
    cxCurveItem curve = cxCurveGet(scurve);
    if(curve != NULL){
        CX_METHOD_OVERRIDE(this->Curve, curve->func);
    }
    //
    cxActionSetSplit(this, cxXMLReadIntAttr(info, "cxAction.split", this->split));
    //
    cxActionSetSpeed(this, cxXMLReadFloatAttr(info, "cxAction.speed", this->speed));
    //actionId
    cxActionSetId(this, cxXMLReadIntAttr(info, "cxAction.id", this->actionId));
    //forever
    if(cxXMLReadBoolAttr(info, "cxAction.forever", false)){
        CX_METHOD_OVERRIDE(this->Exit, cxActionForever);
    }
    //assist
    this->assist = cxXMLReadAssist4fAttr(info, "cxAction.assist", this->assist);
    //event
    cxXMLAppendEvent(info, this, cxAction, onStart);
    cxXMLAppendEvent(info, this, cxAction, onStop);
    cxXMLAppendEvent(info, this, cxAction, onSplit);
    cxXMLAppendEvent(info, this, cxAction, onStep);
}
Beispiel #2
0
//texture="res/a.xml?green.png"
void cxSpriteReadAttr(cxReaderAttrInfo *info)
{
    cxSprite this = info->object;
    //set texture
    cxTextureAttr texAttr = cxXMLReadTextureAttr(info, "cxSprite.texture");
    cxSpriteSetTextureAttr(this, texAttr);
    //flipx flipy
    cxSpriteSetFlipX(this, cxXMLReadBoolAttr(info, "cxSprite.flipX", this->isFlipX));
    cxSpriteSetFlipY(this, cxXMLReadBoolAttr(info, "cxSprite.flipY", this->isFlipY));
    //shader
    cxString shader = cxXMLReadStringAttr(info, "cxSprite.shader");
    cxSpriteSetShader(this, cxStringBody(shader));
    //
    cxViewReadAttr(info);
}
Beispiel #3
0
void cxClippingReadAttr(cxReaderAttrInfo *info)
{
    cxViewReadAttr(info);
    cxClipping this = info->object;
    cxClippingSetInverse(this, cxXMLReadBoolAttr(info, "cxClipping.inverse", this->inverse));
    cxXMLAppendEvent(info, this, cxClipping, onClipping);
}
Beispiel #4
0
static void cxHashRootReadDB(cxDBEnv env,cxHashRoot root,xmlTextReaderPtr reader)
{
    cxReaderAttrInfo *info = cxReaderAttrInfoMake(reader, root, env);
    int depth = xmlTextReaderDepth(reader);
    while(xmlTextReaderRead(reader) && depth != xmlTextReaderDepth(reader)){
        if(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT){
            continue;
        }
        cxConstChars temp = cxXMLReadElementName(reader);
        if(!ELEMENT_IS_TYPE(cxDB)){
            continue;
        }
        cxConstChars file = cxXMLAttr(reader,"file");
        cxConstChars table = cxXMLAttr(reader,"table");
        cxConstChars type = cxXMLAttr(reader,"type");
        cxConstChars sid = cxXMLAttr(reader,"id");
        cxConstChars path = cxXMLAttr(reader,"path");
        //assert file copy ->to document
        cxBool copy = cxXMLReadBoolAttr(info, "copy", false);
        if(copy && file != NULL){
            cxCopyFile(file, NULL, NULL);
        }
        cxBool rdonly = cxXMLReadBoolAttr(info,  "rdonly", false);
        if(sid == NULL){
            CX_WARN("db id not set,will can't add dataset");
        }
        cxString sfile = NULL;
        if(cxConstCharsEqu(path, "assert")){
            sfile = cxAssetsPath(file);
            //assert must set true
            rdonly = true;
        }else if(cxConstCharsEqu(path, "document")){
            sfile = cxDocumentPath(file);
        }else{
            CX_ERROR("must set path assert or document");
        }
        cxAny db = NULL;
        if(file != NULL && table != NULL && type != NULL){
            db = cxDBCreate(env, cxStringBody(sfile), table, type, rdonly);
        }
        if(db != NULL && sid != NULL){
            cxHashSet(root->items, cxHashStrKey(sid), cxDBTypesCreate(db));
        }else{
            CX_ERROR("open dbenv type %s,db %s:%s failed",cxStringBody(env->type),file,table);
        }
    }
}
Beispiel #5
0
static void cxViewCheckChipmunkSupport(cxReaderAttrInfo *info)
{
    cxBool support = cxXMLReadBoolAttr(info, "cxChipmunk.support", false);
    CX_RETURN(!support);
    cxView this = info->object;
    allocator->free(this->cAttr);
    this->cAttr = allocator->malloc(sizeof(cxChipmunkAttr));
    cxChipmunkGetAttr(info, this->cAttr);
}
Beispiel #6
0
void cxViewReadAttr(cxReaderAttrInfo *info)
{
    cxObjectReadAttr(info);
    cxView this = info->object;
    //fixscale
    cxViewSetFixScale(this, cxXMLReadVec2fAttr(info, "cxView.fixScale", this->fixscale));
    //rect
    cxViewRootReadRectToView(info);
    //resize
    cxViewRootReadAutoResize(info);
    //cropping
    cxViewSetCropping(this,cxXMLReadBoolAttr(info, "cxView.cropping", this->isCropping));
    //top
    cxViewSetTop(this, cxXMLReadBoolAttr(info, "cxView.hideTop", this->hideTop));
    //anchor
    cxViewSetAnchor(this, cxXMLReadVec2fAttr(info, "cxView.anchor", this->anchor));
    //scale
    cxViewSetScale(this, cxXMLReadVec2fAttr(info, "cxView.scale", this->scale));
    //color
    cxColor4f color = cxXMLReadColor4fAttr(info, "cxView.color", this->color);
    cxViewSetColor(this, cxColor3fv(color.r, color.g, color.b));
    cxViewSetAlpha(this, cxXMLReadFloatAttr(info, "cxView.alpha", color.a));
    //visible
    cxViewSetVisible(this, cxXMLReadBoolAttr(info, "cxView.visible", this->isVisible));
    //debug border
    cxViewSetBorder(this, cxXMLReadBoolAttr(info, "cxView.border", this->isBorder));
    //rotate raxis
    cxViewSetRaxis(this, cxXMLReadVec3fAttr(info, "cxView.raxis", this->raxis));
    //rotate angle
    cxViewSetAngle(this, cxXMLReadFloatAttr(info, "cxView.angle", this->angle));
    //rotate degress
    cxViewSetDegrees(this, cxXMLReadFloatAttr(info, "cxView.degrees", kmRadiansToDegrees(this->angle)));
    //Chipmunk support
    cxViewCheckChipmunkSupport(info);
    //cxAtlas support
    this->supportAtlasSet = cxXMLReadBoolAttr(info, "cxAtlasSet.support", false);
    //view event
    cxXMLAppendEvent(info, this, cxView, onEnter);
    cxXMLAppendEvent(info, this, cxView, onExit);
    cxXMLAppendEvent(info, this, cxView, onUpdate);
    cxXMLAppendEvent(info, this, cxView, onResize);
    cxXMLAppendEvent(info, this, cxView, onLayout);
    cxXMLAppendEvent(info, this, cxView, onDirty);
}
Beispiel #7
0
void cxHashRootReadDBEnv(cxHashRoot root,xmlTextReaderPtr reader)
{
    cxReaderAttrInfo *info = cxReaderAttrInfoMake(reader, root, NULL);
    cxConstChars type = cxXMLAttr(reader, "type");
    cxBool logger = cxXMLReadBoolAttr(info, "logger", false);
    cxDBEnv env = cxDBEnvCreate(type, logger);
    if(env != NULL){
        cxHashRootReadDB(env, root, reader);
    }
}
Beispiel #8
0
static void cxChipmunkGetAttr(cxReaderAttrInfo *info,cxChipmunkAttr *attr)
{
    cxChipmunkAttrInit(attr);
    attr->shape = cxXMLReadIntAttr(info, "cxChipmunk.shape", cxChipmunkShapeBox);
    attr->cp = cxXMLReadVec2fAttr(info, "cxChipmunk.center", cxVec2fv(0, 0));
    attr->isStatic = cxXMLReadBoolAttr(info, "cxChipmunk.static", attr->isStatic);
    attr->m = cxXMLReadFloatAttr(info, "cxChipmunk.m", attr->m);
    attr->e = cxXMLReadFloatAttr(info, "cxChipmunk.e", attr->e);
    attr->u = cxXMLReadFloatAttr(info, "cxChipmunk.u", attr->u);
    attr->group = cxXMLReadUIntAttr(info, "cxChipmunk.group", CP_NO_GROUP);
    attr->layer = cxXMLReadUIntAttr(info, "cxChipmunk.layer", CP_ALL_LAYERS);
    attr->ctype = cxXMLReadUIntAttr(info, "cxChipmunk.ctype", 0);
}