Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/interfaces/CMakeLists.txt

    r7504 r8706  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  InterfaceCompilation.cc
     3  NotificationListener.cc
    34  Pickupable.cc
    45  PickupCarrier.cc
  • code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc

    r7606 r8706  
    4242#include "core/CoreIncludes.h"
    4343
     44#include "infos/PlayerInfo.h"
     45#include "worldentities/pawns/Pawn.h"
     46
    4447namespace orxonox
    4548{
     
    5962        RegisterRootObject(PlayerTrigger);
    6063
    61         this->player_ = NULL;
    6264        this->isForPlayer_ = false;
     65    }
     66
     67    void PlayerTrigger::setTriggeringPawn(Pawn* pawn)
     68    {
     69        assert(pawn);
     70        this->pawn_ = WeakPtr<Pawn>(pawn);
     71        if (pawn)
     72            this->player_ = WeakPtr<PlayerInfo>(pawn->getPlayer());
    6373    }
    6474
     
    8696        RegisterRootObject(Rewardable);
    8797    }
    88 
    89     //----------------------------
    90     // NotificationListener
    91     //----------------------------
    92     NotificationListener::NotificationListener()
    93     {
    94         RegisterRootObject(NotificationListener);
    95     }
    9698}
  • code/trunk/src/orxonox/interfaces/NotificationListener.h

    r7552 r8706  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Damian 'Mozork' Frick
    2424 *   Co-authors:
    2525 *      ...
     
    4848namespace orxonox
    4949{
    50     class Notification;
     50    // TODO: Document.
     51    namespace notificationMessageType
     52    {
     53        enum Value {
     54            info,
     55            important
     56        };
     57    }
     58   
     59    namespace notificationSendMode
     60    {
     61        enum Value {
     62            local,
     63            network,
     64            broadcast
     65        };
     66    }
     67   
     68    namespace notificationCommand
     69    {
     70        enum Value {
     71            none,
     72            clear
     73        };
     74    }
    5175
     76    // TODO: Update doc.
    5277    /**
    5378    @brief
    5479        NotificationListener interface.
    5580
    56         The NotificationListener interface presents a means to being informed when @ref orxonox::Notification "Notifications" in the target set of this NotificationListener change. (e.g. @ref orxonox::Notification "Notifications" were added or removed)
    57         When inheriting from a NotificationListener it is important to register (in the constructor) and unregister (in the destructor) it to and from the @ref orxonox::NotificationManager "NotificationManager".
     81        The NotificationListener interface (or more precisely abstract class) presents a means of being informed when a new @ref orxonox::Notification "Notification" is sent.
     82        The NotificationListener can be used to send a new notification message (with NotificationListener::sendNotification() ) or a new notification command (with NotificationListener::sendCommand() ). Each NotificationListener is then informed about the new @ref orxonox::Notification "Notification" and can take appropriate action. Currently the only NotificationListener ist the @ref orxonox::NotificationManager "NotificationManager" singleton.
     83
     84        When inheriting from a NotificationListener it is important to provide an appropriate implementation of registerNotification() and executeCommand().
    5885
    5986    @author
    60         Fabian 'x3n' Landau
    61 
     87        Damian 'Mozork' Frick
     88       
    6289    @ingroup Notifications
     90    @todo Consistent terminology between message, notification and command.
    6391    */
    6492    class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
     
    6997
    7098            /**
    71             @brief Get the senders that are targets of this NotificationListener.
    72             @return Returns the set of senders that are targets of this NotificationListener.
     99            @brief Sends a Notification with the specified message to the specified client from the specified sender.
     100            @param message The message that should be sent.
     101            @param sender The sender that sent the notification. Default is 'none'.
     102            @param messageType The type of the message, can be either 'info' or 'important'. Default is 'info'.
     103            @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is notificationSendMode::local.
     104            @param clientId The id of the client the notification should be sent to. Default is 0.
    73105            */
    74             virtual const std::set<std::string> & getTargetsSet(void) = 0;
     106            static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, notificationMessageType::Value messageType = notificationMessageType::info, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
     107                { NotificationListener::sendNetworkHelper(message, sender, sendMode, clientId, false, messageType); }
     108            /**
     109            @brief Sends a specified command to the specified client from the specified sender.
     110            @param command The command that should be sent (and later executed).
     111            @param sender The sender that sent the notification. Default is 'none'.
     112            @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local.
     113            @param clientId The id of the client the command should be sent to. Default is 0.
     114            */
     115            static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
     116                { NotificationListener::sendNetworkHelper(command, sender, sendMode, clientId, true); }
    75117
     118            static void sendHelper(const std::string& message, const std::string& sender, bool isCommand = false, unsigned int messageMode = 0); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.
     119
     120            //TODO: Make protected?
     121           
    76122            /**
    77             @brief Updates the whole NotificationListener.
    78                    This is called by the @ref orxonox::NotificationManager "NotificationManager" when the @ref orxonox::Notification "Notifications" have changed so much, that the NotificationListener may have to re-initialize his operations.
     123            @brief Registers a notification with the NotificationListener.
     124                   This needs to be overloaded by each class inheriting from NotificationListener.
     125            @param message The notification's message.
     126            @param sender The sender of the notification.
     127            @param type The type of the notification.
     128            @return Returns true if the notification was successfully registered, false if not.
    79129            */
    80             virtual void update(void) = 0;
     130            virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     131                { return false; }
    81132            /**
    82             @brief Updates the NotificationListener, when a new Notification has come in at the specified time.
    83             @param notification A pointer to the @ref orxonox::Notification "Notification".
    84             @param time The time the @ref orxonox::Notification "Notification" has come in.
     133            @brief Executes a command with the NotificationListener
     134                   This needs to be overloaded by each class inheriting from NotificationListener.
     135            @param command The command to be executed.
     136            @param sender The sender of the command.
     137            @return Returns true if the command was successfully executed, false if not.
    85138            */
    86             virtual void update(Notification* notification, const std::time_t & time) = 0;
     139            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; }
     140
     141        public:
     142           
     143            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues.
     144            static const std::string NONE; //!< Static string to indicate a sender that sends to no specific NotificationQueues.
     145           
     146            //! Commands
     147            static const std::string COMMAND_CLEAR;
     148            static const std::string COMMAND_NONE;
     149           
     150        protected:
     151            static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network.
     152
     153            static notificationCommand::Value str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.
     154            static const std::string& command2Str(notificationCommand::Value command); // Helper method. Converts a command enum into its corresponding string.
    87155    };
    88156}
  • code/trunk/src/orxonox/interfaces/PlayerTrigger.h

    r7601 r8706  
    3939
    4040#include "core/OrxonoxClass.h"
     41#include "core/WeakPtr.h"
    4142
    4243namespace orxonox
     
    4445    /**
    4546    @brief
    46         PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or more precisely the @ref orxonox::Pawn "Pawn") that triggered it.
     47        PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or the @ref orxonox::Pawn "Pawn") that triggered it.
    4748
    4849    @author
     
    5859
    5960        /**
    60         @brief Returns the player that triggered the PlayerTrigger.
     61        @brief Returns the Pawn that triggered the PlayerTrigger.
    6162        @return Returns a pointer to the Pawn that triggered the PlayerTrigger.
    6263        */
    63         inline Pawn* getTriggeringPlayer(void) const
     64        inline Pawn* getTriggeringPawn(void) const
     65            { return this->pawn_.get(); }
     66
     67        /**
     68        @brief Returns the player that triggered the PlayerTrigger.
     69        @return Returns a pointer to the PlayerInfo that triggered the PlayerTrigger.
     70        */
     71        inline PlayerInfo* getTriggeringPlayer(void) const
    6472            { return this->player_; }
    6573
    6674        /**
    67         @brief Checks whether the PlayerTrigger normally returns a Pawn.
    68         @return Returns true if the PlayerTrigger normally returns a Pawn.
     75        @brief Checks whether the PlayerTrigger normally returns a Pawn/PlayerInfo.
     76        @return Returns true if the PlayerTrigger normally returns a Pawn/PlayerInfo.
    6977        */
    7078        inline bool isForPlayer(void) const
     
    7684        @param player A pointer to the Pawn that triggered the PlayerTrigger.
    7785        */
    78         inline void setTriggeringPlayer(Pawn* player)
    79            { this->player_ = player; }
     86        void setTriggeringPawn(Pawn* pawn);
    8087
    8188        /**
     
    8794
    8895    private:
    89         Pawn* player_; //!< The player that triggered the PlayerTrigger.
     96        WeakPtr<PlayerInfo> player_; //!< The player that triggered the PlayerTrigger.
     97        WeakPtr<Pawn> pawn_; //!< The Pawn that triggered the PlayerTrigger.
    9098        bool isForPlayer_; //!< Is true when the PlayerTrigger should be set to normally be triggered by Pawns.
    9199
Note: See TracChangeset for help on using the changeset viewer.