pause menu added

master
Perttu Ahola 2010-12-14 03:07:13 +02:00
parent c951ce3b7c
commit 451f46f623
2 changed files with 19 additions and 11 deletions

View File

@ -2,7 +2,7 @@
# It's usually sufficient to change just the target name and source file list # 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 # and be sure that CXX is set to a valid compiler
TARGET = test 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)) SOURCES = $(addprefix src/, $(SOURCE_FILES))
OBJECTS = $(SOURCES:.cpp=.o) OBJECTS = $(SOURCES:.cpp=.o)
FASTTARGET = fasttest FASTTARGET = fasttest

View File

@ -236,6 +236,7 @@ Doing now:
#include <fstream> #include <fstream>
#include <time.h> #include <time.h>
#include <jmutexautolock.h> #include <jmutexautolock.h>
#include <locale.h>
#include "common_irrlicht.h" #include "common_irrlicht.h"
#include "debug.h" #include "debug.h"
#include "map.h" #include "map.h"
@ -249,7 +250,7 @@ Doing now:
#include "constants.h" #include "constants.h"
#include "strfnd.h" #include "strfnd.h"
#include "porting.h" #include "porting.h"
#include <locale.h> #include "guiPauseMenu.h"
IrrlichtDevice *g_device = NULL; IrrlichtDevice *g_device = NULL;
@ -431,6 +432,7 @@ public:
if(event.KeyInput.Key == irr::KEY_ESCAPE) if(event.KeyInput.Key == irr::KEY_ESCAPE)
{ {
//TODO: Not used anymore?
if(g_game_focused == true) if(g_game_focused == true)
{ {
dstream<<DTIME<<"ESC pressed"<<std::endl; dstream<<DTIME<<"ESC pressed"<<std::endl;
@ -1260,6 +1262,9 @@ int main(int argc, char *argv[])
scene::ISceneManager* smgr = device->getSceneManager(); scene::ISceneManager* smgr = device->getSceneManager();
// Pause menu
guiPauseMenu pauseMenu(device, &receiver);
gui::IGUIEnvironment* guienv = device->getGUIEnvironment(); gui::IGUIEnvironment* guienv = device->getGUIEnvironment();
gui::IGUISkin* skin = guienv->getSkin(); gui::IGUISkin* skin = guienv->getSkin();
gui::IGUIFont* font = guienv->getFont("../data/fontlucida.png"); gui::IGUIFont* font = guienv->getFont("../data/fontlucida.png");
@ -1543,6 +1548,12 @@ int main(int argc, char *argv[])
while(device->run()) while(device->run())
{ {
/*
Random calculations
*/
v2u32 screensize = driver->getScreenSize();
core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);
// Hilight boxes collected during the loop and displayed // Hilight boxes collected during the loop and displayed
core::list< core::aabbox3d<f32> > hilightboxes; core::list< core::aabbox3d<f32> > hilightboxes;
@ -1695,10 +1706,10 @@ int main(int argc, char *argv[])
/* /*
Special keys Special keys
*/ */
if(g_esc_pressed) /*if(g_esc_pressed)
{ {
break; break;
} }*/
/* /*
Player speed control Player speed control
@ -1758,7 +1769,7 @@ int main(int argc, char *argv[])
Mouse and camera control Mouse and camera control
*/ */
if(device->isWindowActive() && g_game_focused) if(device->isWindowActive() && g_game_focused && !pauseMenu.isVisible())
{ {
device->getCursorControl()->setVisible(false); device->getCursorControl()->setVisible(false);
@ -1767,15 +1778,15 @@ int main(int argc, char *argv[])
first_loop_after_window_activation = false; first_loop_after_window_activation = false;
} }
else{ else{
s32 dx = g_input->getMousePos().X - 320; s32 dx = g_input->getMousePos().X - displaycenter.X;
s32 dy = g_input->getMousePos().Y - 240; s32 dy = g_input->getMousePos().Y - displaycenter.Y;
//std::cout<<"window active, pos difference "<<dx<<","<<dy<<std::endl; //std::cout<<"window active, pos difference "<<dx<<","<<dy<<std::endl;
camera_yaw -= dx*0.2; camera_yaw -= dx*0.2;
camera_pitch += dy*0.2; camera_pitch += dy*0.2;
if(camera_pitch < -89.5) camera_pitch = -89.5; if(camera_pitch < -89.5) camera_pitch = -89.5;
if(camera_pitch > 89.5) camera_pitch = 89.5; if(camera_pitch > 89.5) camera_pitch = 89.5;
} }
g_input->setMousePos(320, 240); g_input->setMousePos(displaycenter.X, displaycenter.Y);
} }
else{ else{
device->getCursorControl()->setVisible(true); device->getCursorControl()->setVisible(true);
@ -2076,9 +2087,6 @@ int main(int argc, char *argv[])
Calculate stuff for drawing Calculate stuff for drawing
*/ */
v2u32 screensize = driver->getScreenSize();
core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);
camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y); camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y);
/* /*