From: Jarda B. <edh...@us...> - 2004-11-30 23:30:15
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2779/plugins/GUIScript Modified Files: GUIScript.cpp Log Message: Added GemRB_CreateTextEdit() and helper function GetBAMSprite() Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.250 retrieving revision 1.251 diff -C2 -d -r1.250 -r1.251 *** GUIScript.cpp 29 Nov 2004 22:19:43 -0000 1.250 --- GUIScript.cpp 30 Nov 2004 23:30:05 -0000 1.251 *************** *** 121,124 **** --- 121,142 ---- } + // Return single BAM frame as a sprite. Use if you want one frame only, + // otherwise it's not efficient + + inline Sprite2D* GetBAMSprite(ieResRef ResRef, int cycle, int frame) + { + AnimationMgr* bam = ( AnimationMgr* ) + core->GetInterface( IE_BAM_CLASS_ID ); + DataStream *str = core->GetResourceMgr()->GetResource( ResRef, IE_BAM_CLASS_ID ); + if (!bam->Open( str, true ) ) { + printMessage( "GUIScript", "Error: %s.BAM not found\n", LIGHT_RED ); + return NULL; + } + Sprite2D *tspr = bam->GetFrameFromCycle( (unsigned char) cycle, frame ); + core->FreeInterface( bam ); + + return tspr; + } + PyDoc_STRVAR( GemRB_SetInfoTextColor__doc, "SetInfoTextColor(red, green, blue, [alpha])\n\n" *************** *** 1346,1349 **** --- 1364,1405 ---- } + PyDoc_STRVAR( GemRB_CreateTextEdit__doc, + "CreateTextEdit(WindowIndex, ControlID, x, y, w, h, font, text) => ControlIndex\n\n" + "Creates and adds a new TextEdit to a Window." ); + + static PyObject* GemRB_CreateTextEdit(PyObject * /*self*/, PyObject* args) + { + int WindowIndex, ControlID, x, y, w, h; + char* font, * text; + + if (!PyArg_ParseTuple( args, "iiiiiiss", &WindowIndex, &ControlID, &x, + &y, &w, &h, &font, &text )) { + return AttributeError( GemRB_CreateTextEdit__doc ); + } + + Window* win = core->GetWindow( WindowIndex ); + if (win == NULL) { + return NULL; + } + TextEdit* edit = new TextEdit( 1000 ); + edit->SetFont( core->GetFont( font ) ); + edit->XPos = x; + edit->YPos = y; + edit->Width = w; + edit->Height = h; + edit->ControlID = ControlID; + edit->ControlType = IE_GUI_EDIT; + edit->Owner = win; + edit->SetText( text ); + + Sprite2D* spr = GetBAMSprite( "CARET", 0, 0 ); + if (spr) edit->SetCursor( spr ); + + win->AddControl( edit ); + + Py_INCREF( Py_None ); + return Py_None; + } + PyDoc_STRVAR( GemRB_CreateButton__doc, "CreateButton(WindowIndex, ControlID, x, y, w, h) => ControlIndex\n\n" *************** *** 4173,4176 **** --- 4229,4233 ---- METHOD(CreateLabel, METH_VARARGS), METHOD(SetLabelTextColor, METH_VARARGS), + METHOD(CreateTextEdit, METH_VARARGS), METHOD(CreateButton, METH_VARARGS), METHOD(SetButtonSprites, METH_VARARGS), |