summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-10 13:03:23 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-10 13:03:23 (GMT)
commit810ea42f99cf9f56c1ac998ce8a203bea01e97b2 (patch)
treeb3c2bc39bfed051003a6eeab6e990e73ddad5dec /src
parentfd40ed234ab157c4e315cb748163969c8ff83b0f (diff)
downloadpowder-810ea42f99cf9f56c1ac998ce8a203bea01e97b2.zip
powder-810ea42f99cf9f56c1ac998ce8a203bea01e97b2.tar.gz
Only render gravity lensing if it's enabled, Ctrl and Shift to alter tool strength (Shift = x10, Ctrl = x0.1)
Diffstat (limited to 'src')
-rw-r--r--src/game/GameController.cpp9
-rw-r--r--src/game/GameModel.cpp13
-rw-r--r--src/game/GameModel.h4
-rw-r--r--src/game/GameView.cpp16
-rw-r--r--src/game/Tool.cpp12
-rw-r--r--src/game/Tool.h3
-rw-r--r--src/graphics/Renderer.cpp10
-rw-r--r--src/simulation/Simulation.cpp18
-rw-r--r--src/simulation/Simulation.h8
9 files changed, 73 insertions, 20 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
index 3d36b75..622752b 100644
--- a/src/game/GameController.cpp
+++ b/src/game/GameController.cpp
@@ -248,6 +248,7 @@ void GameController::DrawRect(int toolSelection, ui::Point point1, ui::Point poi
Brush * cBrush = gameModel->GetBrush();
if(!activeTool || !cBrush)
return;
+ activeTool->SetStrength(gameModel->GetToolStrength());
activeTool->DrawRect(sim, cBrush, PointTranslate(point1), PointTranslate(point2));
}
@@ -258,6 +259,7 @@ void GameController::DrawLine(int toolSelection, ui::Point point1, ui::Point poi
Brush * cBrush = gameModel->GetBrush();
if(!activeTool || !cBrush)
return;
+ activeTool->SetStrength(gameModel->GetToolStrength());
activeTool->DrawLine(sim, cBrush, PointTranslate(point1), PointTranslate(point2));
}
@@ -268,6 +270,7 @@ void GameController::DrawFill(int toolSelection, ui::Point point)
Brush * cBrush = gameModel->GetBrush();
if(!activeTool || !cBrush)
return;
+ activeTool->SetStrength(gameModel->GetToolStrength());
activeTool->DrawFill(sim, cBrush, PointTranslate(point));
}
@@ -288,6 +291,7 @@ void GameController::DrawPoints(int toolSelection, queue<ui::Point*> & pointQueu
}
}
+ activeTool->SetStrength(gameModel->GetToolStrength());
if(!pointQueue.empty())
{
ui::Point sPoint(0, 0);
@@ -595,6 +599,11 @@ void GameController::SetZoomEnabled(bool zoomEnabled)
gameModel->SetZoomEnabled(zoomEnabled);
}
+void GameController::SetToolStrength(float value)
+{
+ gameModel->SetToolStrength(value);
+}
+
void GameController::SetZoomPosition(ui::Point position)
{
ui::Point zoomPosition = position-(gameModel->GetZoomSize()/2);
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 91ddd53..3da3074 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -23,7 +23,8 @@ GameModel::GameModel():
clipboard(NULL),
stamp(NULL),
placeSave(NULL),
- colour(255, 0, 0, 255)
+ colour(255, 0, 0, 255),
+ toolStrength(1.0f)
{
sim = new Simulation();
ren = new Renderer(ui::Engine::Ref().g, sim);
@@ -295,6 +296,16 @@ void GameModel::AddObserver(GameView * observer){
UpdateQuickOptions();
}
+void GameModel::SetToolStrength(float value)
+{
+ toolStrength = value;
+}
+
+float GameModel::GetToolStrength()
+{
+ return toolStrength;
+}
+
void GameModel::SetActiveMenu(Menu * menu)
{
for(int i = 0; i < menuList.size(); i++)
diff --git a/src/game/GameModel.h b/src/game/GameModel.h
index e41ff2b..47a6904 100644
--- a/src/game/GameModel.h
+++ b/src/game/GameModel.h
@@ -55,6 +55,7 @@ private:
User currentUser;
bool colourSelector;
ui::Colour colour;
+ float toolStrength;
std::string infoTip;
std::string toolTip;
@@ -99,6 +100,9 @@ public:
void UpdateQuickOptions();
+ void SetToolStrength(float value);
+ float GetToolStrength();
+
void SetVote(int direction);
SaveInfo * GetSave();
Brush * GetBrush();
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 9b1010d..817887e 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -1538,6 +1538,10 @@ void GameView::enableShiftBehaviour()
if(!shiftBehaviour)
{
shiftBehaviour = true;
+ if(!ctrlBehaviour)
+ c->SetToolStrength(10.0f);
+ else
+ c->SetToolStrength(1.0f);
}
}
@@ -1546,6 +1550,10 @@ void GameView::disableShiftBehaviour()
if(shiftBehaviour)
{
shiftBehaviour = false;
+ if(!ctrlBehaviour)
+ c->SetToolStrength(1.0f);
+ else
+ c->SetToolStrength(.1f);
}
}
@@ -1576,6 +1584,10 @@ void GameView::enableCtrlBehaviour()
saveSimulationButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
searchButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
searchButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
+ if(!shiftBehaviour)
+ c->SetToolStrength(.1f);
+ else
+ c->SetToolStrength(1.0f);
}
}
@@ -1590,6 +1602,10 @@ void GameView::disableCtrlBehaviour()
saveSimulationButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
searchButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
+ if(!shiftBehaviour)
+ c->SetToolStrength(1.0f);
+ else
+ c->SetToolStrength(10.0f);
}
}
diff --git a/src/game/Tool.cpp b/src/game/Tool.cpp
index 763fc82..a93afaf 100644
--- a/src/game/Tool.cpp
+++ b/src/game/Tool.cpp
@@ -19,7 +19,8 @@ Tool::Tool(int id, string name, string description, int r, int g, int b, VideoBu
colRed(r),
colGreen(g),
colBlue(b),
- textureGen(textureGen)
+ textureGen(textureGen),
+ strength(1.0f)
{
}
VideoBuffer * Tool::GetTexture(int width, int height)
@@ -39,13 +40,13 @@ string Tool::GetDescription() { return toolDescription; }
Tool::~Tool() {}
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
void Tool::Draw(Simulation * sim, Brush * brush, ui::Point position) {
- sim->ToolBrush(position.X, position.Y, toolID, brush);
+ sim->ToolBrush(position.X, position.Y, toolID, brush, strength);
}
void Tool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) {
- sim->ToolLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush);
+ sim->ToolLine(position1.X, position1.Y, position2.X, position2.Y, toolID, brush, strength);
}
void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
- sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, brush);
+ sim->ToolBox(position1.X, position1.Y, position2.X, position2.Y, toolID, brush, strength);
}
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
@@ -82,7 +83,9 @@ void WallTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui
if(dragging == false && toolID == WL_FAN && sim->bmap[wallY][wallX]==WL_FAN)
{
float newFanVelX = (position2.X-position1.X)*0.005f;
+ newFanVelX *= strength;
float newFanVelY = (position2.Y-position1.Y)*0.005f;
+ newFanVelY *= strength;
sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, -1, WL_FAN, 0);
for (int j = 0; j < YRES/CELL; j++)
for (int i = 0; i < XRES/CELL; i++)
@@ -138,6 +141,7 @@ void WindTool::DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui
int radiusX, radiusY, sizeX, sizeY;
float strength = dragging?0.01f:0.002f;
+ strength *= this->strength;
radiusX = brush->GetRadius().X;
radiusY = brush->GetRadius().Y;
diff --git a/src/game/Tool.h b/src/game/Tool.h
index f6327cf..c4f44bb 100644
--- a/src/game/Tool.h
+++ b/src/game/Tool.h
@@ -25,10 +25,13 @@ protected:
int toolID;
string toolName;
string toolDescription;
+ float strength;
public:
Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
string GetName();
string GetDescription();
+ void SetStrength(float value) { strength = value; }
+ float GetStrength() { return strength; }
VideoBuffer * GetTexture(int width, int height);
void SetTextureGen(VideoBuffer * (*textureGen)(int, int, int));
virtual ~Tool();
diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp
index 162f79e..ea3c840 100644
--- a/src/graphics/Renderer.cpp
+++ b/src/graphics/Renderer.cpp
@@ -308,12 +308,18 @@ void Renderer::FinaliseParts()
#endif
#if defined(OGLI) && !defined(OGLR)
- render_gravlensing(warpVid);
+ if(display_mode & DISPLAY_WARP)
+ {
+ render_gravlensing(warpVid);
+ }
g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255);
#endif
#if !defined(OGLR) && !defined(OGLI)
- render_gravlensing(warpVid);
+ if(display_mode & DISPLAY_WARP)
+ {
+ render_gravlensing(warpVid);
+ }
#endif
}
diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp
index 717eb80..841984e 100644
--- a/src/simulation/Simulation.cpp
+++ b/src/simulation/Simulation.cpp
@@ -1018,7 +1018,7 @@ int Simulation::Tool(int x, int y, int tool, float strength)
return 0;
}
-int Simulation::ToolBrush(int x, int y, int tool, Brush * cBrush)
+int Simulation::ToolBrush(int x, int y, int tool, Brush * cBrush, float strength)
{
int rx, ry, j, i;
if(!cBrush)
@@ -1032,11 +1032,11 @@ int Simulation::ToolBrush(int x, int y, int tool, Brush * cBrush)
{
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
continue;
- Tool(x+i, y+j, tool, 1.0f);
+ Tool(x+i, y+j, tool, strength);
}
}
-void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush)
+void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength)
{
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy, rx, ry;
float e, de;
@@ -1072,9 +1072,9 @@ void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBru
for (x=x1; x<=x2; x++)
{
if (cp)
- ToolBrush(y, x, tool, cBrush);
+ ToolBrush(y, x, tool, cBrush, strength);
else
- ToolBrush(x, y, tool, cBrush);
+ ToolBrush(x, y, tool, cBrush, strength);
e += de;
if (e >= 0.5f)
{
@@ -1082,15 +1082,15 @@ void Simulation::ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBru
if ((!(rx+ry)) && ((y1<y2) ? (y<=y2) : (y>=y2)))
{
if (cp)
- ToolBrush(y, x, tool, cBrush);
+ ToolBrush(y, x, tool, cBrush, strength);
else
- ToolBrush(x, y, tool, cBrush);
+ ToolBrush(x, y, tool, cBrush, strength);
}
e -= 1.0f;
}
}
}
-void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrush)
+void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength)
{
int i, j;
if (x1>x2)
@@ -1107,7 +1107,7 @@ void Simulation::ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrus
}
for (j=y1; j<=y2; j++)
for (i=x1; i<=x2; i++)
- ToolBrush(i, j, tool, cBrush);
+ ToolBrush(i, j, tool, cBrush, strength);
}
int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush)
diff --git a/src/simulation/Simulation.h b/src/simulation/Simulation.h
index 9b10df2..387d3b3 100644
--- a/src/simulation/Simulation.h
+++ b/src/simulation/Simulation.h
@@ -159,10 +159,10 @@ public:
void SetEdgeMode(int newEdgeMode);
- int Tool(int x, int y, int tool, float strength);
- int ToolBrush(int x, int y, int tool, Brush * cBrush);
- void ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush);
- void ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrush);
+ int Tool(int x, int y, int tool, float strength = 1.0f);
+ int ToolBrush(int x, int y, int tool, Brush * cBrush, float strength = 1.0f);
+ void ToolLine(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength = 1.0f);
+ void ToolBox(int x1, int y1, int x2, int y2, int tool, Brush * cBrush, float strength = 1.0f);
void CreateBox(int x1, int y1, int x2, int y2, int c, int flags);
int FloodINST(int x, int y, int fullc, int cm);