Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 9, 2011, 4:26:37 PM (14 years ago)
Author:
sven
Message:

Added simple GUI for docking..

Location:
code/branches/dockingsystem2/src/modules/docking
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem2/src/modules/docking/CMakeLists.txt

    r8257 r8434  
    1010  FIND_HEADER_FILES
    1111  TOLUA_FILES
     12    Dock.h
    1213  PCH_FILE
    1314    DockingPrecompiledHeaders.h
  • code/branches/dockingsystem2/src/modules/docking/Dock.cc

    r8382 r8434  
    3434#include "Dock.h"
    3535
     36#include "core/CoreIncludes.h"
     37#include "core/LuaState.h"
     38#include "core/GUIManager.h"
    3639#include "infos/HumanPlayer.h"
    3740#include "worldentities/pawns/Pawn.h"
    3841#include "interfaces/PlayerTrigger.h"
    39 #include "controllers/HumanController.h"
    4042#include "core/command/ConsoleCommand.h"
    4143
    42 
     44#include "ToluaBindDocking.h"
    4345
    4446namespace orxonox
    4547{
     48    // Register tolua_open function when loading the library
     49    DeclareToluaInterface(Docking);
     50
    4651    CreateFactory(Dock);
    4752
     
    111116        COUT(0) << "Dock triggered by player: " << player->getName() << ".." << std::endl;
    112117
    113         if(bTriggered) {
     118        if(bTriggered)
     119        {
    114120            // Add player to this Docks candidates
    115121            candidates.insert(player);
    116122
     123            // Show docking dialog
     124            GUIManager::showGUI("DockingDialog");
    117125            //DockingEffect::invokeEffect(docking::DOCKING, player, effects_);
    118         } else {
     126        }
     127        else
     128        {
    119129            // Remove player from candidates list
    120130            candidates.erase(player);
     
    127137
    128138
    129     void Dock::cmdDock() {
    130         PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
    131         for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
     139    void Dock::cmdDock()
     140    {
     141        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
     142        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
     143        {
    132144            if(it->dock(player))
    133145                break;
     
    135147    }
    136148
    137     void Dock::cmdUndock() {
    138         PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
    139         for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it) {
     149    void Dock::cmdUndock()
     150    {
     151        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
     152        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
     153        {
    140154            if(it->undock(player))
    141155                break;
     
    144158
    145159
    146     bool Dock::dock(PlayerInfo* player) {
     160    bool Dock::dock(PlayerInfo* player)
     161    {
    147162        // Check if player is a candidate
    148         if(candidates.find(player) == candidates.end()) {
    149             COUT(0) << "Player is not a candidate!";
     163        if(candidates.find(player) == candidates.end())
     164        {
     165            COUT(0) << "Player is not a candidate!" << std::endl;
    150166            return false;
    151167        }
     
    158174    }
    159175
    160     bool Dock::undock(PlayerInfo* player) {
     176    bool Dock::undock(PlayerInfo* player)
     177    {
    161178        // Check if player is docked to this Dock
    162         if(docked.find(player) == docked.end()) {
     179        if(docked.find(player) == docked.end())
     180        {
    163181            COUT(0) << "Player is not docked to this Dock." << std::endl;
    164182            return false;
     
    173191
    174192
    175     bool Dock::addEffect(DockingEffect* effect) {
     193    unsigned int Dock::getNumberOfActiveDocks()
     194    {
     195        int i = 0;
     196        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
     197        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
     198        {
     199            if(it->candidates.find(player) != it->candidates.end())
     200                i++;
     201        }
     202        return i;
     203    }
     204
     205    Dock* Dock::getActiveDockAtIndex(unsigned int index)
     206    {
     207        PlayerInfo* player = HumanController::getLocalControllerSingleton()->getPlayer();
     208        for(ObjectList<Dock>::iterator it = ObjectList<Dock>::begin(); it != ObjectList<Dock>::end(); ++it)
     209        {
     210            if(it->candidates.find(player) != it->candidates.end())
     211            {
     212                if(index == 0)
     213                    return *it;
     214                index--;
     215            }
     216        }
     217        return NULL;
     218    }
     219
     220
     221    bool Dock::addEffect(DockingEffect* effect)
     222    {
    176223        assert(effect);
    177224        effects.push_back(effect);
     
    179226    }
    180227
    181     const DockingEffect* Dock::getEffect(unsigned int index) const {
     228    const DockingEffect* Dock::getEffect(unsigned int index) const
     229    {
    182230        int i = index;
    183         for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect) {
     231        for (std::list<DockingEffect*>::const_iterator effect = this->effects.begin(); effect != this->effects.end(); ++effect)
     232        {
    184233            if(i == 0)
    185234               return *effect;
  • code/branches/dockingsystem2/src/modules/docking/Dock.h

    r8383 r8434  
    4343
    4444#include "worldentities/StaticEntity.h"
    45 #include "notifications/NotificationManager.h"
     45#include "controllers/HumanController.h"
    4646
    4747#include "DockingEffect.h"
    4848#include "DockingPrereqs.h"
    4949
    50 namespace orxonox {
     50namespace orxonox // tolua_export
     51{  // tolua_export
    5152
    52     class _DockingExport Dock : public StaticEntity {
     53    class _DockingExport Dock  // tolua_export
     54        : public StaticEntity
     55    { // tolua_export
    5356    public:
    5457        Dock(BaseObject* creator);
     
    6669        bool undock(PlayerInfo* player); //!< Undocks a player (player must be docked)
    6770
     71        void dock() { this->dock(HumanController::getLocalControllerSingleton()->getPlayer()); } // tolua_export
     72        static unsigned int getNumberOfActiveDocks(); // tolua_export
     73        static Dock* getActiveDockAtIndex(unsigned int index); // tolua_export
     74
    6875        static void cmdDock();
    6976        static void cmdUndock();
     
    7380        std::set<PlayerInfo*> docked; //!< A set of all docked players
    7481        std::list<DockingEffect*> effects; //!< The list of DockingEffects to be executed when a player docks.
    75     };
    76 
    77 
    78 }
     82    }; // tolua_export
     83} // tolua_export
    7984
    8085#endif /* _Dock_H__ */
Note: See TracChangeset for help on using the changeset viewer.