]> git.jsancho.org Git - lugaru.git/blobdiff - Source/GameTick.cpp
major refactor of menu system, part 2
[lugaru.git] / Source / GameTick.cpp
index 5b58c1c81b954bde07eb81d58699aa00488d8381..75d13958223f69ed036a538a4f5c7eacceeddbc6 100644 (file)
@@ -35,10 +35,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "Input.h"
 #include "Animation.h"
 #include "Awards.h"
+#include "Menu.h"
 
 #include <algorithm>
 
 using namespace std;
+using namespace Game;
 
 // Added more evilness needed for MSVC
 #ifdef _MSC_VER
@@ -82,6 +84,7 @@ extern XYZ windvector;
 extern bool debugmode;
 static int leveltheme;
 extern int mainmenu;
+extern int oldmainmenu;
 extern bool visibleloading;
 extern XYZ envsound[30];
 extern float envsoundvol[30];
@@ -172,9 +175,9 @@ static const char *cmd_names[] = {
 #undef  DECLARE_COMMAND
 };
 
-typedef void (*console_handler)(Game *game, const char *args);
+typedef void (*console_handler)(const char *args);
 
-#define DECLARE_COMMAND(cmd) static void ch_##cmd(Game *game, const char *args);
+#define DECLARE_COMMAND(cmd) static void ch_##cmd(const char *args);
 #include "ConsoleCmds.h"
 #undef  DECLARE_COMMAND
 
@@ -258,19 +261,19 @@ void playdialogueboxsound(){
 
 
 
-static void ch_quit(Game *game, const char *args)
+static void ch_quit(const char *args)
 {
-  game->tryquit = 1;
+  tryquit = 1;
 }
 
-static void ch_map(Game *game, const char *args)
+static void ch_map(const char *args)
 {
-  game->Loadlevel(args);
-  game->whichlevel = -2;
+  Loadlevel(args);
+  whichlevel = -2;
   campaign = 0;
 }
 
-static void ch_save(Game *game, const char *args){
+static void ch_save(const char *args){
     char buf[64];
     snprintf(buf, 63, ":Data:Maps:%s", args);
 
@@ -423,59 +426,59 @@ static void ch_save(Game *game, const char *args){
                 }
         }
 
-    fpackf(tfile, "Bi", game->numpathpoints);
-       for(int j=0;j<game->numpathpoints;j++){
-               fpackf(tfile, "Bf Bf Bf Bi", game->pathpoint[j].x, game->pathpoint[j].y, game->pathpoint[j].z, game->numpathpointconnect[j]);
-               for(int k=0;k<game->numpathpointconnect[j];k++)
-                       fpackf(tfile, "Bi", game->pathpointconnect[j][k]);
+    fpackf(tfile, "Bi", numpathpoints);
+       for(int j=0;j<numpathpoints;j++){
+               fpackf(tfile, "Bf Bf Bf Bi", pathpoint[j].x, pathpoint[j].y, pathpoint[j].z, numpathpointconnect[j]);
+               for(int k=0;k<numpathpointconnect[j];k++)
+                       fpackf(tfile, "Bi", pathpointconnect[j][k]);
        }
 
-    fpackf(tfile, "Bf Bf Bf Bf", game->mapcenter.x, game->mapcenter.y, game->mapcenter.z, game->mapradius);
+    fpackf(tfile, "Bf Bf Bf Bf", mapcenter.x, mapcenter.y, mapcenter.z, mapradius);
 
     fclose(tfile);
 }
 
-static void ch_cellar(Game *game, const char *args)
+static void ch_cellar(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
+  LoadTextureSave(":Data:Textures:Furdarko.jpg",&player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_tint(Game *game, const char *args)
+static void ch_tint(const char *args)
 {
   sscanf(args, "%f%f%f", &tintr, &tintg, &tintb);
 }
 
-static void ch_tintr(Game *game, const char *args)
+static void ch_tintr(const char *args)
 {
   tintr = atof(args);
 }
 
-static void ch_tintg(Game *game, const char *args)
+static void ch_tintg(const char *args)
 {
   tintg = atof(args);
 }
 
-static void ch_tintb(Game *game, const char *args)
+static void ch_tintb(const char *args)
 {
   tintb = atof(args);
 }
 
-static void ch_speed(Game *game, const char *args)
+static void ch_speed(const char *args)
 {
   player[0].speedmult = atof(args);
 }
 
-static void ch_strength(Game *game, const char *args)
+static void ch_strength(const char *args)
 {
   player[0].power = atof(args);
 }
 
-static void ch_power(Game *game, const char *args)
+static void ch_power(const char *args)
 {
   player[0].power = atof(args);
 }
 
-static void ch_size(Game *game, const char *args)
+static void ch_size(const char *args)
 {
   player[0].scale = atof(args) * .2;
 }
@@ -496,7 +499,7 @@ static int find_closest()
   return closest;
 }
 
-static void ch_sizenear(Game *game, const char *args)
+static void ch_sizenear(const char *args)
 {
   int closest = find_closest();
 
@@ -524,12 +527,12 @@ static void set_proportion(int pnum, const char *args)
   }
 }
 
-static void ch_proportion(Game *game, const char *args)
+static void ch_proportion(const char *args)
 {
   set_proportion(0, args);
 }
 
-static void ch_proportionnear(Game *game, const char *args)
+static void ch_proportionnear(const char *args)
 {
   int closest = find_closest();
   if (closest)
@@ -546,12 +549,12 @@ static void set_protection(int pnum, const char *args)
   player[pnum].protectionlow  = low;
 }
 
-static void ch_protection(Game *game, const char *args)
+static void ch_protection(const char *args)
 {
   set_protection(0, args);
 }
 
-static void ch_protectionnear(Game *game, const char *args)
+static void ch_protectionnear(const char *args)
 {
   int closest = find_closest();
   if (closest)
@@ -568,19 +571,19 @@ static void set_armor(int pnum, const char *args)
   player[pnum].armorlow  = low;
 }
 
-static void ch_armor(Game *game, const char *args)
+static void ch_armor(const char *args)
 {
   set_armor(0, args);
 }
 
-static void ch_armornear(Game *game, const char *args)
+static void ch_armornear(const char *args)
 {
   int closest = find_closest();
   if (closest)
     set_armor(closest, args);
 }
 
-static void ch_protectionreset(Game *game, const char *args)
+static void ch_protectionreset(const char *args)
 {
   set_protection(0, "1 1 1");
   set_armor(0, "1 1 1");
@@ -596,38 +599,38 @@ static void set_metal(int pnum, const char *args)
   player[pnum].metallow  = low;
 }
 
-static void ch_metal(Game *game, const char *args)
+static void ch_metal(const char *args)
 {
   set_metal(0, args);
 }
 
-static void set_noclothes(int pnum, Game *game, const char *args)
+static void set_noclothes(int pnum, const char *args)
 {
   player[pnum].numclothes = 0;
-  game->LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin],
+  LoadTextureSave(creatureskin[player[pnum].creature][player[pnum].whichskin],
                        &player[pnum].skeleton.drawmodel.textureptr,1,
                        &player[pnum].skeleton.skinText[0],&player[pnum].skeleton.skinsize);
 }
 
-static void ch_noclothes(Game *game, const char *args)
+static void ch_noclothes(const char *args)
 {
-  set_noclothes(0, game, args);
+  set_noclothes(0, args);
 }
 
-static void ch_noclothesnear(Game *game, const char *args)
+static void ch_noclothesnear(const char *args)
 {
   int closest = find_closest();
   if (closest)
-    set_noclothes(closest, game, args);
+    set_noclothes(closest, args);
 }
 
 
-static void set_clothes(int pnum, Game *game, const char *args)
+static void set_clothes(int pnum, const char *args)
 {
   char buf[64];
   snprintf(buf, 63, ":Data:Textures:%s.png", args);
 
-  if (!game->AddClothes(buf,&player[pnum].skeleton.skinText[pnum]))
+  if (!AddClothes(buf,&player[pnum].skeleton.skinText[pnum]))
     return;
 
   player[pnum].DoMipmaps();
@@ -638,25 +641,25 @@ static void set_clothes(int pnum, Game *game, const char *args)
   player[pnum].numclothes++;
 }
 
-static void ch_clothes(Game *game, const char *args)
+static void ch_clothes(const char *args)
 {
-  set_clothes(0, game, args);
+  set_clothes(0, args);
 }
 
-static void ch_clothesnear(Game *game, const char *args)
+static void ch_clothesnear(const char *args)
 {
   int closest = find_closest();
   if (closest)
-    set_clothes(closest, game, args);
+    set_clothes(closest, args);
 }
 
-static void ch_belt(Game *game, const char *args)
+static void ch_belt(const char *args)
 {
   player[0].skeleton.clothes = !player[0].skeleton.clothes;
 }
 
 
-static void ch_cellophane(Game *game, const char *args)
+static void ch_cellophane(const char *args)
 {
   cellophane = !cellophane;
   float mul = cellophane ? 0 : 1;
@@ -669,7 +672,7 @@ static void ch_cellophane(Game *game, const char *args)
   }
 }
 
-static void ch_funnybunny(Game *game, const char *args)
+static void ch_funnybunny(const char *args)
 {
   player[0].skeleton.id=0;
   player[0].skeleton.Load(":Data:Skeleton:Basic Figure",":Data:Skeleton:Basic Figurelow",
@@ -678,7 +681,7 @@ static void ch_funnybunny(Game *game, const char *args)
                          ":Data:Models:Body4.solid",":Data:Models:Body5.solid",
                          ":Data:Models:Body6.solid",":Data:Models:Body7.solid",
                          ":Data:Models:Bodylow.solid",":Data:Models:Belt.solid",1);
-  game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
   player[0].creature=rabbittype;
   player[0].scale=.2;
@@ -687,7 +690,7 @@ static void ch_funnybunny(Game *game, const char *args)
   set_proportion(0, "1 1 1 1");
 }
 
-static void ch_wolfie(Game *game, const char *args)
+static void ch_wolfie(const char *args)
 {
   player[0].skeleton.id=0;
   player[0].skeleton.Load(":Data:Skeleton:Basic Figure Wolf",":Data:Skeleton:Basic Figure Wolf Low",
@@ -696,80 +699,80 @@ static void ch_wolfie(Game *game, const char *args)
                          ":Data:Models:Wolf4.solid",":Data:Models:Wolf5.solid",
                          ":Data:Models:Wolf6.solid",":Data:Models:Wolf7.solid",
                          ":Data:Models:Wolflow.solid",":Data:Models:Belt.solid",0);
-  game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
   player[0].creature=wolftype;
   player[0].damagetolerance=300;
   set_proportion(0, "1 1 1 1");
 }
 
-static void ch_wolfieisgod(Game *game, const char *args)
+static void ch_wolfieisgod(const char *args)
 {
-  ch_wolfie(game, args);
+  ch_wolfie(args);
 }
 
-static void ch_wolf(Game *game, const char *args)
+static void ch_wolf(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:Wolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_snowwolf(Game *game, const char *args)
+static void ch_snowwolf(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:SnowWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_darkwolf(Game *game, const char *args)
+static void ch_darkwolf(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:DarkWolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_lizardwolf(Game *game, const char *args)
+static void ch_lizardwolf(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:Lizardwolf.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_white(Game *game, const char *args)
+static void ch_white(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:fur.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_brown(Game *game, const char *args)
+static void ch_brown(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:fur3.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_black(Game *game, const char *args)
+static void ch_black(const char *args)
 {
-  game->LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,
+  LoadTextureSave(":Data:Textures:fur2.jpg",&player[0].skeleton.drawmodel.textureptr,1,
                        &player[0].skeleton.skinText[0],&player[0].skeleton.skinsize);
 }
 
-static void ch_sizemin(Game *game, const char *args)
+static void ch_sizemin(const char *args)
 {
   for (int i = 1; i < numplayers; i++)
     if (player[i].scale < 0.8 * 0.2)
       player[i].scale = 0.8 * 0.2;
 }
 
-static void ch_tutorial(Game *game, const char *args)
+static void ch_tutorial(const char *args)
 {
   tutoriallevel = atoi(args);
 }
 
-static void ch_hostile(Game *game, const char *args)
+static void ch_hostile(const char *args)
 {
   hostile = atoi(args);
 }
 
-static void ch_indemo(Game *game, const char *args)
+static void ch_indemo(const char *args)
 {
-  game->indemo=1;
+  indemo=1;
   hotspot[numhotspots]=player[0].coords;
   hotspotsize[numhotspots]=0;
   hotspottype[numhotspots]=-111;
@@ -777,13 +780,13 @@ static void ch_indemo(Game *game, const char *args)
   numhotspots++;
 }
 
-static void ch_notindemo(Game *game, const char *args)
+static void ch_notindemo(const char *args)
 {
-  game->indemo=0;
+  indemo=0;
   numhotspots--;
 }
 
-static void ch_type(Game *game, const char *args)
+static void ch_type(const char *args)
 {
   int n = sizeof(editortypenames) / sizeof(editortypenames[0]);
        for (int i = 0; i < n; i++)
@@ -793,7 +796,7 @@ static void ch_type(Game *game, const char *args)
                }
 }
 
-static void ch_path(Game *game, const char *args)
+static void ch_path(const char *args)
 {
   int n = sizeof(pathtypenames) / sizeof(pathtypenames[0]);
   for (int i = 0; i < n; i++)
@@ -803,7 +806,7 @@ static void ch_path(Game *game, const char *args)
     }
 }
 
-static void ch_hs(Game *game, const char *args)
+static void ch_hs(const char *args)
 {
   hotspot[numhotspots]=player[0].coords;
 
@@ -820,7 +823,7 @@ static void ch_hs(Game *game, const char *args)
   numhotspots++;
 }
 
-static void ch_dialogue(Game *game, const char *args)
+static void ch_dialogue(const char *args)
 {
   int dlg;
   char buf1[32], buf2[64];
@@ -871,7 +874,7 @@ static void ch_dialogue(Game *game, const char *args)
   numdialogues++;
 }
 
-static void ch_fixdialogue(Game *game, const char *args)
+static void ch_fixdialogue(const char *args)
 {
   char buf1[32], buf2[64];
   int whichdi;
@@ -909,47 +912,47 @@ static void ch_fixdialogue(Game *game, const char *args)
   ipstream.close();
 }
 
-static void ch_fixtype(Game *game, const char *args)
+static void ch_fixtype(const char *args)
 {
   int dlg;
   sscanf(args, "%d", &dlg);
   dialoguetype[0] = dlg;
 }
 
-static void ch_fixrotation(Game *game, const char *args)
+static void ch_fixrotation(const char *args)
 {
   participantrotation[whichdialogue][participantfocus[whichdialogue][indialogue]]=player[participantfocus[whichdialogue][indialogue]].rotation;
 }
 
-static void ch_ddialogue(Game *game, const char *args)
+static void ch_ddialogue(const char *args)
 {
   if (numdialogues)
     numdialogues--;
 }
 
-static void ch_dhs(Game *game, const char *args)
+static void ch_dhs(const char *args)
 {
   if (numhotspots)
     numhotspots--;
 }
 
-static void ch_immobile(Game *game, const char *args)
+static void ch_immobile(const char *args)
 {
   player[0].immobile = 1;
 }
 
-static void ch_allimmobile(Game *game, const char *args)
+static void ch_allimmobile(const char *args)
 {
   for (int i = 1; i < numplayers; i++)
     player[i].immobile = 1;
 }
 
-static void ch_mobile(Game *game, const char *args)
+static void ch_mobile(const char *args)
 {
   player[0].immobile = 0;
 }
 
-static void ch_default(Game *game, const char *args)
+static void ch_default(const char *args)
 {
   player[0].armorhead=1;
   player[0].armorhigh=1;
@@ -978,7 +981,7 @@ static void ch_default(Game *game, const char *args)
   }
 
   player[0].numclothes=0;
-  game->LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
+  LoadTextureSave(creatureskin[player[0].creature][player[0].whichskin],
                        &player[0].skeleton.drawmodel.textureptr,1,&player[0].skeleton.skinText[0],
                        &player[0].skeleton.skinsize);
 
@@ -986,7 +989,7 @@ static void ch_default(Game *game, const char *args)
   player[0].immobile=0;
 }
 
-static void ch_play(Game *game, const char *args)
+static void ch_play(const char *args)
 {
   int dlg;
   sscanf(args, "%d", &dlg);
@@ -1010,49 +1013,49 @@ static void ch_play(Game *game, const char *args)
   playdialogueboxsound();
 }
 
-static void ch_mapkilleveryone(Game *game, const char *args)
+static void ch_mapkilleveryone(const char *args)
 {
   maptype = mapkilleveryone;
 }
 
-static void ch_mapkillmost(Game *game, const char *args)
+static void ch_mapkillmost(const char *args)
 {
   maptype = mapkillmost;
 }
 
-static void ch_mapkillsomeone(Game *game, const char *args)
+static void ch_mapkillsomeone(const char *args)
 {
   maptype = mapkillsomeone;
 }
 
-static void ch_mapgosomewhere(Game *game, const char *args)
+static void ch_mapgosomewhere(const char *args)
 {
   maptype = mapgosomewhere;
 }
 
-static void ch_viewdistance(Game *game, const char *args)
+static void ch_viewdistance(const char *args)
 {
   viewdistance = atof(args)*100;
 }
 
-static void ch_fadestart(Game *game, const char *args)
+static void ch_fadestart(const char *args)
 {
   fadestart = atof(args);
 }
 
-static void ch_slomo(Game *game, const char *args)
+static void ch_slomo(const char *args)
 {
   slomospeed = atof(args);
   slomo = !slomo;
   slomodelay = 1000;
 }
 
-static void ch_slofreq(Game *game, const char *args)
+static void ch_slofreq(const char *args)
 {
   slomofreq = atof(args);
 }
 
-static void ch_skytint(Game *game, const char *args)
+static void ch_skytint(const char *args)
 {
   sscanf(args, "%f%f%f", &skyboxr, &skyboxg, &skyboxb);
 
@@ -1060,33 +1063,33 @@ static void ch_skytint(Game *game, const char *args)
   skyboxlightg=skyboxg;
   skyboxlightb=skyboxb;
 
-  game->SetUpLighting();
+  SetUpLighting();
 
   terrain.DoShadows();
   objects.DoShadows();
 }
 
-static void ch_skylight(Game *game, const char *args)
+static void ch_skylight(const char *args)
 {
   sscanf(args, "%f%f%f", &skyboxlightr, &skyboxlightg, &skyboxlightb);
 
-  game->SetUpLighting();
+  SetUpLighting();
 
   terrain.DoShadows();
   objects.DoShadows();
 }
 
-static void ch_skybox(Game *game, const char *args)
+static void ch_skybox(const char *args)
 {
   skyboxtexture = !skyboxtexture;
 
-  game->SetUpLighting();
+  SetUpLighting();
 
   terrain.DoShadows();
   objects.DoShadows();
 }
 
-static void cmd_dispatch(Game *game, const string cmd)
+static void cmd_dispatch(const string cmd)
 {
   int i, n_cmds = sizeof(cmd_names) / sizeof(cmd_names[0]);
 
@@ -1094,7 +1097,7 @@ static void cmd_dispatch(Game *game, const string cmd)
     if (cmd.substr(0,cmd.find(' '))==string(cmd_names[i]))
       {
                  cout << "|" << cmd.substr(cmd.find(' ')+1) << "|" << endl;
-               cmd_handlers[i](game, cmd.substr(cmd.find(' ')+1).c_str());
+               cmd_handlers[i](cmd.substr(cmd.find(' ')+1).c_str());
                break;
       }
   emit_sound_np(i < n_cmds ? consolesuccesssound : consolefailsound);
@@ -5392,6 +5395,64 @@ void Game::doAI(int i){
     }
 }
 
+
+
+void updateSettingsMenu(){
+    char sbuf[256];
+    if((float)newscreenwidth>(float)newscreenheight*1.61||(float)newscreenwidth<(float)newscreenheight*1.59)
+        sprintf (sbuf, "Resolution: %d*%d",(int)newscreenwidth,(int)newscreenheight);
+    else
+        sprintf (sbuf, "Resolution: %d*%d (widescreen)",(int)newscreenwidth,(int)newscreenheight);
+    Menu::setText(0,sbuf);
+    if(newdetail==0) Menu::setText(1,"Detail: Low");
+    if(newdetail==1) Menu::setText(1,"Detail: Medium");
+    if(newdetail==2) Menu::setText(1,"Detail: High");
+    if(bloodtoggle==0) Menu::setText(2,"Blood: Off");
+    if(bloodtoggle==1) Menu::setText(2,"Blood: On, low detail");
+    if(bloodtoggle==2) Menu::setText(2,"Blood: On, high detail (slower)");
+    if(difficulty==0) Menu::setText(3,"Difficulty: Easier");
+    if(difficulty==1) Menu::setText(3,"Difficulty: Difficult");
+    if(difficulty==2) Menu::setText(3,"Difficulty: Insane");
+    Menu::setText(4,ismotionblur?"Blur Effects: Enabled (less compatible)":"Blur Effects: Disabled (more compatible)");
+    Menu::setText(5,decals?"Decals: Enabled (slower)":"Decals: Disabled");
+    Menu::setText(6,musictoggle?"Music: Enabled":"Music: Disabled");
+    Menu::setText(9,invertmouse?"Invert mouse: Yes":"Invert mouse: No");
+    sprintf (sbuf, "Mouse Speed: %d", (int)(usermousesensitivity*5));
+    Menu::setText(10,sbuf);
+    sprintf (sbuf, "Volume: %d%%", (int)(volume*100));
+    Menu::setText(11,sbuf);
+    Menu::setText(13,showdamagebar?"Damage Bar: On":"Damage Bar: Off");
+    if(newdetail==detail&&newscreenheight==(int)screenheight&&newscreenwidth==(int)screenwidth)
+        sprintf (sbuf, "Back");
+    else
+        sprintf (sbuf, "Back (some changes take effect next time Lugaru is opened)");
+    Menu::setText(8,sbuf);
+}
+
+void updateStereoConfigMenu(){
+    char sbuf[256];
+    sprintf(sbuf, "Stereo mode: %s", StereoModeName(newstereomode));
+    Menu::setText(0,sbuf);
+    sprintf(sbuf, "Stereo separation: %.3f", stereoseparation);
+    Menu::setText(1,sbuf);
+    sprintf(sbuf, "Reverse stereo: %s", stereoreverse ? "Yes" : "No");
+    Menu::setText(2,sbuf);
+}
+
+void updateControlsMenu(){
+    Menu::setText(0,(string)"Forwards: "+(keyselect==0?"_":Input::keyToChar(forwardkey)));
+    Menu::setText(1,(string)"Back: "    +(keyselect==1?"_":Input::keyToChar(backkey)));
+    Menu::setText(2,(string)"Left: "    +(keyselect==2?"_":Input::keyToChar(leftkey)));
+    Menu::setText(3,(string)"Right: "   +(keyselect==3?"_":Input::keyToChar(rightkey)));
+    Menu::setText(4,(string)"Crouch: "  +(keyselect==4?"_":Input::keyToChar(crouchkey)));
+    Menu::setText(5,(string)"Jump: "    +(keyselect==5?"_":Input::keyToChar(jumpkey)));
+    Menu::setText(6,(string)"Draw: "    +(keyselect==6?"_":Input::keyToChar(drawkey)));
+    Menu::setText(7,(string)"Throw: "   +(keyselect==7?"_":Input::keyToChar(throwkey)));
+    Menu::setText(8,(string)"Attack: "  +(keyselect==8?"_":Input::keyToChar(attackkey)));
+    if(debugmode)
+        Menu::setText(9,(string)"Console: "+(keyselect==9?"_":Input::keyToChar(consolekey)));
+}
+
 /*
 Values of mainmenu :
 1 Main menu
@@ -5407,10 +5468,155 @@ Values of mainmenu :
 11 Same that 9 ??? => unused
 18 stereo configuration
 */
-    
+
+void Game::LoadMenu(){
+    Menu::clearMenu();
+    switch(mainmenu) {
+        case 1:
+        case 2:
+            Menu::addImage(0,Mainmenuitems[0],150,480-128,256,128);
+            Menu::addButtonImage(1,Mainmenuitems[mainmenu==1?1:5],18,480-152-32,128,32);
+            Menu::addButtonImage(2,Mainmenuitems[2],18,480-228-32,112,32);
+            Menu::addButtonImage(3,Mainmenuitems[mainmenu==1?3:6],18,480-306-32,mainmenu==1?68:132,32);
+        break;
+        case 3:
+            Menu::addButton( 0,"",10+20,440);
+            Menu::addButton( 1,"",10+60,405);
+            Menu::addButton( 2,"",10+70,370);
+            Menu::addButton( 3,"",10+20-1000,335-1000);
+            Menu::addButton( 4,"",10   ,335);
+            Menu::addButton( 5,"",10+60,300);
+            Menu::addButton( 6,"",10+70,265);
+            Menu::addButton( 9,"",10   ,230);
+            Menu::addButton(10,"",20   ,195);
+            Menu::addButton(11,"",10+60,160);
+            Menu::addButton(13,"",30   ,125);
+            Menu::addButton( 7,"-Configure Controls-",10+15, 90);
+            Menu::addButton(12,"-Configure Stereo -",10+15, 55);
+            Menu::addButton(8,"Back",10,10);
+            updateSettingsMenu();
+        break;
+        case 4:
+            Menu::addButton(0,"",10   ,400);
+            Menu::addButton(1,"",10+40,360);
+            Menu::addButton(2,"",10+40,320);
+            Menu::addButton(3,"",10+30,280);
+            Menu::addButton(4,"",10+20,240);
+            Menu::addButton(5,"",10+40,200);
+            Menu::addButton(6,"",10+40,160);
+            Menu::addButton(7,"",10+30,120);
+            Menu::addButton(8,"",10+20,80);
+            if(debugmode)
+                Menu::addButton(9,"",10+10,40);
+            Menu::addButton(debugmode?10:9,"Back",10,10);
+            updateControlsMenu();
+        break;
+        case 5: {
+            LoadCampaign();
+            Menu::addLabel(-1,accountactive->getName(),5,400);
+            Menu::addButton(1,"Tutorial",5,300);
+            Menu::addButton(2,"Challenge",5,240);
+            Menu::addButton(3,"Delete User",400,10);
+            Menu::addButton(4,"Main Menu",5,10);
+            Menu::addButton(5,"Change User",5,180);
+            Menu::addButton(6,"Campaign : "+accountactive->getCurrentCampaign(),200,420);
+
+            //show campaign map
+            //with (2,-5) offset from old code
+            Menu::addImage(-1,Mainmenuitems[7],150+2,60-5,400,400);
+            //show levels
+            int numlevels = accountactive->getCampaignChoicesMade();
+            numlevels += numlevels>0 ? campaignlevels[numlevels-1].nextlevel.size() : 1;
+            for(int i=0;i<numlevels;i++){
+                XYZ midpoint=campaignlevels[i].getCenter();
+                float itemsize=campaignlevels[i].getWidth();
+                const bool active=i>=accountactive->getCampaignChoicesMade();
+                if(!active)
+                    itemsize/=2;
+
+                if(i>=1){
+                    XYZ start=campaignlevels[i-1].getCenter();
+                    Menu::addMapLine(start.x,start.y,midpoint.x-start.x,midpoint.y-start.y,0.5,active?1:0.5,active?1:0.5,0,0);
+                }
+                Menu::addMapMarker(NB_CAMPAIGN_MENU_ITEM+i, Mapcircletexture,
+                        midpoint.x-itemsize/2, midpoint.y-itemsize/2, itemsize, itemsize, active?1:0.5, 0, 0);
+
+                if(active){
+                    Menu::addMapLabel(-2,campaignlevels[i].description,
+                            campaignlevels[i].getStartX()+10,
+                            campaignlevels[i].getStartY()-4);
+                }
+            }
+        } break;
+        case 6:
+            Menu::addLabel(-1,"Are you sure you want to delete this user?",10,400);
+            Menu::addButton(1,"Yes",10,360);
+            Menu::addButton(2,"No",10,320);
+            break;
+        case 7:
+            if(Account::getNbAccounts()<8)
+                Menu::addButton(0,"New User",10,400);
+            else
+                Menu::addLabel(0,"No More Users",10,400);
+            Menu::addLabel(-2,"",20,400);
+            Menu::addButton(Account::getNbAccounts()+1,"Back",10,10);
+            for(int i=0;i<Account::getNbAccounts();i++)
+                Menu::addButton(i+1,Account::get(i)->getName(),10,340-20*(i+1));
+            break;
+        case 8:
+            Menu::addButton(0,"Easier",10,400);
+            Menu::addButton(1,"Difficult",10,360);
+            Menu::addButton(2,"Insane",10,320);
+            break;
+        case 9:
+            for(int i=0;i<numchallengelevels;i++){
+                char temp[255];
+                string name="";
+                sprintf (temp, "Level %d",i+1);
+                for(int j=strlen(temp);j<17;j++)
+                        strcat(temp," ");
+                name+=temp;
+                sprintf (temp, "%d",(int)accountactive->getHighScore(i));
+                for(int j=strlen(temp);j<(32-17);j++)
+                        strcat(temp," ");
+                name+=temp;
+                sprintf (temp, "%d:",(int)(((int)accountactive->getFastTime(i)-(int)(accountactive->getFastTime(i))%60)/60));
+                if((int)(accountactive->getFastTime(i))%60<10)strcat(temp,"0");
+                name+=temp;
+                sprintf (temp, "%d",(int)(accountactive->getFastTime(i))%60);
+                name+=temp;
+
+                Menu::addButton(i,name,10,400-i*25,i>accountactive->getProgress()?0.5:1,0,0);
+            }
+
+            Menu::addButton(-1,"             High Score      Best Time",10,440);
+            Menu::addButton(numchallengelevels,"Back",10,10);
+            break;
+        case 10: {
+            Menu::addLabel(0,"Congratulations!",220,330);
+            Menu::addLabel(1,"You have avenged your family and",140,300);
+            Menu::addLabel(2,"restored peace to the island of Lugaru.",110,270);
+            Menu::addButton(3,"Back",10,10);
+            char sbuf[256];
+            sprintf(sbuf,"Your score:         %d",(int)accountactive->getCampaignScore());
+            Menu::addLabel(4,sbuf,190,200);
+            sprintf(sbuf,"Highest score:      %d",(int)accountactive->getCampaignHighScore());
+            Menu::addLabel(5,sbuf,190,180);
+        } break;
+        case 18:
+            Menu::addButton(0,"",70,400);
+            Menu::addButton(1,"",10,360);
+            Menu::addButton(2,"",40,320);
+            Menu::addButton(3,"Back",10,10);
+            updateStereoConfigMenu();
+        break;
+    }
+}
+
 void Game::MenuTick(){
     //menu buttons
-    
+    selected=Menu::getSelected(mousecoordh*640/screenwidth,480-mousecoordv*480/screenheight);
+
     // some specific case where we do something even if the left mouse button is not pressed.
        if((mainmenu==5) && (endgame==2)) {
                accountactive->endGame();
@@ -5418,9 +5624,15 @@ void Game::MenuTick(){
        }
        if(mainmenu==10)
                endgame=2;
-       if( (mainmenu==18) && Input::isKeyPressed(MOUSEBUTTON2) && (selected==1) )
+       if(mainmenu==18 && Input::isKeyPressed(MOUSEBUTTON2) && selected==1){
                stereoseparation-=0.001;
-               
+        updateStereoConfigMenu();
+    }
+
+    static int oldmainmenu=mainmenu;
+
+    char sbuf[256];
+
     if(Input::MouseClicked() && (selected >= 0)) { // handling of the left mouse clic in menus
                switch(mainmenu) {
                        case 1:
@@ -5520,7 +5732,6 @@ void Game::MenuTick(){
                                                break;
                                        case 6:
                                                musictoggle = !musictoggle;
-
                                                if(musictoggle) {
                                                  emit_stream_np(stream_menutheme);
                                                } else {
@@ -5533,7 +5744,6 @@ void Game::MenuTick(){
                                                                musicvolume[i]=0;
                                                        }
                                                }
-
                                                break;
                                        case 7: // controls
                                                flash();
@@ -5543,8 +5753,7 @@ void Game::MenuTick(){
                                                break;
                                        case 8:
                                                flash();
-                                               
-                                               SaveSettings(*this);
+                                               SaveSettings();
                                                mainmenu=gameon?2:1;
                                                break;
                                        case 9:
@@ -5552,16 +5761,17 @@ void Game::MenuTick(){
                                                break;
                                        case 10:
                                                usermousesensitivity+=.2;
-                                               if(usermousesensitivity>2) usermousesensitivity=.2;
+                                               if(usermousesensitivity>2)
+                            usermousesensitivity=.2;
                                                break;
                                        case 11:
                                                volume+=.1f;
-                                               if(volume>1.0001f) volume=0;
+                                               if(volume>1.0001f)
+                            volume=0;
                                                OPENAL_SetSFXMasterVolume((int)(volume*255));
                                                break;
                                        case 12:
                                                flash();
-                                               
                                                newstereomode = stereomode;
                                                mainmenu=18;
                                                keyselect=-1;
@@ -5570,20 +5780,21 @@ void Game::MenuTick(){
                                                showdamagebar = !showdamagebar;
                                                break;
                                }
+                updateSettingsMenu();
                                break;
                        case 4:
                                if(!waiting) {
                                        fireSound();
-                                       if(selected<nummenuitems-1 && keyselect==-1)
+                                       if(selected<(debugmode?10:9) && keyselect==-1)
                                                keyselect=selected;
                                        if(keyselect!=-1)
                                                setKeySelected();
-                                       if(selected==nummenuitems-1){
+                                       if(selected==(debugmode?10:9)){
                                                flash();
-
                                                mainmenu=3;
                                        }
                                }
+                updateControlsMenu();
                                break;
                        case 5:
                                fireSound();
@@ -5649,7 +5860,7 @@ void Game::MenuTick(){
                                                                c=campaigns.begin();
                                                        accountactive->setCurrentCampaign(*c);
                                                }
-                                               LoadCampaign();
+                                               LoadMenu();
                                                break;
                                }
                                break;
@@ -5674,7 +5885,10 @@ void Game::MenuTick(){
                                        accountactive=Account::get(selected-1);
                                } else if (selected == Account::getNbAccounts()+1) {
                                        flash();
-                                       mainmenu=5;
+                    if(accountactive)
+                        mainmenu=5;
+                    else
+                        mainmenu=1;
                                        for(int j=0;j<255;j++){
                                                displaytext[0][j]=0;
                                        }
@@ -5747,6 +5961,7 @@ void Game::MenuTick(){
                                                InitStereo(stereomode);
                                        }
                                }
+                updateStereoConfigMenu();
                                break;
                }
        }
@@ -5754,13 +5969,13 @@ void Game::MenuTick(){
     if(Input::isKeyDown(SDLK_q) && Input::isKeyDown(SDLK_LMETA)){
         tryquit=1;
         if(mainmenu==3) {
-            SaveSettings(*this);
+            SaveSettings();
         }
     }
 
     OPENAL_SetFrequency(channels[stream_menutheme], 22050);
 
-    if(entername) {
+    if(entername){
         inputText(displaytext[0],&displayselected,&displaychars[0]);
         if(!waiting) { // the input as finished
             if(displaychars[0]){ // with enter
@@ -5788,6 +6003,16 @@ void Game::MenuTick(){
             displayblink=1-displayblink;
         }
     }
+
+    if(entername){
+        Menu::setText(0,displaytext[0],20,400,-1,-1);
+        Menu::setText(-2,displayblink?"_":"",20+displayselected*10,400,-1,-1);
+    }
+
+    if(oldmainmenu!=mainmenu)
+        LoadMenu();
+       oldmainmenu=mainmenu;
+
 }
 
 void Game::Tick(){
@@ -5868,7 +6093,7 @@ void Game::Tick(){
                 emit_stream_np(stream_menutheme);
                 pause_sound(leveltheme);
             }
-                       LoadCampaign();
+                       LoadMenu();
         }
         //escape key pressed
         //TODO: there must be code somewhere else that handles clicking the Back button, merge it with this
@@ -5893,7 +6118,7 @@ void Game::Tick(){
             }
             //finished with settings menu
                        if(mainmenu==3){
-                               SaveSettings(*this);
+                               SaveSettings();
                        }
             //effects
                        if(mainmenu>=3&&mainmenu!=8){
@@ -5971,7 +6196,7 @@ void Game::Tick(){
                                archiveselected=0;
                                if(consolechars[0]>0) {
                     consoletext[0][consolechars[0]]='\0';
-                    cmd_dispatch(this, consoletext[0]);
+                    cmd_dispatch(consoletext[0]);
                                        for(int k=14;k>=1;k--) {
                                                for(int j=0;j<255;j++)
                                                        consoletext[k][j]=consoletext[k-1][j];
@@ -5996,7 +6221,7 @@ void Game::Tick(){
                if(Input::isKeyDown(SDLK_q)&&Input::isKeyDown(SDLK_LMETA)){
                        tryquit=1;
                        if(mainmenu==3) {
-                               SaveSettings(*this);
+                               SaveSettings();
                        }
                }