pause menu added
authorPerttu Ahola <celeron55@gmail.com>
Tue, 14 Dec 2010 01:07:13 +0000 (03:07 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Tue, 14 Dec 2010 01:07:13 +0000 (03:07 +0200)
Makefile
src/main.cpp

index 2bdc9c3f052f1515631a9aee42cc847974818f8b..dfe180573e64efcccb4011c7f2158b44b880d02c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 # It's usually sufficient to change just the target name and source file list\r
 # and be sure that CXX is set to a valid compiler\r
 TARGET = test\r
-SOURCE_FILES = mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp\r
+SOURCE_FILES = guiPauseMenu.cpp mapnode.cpp tile.cpp voxel.cpp mapblockobject.cpp inventory.cpp debug.cpp serialization.cpp light.cpp filesys.cpp connection.cpp environment.cpp client.cpp server.cpp socket.cpp mapblock.cpp mapsector.cpp heightmap.cpp map.cpp player.cpp utility.cpp main.cpp test.cpp\r
 SOURCES = $(addprefix src/, $(SOURCE_FILES))\r
 OBJECTS = $(SOURCES:.cpp=.o)\r
 FASTTARGET = fasttest\r
index 8420ca9e03ce60d25438138a7d557f2f42719061..31901ae7001758295b953c5de01649362071e282 100644 (file)
@@ -236,6 +236,7 @@ Doing now:
 #include <fstream>\r
 #include <time.h>\r
 #include <jmutexautolock.h>\r
+#include <locale.h>\r
 #include "common_irrlicht.h"\r
 #include "debug.h"\r
 #include "map.h"\r
@@ -249,7 +250,7 @@ Doing now:
 #include "constants.h"\r
 #include "strfnd.h"\r
 #include "porting.h"\r
-#include <locale.h>\r
+#include "guiPauseMenu.h"\r
 \r
 IrrlichtDevice *g_device = NULL;\r
 \r
@@ -431,6 +432,7 @@ public:
                                \r
                                if(event.KeyInput.Key == irr::KEY_ESCAPE)\r
                                {\r
+                                       //TODO: Not used anymore?\r
                                        if(g_game_focused == true)\r
                                        {\r
                                                dstream<<DTIME<<"ESC pressed"<<std::endl;\r
@@ -1259,6 +1261,9 @@ int main(int argc, char *argv[])
        //driver->setMinHardwareBufferVertexCount(1);\r
 \r
        scene::ISceneManager* smgr = device->getSceneManager();\r
+       \r
+       // Pause menu\r
+       guiPauseMenu pauseMenu(device, &receiver);\r
 \r
        gui::IGUIEnvironment* guienv = device->getGUIEnvironment();\r
        gui::IGUISkin* skin = guienv->getSkin();\r
@@ -1543,6 +1548,12 @@ int main(int argc, char *argv[])
 \r
        while(device->run())\r
        {\r
+               /*\r
+                       Random calculations\r
+               */\r
+               v2u32 screensize = driver->getScreenSize();\r
+               core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);\r
+\r
                // Hilight boxes collected during the loop and displayed\r
                core::list< core::aabbox3d<f32> > hilightboxes;\r
                \r
@@ -1695,10 +1706,10 @@ int main(int argc, char *argv[])
                /*\r
                        Special keys\r
                */\r
-               if(g_esc_pressed)\r
+               /*if(g_esc_pressed)\r
                {\r
                        break;\r
-               }\r
+               }*/\r
 \r
                /*\r
                        Player speed control\r
@@ -1758,7 +1769,7 @@ int main(int argc, char *argv[])
                        Mouse and camera control\r
                */\r
                \r
-               if(device->isWindowActive() && g_game_focused)\r
+               if(device->isWindowActive() && g_game_focused && !pauseMenu.isVisible())\r
                {\r
                        device->getCursorControl()->setVisible(false);\r
 \r
@@ -1767,15 +1778,15 @@ int main(int argc, char *argv[])
                                first_loop_after_window_activation = false;\r
                        }\r
                        else{\r
-                               s32 dx = g_input->getMousePos().X - 320;\r
-                               s32 dy = g_input->getMousePos().Y - 240;\r
+                               s32 dx = g_input->getMousePos().X - displaycenter.X;\r
+                               s32 dy = g_input->getMousePos().Y - displaycenter.Y;\r
                                //std::cout<<"window active, pos difference "<<dx<<","<<dy<<std::endl;\r
                                camera_yaw -= dx*0.2;\r
                                camera_pitch += dy*0.2;\r
                                if(camera_pitch < -89.5) camera_pitch = -89.5;\r
                                if(camera_pitch > 89.5) camera_pitch = 89.5;\r
                        }\r
-                       g_input->setMousePos(320, 240);\r
+                       g_input->setMousePos(displaycenter.X, displaycenter.Y);\r
                }\r
                else{\r
                        device->getCursorControl()->setVisible(true);\r
@@ -2076,9 +2087,6 @@ int main(int argc, char *argv[])
                        Calculate stuff for drawing\r
                */\r
 \r
-               v2u32 screensize = driver->getScreenSize();\r
-               core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);\r
-\r
                camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y);\r
 \r
                /*\r