Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/notifications/dispatchers/CommandNotification.h @ 11527

Last change on this file since 11527 was 11052, checked in by landauf, 9 years ago

merged branch presentationHS15 back to trunk

  • Property svn:eol-style set to native
File size: 4.8 KB
RevLine 
[7193]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Damian 'Mozork' Frick
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
[7456]30    @file CommandNotification.h
[7193]31    @brief Definition of the CommandNotification class.
[7456]32    @ingroup NotificationDispatchers
[7193]33*/
34
35#ifndef _CommandNotification_H__
36#define _CommandNotification_H__
37
38#include "notifications/NotificationsPrereqs.h"
39
[7474]40#include <string>
[7193]41#include "notifications/NotificationDispatcher.h"
42
43namespace orxonox {
44
45    /**
46    @brief
47        This class implements a method of displaying a Notification with information to an input command and the key the command is mapped to.
[7489]48        The message that is displayed is a string made out of the concatenation of the preMessage, the key the specified command is mapped to and the postMessage.
[7484]49
50        In use it would like this:
51        @code
[7488]52        <CommandNotification preMessage="Please press " command="someCommand" postMessage=" to do something." sender="me">
[7484]53            <events>
54                <trigger>
55                    <PlayerTrigger />
56                </trigger>
57            </events>
58        </CommandNotification>
59        @endcode
60        Upon being triggered this would display the @ref orxonox::Notification "Notification" "Please press {the binding of the specified command} to do something".
61        For more information on what can be used for @code <PlayerTrigger /> @endcode see the @ref orxonox::NotificationDispatcher "NotificationDispatcher" documentation.
[7552]62
[7193]63    @author
64        Damian 'Mozork' Frick
[7552]65
66    @ingroup NotificationDispatchers
[7193]67    */
68    class _NotificationsExport CommandNotification : public NotificationDispatcher
69    {
70
71        public:
[9667]72            CommandNotification(Context* context); //!< Default Constructor.
[7193]73            virtual ~CommandNotification(); //!< Destructor.
74
[7210]75            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a CommandNotification object through XML.
[7193]76
77            /**
78            @brief Get the command, whose key is displayed.
79            @return Returns the name of the command.
80            */
81            const std::string& getCommand(void)
82                { return this->command_; }
83            /**
84            @brief Get the preMessage, the first part of the displayed message.
85            @return Returns the preMessage.
86            */
87            const std::string& getPreMessage(void)
88                { return this->preMessage_; }
89            /**
90            @brief Get the postMessage, the last part of the displayed message.
91            @return Returns the postMessage.
92            */
93            const std::string& getPostMessage(void)
94                { return this->postMessage_; }
95
96        protected:
97            virtual const std::string& createNotificationMessage(void); //!< Composes the Notification of the preMessage the name of the key the command is mapped to and the postMessage.
98
99        private:
100            std::string command_; //!< The name of the command.
101            std::string preMessage_; //!< The first part of the displayed message.
102            std::string postMessage_; //!< The last part of the displayed message.
103
[7484]104            void registerVariables(void); //!< Register some variables for synchronisation.
[7474]105
[7193]106            /**
107            @brief Set the command, whose key is displayed.
108            @param command The name of the command.
109            */
110            void setCommand(const std::string& command)
111                { this->command_ = command; }
112            /**
113            @brief Set the preMessage, the first part of the displayed message.
114            @param message The preMessage.
115            */
116            void setPreMessage(const std::string& message)
117                { this->preMessage_ = message; }
118            /**
119            @brief Set the postMessage, the last part of the displayed message.
120            @param message The postMessage.
121            */
122            void setPostMessage(const std::string& message)
123                 { this->postMessage_ = message; }
124    };
125
126}
127
128#endif // _CommandNotification_H__
Note: See TracBrowser for help on using the repository browser.