diff options
Diffstat (limited to 'scene.cpp')
-rw-r--r-- | scene.cpp | 60 |
1 files changed, 53 insertions, 7 deletions
@@ -21,6 +21,7 @@ Scene::Scene() { do_select = false; show_selection = false; + dialog = false; /* setup shader programs */ GLVertexShader terrain_vertex("shaders/terrain_vertex.glsl"); @@ -58,12 +59,15 @@ Scene::Scene() { /* load font */ font = new FTTextureFont("fonts/VeraMono.ttf"); font->FaceSize(10); + + gui = new GUI(); } Scene::~Scene() { if(qt) delete qt; delete font; + delete gui; } void Scene::lookat() { @@ -161,29 +165,62 @@ void Scene::events() { case SDLK_u: update(); break; + case SDLK_TAB: + dialog = !dialog; default: break; } break; + case SDL_MOUSEBUTTONDOWN: + switch(event.button.button) { + case SDL_BUTTON_LEFT: + if(dialog) + CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::LeftButton); + break; + case SDL_BUTTON_RIGHT: + if(dialog) + CEGUI::System::getSingleton().injectMouseButtonDown(CEGUI::RightButton); + break; + } + break; case SDL_MOUSEBUTTONUP: switch(event.button.button) { case SDL_BUTTON_LEFT: - sx = event.button.x; - sy = event.button.y; - do_select = true; - // TODO: reimplement selection + if(dialog) + CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::LeftButton); + else { + sx = event.button.x; + sy = event.button.y; + do_select = true; + } break; case SDL_BUTTON_RIGHT: - show_selection = false; + if(dialog) + CEGUI::System::getSingleton().injectMouseButtonUp(CEGUI::RightButton); + else + show_selection = false; break; case SDL_BUTTON_WHEELUP: - qt->raise(selected.x, selected.z, 10, 1, 1); + if(dialog) + CEGUI::System::getSingleton().injectMouseWheelChange(1); + else + qt->raise(selected.x, selected.z, gui->radius_sb->getScrollPosition(), gui->focus_sb->getScrollPosition(), + gui->strength_sb->getScrollPosition()); break; case SDL_BUTTON_WHEELDOWN: - qt->raise(selected.x, selected.z, 10, 1, -1); + if(dialog) + CEGUI::System::getSingleton().injectMouseWheelChange(-1); + else + qt->raise(selected.x, selected.z, gui->radius_sb->getScrollPosition(), gui->focus_sb->getScrollPosition(), + -gui->strength_sb->getScrollPosition()); break; } + break; case SDL_MOUSEMOTION: + if(dialog) { + CEGUI::System::getSingleton().injectMousePosition(event.motion.x, event.motion.y); + break; + } if(event.motion.x == video::width/2 && event.motion.y == video::height/2) break; yaw += (float)event.motion.xrel / 500; @@ -198,6 +235,9 @@ void Scene::events() { pitch = 0; SDL_WarpMouse(video::width/2, video::height/2); break; + case SDL_VIDEORESIZE: + CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Size(event.resize.w, event.resize.h)); + break; } } } @@ -207,6 +247,8 @@ void Scene::render() { unsigned int steps = time - last_time + 1; last_time = time; + CEGUI::System::getSingleton().injectTimePulse(0.001*(float)steps); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); video::persp(); @@ -309,6 +351,7 @@ void Scene::render() { glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } + glBindBuffer(GL_ARRAY_BUFFER, 0); glDisable(GL_TEXTURE_2D); // set active to texture0 to avoid breaking the texture font glActiveTexture(GL_TEXTURE0); @@ -375,6 +418,9 @@ void Scene::render() { font->Render(selected->str().c_str()); }*/ + if(dialog) + gui->render(); + SDL_GL_SwapBuffers(); } |