Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2010, 3:37:40 AM (14 years ago)
Author:
landauf
Message:

merged consolecommands3 branch back to trunk.

note: the console command interface has changed completely, but the documentation is not yet up to date. just copy an existing command and change it to your needs, it's pretty self-explanatory. also the include files related to console commands are now located in core/command/. in the game it should work exactly like before, except for some changes in the auto-completion.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/Test.cc

    r7163 r7284  
    2929#include "core/CoreIncludes.h"
    3030#include "core/ConfigValueIncludes.h"
    31 #include "core/ConsoleCommand.h"
     31#include "core/command/ConsoleCommand.h"
    3232#include "network/NetworkFunction.h"
    3333#include "Test.h"
     
    3737{
    3838    CreateFactory ( Test );
    39  
    40     SetConsoleCommand(Test, printV1, true).accessLevel(AccessLevel::User);
    41     SetConsoleCommand(Test, printV2, true).accessLevel(AccessLevel::User);
    42     SetConsoleCommand(Test, printV3, true).accessLevel(AccessLevel::User);
    43     SetConsoleCommand(Test, printV4, true).accessLevel(AccessLevel::User);
    44     SetConsoleCommand(Test, call, true).accessLevel(AccessLevel::User);
    45     SetConsoleCommand(Test, call2, true).accessLevel(AccessLevel::User);
    46  
    47  
     39
     40    SetConsoleCommand("Test", "printV1", &Test::printV1).addShortcut();
     41    SetConsoleCommand("Test", "printV2", &Test::printV2).addShortcut();
     42    SetConsoleCommand("Test", "printV3", &Test::printV3).addShortcut();
     43    SetConsoleCommand("Test", "printV4", &Test::printV4).addShortcut();
     44    SetConsoleCommand("Test", "call",    &Test::call).addShortcut();
     45    SetConsoleCommand("Test", "call2",   &Test::call2).addShortcut();
     46
     47
    4848  //void=* aaaaa = copyPtr<sizeof(&Test::printV1)>( &NETWORK_FUNCTION_POINTER, &Test::printV1 );
    4949  //void* NETWORK_FUNCTION_TEST_B = memcpy(&NETWORK_FUNCTION_POINTER, &a, sizeof(a));
    5050//   NetworkFunctionBase* NETWORK_FUNCTION_TEST_C = new NetworkFunctionStatic( createFunctor(&Test::printV1), "bla", NETWORK_FUNCTION_POINTER );
    51  
     51
    5252    registerStaticNetworkFunction( &Test::printV1 );
    5353    registerMemberNetworkFunction( Test, checkU1 );
    5454    registerMemberNetworkFunction( Test, printBlaBla );
    55  
     55
    5656    Test* Test::instance_ = 0;
    5757
     
    7878        SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
    7979        SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
    80    
     80
    8181        SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
    8282        SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     
    8989    {
    9090        registerVariable ( this->mySet_, VariableDirection::ToClient );
    91      
     91
    9292//         registerVariable ( u1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
    9393//         registerVariable ( u2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkU2 ));
    9494//         registerVariable ( u3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
    9595//         registerVariable ( u4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
    96    
     96
    9797//         registerVariable ( s1, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
    9898//         registerVariable ( s2, VariableDirection::ToServer, new NetworkCallback<Test> ( this, &Test::checkS2 ));
    9999//         registerVariable ( s3, Bidirectionality::ServerMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
    100100//         registerVariable ( s4, Bidirectionality::ClientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    101    
     101
    102102//         registerVariable ( pointer_, VariableDirection::ToClient, new NetworkCallback<Test> ( this, &Test::printPointer ) );
    103103    }
    104  
     104
    105105  void Test::call(unsigned int clientID)
    106106    {
     
    108108        callStaticNetworkFunction( &Test::printV1, clientID );
    109109    }
    110  
     110
    111111    void Test::call2(unsigned int clientID, std::string s1, std::string s2, std::string s3, std::string s4)
    112112    {
    113113        callMemberNetworkFunction( Test, printBlaBla, this->getObjectID(), clientID, s1, s2, s3, s4, s4 );
    114114    }
    115  
     115
    116116    void Test::tick(float dt)
    117117    {
     
    132132    //       callMemberNetworkFunction( Test, checkU1, this->getObjectID(), 0 );
    133133    }
    134    
     134
    135135    void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
    136136    {
    137137        COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
    138138    }
    139    
     139
    140140    void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
    141141    void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
     
    147147    void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
    148148    void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
    149    
     149
    150150    void Test::printPointer(){ CCOUT(1) << "pointer: " << this->pointer_ << endl; }
    151151
Note: See TracChangeset for help on using the changeset viewer.