Only render gravity lensing if it's enabled, Ctrl and Shift to alter tool strength (Shift = x10, Ctrl = x0.1)
This commit is contained in:
parent
fd40ed234a
commit
810ea42f99
@ -221,6 +221,7 @@ if(GetOption('win')):
|
||||
env.Command(['generated/ElementClasses.cpp', 'generated/ElementClasses.h'], Glob('src/simulation/elements/*.cpp'), "python generator.py elements $TARGETS $SOURCES")
|
||||
env.Command(['generated/ToolClasses.cpp', 'generated/ToolClasses.h'], Glob('src/simulation/tools/*.cpp'), "python generator.py tools $TARGETS $SOURCES")
|
||||
t=env.Program(target=programName, source=sources)
|
||||
Decider('MD5')
|
||||
Default(t)
|
||||
|
||||
#if(GetOption('release')):
|
||||
|
@ -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);
|
||||
|
@ -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++)
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user