From 451f46f623f7e7e957cbf9d973ec2dceb74a56dc Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 14 Dec 2010 03:07:13 +0200 Subject: [PATCH] pause menu added --- Makefile | 2 +- src/main.cpp | 28 ++++++++++++++++++---------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2bdc9c3f0..dfe180573 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ # It's usually sufficient to change just the target name and source file list # and be sure that CXX is set to a valid compiler TARGET = test -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 +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 SOURCES = $(addprefix src/, $(SOURCE_FILES)) OBJECTS = $(SOURCES:.cpp=.o) FASTTARGET = fasttest diff --git a/src/main.cpp b/src/main.cpp index 8420ca9e0..31901ae70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -236,6 +236,7 @@ Doing now: #include #include #include +#include #include "common_irrlicht.h" #include "debug.h" #include "map.h" @@ -249,7 +250,7 @@ Doing now: #include "constants.h" #include "strfnd.h" #include "porting.h" -#include +#include "guiPauseMenu.h" IrrlichtDevice *g_device = NULL; @@ -431,6 +432,7 @@ public: if(event.KeyInput.Key == irr::KEY_ESCAPE) { + //TODO: Not used anymore? if(g_game_focused == true) { dstream<setMinHardwareBufferVertexCount(1); scene::ISceneManager* smgr = device->getSceneManager(); + + // Pause menu + guiPauseMenu pauseMenu(device, &receiver); gui::IGUIEnvironment* guienv = device->getGUIEnvironment(); gui::IGUISkin* skin = guienv->getSkin(); @@ -1543,6 +1548,12 @@ int main(int argc, char *argv[]) while(device->run()) { + /* + Random calculations + */ + v2u32 screensize = driver->getScreenSize(); + core::vector2d displaycenter(screensize.X/2,screensize.Y/2); + // Hilight boxes collected during the loop and displayed core::list< core::aabbox3d > hilightboxes; @@ -1695,10 +1706,10 @@ int main(int argc, char *argv[]) /* Special keys */ - if(g_esc_pressed) + /*if(g_esc_pressed) { break; - } + }*/ /* Player speed control @@ -1758,7 +1769,7 @@ int main(int argc, char *argv[]) Mouse and camera control */ - if(device->isWindowActive() && g_game_focused) + if(device->isWindowActive() && g_game_focused && !pauseMenu.isVisible()) { device->getCursorControl()->setVisible(false); @@ -1767,15 +1778,15 @@ int main(int argc, char *argv[]) first_loop_after_window_activation = false; } else{ - s32 dx = g_input->getMousePos().X - 320; - s32 dy = g_input->getMousePos().Y - 240; + s32 dx = g_input->getMousePos().X - displaycenter.X; + s32 dy = g_input->getMousePos().Y - displaycenter.Y; //std::cout<<"window active, pos difference "< 89.5) camera_pitch = 89.5; } - g_input->setMousePos(320, 240); + g_input->setMousePos(displaycenter.X, displaycenter.Y); } else{ device->getCursorControl()->setVisible(true); @@ -2076,9 +2087,6 @@ int main(int argc, char *argv[]) Calculate stuff for drawing */ - v2u32 screensize = driver->getScreenSize(); - core::vector2d displaycenter(screensize.X/2,screensize.Y/2); - camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y); /*