Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 12, 2009, 8:20:07 PM (15 years ago)
Author:
rgrieder
Message:

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/modules/objects/eventsystem/EventTarget.cc

    r5781 r5929  
    2929#include "EventTarget.h"
    3030#include "core/CoreIncludes.h"
     31#include "core/XMLPort.h"
    3132
    3233namespace orxonox
     
    3738    {
    3839        RegisterObject(EventTarget);
     40
     41        this->bActive_ = false;
    3942    }
    4043
     
    4245    {
    4346    }
     47   
     48    void EventTarget::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     49    {
     50        SUPER(EventTarget, XMLPort, xmlelement, mode);
    4451
    45     void EventTarget::changedName()
     52        XMLPortParam(EventTarget, "target", setTargetName, getTargetName, xmlelement, mode);
     53
     54        // since we need event sources mapped to any state, we have to parse XML by ourselves
     55        this->loadAllEventStates(xmlelement, mode, this, Class(EventTarget));
     56    }
     57
     58    void EventTarget::processEvent(Event& event)
    4659    {
    47         SUPER(EventTarget, changedName);
     60        if (this->bActive_)
     61        {
     62            COUT(2) << "Warning: Detected Event loop in EventTarget \"" << this->getName() << "\"" << std::endl;
     63            return;
     64        }
    4865
     66        this->bActive_ = true;
     67        this->fireEvent(event);
     68        this->bActive_ = false;
     69    }
     70
     71    void EventTarget::setTargetName(const std::string& name)
     72    {
     73        this->target_ = name;
     74       
    4975        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    50             if (it->getName() == this->getName())
    51                 this->addAsEvent(*it);
     76            if (it->getName() == this->target_)
     77                this->addEventTarget(*it);
    5278    }
    5379
    5480    void EventTarget::loadedNewXMLName(BaseObject* object)
    5581    {
    56         if (this->getName() == "")
     82        if (this->target_ == "")
    5783            return;
    5884
    59         if (object->getName() == this->getName())
    60             this->addAsEvent(object);
     85        if (object->getName() == this->target_)
     86            this->addEventTarget(object);
    6187    }
    6288
    63     void EventTarget::addAsEvent(BaseObject* object)
     89    void EventTarget::addEventTarget(BaseObject* object)
    6490    {
    6591        if (object != static_cast<BaseObject*>(this))
    66             object->addEvent(this, "");
     92            object->addEventSource(this, "");
    6793    }
    6894}
Note: See TracChangeset for help on using the changeset viewer.