From: Laszlo T. <ave...@us...> - 2006-08-04 21:42:48
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv10310/plugins/GUIScript Modified Files: GUIScript.cpp Log Message: bg2:spell/innate lists work too Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.403 retrieving revision 1.404 diff -C2 -d -r1.403 -r1.404 *** GUIScript.cpp 3 Aug 2006 21:13:05 -0000 1.403 --- GUIScript.cpp 4 Aug 2006 21:42:45 -0000 1.404 *************** *** 76,81 **** static SpellDescType *StoreSpells = NULL; ! ItemExtHeader *ItemArray; ! //SpellExtHeader *SpellArray; static int ReputationIncrease[20]={(int) UNINIT_IEDWORD}; --- 76,81 ---- static SpellDescType *StoreSpells = NULL; ! static ItemExtHeader *ItemArray = NULL; ! static SpellExtHeader *SpellArray = NULL; static int ReputationIncrease[20]={(int) UNINIT_IEDWORD}; *************** *** 6298,6301 **** --- 6298,6370 ---- } + PyDoc_STRVAR( GemRB_SetupSpellIcons__doc, + "SetupEquipmentIcons(WindowIndex, slot[, Start])\n\n" + "Automagically sets up the controls of the equipment list window for a PC indexed by slot."); + + static PyObject* GemRB_SetupSpellIcons(PyObject * /*self*/, PyObject* args) + { + int wi, slot, Type; + int Start = 0; + + if (!PyArg_ParseTuple( args, "iii|i", &wi, &slot, &Type, &Start )) { + return AttributeError( GemRB_SetupSpellIcons__doc ); + } + + Game *game = core->GetGame(); + if (!game) { + return RuntimeError( "No game loaded!" ); + } + Actor* actor = game->FindPC( slot ); + if (!actor) { + return RuntimeError( "Actor not found" ); + } + + //-2 because of the left/right scroll icons + if (!SpellArray) { + SpellArray = (SpellExtHeader *) malloc((GUIBT_COUNT) * sizeof (SpellExtHeader) ); + } + bool more = actor->spellbook.GetSpellInfo(SpellArray, Type, Start, GUIBT_COUNT-(Start?1:0)); + int i; + if (Start) { + PyObject *ret = SetActionIcon(wi,core->GetControl(wi, 0),ACT_LEFT,0); + if (!ret) { + return RuntimeError("Cannot set action button!\n"); + } + } + + for (i=0;i<GUIBT_COUNT-(more?1:0);i++) { + int ci = core->GetControl(wi, i+(Start?1:0) ); + Button* btn = (Button *) GetControl( wi, ci, IE_GUI_BUTTON ); + SpellExtHeader *spell = SpellArray+i; + + Sprite2D *Picture = core->GetBAMSprite(spell->MemorisedIcon, 0, 0); + + if (!Picture) { + btn->SetState(IE_GUI_BUTTON_LOCKED); + btn->SetFlags(IE_GUI_BUTTON_NO_IMAGE, BM_SET); + btn->SetTooltip(NULL); + } else { + btn->SetPicture( Picture ); + btn->SetState(IE_GUI_BUTTON_UNPRESSED); + btn->SetTooltip(core->GetString(spell->strref,0)); + char usagestr[10]; + + if (spell->count>1) { + sprintf(usagestr,"%d", spell->count); + btn->SetText( usagestr ); + } + } + } + if (more) { + PyObject *ret = SetActionIcon(wi,core->GetControl(wi, i+1),ACT_RIGHT,i+1); + if (!ret) { + return RuntimeError("Cannot set action button!\n"); + } + } + + Py_INCREF( Py_None ); + return Py_None; + } + PyDoc_STRVAR( GemRB_SetupControls__doc, "SetupControls(WindowIndex, slot[, Start])\n\n" *************** *** 6359,6362 **** --- 6428,6442 ---- ieDword modalstate = actor->ModalState; switch (action) { + case ACT_INNATE: + if(!actor->spellbook.GetSpellInfo(NULL, 4, 0, 0)) { + state = IE_GUI_BUTTON_DISABLED; + } + break; + case ACT_CAST: + //returns true if there is ANY equipment + if(!actor->spellbook.GetSpellInfo(NULL, 3, 0, 0)) { + state = IE_GUI_BUTTON_DISABLED; + } + break; case ACT_USE: //returns true if there is ANY equipment *************** *** 6813,6816 **** --- 6893,6897 ---- METHOD(SetupControls, METH_VARARGS), METHOD(SetupEquipmentIcons, METH_VARARGS), + METHOD(SetupSpellIcons, METH_VARARGS), METHOD(ClearAction, METH_VARARGS), METHOD(SetDefaultActions, METH_VARARGS), *************** *** 6848,6851 **** --- 6929,6936 ---- ItemArray=NULL; } + if (SpellArray) { + free(SpellArray); + SpellArray=NULL; + } if (StoreSpells) { free(StoreSpells); |