From: <edh...@us...> - 2004-02-29 19:43:03
|
Update of /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4816/gemrb/plugins/GUIScript Modified Files: GUIScript.cpp Log Message: Changed loading of saved games: - cleaned up SaveGameIterator, made it cache the directory names - changes in GUIScript - first load the save game, THEN open GameControl - load more parts of GAM files - core->GetPartySize() should look into game, not actors - some demo code for PST to display PC portraits in GameControl - new option in config file and in core object: SavePath is a root for save & mpsave folders - will allow per-user saves Index: GUIScript.cpp =================================================================== RCS file: /cvsroot/gemrb/gemrb/gemrb/plugins/GUIScript/GUIScript.cpp,v retrieving revision 1.129 retrieving revision 1.130 diff -C2 -d -r1.129 -r1.130 *** GUIScript.cpp 29 Feb 2004 17:36:10 -0000 1.129 --- GUIScript.cpp 29 Feb 2004 19:32:35 -0000 1.130 *************** *** 115,120 **** return NULL; } - GameControl* gc = StartGameControl(); core->LoadGame( GameIndex ); gc->SetCurrentArea( 0 ); Py_INCREF( Py_None ); --- 115,120 ---- return NULL; } core->LoadGame( GameIndex ); + GameControl* gc = StartGameControl(); gc->SetCurrentArea( 0 ); Py_INCREF( Py_None ); *************** *** 124,127 **** --- 124,128 ---- static PyObject* GemRB_EnterGame(PyObject*, PyObject* args) { + core->LoadGame( -1 ); GameControl* gc = StartGameControl(); // 0 - single player, 1 - tutorial, 2 - multiplayer *************** *** 134,138 **** int startX = atoi( tm->QueryField( playmode + 1 ) ); int startY = atoi( tm->QueryField( playmode + 2 ) ); - core->LoadGame( -1 ); gc->SetCurrentArea( 0 ); core->GetVideoDriver()->MoveViewportTo( startX, startY ); --- 135,138 ---- *************** *** 1577,1581 **** &ResRef, &CycleIndex, &FrameIndex, &col1 )) { printMessage( "GUIScript", ! "Syntax Error: SetButtonBAM(WindowIndex, ControlIndex, BAMResRef, col1)\n", LIGHT_RED ); return NULL; --- 1577,1581 ---- &ResRef, &CycleIndex, &FrameIndex, &col1 )) { printMessage( "GUIScript", ! "Syntax Error: SetButtonBAM(WindowIndex, ControlIndex, BAMResRef, CycleIndex, FrameIndex, col1)\n", LIGHT_RED ); return NULL; *************** *** 1788,1791 **** --- 1788,1861 ---- } + static PyObject * GemRB_ReplaceVarsInText (PyObject * /*self*/, PyObject *args) + { + ieStrRef Strref; + char* Variable; + unsigned long value; + //PyDict_Type reqtype; + PyObject *dict; + + //char newtext[4096]; + + if(!PyArg_ParseTuple(args, "iO!", &Strref, &PyDict_Type, &dict)) { + printMessage("GUIScript", "Syntax Error: ReplaceVarsInText(StrRef)\n", LIGHT_RED); + return NULL; + } + + char newtext[4096] = ""; + char *src = core->GetString (Strref); + //char *src = "Page <PAGE> in <NUMPAGES> of <jshd> kjj <<ok> on <<XYX>> fif <ABC"; + char *dest = newtext; + char *next; + int len; + + while (1) { + next = strchr (src, '<'); + if (! next) { + strcpy (dest, src); + break; + } + + len = next - src; + memcpy (dest, src, len); + src += len; + dest += len; + + len = strspn (src + 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"); + + if (len == 0 || *(src + len + 1) != '>') { + memcpy (dest, src, len + 1); + src += len + 1; + dest += len + 1; + continue; + } + + // do replace + memcpy (dest, src + 1, len); + dest[len] = 0; + + //printf ("REPLACE: %s\n", dest); + + /* + if(!core->GetDictionary()->Lookup(Variable, value)) + return Py_BuildValue("l", (unsigned long) 0); + */ + + PyObject *res = PyDict_GetItemString(dict, dest); + if (! res) { + dest += len; + } + else { + strcpy (dest, PyString_AsString (res)); + dest += strlen (dest); + } + src += len + 2; + } + + //printf ("RES: %s\n", newtext); + + return Py_BuildValue("s", newtext); + } + static PyObject* GemRB_PlayMovie(PyObject * /*self*/, PyObject* args) { *************** *** 1822,1826 **** return NULL; } ! core->GetSaveGameIterator()->GetSaveGame( SlotCount, true ); Py_INCREF( Py_None ); return Py_None; --- 1892,1896 ---- return NULL; } ! core->GetSaveGameIterator()->DeleteSaveGame( SlotCount ); Py_INCREF( Py_None ); return Py_None; *************** *** 2013,2016 **** --- 2083,2102 ---- } + static PyObject* GemRB_ActorGetSmallPortrait(PyObject * /*self*/, PyObject* args) + { + int index; + + if (!PyArg_ParseTuple( args, "i", &index )) { + printMessage( "GUIScript", + "Syntax Error: ActorGetSmallPortrait(index)\n", LIGHT_RED ); + } + + printf ("game: %p\n", core->GetGame ()); + Actor * actor = core->GetGame ()->GetPC (index); + printf ("actor: %p\n", actor); + return Py_BuildValue( "s", actor->GetPortrait (0)); + } + + static PyObject* GemRB_GetPartySize(PyObject * /*self*/, PyObject * /*args*/) { *************** *** 2510,2513 **** --- 2596,2605 ---- {"StatComment", GemRB_StatComment, METH_VARARGS, "Replaces values into an strref."}, + + {"ReplaceVarsInText", GemRB_ReplaceVarsInText, METH_VARARGS, + "Replaces named vars into an strref."}, + {"ActorGetSmallPortrait", GemRB_ActorGetSmallPortrait, METH_VARARGS, + "Returns actor's small portrait resref."}, + {"EndCutSceneMode", GemRB_EndCutSceneMode, METH_NOARGS, "Exits the CutScene Mode."}, |