Mercurial > fife-parpg
changeset 587:2de93d36ca6d
Added getNextLocation() to the python interface file for the abstract pather.
Fixed a problem when an instance changes rotation and does not notify the instance change listeners.
Fixed a bug in SDLImage where m_isalphaoptimized was incorrectly set.
Updated instance to no longer derive from ResourceClass. It now derives from FifeClass directly.
fixes[t:475]
author | prock@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Wed, 11 Aug 2010 16:52:57 +0000 |
parents | dc19d9e38880 |
children | a46368b3d8a0 |
files | engine/core/model/metamodel/abstractpather.i engine/core/model/structures/instance.cpp engine/core/model/structures/instance.h engine/core/model/structures/instance.i engine/core/video/sdl/sdlimage.cpp engine/python/fife/extensions/pychan/widgets/widget.py |
diffstat | 6 files changed, 34 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/model/metamodel/abstractpather.i Sun Aug 08 22:54:11 2010 +0000 +++ b/engine/core/model/metamodel/abstractpather.i Wed Aug 11 16:52:57 2010 +0000 @@ -24,12 +24,18 @@ #include "model/metamodel/abstractpather.h" %} +%include "model/structures/instance.i" + namespace FIFE { class Map; class AbstractPather { public: virtual ~AbstractPather(); + virtual int getNextLocation(const Instance* instance, const Location& target, + double distance_to_travel, Location& nextLocation, + Location& facingLocation, int session_id=-1, + int priority = MEDIUM_PRIORITY) = 0; virtual std::string getName() const = 0; private: AbstractPather();
--- a/engine/core/model/structures/instance.cpp Sun Aug 08 22:54:11 2010 +0000 +++ b/engine/core/model/structures/instance.cpp Wed Aug 11 16:52:57 2010 +0000 @@ -104,6 +104,7 @@ Instance::InstanceActivity::InstanceActivity(Instance& source): m_location(source.m_location), + m_rotation(source.m_rotation), m_facinglocation(), m_action(), m_speed(0), @@ -131,6 +132,10 @@ source.m_changeinfo |= ICHANGE_LOC; m_location = source.m_location; } + if (m_rotation != source.m_rotation) { + source.m_changeinfo |= ICHANGE_ROTATION; + m_rotation = source.m_rotation; + } if (source.m_facinglocation && (m_facinglocation != *source.m_facinglocation)) { source.m_changeinfo |= ICHANGE_FACING_LOC; m_facinglocation = *source.m_facinglocation; @@ -208,7 +213,7 @@ } } } - + bool Instance::isActive() const { return bool(m_activity); } @@ -224,7 +229,11 @@ void Instance::setRotation(int rotation) { m_rotation = rotation; - m_changeinfo |= ICHANGE_ROTATION; + if(isActive()) { + refresh(); + } else { + initializeChanges(); + } } void Instance::setId(const std::string& identifier) { @@ -577,8 +586,8 @@ } } void Instance::onInstanceDeleted(Instance* instance) { - if(m_activity && - m_activity->m_actioninfo && + if(m_activity && + m_activity->m_actioninfo && m_activity->m_actioninfo->m_leader == instance) { m_activity->m_actioninfo->m_leader = NULL; }
--- a/engine/core/model/structures/instance.h Sun Aug 08 22:54:11 2010 +0000 +++ b/engine/core/model/structures/instance.h Wed Aug 11 16:52:57 2010 +0000 @@ -31,6 +31,8 @@ // These includes are split up in two parts, separated by one empty line // First block: files included from the FIFE root src directory // Second block: files included from the same folder +#include "util/base/fifeclass.h" + #include "model/metamodel/object.h" #include "model/metamodel/abstractvisual.h" @@ -60,7 +62,7 @@ ICHANGE_ACTION = 0x0008, ICHANGE_TIME_MULTIPLIER = 0x0010, ICHANGE_SAYTEXT = 0x0020, - ICHANGE_ROTATION = 0x0040, // NOTE! does not currently get updated onInstanceChange unless some other activity is performed + ICHANGE_ROTATION = 0x0040, }; typedef unsigned int InstanceChangeInfo; @@ -80,7 +82,7 @@ /** * An Instance is an "instantiation" of an Object at a Location. */ - class Instance : public ResourceClass, public InstanceDeleteListener { + class Instance : public FifeClass, public InstanceDeleteListener { public: /** Constructor @@ -250,7 +252,7 @@ * @returns marked changes */ InstanceChangeInfo update(); - + /** If this returns true, the instance needs to be updated */ bool isActive() const; @@ -289,7 +291,7 @@ */ inline InstanceChangeInfo getChangeInfo(); - /** callback so other instances we depend on can notify us if they go away + /** callback so other instances we depend on can notify us if they go away */ void onInstanceDeleted(Instance* instance); @@ -318,6 +320,8 @@ void update(Instance& source); // location on previous round Location m_location; + // rotation on previous round + int m_rotation; // facing location on previous round Location m_facinglocation; // action on previous round. @NOTE: might become invalid, only used for address comparison
--- a/engine/core/model/structures/instance.i Sun Aug 08 22:54:11 2010 +0000 +++ b/engine/core/model/structures/instance.i Wed Aug 11 16:52:57 2010 +0000 @@ -27,6 +27,7 @@ %include "model/metamodel/modelcoords.i" %include "model/metamodel/abstractvisual.i" %include "util/structures/utilstructures.i" +%include "util/base/utilbase.i" %include "location.i" namespace FIFE { @@ -62,7 +63,7 @@ virtual void onInstanceChanged(Instance* instance, InstanceChangeInfo info) = 0; }; - class Instance : public ResourceClass { + class Instance : public FifeClass { public: Instance(Object* object, const Location& location, const std::string& identifier=""); virtual ~Instance();
--- a/engine/core/video/sdl/sdlimage.cpp Sun Aug 08 22:54:11 2010 +0000 +++ b/engine/core/video/sdl/sdlimage.cpp Wed Aug 11 16:52:57 2010 +0000 @@ -246,7 +246,7 @@ m_surface = SDL_DisplayFormat(m_surface); } else { RenderBackendSDL* be = static_cast<RenderBackendSDL*>(RenderBackend::instance()); - m_isalphaoptimized &= be->isAlphaOptimizerEnabled(); + m_isalphaoptimized = be->isAlphaOptimizerEnabled(); if( m_isalphaoptimized ) { m_surface = optimize(m_surface); } else { @@ -374,7 +374,7 @@ src->format->Rmask, src->format->Gmask, src->format->Bmask, 0); bpp = dst->format->BytesPerPixel; - + Uint32 key = SDL_MapRGB(dst->format, m_colorkey.r, m_colorkey.g, m_colorkey.b); // if the global color key feature is disabled, then use the manually found color key @@ -384,7 +384,7 @@ ((keycolor & 0xf0) | 0xf), (((keycolor & 0xf) << 4) | 0xf)); } - + if(SDL_MUSTLOCK(src)) { SDL_LockSurface(src); }
--- a/engine/python/fife/extensions/pychan/widgets/widget.py Sun Aug 08 22:54:11 2010 +0000 +++ b/engine/python/fife/extensions/pychan/widgets/widget.py Wed Aug 11 16:52:57 2010 +0000 @@ -182,8 +182,8 @@ the is_focusable property. """ - - self.real_widget.requestFocus() + if self.isVisible(): + self.real_widget.requestFocus() def match(self,**kwargs): """