summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-07-21 17:43:46 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-07-21 17:43:46 (GMT)
commitf7d8556965832821036c210ffc1f9e73f3ff70cc (patch)
tree58e985bdc6e99a2ad8e7382ebaf33553ae93d836 /src/game
parent5bf0a084ace0e6b673efa4552b40de8b36e0668e (diff)
downloadpowder-f7d8556965832821036c210ffc1f9e73f3ff70cc.zip
powder-f7d8556965832821036c210ffc1f9e73f3ff70cc.tar.gz
Icons for menu items
Diffstat (limited to 'src/game')
-rw-r--r--src/game/GameModel.cpp2
-rw-r--r--src/game/GameView.cpp5
-rw-r--r--src/game/SignTool.cpp5
-rw-r--r--src/game/Tool.cpp25
-rw-r--r--src/game/Tool.h18
-rw-r--r--src/game/ToolButton.cpp9
6 files changed, 47 insertions, 17 deletions
diff --git a/src/game/GameModel.cpp b/src/game/GameModel.cpp
index e4ee15b..29d13ce 100644
--- a/src/game/GameModel.cpp
+++ b/src/game/GameModel.cpp
@@ -84,7 +84,7 @@ GameModel::GameModel():
//Build other menus from wall data
for(int i = 0; i < UI_WALLCOUNT; i++)
{
- Tool * tempTool = new WallTool(i, "", std::string(sim->wtypes[i].descs), PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour));
+ Tool * tempTool = new WallTool(i, "", std::string(sim->wtypes[i].descs), PIXR(sim->wtypes[i].colour), PIXG(sim->wtypes[i].colour), PIXB(sim->wtypes[i].colour), sim->wtypes[i].textureGen);
menuList[SC_WALL]->AddTool(tempTool);
//sim->wtypes[i]
}
diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp
index 69beb75..6b4a953 100644
--- a/src/game/GameView.cpp
+++ b/src/game/GameView.cpp
@@ -441,6 +441,11 @@ void GameView::NotifyToolListChanged(GameModel * sender)
currentX -= 31;
tempButton->SetActionCallback(new ToolAction(this, toolList[i]));
+ VideoBuffer * tempTexture = toolList[i]->GetTexture(30, 18);
+ tempButton->Appearance.SetTexture(tempTexture);
+ if(tempTexture)
+ delete tempTexture;
+
tempButton->Appearance.BackgroundInactive = ui::Colour(toolList[i]->colRed, toolList[i]->colGreen, toolList[i]->colBlue);
if(sender->GetActiveTool(0) == toolList[i])
diff --git a/src/game/SignTool.cpp b/src/game/SignTool.cpp
index 35f802d..5b3bb8b 100644
--- a/src/game/SignTool.cpp
+++ b/src/game/SignTool.cpp
@@ -118,6 +118,11 @@ void SignWindow::OnDraw()
g->drawrect(Position.X, Position.Y, Size.X, Size.Y, 200, 200, 200, 255);
}
+VideoBuffer * SignTool::GetIcon(int toolID, int width, int height)
+{
+
+}
+
void SignTool::Click(Simulation * sim, Brush * brush, ui::Point position)
{
int signX, signY, signW, signH, signIndex = -1;
diff --git a/src/game/Tool.cpp b/src/game/Tool.cpp
index efe4831..977896b 100644
--- a/src/game/Tool.cpp
+++ b/src/game/Tool.cpp
@@ -12,15 +12,24 @@
using namespace std;
-Tool::Tool(int id, string name, string description, int r, int g, int b):
+Tool::Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)):
toolID(id),
toolName(name),
toolDescription(description),
colRed(r),
colGreen(g),
- colBlue(b)
+ colBlue(b),
+ textureGen(textureGen)
{
}
+VideoBuffer * Tool::GetTexture(int width, int height)
+{
+ if(textureGen)
+ {
+ return textureGen(toolID, width, height);
+ }
+ return NULL;
+}
string Tool::GetName() { return toolName; }
string Tool::GetDescription() { return toolDescription; }
Tool::~Tool() {}
@@ -36,8 +45,8 @@ void Tool::DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Po
}
void Tool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
-ElementTool::ElementTool(int id, string name, string description, int r, int g, int b):
- Tool(id, name, description, r, g, b)
+ElementTool::ElementTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)):
+ Tool(id, name, description, r, g, b, textureGen)
{
}
ElementTool::~ElementTool() {}
@@ -55,8 +64,8 @@ void ElementTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position)
}
-WallTool::WallTool(int id, string name, string description, int r, int g, int b):
-Tool(id, name, description, r, g, b)
+WallTool::WallTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)):
+Tool(id, name, description, r, g, b, textureGen)
{
}
WallTool::~WallTool() {}
@@ -74,8 +83,8 @@ void WallTool::DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
}
-GolTool::GolTool(int id, string name, string description, int r, int g, int b):
- Tool(id, name, description, r, g, b)
+GolTool::GolTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int)):
+ Tool(id, name, description, r, g, b, textureGen)
{
}
GolTool::~GolTool() {}
diff --git a/src/game/Tool.h b/src/game/Tool.h
index 2cc33be..c7b7f58 100644
--- a/src/game/Tool.h
+++ b/src/game/Tool.h
@@ -16,17 +16,20 @@ using namespace std;
class Simulation;
class Brush;
+class VideoBuffer;
class Tool
{
protected:
+ VideoBuffer * (*textureGen)(int, int, int);
int toolID;
string toolName;
string toolDescription;
public:
- Tool(int id, string name, string description, int r, int g, int b);
+ Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
string GetName();
string GetDescription();
+ VideoBuffer * GetTexture(int width, int height);
virtual ~Tool();
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
@@ -40,9 +43,10 @@ class SignTool: public Tool
{
public:
SignTool():
- Tool(0, "SIGN", "Sign. Click a sign to edit or anywhere else to create a new one", 0, 0, 0)
+ Tool(0, "SIGN", "Sign. Click a sign to edit or anywhere else to create a new one", 0, 0, 0, SignTool::GetIcon)
{
}
+ static VideoBuffer * GetIcon(int toolID, int width, int height);
virtual ~SignTool() {}
virtual void Click(Simulation * sim, Brush * brush, ui::Point position);
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) { }
@@ -55,7 +59,7 @@ class PropertyTool: public Tool
{
public:
PropertyTool():
- Tool(0, "PROP", "Property Edit. Click to alter the properties of elements in the field", 0, 0, 0)
+ Tool(0, "PROP", "Property Edit. Click to alter the properties of elements in the field", 0, 0, 0, NULL)
{
}
virtual ~PropertyTool() {}
@@ -69,7 +73,7 @@ public:
class Element_LIGH_Tool: public Tool
{
public:
- Element_LIGH_Tool(int id, string name, string description, int r, int g, int b):
+ Element_LIGH_Tool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL):
Tool(id, name, description, r, g, b)
{
}
@@ -84,7 +88,7 @@ public:
class ElementTool: public Tool
{
public:
- ElementTool(int id, string name, string description, int r, int g, int b);
+ ElementTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
virtual ~ElementTool();
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
@@ -95,7 +99,7 @@ public:
class WallTool: public Tool
{
public:
- WallTool(int id, string name, string description, int r, int g, int b);
+ WallTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
virtual ~WallTool();
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
@@ -106,7 +110,7 @@ public:
class GolTool: public Tool
{
public:
- GolTool(int id, string name, string description, int r, int g, int b);
+ GolTool(int id, string name, string description, int r, int g, int b, VideoBuffer * (*textureGen)(int, int, int) = NULL);
virtual ~GolTool();
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position);
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2);
diff --git a/src/game/ToolButton.cpp b/src/game/ToolButton.cpp
index 7295309..21e19be 100644
--- a/src/game/ToolButton.cpp
+++ b/src/game/ToolButton.cpp
@@ -40,7 +40,14 @@ void ToolButton::Draw(const ui::Point& screenPos)
Graphics * g = ui::Engine::Ref().g;
int totalColour = Appearance.BackgroundInactive.Blue + (3*Appearance.BackgroundInactive.Green) + (2*Appearance.BackgroundInactive.Red);
- g->fillrect(screenPos.X+2, screenPos.Y+2, Size.X-4, Size.Y-4, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha);
+ if(Appearance.GetTexture())
+ {
+ g->draw_image(Appearance.GetTexture(), screenPos.X, screenPos.Y, 255);
+ }
+ else
+ {
+ g->fillrect(screenPos.X+2, screenPos.Y+2, Size.X-4, Size.Y-4, Appearance.BackgroundInactive.Red, Appearance.BackgroundInactive.Green, Appearance.BackgroundInactive.Blue, Appearance.BackgroundInactive.Alpha);
+ }
if(isMouseInside && currentSelection == -1)
{