From: <bal...@us...> - 2003-10-29 23:50:35
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs1:/tmp/cvs-serv29119/GUIScript Modified Files: GUIScript.cpp Log Message: Added some Python functions: * GetTableRowName(TableIndex, RowIndex) : Returns the Name of the given Row * GetTableRowCount(TableIndex) : Returns the Number of Rows in the given Table * SetButtonPicture(WindowIndex, ControlIndex, PictureResRef) : Sets the Picture/Portrait associated with a Button Control Fixed a Bug in Button: Never shows the Picture when the IE_BUTTON_NO_IMAGE flag was set Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** GUIScript.cpp 29 Oct 2003 18:22:16 -0000 1.25 --- GUIScript.cpp 29 Oct 2003 23:50:30 -0000 1.26 *************** *** 180,183 **** --- 180,218 ---- } + static PyObject * GemRB_GetTableRowName(PyObject *self, PyObject *args) + { + int ti, row; + + if(!PyArg_ParseTuple(args, "ii", &ti, &row)) { + printMessage("GUIScript", "Syntax Error: GetTableRowName(TableIndex, RowIndex)\n", LIGHT_RED); + return NULL; + } + + TableMgr * tm = core->GetTable(ti); + if(tm == NULL) + return NULL; + const char * str = tm->GetRowName(row); + if(str == NULL) + return NULL; + + return Py_BuildValue("s", str); + } + + static PyObject * GemRB_GetTableRowCount(PyObject *self, PyObject *args) + { + int ti; + + if(!PyArg_ParseTuple(args, "i", &ti)) { + printMessage("GUIScript", "Syntax Error: Expected Integer\n", LIGHT_RED); + return NULL; + } + + TableMgr * tm = core->GetTable(ti); + if(tm == NULL) + return NULL; + + return Py_BuildValue("i", tm->GetRowCount()); + } + static PyObject * GemRB_LoadSymbol(PyObject *self, PyObject *args) { *************** *** 591,594 **** --- 626,675 ---- } + static PyObject * GemRB_SetButtonPicture(PyObject *self, PyObject *args) + { + int WindowIndex, ControlIndex; + char * ResRef; + + if(!PyArg_ParseTuple(args, "iis", &WindowIndex, &ControlIndex, &ResRef)) { + printMessage("GUIScript", "Syntax Error: SetButtonPicture(WindowIndex, ControlIndex, PictureResRef)\n", LIGHT_RED); + return NULL; + } + + Window * win = core->GetWindow(WindowIndex); + if(win == NULL) + return NULL; + + Control * ctrl = win->GetControl(ControlIndex); + if(ctrl == NULL) + return NULL; + + if(ctrl->ControlType != 0) + return NULL; + + DataStream * str = core->GetResourceMgr()->GetResource(ResRef, IE_BMP_CLASS_ID); + if(str == NULL) + return NULL; + ImageMgr * im = (ImageMgr*)core->GetInterface(IE_BMP_CLASS_ID); + if(im == NULL) + return NULL; + + if(!im->Open(str, true)) { + delete(str); + core->FreeInterface(im); + return NULL; + } + + Sprite2D * Picture = im->GetImage(); + if(Picture == NULL) + return NULL; + + Button * btn = (Button*)ctrl; + btn->SetPicture(Picture); + + core->FreeInterface(im); + + Py_INCREF(Py_None); + return Py_None; + } static PyObject * GemRB_PlaySound(PyObject *self, PyObject *args) { *************** *** 710,713 **** --- 791,800 ---- "Returns a field of a 2DA Table."}, + {"GetTableRowName", GemRB_GetTableRowName, METH_VARARGS, + "Returns the Name of a Row in a 2DA Table."}, + + {"GetTableRowCount", GemRB_GetTableRowCount, METH_VARARGS, + "Returns the number of rows in a 2DA Table."}, + {"LoadSymbol", GemRB_LoadSymbol, METH_VARARGS, "Loads a IDS Symbol Table."}, *************** *** 760,763 **** --- 847,853 ---- {"SetButtonState", GemRB_SetButtonState, METH_VARARGS, "Sets the state of a Button Control."}, + + {"SetButtonPicture", GemRB_SetButtonPicture, METH_VARARGS, + "Sets the Picture of a Button Control."}, {"PlaySound", GemRB_PlaySound, METH_VARARGS, |