]> git.jsancho.org Git - lugaru.git/commitdiff
The console key is now easy to configure. (the option will only be shown in debug...
authorCôme BERNIGAUD <come.bernigaud@gmail.com>
Wed, 18 May 2011 15:20:42 +0000 (17:20 +0200)
committerCôme BERNIGAUD <come.bernigaud@gmail.com>
Wed, 18 May 2011 15:20:42 +0000 (17:20 +0200)
Source/Game.cpp
Source/Game.h
Source/GameDraw.cpp
Source/GameTick.cpp
Source/Settings.cpp

index 77b9a5b21cda64a480dc3f230f8c129fba868934..0cc5057361aa86855ff8ff42fa6fc2ddf0f29b6a 100644 (file)
@@ -161,6 +161,7 @@ Game::Game()
        autocam = 0;
 
        crouchkey = 0,jumpkey = 0,forwardkey = 0,chatkey = 0,backkey = 0,leftkey = 0,rightkey = 0,drawkey = 0,throwkey = 0,attackkey = 0;
+       consolekey = 0;
        oldattackkey = 0;
 
        loading = 0;
@@ -310,6 +311,8 @@ void Game::setKeySelected_thread() {
                        break;
                        case 8: attackkey=keycode;
                        break;
+                       case 9: consolekey=keycode;
+                       break;
                        default:
                        break;
                }
index cb08024bc41559667f6098fc148a6bfa43ad2b1f..fc89b4cf0f86c680e188eb87ab355aab06dbc8b2 100644 (file)
@@ -280,6 +280,7 @@ class Game
                bool autocam;
 
                unsigned short crouchkey,jumpkey,forwardkey,chatkey,backkey,leftkey,rightkey,drawkey,throwkey,attackkey;
+               unsigned short consolekey;
                bool oldattackkey;
 
                static void LoadTexture(const string fileName, GLuint *textureid,int mipmap, bool hasalpha);
index 522681bc781434e18e23a23e21d4274ebc963956..19b7f1794f385c9d9517f8f84ca86526e2fa8a98 100644 (file)
@@ -2278,10 +2278,18 @@ void Game::DrawMenu() {
                        else sprintf (menustring[8], "Attack: _");
                        startx[8]=10+20;
                        starty[8]=80;
-
-                       sprintf (menustring[9], "Back");
-                       startx[9]=10;
-                       starty[9]=10;
+                       
+                       if(debugmode) {
+                               if(keyselect!=9)sprintf (menustring[9], "Console: %s",Input::keyToChar(consolekey));
+                               else sprintf (menustring[9], "Console: _");
+                               startx[9]=10+10;
+                               starty[9]=40;
+                               nummenuitems++;
+                       }
+                       
+                       sprintf (menustring[nummenuitems-1], "Back");
+                       startx[nummenuitems-1]=10;
+                       starty[nummenuitems-1]=10;
                }
                break;
                case 5: {                       
index 047c5f133feb8077a0d790bb01e0c808740afb09..7d9ec2cd0edc6c0944879e2e1a9d3bbbc8fcf37b 100644 (file)
@@ -5591,11 +5591,11 @@ void Game::MenuTick(){
                        case 4:
                                if(!waiting) {
                                        fireSound();
-                                       if(selected<9 && keyselect==-1)
+                                       if(selected<nummenuitems-1 && keyselect==-1)
                                                keyselect=selected;
                                        if(keyselect!=-1)
                                                setKeySelected();
-                                       if(selected==9){
+                                       if(selected==nummenuitems-1){
                                                flash();
 
                                                mainmenu=3;
@@ -5970,7 +5970,7 @@ void Game::Tick(){
                if(chatting)
             keyboardfrozen=true;
 
-               if(Input::isKeyPressed(SDLK_BACKQUOTE)&&debugmode){
+               if(Input::isKeyPressed(consolekey)&&debugmode){
                        console=!console;
                        if(console){
                                OPENAL_SetFrequency(OPENAL_ALL, 0.001);
index 284baf47fee87a90e732d7ed37a4ef72ef07e737..ef3cebe22e9f5ead286eff1659636a12d9d2fd93 100644 (file)
@@ -40,6 +40,7 @@ void DefaultSettings(Game &game) {
        game.drawkey=SDLK_e;
        game.throwkey=SDLK_q;
        game.attackkey=MOUSEBUTTON1;
+       game.consolekey=SDLK_BACKQUOTE;
        game.chatkey=SDLK_t;
 }
 
@@ -122,6 +123,8 @@ void SaveSettings(Game &game) {
        opstream << Input::keyToChar(game.throwkey);
        opstream << "\nAttack key:\n";
        opstream << Input::keyToChar(game.attackkey);
+       opstream << "\nConsole key:\n";
+       opstream << Input::keyToChar(game.consolekey);
        opstream << "\nChat key:\n";
        opstream << Input::keyToChar(game.chatkey);
        opstream << "\nDamage bar:\n";
@@ -246,6 +249,9 @@ bool LoadSettings(Game &game) {
                } else if ( !strncmp(setting, "Attack key", 10) ) {
                        ipstream.getline( string, sizeof(string) );
                        game.attackkey = Input::CharToKey(string);
+               } else if ( !strncmp(setting, "Console key", 11) ) {
+                       ipstream.getline( string, sizeof(string) );
+                       game.consolekey = Input::CharToKey(string);
                } else if ( !strncmp(setting, "Chat key", 8) ) {
                        ipstream.getline( string, sizeof(string) );
                        game.chatkey = Input::CharToKey(string);