Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 7, 2011, 3:11:16 PM (13 years ago)
Author:
landauf
Message:

enhanced chat system. chat related code is now separated into network-side code (located in Host, Client, Server) and client-side code (located in ChatManager).
note that there are now two chat related listeners: NetworkChatListener, which is used to send chat from the network to ChatManager, and ChatListener, which is used to send online and offline chat from ChatManager to the actual chat interfaces (ChatOverlay, ChatInputHandler, …).
the "chat" console command now supports a second argument which is the clientID of the receiver. this allows private messages (or gameplay messages directed to only one specific player).

Location:
code/branches/output/src/orxonox
Files:
3 added
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/output/src/orxonox/OrxonoxPrereqs.h

    r8351 r8829  
    7777    class Radar;
    7878    class Scene;
     79
     80    // chat
     81    class ChatHistory;
     82    class ChatInputHandler;
     83    class ChatListener;
     84    class ChatManager;
    7985
    8086    // collisionshapes
  • code/branches/output/src/orxonox/chat/CMakeLists.txt

    r8828 r8829  
    22  ChatHistory.cc
    33  ChatInputHandler.cc
     4  ChatManager.cc
    45)
  • code/branches/output/src/orxonox/chat/ChatHistory.cc

    r8828 r8829  
    7474
    7575  /* react to incoming chat */
    76   void ChatHistory::incomingChat(const std::string& message,
    77     unsigned int senderID)
     76  void ChatHistory::incomingChat(const std::string& message, const std::string& /*name*/)
    7877  {
    79     /* --> a) look up the actual name of the sender */
    80     std::string text = message;
    81 
    82 #ifndef CHATTEST
    83     /* get sender ID and prepend it to the message */
    84     if (senderID != NETWORK_PEER_ID_UNKNOWN)
    85     {
    86       PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
    87       if (player)
    88         text = player->getName() + ": " + message;
    89     }
    90 #endif
    91 
    9278    /* add the line to the history */
    93     this->chat_hist_addline( text );
     79    this->chat_hist_addline( message );
    9480
    9581    /* add the line to the log */
    96     this->chat_hist_logline( text );
     82    this->chat_hist_logline( message );
    9783  }
    9884
  • code/branches/output/src/orxonox/chat/ChatHistory.h

    r8828 r8829  
    3737
    3838#ifndef CHATTEST
    39 #include <OrxonoxPrereqs.h>
    40 #include <PlayerManager.h>
    41 #include <infos/PlayerInfo.h>
    42 #include <core/BaseObject.h>
    43 #include <network/ChatListener.h>
    44 #include <core/PathConfig.h>
    45 #include <util/Singleton.h>
     39#include "OrxonoxPrereqs.h"
     40
     41#include "util/Singleton.h"
     42#include "core/BaseObject.h"
     43#include "core/PathConfig.h"
     44#include "chat/ChatListener.h"
     45#include "infos/PlayerInfo.h"
     46#include "PlayerManager.h"
    4647#endif
    4748
     
    8283       * \param senderID Identification number of the sender
    8384       */
    84       virtual void incomingChat(const std::string& message,
    85         unsigned int senderID);
     85      virtual void incomingChat(const std::string& message, const std::string& name);
    8686
    8787      /** Synchronize logfile onto the hard drive
  • code/branches/output/src/orxonox/chat/ChatInputHandler.cc

    r8828 r8829  
    4444#include "core/input/InputManager.h"
    4545#include "core/input/InputState.h"
    46 #include "network/Host.h"
    47 
     46
     47#include "chat/ChatManager.h"
    4848#include "PlayerManager.h"
    4949#include "infos/PlayerInfo.h"
     
    213213
    214214  /* handle incoming chat */
    215   void ChatInputHandler::incomingChat(const std::string& message,
    216     unsigned int senderID)
    217   {
    218     /* look up the actual name of the sender */
    219     std::string text = message;
    220     std::string name = "";
    221 
    222     /* setup player name info */
    223     if (senderID != NETWORK_PEER_ID_UNKNOWN)
    224     {
    225        PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
    226        if (player)
    227        {
    228          name = player->getName();
    229          text = name + ": " + message;
    230        }
    231     }
    232 
     215  void ChatInputHandler::incomingChat(const std::string& message, const std::string& name)
     216  {
    233217    /* create item */
    234     CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text );
     218    CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( message );
    235219
    236220    /* setup colors */
     
    320304
    321305    /* c) send the chat via some call */
    322     Host::Chat( msgtosend );
     306    ChatManager::chat( msgtosend );
    323307
    324308    /* d) stop listening to input - only if this is not fullchat */
  • code/branches/output/src/orxonox/chat/ChatInputHandler.h

    r8828 r8829  
    3030#define _ChatInputHandler_H__
    3131
    32 #include <OrxonoxPrereqs.h>
     32#include "OrxonoxPrereqs.h"
    3333
    3434#include <string>
     
    3737
    3838#include "util/Singleton.h"
    39 #include "network/ChatListener.h"
     39#include "chat/ChatListener.h"
    4040
    4141namespace orxonox // tolua_export
     
    112112       * history window of the full chat window)
    113113       */
    114       void incomingChat( const std::string& message,
    115         unsigned int senderID );
     114      void incomingChat(const std::string& message, const std::string& name);
    116115
    117116      /** \param full true means show full chat window with history,
  • code/branches/output/src/orxonox/gametypes/Asteroids.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3333#include "worldentities/pawns/Pawn.h"
    3434
     
    7474
    7575        std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
    76         Host::Broadcast(message);
     76        ChatManager::message(message);
    7777
    7878    }
     
    8383
    8484        std::string message("The match has ended.");
    85         Host::Broadcast(message);
     85        ChatManager::message(message);
    8686    }
    8787}
  • code/branches/output/src/orxonox/gametypes/Deathmatch.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3333#include "infos/PlayerInfo.h"
    3434#include "worldentities/pawns/Pawn.h"
     
    4848
    4949        std::string message("The match has started!");
    50         Host::Broadcast(message);
     50        ChatManager::message(message);
    5151    }
    5252
     
    5656
    5757        std::string message("The match has ended.");
    58         Host::Broadcast(message);
     58        ChatManager::message(message);
    5959    }
    6060
     
    6464
    6565        const std::string& message = player->getName() + " entered the game";
    66         Host::Broadcast(message);
     66        ChatManager::message(message);
    6767    }
    6868
     
    7474        {
    7575            const std::string& message = player->getName() + " left the game";
    76             Host::Broadcast(message);
     76            ChatManager::message(message);
    7777        }
    7878
     
    8787        {
    8888            const std::string& message = player->getOldName() + " changed name to " + player->getName();
    89             Host::Broadcast(message);
     89            ChatManager::message(message);
    9090        }
    9191
     
    108108                message = victim->getPlayer()->getName() + " died";
    109109
    110             Host::Broadcast(message);
     110            ChatManager::message(message);
    111111        }
    112112
     
    121121        {
    122122            const std::string& message = player->getName() + " scores!";
    123             Host::Broadcast(message);
     123            ChatManager::message(message);
    124124        }
    125125    }
  • code/branches/output/src/orxonox/gametypes/Dynamicmatch.cc

    r8822 r8829  
    4949#include "core/CoreIncludes.h"
    5050#include "core/command/Executor.h"
    51 #include "network/Host.h"
     51#include "chat/ChatManager.h"
    5252#include "infos/PlayerInfo.h"
    5353#include "worldentities/pawns/Pawn.h"
     
    343343        Gametype::playerEntered(player);
    344344        const std::string& message = player->getName() + " entered the game";
    345         Host::Broadcast(message);
     345        ChatManager::message(message);
    346346    }
    347347
     
    358358            }
    359359            const std::string& message = player->getName() + " left the game";
    360             Host::Broadcast(message);
     360            ChatManager::message(message);
    361361            //remove player from map
    362362            playerParty_.erase (player);
     
    615615        {
    616616            const std::string& message = player->getOldName() + " changed name to " + player->getName();
    617             Host::Broadcast(message);
     617            ChatManager::message(message);
    618618        }
    619619
     
    627627        {
    628628            std::string message("Dynamicmatch started!");
    629             Host::Broadcast(message);
     629            ChatManager::message(message);
    630630        }
    631631        else if(tutorial) // Announce selectionphase
     
    643643    {
    644644        std::string message("Earn points:\n\n\n\tIf you're red: Chase the blue player!\n\n\tIf you're blue shoot at a red player or hide.\n\n\tIf you're green: You've got the licence to kill red players!");
    645         Host::Broadcast(message);
     645        ChatManager::message(message);
    646646        callInstructions_.setTimer(10, false, createExecutor(createFunctor(&Dynamicmatch::furtherInstructions, this)));
    647647    }
     
    650650    {
    651651        std::string message("After 3 Minutes the game is over.");
    652         Host::Broadcast(message);
     652        ChatManager::message(message);
    653653    }*/
    654654    void Dynamicmatch::end()
     
    657657
    658658        std::string message("Time out. Press F2 to see the points you scored.");
    659         Host::Broadcast(message);
     659        ChatManager::message(message);
    660660    }
    661661    SpawnPoint* Dynamicmatch::getBestSpawnPoint(PlayerInfo* player) const
  • code/branches/output/src/orxonox/gametypes/LastManStanding.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3333#include "infos/PlayerInfo.h"
    3434#include "worldentities/pawns/Pawn.h"
     
    105105            this->playersAlive--;
    106106            const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
    107             Host::Broadcast(message);
     107            ChatManager::message(message);
    108108        }
    109109
  • code/branches/output/src/orxonox/gametypes/LastTeamStanding.cc

    r8822 r8829  
    3030
    3131#include "core/CoreIncludes.h"
    32 #include "network/NetworkPrereqs.h"
    33 #include "network/Host.h"
     32#include "chat/ChatManager.h"
    3433#include "infos/PlayerInfo.h"
    3534#include "worldentities/pawns/Pawn.h"
     
    119118                this->teamsAlive--;
    120119            const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
    121             Host::Broadcast(message);
     120            ChatManager::message(message);
    122121        }
    123122        return allow;
  • code/branches/output/src/orxonox/gametypes/UnderAttack.cc

    r8822 r8829  
    3232#include "core/CoreIncludes.h"
    3333#include "core/ConfigValueIncludes.h"
    34 #include "network/Host.h"
     34#include "chat/ChatManager.h"
    3535#include "worldentities/pawns/Destroyer.h"
    3636#include "infos/PlayerInfo.h"
     
    7070        this->end(); //end gametype
    7171        std::string message("Ship destroyed! Team 0 has won!");
    72         Host::Broadcast(message);
     72        ChatManager::message(message);
    7373        this->gameEnded_ = true;
    7474
     
    152152                this->end();
    153153                std::string message("Time is up! Team 1 has won!");
    154                 Host::Broadcast(message);
     154                ChatManager::message(message);
    155155
    156156                for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
     
    171171                const std::string& message = multi_cast<std::string>(timesequence_) + " seconds left!";
    172172/*
    173                 Host::Broadcast(message);
     173                ChatManager::message(message);
    174174*/
    175175                this->gtinfo_->sendAnnounceMessage(message);
Note: See TracChangeset for help on using the changeset viewer.