X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FSettings.cpp;h=7b5854f461c7586004c4de7fdd07ae11789995f7;hb=d3f49f860739b0f3abfcae0f49f19d260b532af5;hp=8261ed2b0d0247b35cf925c9c31408d6777f689a;hpb=e557f9d3439aa7bcf5a4d951c99a9c20b56cb7bc;p=lugaru.git diff --git a/Source/Settings.cpp b/Source/Settings.cpp index 8261ed2..7b5854f 100644 --- a/Source/Settings.cpp +++ b/Source/Settings.cpp @@ -1,13 +1,15 @@ #include "Settings.h" #include "Game.h" +#include "Input.h" +using namespace Game; -void DefaultSettings(Game &game) { +void DefaultSettings() { detail=1; ismotionblur=0; usermousesensitivity=1; - kContextWidth=640; - kContextHeight=480; + newscreenwidth=kContextWidth=640; + newscreenheight=kContextHeight=480; kBitsPerPixel = 32; floatjump=0; autoslomo=1; @@ -23,37 +25,45 @@ void DefaultSettings(Game &game) { texttoggle=1; alwaysblur=0; showpoints=0; + showdamagebar=0; immediate=0; velocityblur=0; volume = 0.8f; ambientsound=1; - vblsync=0; + vblsync=1; debugmode=0; - game.crouchkey=MAC_SHIFT_KEY; - game.jumpkey=MAC_SPACE_KEY; - game.leftkey=MAC_A_KEY; - game.forwardkey=MAC_W_KEY; - game.backkey=MAC_S_KEY; - game.rightkey=MAC_D_KEY; - game.drawkey=MAC_E_KEY; - game.throwkey=MAC_Q_KEY; - game.attackkey=MAC_MOUSEBUTTON1; - game.chatkey=MAC_T_KEY; + crouchkey=SDLK_LSHIFT; + jumpkey=SDLK_SPACE; + leftkey=SDLK_a; + forwardkey=SDLK_w; + backkey=SDLK_s; + rightkey=SDLK_d; + drawkey=SDLK_e; + throwkey=SDLK_q; + attackkey=MOUSEBUTTON1; + consolekey=SDLK_BACKQUOTE; + chatkey=SDLK_t; } -void SaveSettings(Game &game) { +void SaveSettings() { + if(newdetail<0) newdetail=0; + if(newdetail>2) newdetail=2; + if(newscreenwidth>3000) newscreenwidth=screenwidth; + if(newscreenwidth<0) newscreenwidth=screenwidth; + if(newscreenheight>3000) newscreenheight=screenheight; + if(newscreenheight<0) newscreenheight=screenheight; ofstream opstream(ConvertFileName(":Data:config.txt", "w")); opstream << "Screenwidth:\n"; - opstream << kContextWidth; + opstream << newscreenwidth; opstream << "\nScreenheight:\n"; - opstream << kContextHeight; + opstream << newscreenheight; opstream << "\nMouse sensitivity:\n"; opstream << usermousesensitivity; opstream << "\nBlur(0,1):\n"; opstream << ismotionblur; opstream << "\nOverall Detail(0,1,2) higher=better:\n"; - opstream << detail; + opstream << newdetail; opstream << "\nFloating jump:\n"; opstream << floatjump; opstream << "\nMouse jump:\n"; @@ -98,29 +108,39 @@ void SaveSettings(Game &game) { opstream << "\nVolume:\n"; opstream << volume; opstream << "\nForward key:\n"; - opstream << KeyToChar(game.forwardkey); + opstream << Input::keyToChar(forwardkey); opstream << "\nBack key:\n"; - opstream << KeyToChar(game.backkey); + opstream << Input::keyToChar(backkey); opstream << "\nLeft key:\n"; - opstream << KeyToChar(game.leftkey); + opstream << Input::keyToChar(leftkey); opstream << "\nRight key:\n"; - opstream << KeyToChar(game.rightkey); + opstream << Input::keyToChar(rightkey); opstream << "\nJump key:\n"; - opstream << KeyToChar(game.jumpkey); + opstream << Input::keyToChar(jumpkey); opstream << "\nCrouch key:\n"; - opstream << KeyToChar(game.crouchkey); + opstream << Input::keyToChar(crouchkey); opstream << "\nDraw key:\n"; - opstream << KeyToChar(game.drawkey); + opstream << Input::keyToChar(drawkey); opstream << "\nThrow key:\n"; - opstream << KeyToChar(game.throwkey); + opstream << Input::keyToChar(throwkey); opstream << "\nAttack key:\n"; - opstream << KeyToChar(game.attackkey); + opstream << Input::keyToChar(attackkey); + opstream << "\nConsole key:\n"; + opstream << Input::keyToChar(consolekey); opstream << "\nChat key:\n"; - opstream << KeyToChar(game.chatkey); + opstream << Input::keyToChar(chatkey); + opstream << "\nDamage bar:\n"; + opstream << showdamagebar; + opstream << "\nStereoMode:\n"; + opstream << stereomode; + opstream << "\nStereoSeparation:\n"; + opstream << stereoseparation; + opstream << "\nStereoReverse:\n"; + opstream << stereoreverse; opstream.close(); } -bool LoadSettings(Game &game) { +bool LoadSettings() { ifstream ipstream(ConvertFileName(":Data:config.txt"), std::ios::in); if ( !ipstream || ipstream.fail() ) { printf("Config file not found\n"); @@ -136,6 +156,7 @@ bool LoadSettings(Game &game) { // skip blank lines // assume lines starting with spaces are all blank if ( strlen(setting) == 0 || setting[0] == ' ' || setting[0] == '\t') continue; + //~ printf("setting : %s\n",setting); if ( ipstream.eof() || ipstream.fail() ) { fprintf(stderr, "Error reading config file: Got setting name '%s', but value can't be read\n", setting); @@ -204,35 +225,48 @@ bool LoadSettings(Game &game) { } else if ( !strncmp(setting, "Volume", 6) ) { ipstream >> volume; } else if ( !strncmp(setting, "Forward key", 11) ) { - ipstream >> string; - game.forwardkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + forwardkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Back key", 8) ) { - ipstream >> string; - game.backkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + backkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Left key", 8) ) { - ipstream >> string; - game.leftkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + leftkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Right key", 9) ) { - ipstream >> string; - game.rightkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + rightkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Jump key", 8) ) { - ipstream >> string; - game.jumpkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + jumpkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Crouch key", 10) ) { - ipstream >> string; - game.crouchkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + crouchkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Draw key", 8) ) { - ipstream >> string; - game.drawkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + drawkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Throw key", 9) ) { - ipstream >> string; - game.throwkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + throwkey = Input::CharToKey(string); } else if ( !strncmp(setting, "Attack key", 10) ) { - ipstream >> string; - game.attackkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + attackkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Console key", 11) ) { + ipstream.getline( string, sizeof(string) ); + consolekey = Input::CharToKey(string); } else if ( !strncmp(setting, "Chat key", 8) ) { - ipstream >> string; - game.chatkey = CharToKey(string); + ipstream.getline( string, sizeof(string) ); + chatkey = Input::CharToKey(string); + } else if ( !strncmp(setting, "Damage bar", 10) ) { + ipstream >> showdamagebar; + } else if ( !strncmp(setting, "StereoMode", 10) ) { + int i; + ipstream >> i; + stereomode = (StereoMode)i; + } else if ( !strncmp(setting, "StereoSeparation", 16) ) { + ipstream >> stereoseparation; + } else if ( !strncmp(setting, "StereoReverse", 13) ) { + ipstream >> stereoreverse; } else { ipstream >> string; fprintf(stderr, "Unknown config option '%s' with value '%s'. Ignoring.\n", setting, string);