mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-13 20:04:01 +02:00
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:
@@ -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/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")
|
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)
|
t=env.Program(target=programName, source=sources)
|
||||||
|
Decider('MD5')
|
||||||
Default(t)
|
Default(t)
|
||||||
|
|
||||||
#if(GetOption('release')):
|
#if(GetOption('release')):
|
||||||
|
@@ -248,6 +248,7 @@ void GameController::DrawRect(int toolSelection, ui::Point point1, ui::Point poi
|
|||||||
Brush * cBrush = gameModel->GetBrush();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
return;
|
return;
|
||||||
|
activeTool->SetStrength(gameModel->GetToolStrength());
|
||||||
activeTool->DrawRect(sim, cBrush, PointTranslate(point1), PointTranslate(point2));
|
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();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
return;
|
return;
|
||||||
|
activeTool->SetStrength(gameModel->GetToolStrength());
|
||||||
activeTool->DrawLine(sim, cBrush, PointTranslate(point1), PointTranslate(point2));
|
activeTool->DrawLine(sim, cBrush, PointTranslate(point1), PointTranslate(point2));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,6 +270,7 @@ void GameController::DrawFill(int toolSelection, ui::Point point)
|
|||||||
Brush * cBrush = gameModel->GetBrush();
|
Brush * cBrush = gameModel->GetBrush();
|
||||||
if(!activeTool || !cBrush)
|
if(!activeTool || !cBrush)
|
||||||
return;
|
return;
|
||||||
|
activeTool->SetStrength(gameModel->GetToolStrength());
|
||||||
activeTool->DrawFill(sim, cBrush, PointTranslate(point));
|
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())
|
if(!pointQueue.empty())
|
||||||
{
|
{
|
||||||
ui::Point sPoint(0, 0);
|
ui::Point sPoint(0, 0);
|
||||||
@@ -595,6 +599,11 @@ void GameController::SetZoomEnabled(bool zoomEnabled)
|
|||||||
gameModel->SetZoomEnabled(zoomEnabled);
|
gameModel->SetZoomEnabled(zoomEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::SetToolStrength(float value)
|
||||||
|
{
|
||||||
|
gameModel->SetToolStrength(value);
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::SetZoomPosition(ui::Point position)
|
void GameController::SetZoomPosition(ui::Point position)
|
||||||
{
|
{
|
||||||
ui::Point zoomPosition = position-(gameModel->GetZoomSize()/2);
|
ui::Point zoomPosition = position-(gameModel->GetZoomSize()/2);
|
||||||
|
@@ -23,7 +23,8 @@ GameModel::GameModel():
|
|||||||
clipboard(NULL),
|
clipboard(NULL),
|
||||||
stamp(NULL),
|
stamp(NULL),
|
||||||
placeSave(NULL),
|
placeSave(NULL),
|
||||||
colour(255, 0, 0, 255)
|
colour(255, 0, 0, 255),
|
||||||
|
toolStrength(1.0f)
|
||||||
{
|
{
|
||||||
sim = new Simulation();
|
sim = new Simulation();
|
||||||
ren = new Renderer(ui::Engine::Ref().g, sim);
|
ren = new Renderer(ui::Engine::Ref().g, sim);
|
||||||
@@ -295,6 +296,16 @@ void GameModel::AddObserver(GameView * observer){
|
|||||||
UpdateQuickOptions();
|
UpdateQuickOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameModel::SetToolStrength(float value)
|
||||||
|
{
|
||||||
|
toolStrength = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GameModel::GetToolStrength()
|
||||||
|
{
|
||||||
|
return toolStrength;
|
||||||
|
}
|
||||||
|
|
||||||
void GameModel::SetActiveMenu(Menu * menu)
|
void GameModel::SetActiveMenu(Menu * menu)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < menuList.size(); i++)
|
for(int i = 0; i < menuList.size(); i++)
|
||||||
|
@@ -55,6 +55,7 @@ private:
|
|||||||
User currentUser;
|
User currentUser;
|
||||||
bool colourSelector;
|
bool colourSelector;
|
||||||
ui::Colour colour;
|
ui::Colour colour;
|
||||||
|
float toolStrength;
|
||||||
|
|
||||||
std::string infoTip;
|
std::string infoTip;
|
||||||
std::string toolTip;
|
std::string toolTip;
|
||||||
@@ -99,6 +100,9 @@ public:
|
|||||||
|
|
||||||
void UpdateQuickOptions();
|
void UpdateQuickOptions();
|
||||||
|
|
||||||
|
void SetToolStrength(float value);
|
||||||
|
float GetToolStrength();
|
||||||
|
|
||||||
void SetVote(int direction);
|
void SetVote(int direction);
|
||||||
SaveInfo * GetSave();
|
SaveInfo * GetSave();
|
||||||
Brush * GetBrush();
|
Brush * GetBrush();
|
||||||
|
@@ -1538,6 +1538,10 @@ void GameView::enableShiftBehaviour()
|
|||||||
if(!shiftBehaviour)
|
if(!shiftBehaviour)
|
||||||
{
|
{
|
||||||
shiftBehaviour = true;
|
shiftBehaviour = true;
|
||||||
|
if(!ctrlBehaviour)
|
||||||
|
c->SetToolStrength(10.0f);
|
||||||
|
else
|
||||||
|
c->SetToolStrength(1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1546,6 +1550,10 @@ void GameView::disableShiftBehaviour()
|
|||||||
if(shiftBehaviour)
|
if(shiftBehaviour)
|
||||||
{
|
{
|
||||||
shiftBehaviour = false;
|
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);
|
saveSimulationButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
|
||||||
searchButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
|
searchButton->Appearance.BackgroundInactive = ui::Colour(255, 255, 255);
|
||||||
searchButton->Appearance.TextInactive = ui::Colour(0, 0, 0);
|
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);
|
saveSimulationButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
|
||||||
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
searchButton->Appearance.BackgroundInactive = ui::Colour(0, 0, 0);
|
||||||
searchButton->Appearance.TextInactive = ui::Colour(255, 255, 255);
|
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),
|
colRed(r),
|
||||||
colGreen(g),
|
colGreen(g),
|
||||||
colBlue(b),
|
colBlue(b),
|
||||||
textureGen(textureGen)
|
textureGen(textureGen),
|
||||||
|
strength(1.0f)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
VideoBuffer * Tool::GetTexture(int width, int height)
|
VideoBuffer * Tool::GetTexture(int width, int height)
|
||||||
@@ -39,13 +40,13 @@ string Tool::GetDescription() { return toolDescription; }
|
|||||||
Tool::~Tool() {}
|
Tool::~Tool() {}
|
||||||
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
void Tool::Click(Simulation * sim, Brush * brush, ui::Point position) { }
|
||||||
void Tool::Draw(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) {
|
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) {
|
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) {};
|
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)
|
if(dragging == false && toolID == WL_FAN && sim->bmap[wallY][wallX]==WL_FAN)
|
||||||
{
|
{
|
||||||
float newFanVelX = (position2.X-position1.X)*0.005f;
|
float newFanVelX = (position2.X-position1.X)*0.005f;
|
||||||
|
newFanVelX *= strength;
|
||||||
float newFanVelY = (position2.Y-position1.Y)*0.005f;
|
float newFanVelY = (position2.Y-position1.Y)*0.005f;
|
||||||
|
newFanVelY *= strength;
|
||||||
sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, -1, WL_FAN, 0);
|
sim->FloodWalls(position1.X, position1.Y, WL_FLOODHELPER, -1, WL_FAN, 0);
|
||||||
for (int j = 0; j < YRES/CELL; j++)
|
for (int j = 0; j < YRES/CELL; j++)
|
||||||
for (int i = 0; i < XRES/CELL; i++)
|
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;
|
int radiusX, radiusY, sizeX, sizeY;
|
||||||
|
|
||||||
float strength = dragging?0.01f:0.002f;
|
float strength = dragging?0.01f:0.002f;
|
||||||
|
strength *= this->strength;
|
||||||
|
|
||||||
radiusX = brush->GetRadius().X;
|
radiusX = brush->GetRadius().X;
|
||||||
radiusY = brush->GetRadius().Y;
|
radiusY = brush->GetRadius().Y;
|
||||||
|
@@ -25,10 +25,13 @@ protected:
|
|||||||
int toolID;
|
int toolID;
|
||||||
string toolName;
|
string toolName;
|
||||||
string toolDescription;
|
string toolDescription;
|
||||||
|
float strength;
|
||||||
public:
|
public:
|
||||||
Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
|
||||||
string GetName();
|
string GetName();
|
||||||
string GetDescription();
|
string GetDescription();
|
||||||
|
void SetStrength(float value) { strength = value; }
|
||||||
|
float GetStrength() { return strength; }
|
||||||
VideoBuffer * GetTexture(int width, int height);
|
VideoBuffer * GetTexture(int width, int height);
|
||||||
void SetTextureGen(VideoBuffer * (*textureGen)(int, int, int));
|
void SetTextureGen(VideoBuffer * (*textureGen)(int, int, int));
|
||||||
virtual ~Tool();
|
virtual ~Tool();
|
||||||
|
@@ -308,12 +308,18 @@ void Renderer::FinaliseParts()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(OGLI) && !defined(OGLR)
|
#if defined(OGLI) && !defined(OGLR)
|
||||||
|
if(display_mode & DISPLAY_WARP)
|
||||||
|
{
|
||||||
render_gravlensing(warpVid);
|
render_gravlensing(warpVid);
|
||||||
|
}
|
||||||
g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255);
|
g->draw_image(vid, 0, 0, VIDXRES, VIDYRES, 255);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(OGLR) && !defined(OGLI)
|
#if !defined(OGLR) && !defined(OGLI)
|
||||||
|
if(display_mode & DISPLAY_WARP)
|
||||||
|
{
|
||||||
render_gravlensing(warpVid);
|
render_gravlensing(warpVid);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1018,7 +1018,7 @@ int Simulation::Tool(int x, int y, int tool, float strength)
|
|||||||
return 0;
|
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;
|
int rx, ry, j, i;
|
||||||
if(!cBrush)
|
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)
|
if ( x+i<0 || y+j<0 || x+i>=XRES || y+j>=YRES)
|
||||||
continue;
|
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;
|
int cp=abs(y2-y1)>abs(x2-x1), x, y, dx, dy, sy, rx, ry;
|
||||||
float e, de;
|
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++)
|
for (x=x1; x<=x2; x++)
|
||||||
{
|
{
|
||||||
if (cp)
|
if (cp)
|
||||||
ToolBrush(y, x, tool, cBrush);
|
ToolBrush(y, x, tool, cBrush, strength);
|
||||||
else
|
else
|
||||||
ToolBrush(x, y, tool, cBrush);
|
ToolBrush(x, y, tool, cBrush, strength);
|
||||||
e += de;
|
e += de;
|
||||||
if (e >= 0.5f)
|
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 ((!(rx+ry)) && ((y1<y2) ? (y<=y2) : (y>=y2)))
|
||||||
{
|
{
|
||||||
if (cp)
|
if (cp)
|
||||||
ToolBrush(y, x, tool, cBrush);
|
ToolBrush(y, x, tool, cBrush, strength);
|
||||||
else
|
else
|
||||||
ToolBrush(x, y, tool, cBrush);
|
ToolBrush(x, y, tool, cBrush, strength);
|
||||||
}
|
}
|
||||||
e -= 1.0f;
|
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;
|
int i, j;
|
||||||
if (x1>x2)
|
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 (j=y1; j<=y2; j++)
|
||||||
for (i=x1; i<=x2; i++)
|
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)
|
int Simulation::CreateParts(int positionX, int positionY, int c, Brush * cBrush)
|
||||||
|
@@ -159,10 +159,10 @@ public:
|
|||||||
|
|
||||||
void SetEdgeMode(int newEdgeMode);
|
void SetEdgeMode(int newEdgeMode);
|
||||||
|
|
||||||
int Tool(int x, int y, int tool, float strength);
|
int Tool(int x, int y, int tool, float strength = 1.0f);
|
||||||
int ToolBrush(int x, int y, int tool, Brush * cBrush);
|
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);
|
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);
|
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);
|
void CreateBox(int x1, int y1, int x2, int y2, int c, int flags);
|
||||||
int FloodINST(int x, int y, int fullc, int cm);
|
int FloodINST(int x, int y, int fullc, int cm);
|
||||||
|
Reference in New Issue
Block a user