Esempio n. 1
0
void pawsFrameDrawable::LoadPiece(csRef<iDocumentNode> node, FRAME_DRAWABLE_PIECE piece)
{
    bool tiled = node->GetAttributeValueAsBool("tile");
    csRect textureRect;
    textureRect.SetPos(node->GetAttributeValueAsInt("tx"), node->GetAttributeValueAsInt("ty"));
    textureRect.SetSize(node->GetAttributeValueAsInt("tw"), node->GetAttributeValueAsInt("th"));
    pieces[piece].drawable.AttachNew(new pawsImageDrawable(imageFileLocation, resourceName, tiled, textureRect, defaultAlphaValue, defaultTransparentColourRed, defaultTransparentColourGreen, defaultTransparentColourBlue));
    pieces[piece].offsetx = node->GetAttributeValueAsInt("offsetx");
    pieces[piece].offsety = node->GetAttributeValueAsInt("offsety");
}
Esempio n. 2
0
pawsImageDrawable::pawsImageDrawable(csRef<iDocumentNode> node)
                 : scfImplementationType (this)
{
    debugImageErrors = true;
    defaultTransparentColourBlue  = -1;
    defaultTransparentColourGreen = -1;
    defaultTransparentColourRed   = -1;

    defaultAlphaValue = 0;

    // Read off the image and file vars
    imageFileLocation = node->GetAttributeValue( "file" );
    resourceName = node->GetAttributeValue( "resource" );

    tiled = node->GetAttributeValueAsBool("tiled");

    csRef<iDocumentNodeIterator> iter = node->GetNodes();
    while ( iter->HasNext() )
    {
        csRef<iDocumentNode> childNode = iter->Next();       

        // Read the texture rectangle for this image.
        if ( strcmp( childNode->GetValue(), "texturerect" ) == 0 )
        {
            textureRectangle.xmin = childNode->GetAttributeValueAsInt("x");
            textureRectangle.ymin = childNode->GetAttributeValueAsInt("y");

            int width = childNode->GetAttributeValueAsInt("width");
            int height = childNode->GetAttributeValueAsInt("height");

            textureRectangle.SetSize(width, height);
        }

        // Read the default alpha value.
        if ( strcmp( childNode->GetValue(), "alpha" ) == 0 )
        {
            defaultAlphaValue = childNode->GetAttributeValueAsInt("level");            
        }

        // Read the default transparent colour.
        if ( strcmp( childNode->GetValue(), "trans" ) == 0 )
        {
            defaultTransparentColourRed   = childNode->GetAttributeValueAsInt("r");            
            defaultTransparentColourGreen = childNode->GetAttributeValueAsInt("g");            
            defaultTransparentColourBlue  = childNode->GetAttributeValueAsInt("b");                                    
        }
    }

    PreparePixmap();
}