Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8434


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

Added simple GUI for docking..

Location:
code/branches/dockingsystem2
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/dockingsystem2/data/levels/docking.oxw

    r8382 r8434  
    2727    <Light type="directional" position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
    2828
     29
     30
    2931    <?lua for i = 1, 10, 1 do ?>
    30       <SpawnPoint position="<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>,<?lua print(math.random() * 500 - 250) ?>" lookat="0,0,0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
     32      <SpawnPoint position="<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>,<?lua print(math.random() * 200 - 100) ?>" lookat="0,0,0" spawnclass="SpaceShip" pawndesign="spaceshipassff" />
    3133    <?lua end ?>
    3234
    33     <Dock position="-50,-100,50">
    34             <effects>
    35                 <DockToShip target="theDestroyer" />
    36             </effects>
    37             <events>
    38                 <execute>
    39                     <EventListener event="dockMe" />
    40                 </execute>
    41             </events>
    42             <attached>
    43                 <DistanceTrigger position="0,0,0" distance="20" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
    44                 <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
    45             </attached>
    46         </Dock>
    47 
    48 
    49    
     35
     36
     37
     38    <Dock>
     39        <effects>
     40            <DockToShip target="destroyer" />
     41        </effects>
     42        <events>
     43            <execute>
     44                <EventListener event="dockMe" />
     45            </execute>
     46        </events>
     47        <attached>
     48            <DistanceTrigger position="0,0,0" distance="50" target="Pawn" beaconMode="exclude" targetname="destroyerBeacon" name="dockMe" />
     49            <Billboard material="Examples/Flare" colour="1.0, 0, 0" />
     50        </attached>
     51    </Dock>
     52
     53
    5054
    5155      <SpaceShip
     56   position               = "-150,-50,-100"
    5257   hudtemplate            = "spaceshiphud"
    5358   camerapositiontemplate = "spaceshipassffcameras"
     
    7176  >
    7277    <attached>
    73         <DistanceTriggerBeacon name="beacon1" />
    74         <DockingTarget name="asdf" />
     78        <DistanceTriggerBeacon name="bcnSpaceShip1" />
     79        <DockingTarget name="spaceShip1" />
    7580
    7681      <Model position="0,0,0" yaw="90" pitch="-90" roll="0" scale="4" mesh="assff.mesh" />
     
    96101
    97102    <Destroyer
    98       position          = "100,150,0"
     103      position          = "100,150,100"
    99104      collisionType     = "dynamic"
    100105      mass              = "100000"
     
    108113      <attached>
    109114
    110         <DistanceTriggerBeacon name="destroyerBeacon" />
    111         <DockingTarget name="theDestroyer" />
     115        <DistanceTriggerBeacon name="bcnDestroyer" />
     116        <DockingTarget name="destroyer" />
    112117
    113118
  • 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.