From f19c7f62c77f6a3e8f5728e015166b0c625f5f67 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Thu, 16 Aug 2012 12:15:29 +0100 Subject: [PATCH] Air invert and grid mode switching --- src/game/GameController.cpp | 14 ++++++++++++++ src/game/GameController.h | 2 ++ src/game/GameView.cpp | 8 ++++++++ src/graphics/Renderer.cpp | 11 ++++++----- src/graphics/Renderer.h | 4 ++++ src/simulation/Air.cpp | 14 ++++++++++++++ src/simulation/Air.h | 1 + 7 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 9831c7816..5237af71e 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -231,6 +231,20 @@ void GameController::Install() #endif } +void GameController::AdjustGridSize(int direction) +{ + if(direction > 0) + gameModel->GetRenderer()->SetGridSize((gameModel->GetRenderer()->GetGridSize()+1)%10); + else + gameModel->GetRenderer()->SetGridSize((gameModel->GetRenderer()->GetGridSize()+9)%10); +} + +void GameController::InvertAirSim() +{ + gameModel->GetSimulation()->air->Invert(); +} + + void GameController::AdjustBrushSize(int direction, bool logarithmic, bool xAxis, bool yAxis) { if(xAxis && yAxis) diff --git a/src/game/GameController.h b/src/game/GameController.h index 72ebd375c..c6d41b515 100644 --- a/src/game/GameController.h +++ b/src/game/GameController.h @@ -69,6 +69,8 @@ public: void Install(); + void AdjustGridSize(int direction); + void InvertAirSim(); void LoadRenderPreset(RenderPreset preset); void SetZoomEnabled(bool zoomEnable); void SetZoomPosition(ui::Point position); diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 45addebf1..af13797c8 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1243,6 +1243,12 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool case 'f': c->FrameStep(); break; + case 'g': + if(shift) + c->AdjustGridSize(-1); + else + c->AdjustGridSize(1); + break; case 'd': showDebug = !showDebug; break; @@ -1345,6 +1351,8 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool case 'i': if(ctrl) c->Install(); + else + c->InvertAirSim(); break; } diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp index 746749354..292450320 100644 --- a/src/graphics/Renderer.cpp +++ b/src/graphics/Renderer.cpp @@ -1086,17 +1086,17 @@ void Renderer::render_parts() glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo); glTranslated(0, MENUSIZE, 0); #else - /*if (GRID_MODE)//draws the grid + if (gridSize)//draws the grid { for (ny=0; nyparts_lastActiveIndex; i++) { if (sim->parts[i].type) { @@ -2284,7 +2284,8 @@ Renderer::Renderer(Graphics * g, Simulation * sim): mousePosY(-1), display_mode(0), render_mode(0), - colour_mode(0) + colour_mode(0), + gridSize(0) { this->g = g; this->sim = sim; diff --git a/src/graphics/Renderer.h b/src/graphics/Renderer.h index 2f9f4044d..dc5d63351 100644 --- a/src/graphics/Renderer.h +++ b/src/graphics/Renderer.h @@ -131,12 +131,16 @@ public: void SetColourMode(unsigned int mode); unsigned int GetColourMode(); + int GetGridSize() { return gridSize; } + void SetGridSize(int value) { gridSize = value; } + static VideoBuffer * WallIcon(int wallID, int width, int height); Renderer(Graphics * g, Simulation * sim); ~Renderer(); private: + int gridSize; #ifdef OGLR GLuint zoomTex, airBuf, fireAlpha, glowAlpha, blurAlpha, partsFboTex, partsFbo, partsTFX, partsTFY, airPV, airVY, airVX; GLuint fireProg, airProg_Pressure, airProg_Velocity, airProg_Cracker, lensProg; diff --git a/src/simulation/Air.cpp b/src/simulation/Air.cpp index 6d7b5dd29..2dfcae090 100644 --- a/src/simulation/Air.cpp +++ b/src/simulation/Air.cpp @@ -1,4 +1,5 @@ #include +#include #include "Config.h" #include "Air.h" //#include @@ -295,6 +296,19 @@ void Air::update_air(void) memcpy(pv, opv, sizeof(pv)); } } + +void Air::Invert() +{ + int nx, ny; + for (nx = 0; nx