summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-04 14:26:55 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-04 14:26:55 (GMT)
commit055832270979cdb027c0c30a74cf82c23df13689 (patch)
treeb2ee525f713764c020b8668fe5776f4aa3d60643 /src
parentf32cd872ca2214b670b1ed4efa0b5b12a9c1ed30 (diff)
downloadpowder-055832270979cdb027c0c30a74cf82c23df13689.zip
powder-055832270979cdb027c0c30a74cf82c23df13689.tar.gz
Add icons for erase, improve icons for certain walls, fix issue #45
Diffstat (limited to 'src')
-rw-r--r--src/game/GameModel.cpp6
-rw-r--r--src/game/SignTool.cpp4
-rw-r--r--src/game/Tool.cpp4
-rw-r--r--src/game/Tool.h1
-rw-r--r--src/graphics/Renderer.cpp56
-rw-r--r--src/simulation/elements/Element.cpp3
-rw-r--r--src/simulation/elements/Element.h1
-rw-r--r--src/simulation/elements/NONE.cpp19
8 files changed, 60 insertions, 34 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index 7566044..85f54d3 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -167,15 +167,15 @@ void GameModel::BuildMenus()
Tool * tempTool;
if(i == PT_LIGH)
{
- tempTool = new Element_LIGH_Tool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
+ tempTool = new Element_LIGH_Tool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), sim->elements[i].IconGenerator);
}
else if(i == PT_STKM || i == PT_FIGH || i == PT_STKM2)
{
- tempTool = new PlopTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
+ tempTool = new PlopTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), sim->elements[i].IconGenerator);
}
else
{
- tempTool = new ElementTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour));
+ tempTool = new ElementTool(i, sim->elements[i].Name, sim->elements[i].Description, PIXR(sim->elements[i].Colour), PIXG(sim->elements[i].Colour), PIXB(sim->elements[i].Colour), sim->elements[i].IconGenerator);
}
menuList[sim->elements[i].MenuSection]->AddTool(tempTool);
}
diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp
index 0ad755e..cea6978 100644
--- a/src/game/SignTool.cpp
+++ b/src/game/SignTool.cpp
@@ -138,8 +138,8 @@ VideoBuffer * SignTool::GetIcon(int toolID, int width, int height)
newTexture->SetPixel(x, y, PIXR(pc), PIXG(pc), PIXB(pc), 255);
}
}
- newTexture->SetCharacter((width/2)-5, (height/2)-4, 0xA1, 32, 64, 128, 255);
- newTexture->SetCharacter((width/2)-5, (height/2)-4, 0xA0, 255, 255, 255, 255);
+ newTexture->SetCharacter((width/2)-5, (height/2)-5, 0xA1, 32, 64, 128, 255);
+ newTexture->SetCharacter((width/2)-5, (height/2)-5, 0xA0, 255, 255, 255, 255);
return newTexture;
}
diff --git a/src/game/Tool.cpp b/src/game/Tool.cpp
index 43c2800..e3f1ded 100644
--- a/src/game/Tool.cpp
+++ b/src/game/Tool.cpp
@@ -30,6 +30,10 @@ VideoBuffer * Tool::GetTexture(int width, int height)
}
return NULL;
}
+void Tool::SetTextureGen(VideoBuffer * (*textureGen)(int, int, int))
+{
+ this->textureGen = textureGen;
+}
string Tool::GetName() { return toolName; }
string Tool::GetDescription() { return toolDescription; }
Tool::~Tool() {}
diff --git a/src/game/Tool.h b/src/game/Tool.h
index 1b70768..aa021fc 100644
--- a/src/game/Tool.h
+++ b/src/game/Tool.h
@@ -30,6 +30,7 @@ public:
string GetName();
string GetDescription();
VideoBuffer * GetTexture(int width, int height);
+ void SetTextureGen(VideoBuffer * (*textureGen)(int, int, int));
virtual ~Tool();
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
diff --git a/src/graphics/Renderer.cpp b/src/graphics/Renderer.cpp
index f18dbbb..9949926 100644
--- a/src/graphics/Renderer.cpp
+++ b/src/graphics/Renderer.cpp
@@ -441,17 +441,18 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
if (wt==WL_EWALL)
{
for (j=0; j<height; j++)
- for (i=0; i<width; i++)
- if(i > width/2)
- {
- if (i&j&1)
- newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
- }
- else
- {
- if (!(i&j&1))
- newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
- }
+ {
+ for (i=0; i<(width/4)+j; i++)
+ {
+ if (!(i&j&1))
+ newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
+ }
+ for (; i<width; i++)
+ {
+ if (i&j&1)
+ newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
+ }
+ }
}
else if (wt==WL_WALLELEC)
{
@@ -467,17 +468,18 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
else if (wt==WL_EHOLE)
{
for (j=0; j<height; j++)
- for (i=0; i<width; i++)
- if(i < width/2)
- {
- if (i&j&1)
- newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
- }
- else
- {
- if (!(i&j&1))
- newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
- }
+ {
+ for (i=0; i<(width/4)+j; i++)
+ {
+ if (i&j&1)
+ newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
+ }
+ for (; i<width; i++)
+ {
+ if (!(i&j&1))
+ newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
+ }
+ }
}
else if (wt == WL_ERASE)
{
@@ -495,12 +497,12 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
}
}
- for (j=4; j<width/2; j++)
+ for (j=3; j<(width-4)/2; j++)
{
newTexture->SetPixel(j+6, j, 0xFF, 0, 0, 255);
newTexture->SetPixel(j+7, j, 0xFF, 0, 0, 255);
- newTexture->SetPixel(-j+21, j, 0xFF, 0, 0, 255);
- newTexture->SetPixel(-j+22, j, 0xFF, 0, 0, 255);
+ newTexture->SetPixel(-j+19, j, 0xFF, 0, 0, 255);
+ newTexture->SetPixel(-j+20, j, 0xFF, 0, 0, 255);
}
}
else if(wt == WL_STREAM)
@@ -513,10 +515,10 @@ VideoBuffer * Renderer::WallIcon(int wallID, int width, int height)
newTexture->SetPixel(i, j, PIXR(pc), PIXG(pc), PIXB(pc), 255);
}
}
- newTexture->SetCharacter(4, 3, 0x8D, 255, 255, 255, 255);
+ newTexture->SetCharacter(4, 2, 0x8D, 255, 255, 255, 255);
for (i=width/3; i<width; i++)
{
- newTexture->SetPixel(i, 8+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255);
+ newTexture->SetPixel(i, 7+(int)(3.9f*cos(i*0.3f)), 255, 255, 255, 255);
}
}
return newTexture;
diff --git a/src/simulation/elements/Element.cpp b/src/simulation/elements/Element.cpp
index 44e7251..83f8c76 100644
--- a/src/simulation/elements/Element.cpp
+++ b/src/simulation/elements/Element.cpp
@@ -42,7 +42,8 @@ Element::Element():
HighTemperatureTransition(NT),
Update(NULL),
- Graphics(&Element::defaultGraphics)
+ Graphics(&Element::defaultGraphics),
+ IconGenerator(NULL)
{
}
diff --git a/src/simulation/elements/Element.h b/src/simulation/elements/Element.h
index 29c7fa0..7fca108 100644
--- a/src/simulation/elements/Element.h
+++ b/src/simulation/elements/Element.h
@@ -38,6 +38,7 @@ public:
unsigned int Properties;
int (*Update) (UPDATE_FUNC_ARGS);
int (*Graphics) (GRAPHICS_FUNC_ARGS);
+ VideoBuffer * (*IconGenerator)(int, int, int);
float HighPressure;
int HighPressureTransition;
diff --git a/src/simulation/elements/NONE.cpp b/src/simulation/elements/NONE.cpp
index d271c90..95d9d3e 100644
--- a/src/simulation/elements/NONE.cpp
+++ b/src/simulation/elements/NONE.cpp
@@ -43,7 +43,24 @@ Element_NONE::Element_NONE()
HighTemperatureTransition = NT;
Update = NULL;
-
+ IconGenerator = &Element_NONE::iconGen;
}
+//#TPT-Directive ElementHeader Element_NONE static VideoBuffer * iconGen(int, int, int)
+VideoBuffer * Element_NONE::iconGen(int wallID, int width, int height)
+{
+ VideoBuffer * newTexture = new VideoBuffer(width, height);
+
+ for (int j=3; j<(width-4)/2; j++)
+ {
+ newTexture->SetPixel(j+6, j, 0xFF, 0, 0, 255);
+ newTexture->SetPixel(j+7, j, 0xFF, 0, 0, 255);
+ newTexture->SetPixel(-j+19, j, 0xFF, 0, 0, 255);
+ newTexture->SetPixel(-j+20, j, 0xFF, 0, 0, 255);
+ }
+
+ return newTexture;
+}
+
+
Element_NONE::~Element_NONE() {} \ No newline at end of file