X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=1a743f3979536ff84e0a6d6ca002d6932cf472e9;hb=5931bd1edf827e8645f89b5a4a16585cb25bc6e1;hp=122471a4d769c4bdd1766c10889b6f1e9c70b145;hpb=1c7d28a2fc93699ab955ea66203d0c36bba9d977;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 122471a..1a743f3 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -44,6 +44,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Menu.h" #include +#include using namespace std; using namespace Game; @@ -147,12 +148,13 @@ extern bool winfreeze; extern bool campaign; +extern void toggleFullscreen(); + void Loadlevel(int which); void Loadlevel(const char *name); - class CampaignLevel { private: @@ -5794,6 +5796,7 @@ void updateSettingsMenu() else sprintf (sbuf, "Resolution: %d*%d (widescreen)", (int)newscreenwidth, (int)newscreenheight); Menu::setText(0, sbuf); + Menu::setText(14, fullscreen ? "Fullscreen: On" : "Fullscreen: Off"); if (newdetail == 0) Menu::setText(1, "Detail: Low"); if (newdetail == 1) Menu::setText(1, "Detail: Medium"); if (newdetail == 2) Menu::setText(1, "Detail: High"); @@ -5874,6 +5877,7 @@ void Game::LoadMenu() break; case 3: Menu::addButton( 0, "", 10 + 20, 440); + Menu::addButton(14, "", 10 + 400, 440); Menu::addButton( 1, "", 10 + 60, 405); Menu::addButton( 2, "", 10 + 70, 370); Menu::addButton( 3, "", 10 + 20 - 1000, 335 - 1000); @@ -6009,7 +6013,7 @@ void Game::LoadMenu() } } -extern SDL_Rect **resolutions; +extern set> resolutions; void MenuTick() { @@ -6033,6 +6037,7 @@ void MenuTick() char sbuf[256]; if (Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus + set>::iterator newscreenresolution; switch (mainmenu) { case 1: case 2: @@ -6081,40 +6086,17 @@ void MenuTick() break; case 3: fireSound(); - bool isCustomResolution, found; switch (selected) { case 0: - isCustomResolution = true; - found = false; - for (int i = 0; (!found) && (resolutions[i]); i++) { - if ((resolutions[i]->w == screenwidth) && (resolutions[i]->h == screenwidth)) - isCustomResolution = false; - - if ((resolutions[i]->w == newscreenwidth) && (resolutions[i]->h == newscreenheight)) { - i++; - if (resolutions[i] != NULL) { - newscreenwidth = (int) resolutions[i]->w; - newscreenheight = (int) resolutions[i]->h; - } else if (isCustomResolution) { - if ((screenwidth == newscreenwidth) && (screenheight == newscreenheight)) { - newscreenwidth = (int) resolutions[0]->w; - newscreenheight = (int) resolutions[0]->h; - } else { - newscreenwidth = screenwidth; - newscreenheight = screenheight; - } - } else { - newscreenwidth = (int) resolutions[0]->w; - newscreenheight = (int) resolutions[0]->h; - } - found = true; - } - } - - if (!found) { - newscreenwidth = (int) resolutions[0]->w; - newscreenheight = (int) resolutions[0]->h; + newscreenresolution = resolutions.find(make_pair(newscreenwidth, newscreenheight)); + /* Next one (end() + 1 is also end() so the ++ is safe even if it was not found) */ + newscreenresolution++; + if (newscreenresolution == resolutions.end()) { + /* It was the last one (or not found), go back to the beginning */ + newscreenresolution = resolutions.begin(); } + newscreenwidth = newscreenresolution->first; + newscreenheight = newscreenresolution->second; break; case 1: newdetail++; @@ -6186,6 +6168,9 @@ void MenuTick() case 13: showdamagebar = !showdamagebar; break; + case 14: + toggleFullscreen(); + break; } updateSettingsMenu(); break; @@ -6567,28 +6552,6 @@ void Game::Tick() } } - if (Input::isKeyPressed(chatkey) && !console && !chatting && debugmode) - chatting = 1; - - if (chatting) { - inputText(displaytext[0], &displayselected); - if (!waiting) { - if (!displaytext[0].empty()) { - displaytext[0].clear(); - displayselected = 0; - } - chatting = 0; - } - - displayblinkdelay -= multiplier; - if (displayblinkdelay <= 0) { - displayblinkdelay = .3; - displayblink = 1 - displayblink; - } - } - if (chatting) - keyboardfrozen = true; - if (Input::isKeyPressed(consolekey) && debugmode) { console = !console; if (console) {