From: <ave...@us...> - 2008-10-18 16:47:12
|
Revision: 5460 http://gemrb.svn.sourceforge.net/gemrb/?rev=5460&view=rev Author: avenger_teambg Date: 2008-10-18 16:47:05 +0000 (Sat, 18 Oct 2008) Log Message: ----------- hacked ControlAnimation to handle clown colors flag for centering the animation now works for control animations fixed iwd2 inventory screen to display the animated avatar correctly Modified Paths: -------------- gemrb/trunk/gemrb/GUIScripts/iwd2/GUIINV.py gemrb/trunk/gemrb/plugins/Core/AnimationFactory.h gemrb/trunk/gemrb/plugins/Core/Button.cpp gemrb/trunk/gemrb/plugins/Core/CharAnimations.cpp gemrb/trunk/gemrb/plugins/Core/Control.cpp gemrb/trunk/gemrb/plugins/Core/ControlAnimation.cpp gemrb/trunk/gemrb/plugins/Core/ControlAnimation.h gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp Modified: gemrb/trunk/gemrb/GUIScripts/iwd2/GUIINV.py =================================================================== --- gemrb/trunk/gemrb/GUIScripts/iwd2/GUIINV.py 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/GUIScripts/iwd2/GUIINV.py 2008-10-18 16:47:05 UTC (rev 5460) @@ -289,7 +289,9 @@ Color6 = GemRB.GetPlayerStat (pc, IE_ARMOR_COLOR) Color7 = GemRB.GetPlayerStat (pc, IE_HAIR_COLOR) + GemRB.SetButtonFlags (Window, Button, IE_GUI_BUTTON_CENTER_PICTURES, OP_OR) GemRB.SetAnimation (Window, Button, GetActorPaperDoll (pc)+"G11") + GemRB.SetAnimationPalette (Window, Button, Color1, Color2, Color3, Color4, Color5, Color6, Color7, 0) # portrait Button = GemRB.GetControl (Window, 84) Modified: gemrb/trunk/gemrb/plugins/Core/AnimationFactory.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/AnimationFactory.h 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/Core/AnimationFactory.h 2008-10-18 16:47:05 UTC (rev 5460) @@ -44,7 +44,7 @@ std::vector< CycleEntry> cycles; unsigned short* FLTable; // Frame Lookup Table unsigned char* FrameData; - int datarefcount; + int datarefcount; public: AnimationFactory(const char* ResRef); ~AnimationFactory(void); @@ -62,8 +62,8 @@ Sprite2D* GetPaperdollImage(ieDword *Colors, Sprite2D *&Picture2, unsigned int type); - void IncDataRefCount(); - void DecDataRefCount(); + void IncDataRefCount(); + void DecDataRefCount(); }; #endif Modified: gemrb/trunk/gemrb/plugins/Core/Button.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Button.cpp 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/Core/Button.cpp 2008-10-18 16:47:05 UTC (rev 5460) @@ -239,7 +239,12 @@ int xOffs = ( Width / 2 ) - ( AnimPicture->Width / 2 ); int yOffs = ( Height / 2 ) - ( AnimPicture->Height / 2 ); Region r( x + XPos + xOffs, y + YPos + yOffs, (int)(AnimPicture->Width * Clipping), AnimPicture->Height ); - video->BlitSprite( AnimPicture, x + XPos + xOffs, y + YPos + yOffs, true, &r ); + + if (Flags & IE_GUI_BUTTON_CENTER_PICTURES) { + video->BlitSprite( AnimPicture, x + XPos + xOffs + AnimPicture->XPos, y + YPos + yOffs + AnimPicture->YPos, true, &r ); + } else { + video->BlitSprite( AnimPicture, x + XPos + xOffs, y + YPos + yOffs, true, &r ); + } } // Button label Modified: gemrb/trunk/gemrb/plugins/Core/CharAnimations.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/CharAnimations.cpp 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/Core/CharAnimations.cpp 2008-10-18 16:47:05 UTC (rev 5460) @@ -753,8 +753,7 @@ AnimationFactory* af = ( AnimationFactory* ) core->GetResourceMgr()->GetFactoryResource( NewResRef, - IE_BAM_CLASS_ID, - IE_NORMAL ); + IE_BAM_CLASS_ID, IE_NORMAL ); if (!af) { if (part < actorPartCount) { Modified: gemrb/trunk/gemrb/plugins/Core/Control.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/Control.cpp 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/Core/Control.cpp 2008-10-18 16:47:05 UTC (rev 5460) @@ -221,7 +221,11 @@ { core->GetVideoDriver()->FreeSprite(AnimPicture); AnimPicture = newpic; - Changed = true; + //apparently this is needed too, so the artifacts are not visible + if (Owner->Visible==WINDOW_VISIBLE) { + Changed = true; + Owner->Invalidate(); + } } /** Sets the Scroll Bar Pointer. If 'ptr' is NULL no Scroll Bar will be linked Modified: gemrb/trunk/gemrb/plugins/Core/ControlAnimation.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/ControlAnimation.cpp 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/Core/ControlAnimation.cpp 2008-10-18 16:47:05 UTC (rev 5460) @@ -23,9 +23,10 @@ #include "ControlAnimation.h" #include "Interface.h" #include "ResourceMgr.h" +#include "Video.h" /* needed only for paperdoll palettes */ +#include "Palette.h" /* needed only for paperdoll palettes */ #include "Button.h" - ControlAnimation::ControlAnimation(Control* ctl, const ieResRef ResRef, int Cycle) { control = NULL; @@ -34,15 +35,15 @@ frame = 0; anim_phase = 0; - bam = ( AnimationFactory* ) - core->GetResourceMgr()->GetFactoryResource( ResRef, - IE_BAM_CLASS_ID, - IE_NORMAL ); + bam = ( AnimationFactory* ) core->GetResourceMgr()->GetFactoryResource( ResRef, + IE_BAM_CLASS_ID, IE_NORMAL ); + if (! bam) return; control = ctl; control->animation = this; + has_palette = false; } //freeing the bitmaps only once, but using an intelligent algorithm @@ -93,7 +94,11 @@ } } else { frame ++; - time = 15; + if (has_palette) { + time = 100; //hack for slower movement + } else { + time = 15; + } } Sprite2D* pic = bam->GetFrame( (unsigned short) frame, (unsigned char) Cycle ); @@ -106,9 +111,28 @@ } anim_phase = 0; frame = 0; - pic = bam->GetFrame( 0, 0 ); + pic = bam->GetFrame( 0, (unsigned char) Cycle ); } + if (pic == NULL) { + return; + } + + if (has_palette) { + Video *video = core->GetVideoDriver(); + Palette* palette = video->GetPalette(pic); + palette->SetupPaperdollColours(colors, 0); + video->SetPalette(pic, palette); + palette->Release(); + } + control->SetAnimPicture( pic ); core->timer->AddAnimation( this, time ); } + +void ControlAnimation::SetPaletteGradients(ieDword *col) +{ + memcpy(colors, col, 8*sizeof(ieDword)); + has_palette = true; +} + Modified: gemrb/trunk/gemrb/plugins/Core/ControlAnimation.h =================================================================== --- gemrb/trunk/gemrb/plugins/Core/ControlAnimation.h 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/Core/ControlAnimation.h 2008-10-18 16:47:05 UTC (rev 5460) @@ -53,12 +53,15 @@ unsigned int cycle; unsigned int frame; unsigned int anim_phase; + bool has_palette; + ieDword colors[8]; public: ControlAnimation(Control* ctl, const ieResRef ResRef, int Cycle = 0); ~ControlAnimation(void); void UpdateAnimation(); //report if the current resource is the same as descripted by the params bool SameResource(const ieResRef ResRef, int Cycle); + void SetPaletteGradients(ieDword *col); }; #endif Modified: gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp 2008-10-17 16:01:31 UTC (rev 5459) +++ gemrb/trunk/gemrb/plugins/GUIScript/GUIScript.cpp 2008-10-18 16:47:05 UTC (rev 5460) @@ -3151,6 +3151,37 @@ return ret; } +PyDoc_STRVAR( GemRB_SetAnimationPalette__doc, +"SetAnimationPalette(WindowIndex, ControlIndex, col1, col2, col3, col4, col5, col6, col7, col8)\n\n" +"Sets the palette of an animation already assigned to the button."); + +static PyObject* GemRB_SetAnimationPalette(PyObject * /*self*/, PyObject* args) +{ + int wi, ci; + ieDword col[8]; + + memset(col,-1,sizeof(col)); + if (!PyArg_ParseTuple( args, "iiiiiiiiii", &wi, &ci, + &(col[0]), &(col[1]), &(col[2]), &(col[3]), + &(col[4]), &(col[5]), &(col[6]), &(col[7])) ) { + return AttributeError( GemRB_SetAnimationPalette__doc ); + } + + Control* ctl = GetControl(wi, ci, -1); + if (!ctl) { + return NULL; + } + + ControlAnimation* anim = ctl->animation; + if (!anim) { + return RuntimeError("No animation!"); + } + + anim->SetPaletteGradients(col); + Py_INCREF( Py_None ); + return Py_None; +} + PyDoc_STRVAR( GemRB_SetAnimation__doc, "SetAnimation(WindowIndex, ControlIndex, BAMResRef[, Cycle])\n\n" "Sets the animation of a Control (usually a Button) from a BAM file. Optionally an animation cycle could be set too."); @@ -8661,6 +8692,7 @@ METHOD(SaveGame, METH_VARARGS), METHOD(SetActionIcon, METH_VARARGS), METHOD(SetAnimation, METH_VARARGS), + METHOD(SetAnimationPalette, METH_VARARGS), METHOD(SetBufferLength, METH_VARARGS), METHOD(SetButtonSprites, METH_VARARGS), METHOD(SetButtonBorder, METH_VARARGS), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |