diff --git a/src/game/DecorationTool.h b/src/game/DecorationTool.h index 5a11bc6bf..c45eca32d 100644 --- a/src/game/DecorationTool.h +++ b/src/game/DecorationTool.h @@ -7,7 +7,7 @@ class DecorationTool: public Tool { public: - enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW }; + enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW, BlendSmudge = DECO_SMUDGE }; ToolType decoMode; diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp index fa18e24f9..5a29d098a 100644 --- a/src/game/GameModel.cpp +++ b/src/game/GameModel.cpp @@ -97,6 +97,7 @@ GameModel::GameModel(): menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", 0, 0, 0)); menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", 0, 0, 0)); menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", 0, 0, 0)); + menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", 0, 0, 0)); menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", 0, 0, 0)); //Set default brush palette diff --git a/src/simulation/Simulation.cpp b/src/simulation/Simulation.cpp index 7941d25ac..aaa48346d 100644 --- a/src/simulation/Simulation.cpp +++ b/src/simulation/Simulation.cpp @@ -371,6 +371,28 @@ void Simulation::ApplyDecoration(int x, int y, int colR_, int colG_, int colB_, tg /= 1.0f+(colG*0.1f)*colA; tb /= 1.0f+(colB*0.1f)*colA; } + else if (mode == DECO_SMUDGE) + { + int rx, ry, num = 0; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + { + if ((pmap[y+ry][x+rx]&0xFF) && parts[pmap[y+ry][x+rx]>>8].dcolour) + { + num++; + ta += float((parts[pmap[y+ry][x+rx]>>8].dcolour>>24)&0xFF)/255.0f; + tr += float((parts[pmap[y+ry][x+rx]>>8].dcolour>>16)&0xFF)/255.0f; + tg += float((parts[pmap[y+ry][x+rx]>>8].dcolour>>8)&0xFF)/255.0f; + tb += float((parts[pmap[y+ry][x+rx]>>8].dcolour)&0xFF)/255.0f; + } + } + if (num == 0) + return; + ta = ta/float(num)+0.5f; + tr = tr/float(num)+0.5f; + tg = tg/float(num)+0.5f; + tb = tb/float(num)+0.5f; + } colA_ = ta*255.0f; colR_ = tr*255.0f; diff --git a/src/simulation/SimulationData.h b/src/simulation/SimulationData.h index 2c1345033..1e1c455ee 100644 --- a/src/simulation/SimulationData.h +++ b/src/simulation/SimulationData.h @@ -61,6 +61,7 @@ #define DECO_SUBTRACT 2 #define DECO_MULTIPLY 3 #define DECO_DIVIDE 4 +#define DECO_SMUDGE 5 //Old IDs for GOL types #define GT_GOL 78