Skip to content

Commit

Permalink
Expose pyLayer get/set texture as separate methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Deledrius committed Nov 10, 2024
1 parent 13117a7 commit c1555a6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Scripts/Python/stupStartUp.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ def randomizeBackground(self):
# Choose a random image from the available images
bgChoice = random.choice(ilm.getImages())
# Update the Background Layer's texture to our chosen image
BGLayer.layer.texture = bgChoice
BGLayer.layer.setTexture(bgChoice)
PtDebugPrint("stupStartUp: Background has been randomized.")
17 changes: 7 additions & 10 deletions Sources/Plasma/FeatureLib/pfPython/pyLayerGlue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,24 @@ PYTHON_INIT_DEFINITION(ptLayer, args, keywords)
PYTHON_RETURN_INIT_OK;
}

PYTHON_GET_DEFINITION(ptLayer, texture)
PYTHON_METHOD_DEFINITION_NOARGS(ptLayer, getTexture)
{
return self->fThis->GetTexture();
}

PYTHON_SET_DEFINITION(ptLayer, texture, value)
PYTHON_METHOD_DEFINITION(ptLayer, setTexture, value)
{
if (pyImage::Check(value)) {
self->fThis->SetTexture(pyImage::ConvertFrom(value)->GetImage());
PYTHON_RETURN_SET_OK;
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "setTexture expects a ptImage");
PYTHON_RETURN_SET_ERROR;
PYTHON_RETURN_ERROR;
}

PYTHON_START_GETSET_TABLE(ptLayer)
PYTHON_GETSET(ptLayer, texture, "The image texture of the layer"),
PYTHON_END_GETSET_TABLE;

PYTHON_START_METHODS_TABLE(ptLayer)
// no methods
PYTHON_METHOD_NOARGS(ptLayer, getTexture, "Returns the image texture of the layer"),
PYTHON_METHOD(ptLayer, setTexture, "Params: image\nSets the ptImage texture of the layer"),
PYTHON_END_METHODS_TABLE;

// Type structure definition
Expand All @@ -101,7 +98,7 @@ PYTHON_END_METHODS_TABLE;
#define ptLayer_GETATTRO PYTHON_NO_GETATTRO
#define ptLayer_SETATTRO PYTHON_NO_SETATTRO
#define ptLayer_RICH_COMPARE PYTHON_NO_RICH_COMPARE
#define ptLayer_GETSET PYTHON_DEFAULT_GETSET(ptLayer)
#define ptLayer_GETSET PYTHON_NO_GETSET
#define ptLayer_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptLayer, "Params: layerKey\nPlasma layer class");

Expand Down

0 comments on commit c1555a6

Please sign in to comment.