Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 2, 2008, 9:23:30 PM (17 years ago)
Author:
landauf
Message:

merged console-branch back to trunk.
IMPORTANT: update your media directory!

you need TCL to compile. TCL is available here: http://www.tcl.tk/
another option is to check out https://svn.orxonox.net/ogre/tcl8.5.2/ and compile it by yourself. makefiles are in the 'macosx', 'unix' and 'win' subfolders.
FindTCL.cmake searches in the usual locations and in ../libs/tcl8.5.2/

the orxonox console can be activated with numpad-enter. whatever you enter will be parsed by TCL. if TCL doesn't know a command, it gets executed by orxonox.

simple tcl commands are: "puts text" to write "text" into the console, "expr 1+1" to calculate the result of the given expression. just try it by yourself with "puts [expr 1+1]".
[x] means: evaluate x and use the returnvalue as an argument. in this case the returned value is "2" and the resulting command therefore "puts 2".

you can combine orxonox and tcl commands. a simple orxonox command is "log text" that writes text into the console and the logfile. test it with "log [expr 1+1]" to write "2" into all output channels of orxonox. something more advanced: "log [clock seconds]" writes the seconds since 1970 into the logfile. feel free to combine both: "log [clock seconds]: 1+1 is [expr 1+1]"

TCL uses variables. to set a new variable, use "set varname value". you can use the variable wherever you want with $varname. with this we can make the above command a bit more elegant:
set myexpression 1+1
log [clock seconds]: $myexpression is [expr $myexpression]

read more about tcl in the wiki: http://wiki.tcl.tk/

Location:
code/trunk/src/orxonox/console
Files:
3 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/console/InGameConsole.cc

    r1145 r1214  
    6868    void InGameConsole::listen(){
    6969        if(!active) activate();
    70         print(this->ib_->get());
     70        print(convert2UTF(this->ib_->get()));
    7171    }
    7272
     
    8484        newline();
    8585        this->ib_->set(CommandExecutor::complete(this->ib_->get()));
    86         print(this->ib_->get());
     86        print(convert2UTF(this->ib_->get()));
    8787    }
    8888
     
    109109        scrollTimer = 0;
    110110        cursor = 0;
     111
    111112        // create overlay and elements
    112113        om = &Ogre::OverlayManager::getSingleton();
     
    195196        cursor += dt;
    196197        if(cursor >= 2*BLINK) cursor = 0;
    197         print(this->ib_->get());
     198        print(convert2UTF(this->ib_->get()));
    198199
    199200// this creates a flickering effect
     
    243244    @param s string to be printed
    244245    */
    245     void InGameConsole::print(std::string s){
     246    void InGameConsole::print(Ogre::UTFString s){
    246247        if(cursor>BLINK) consoleOverlayTextAreas[0]->setCaption(">" + s);
    247248        else consoleOverlayTextAreas[0]->setCaption(">" + s + "_");
     
    252253    */
    253254    void InGameConsole::newline(){
    254 
    255         std::string line;
     255        Ogre::UTFString line;
    256256        for(int i = LINES-1; i>=1; i--){
    257257            line = consoleOverlayTextAreas[i-1]->getCaption();
     
    263263        consoleOverlayTextAreas[0]->setCaption(">");
    264264    }
     265
     266    Ogre::UTFString InGameConsole::convert2UTF(std::string s){
     267        Ogre::UTFString utf;
     268        int i;
     269        Ogre::UTFString::code_point cp;
     270        for (i=0; i<(int)s.size(); ++i){
     271          cp = s[i];
     272          cp &= 0xFF;
     273          utf.append(1, cp);
     274        }
     275        return utf;
     276    }
    265277}
  • code/trunk/src/orxonox/console/InGameConsole.h

    r1145 r1214  
    6060        private:
    6161            void resize();
    62             void print(std::string s);
     62            void print(Ogre::UTFString s);
    6363            void newline();
     64            Ogre::UTFString convert2UTF(std::string s);
    6465
    6566            int windowW;
Note: See TracChangeset for help on using the changeset viewer.