deco menu button textures (not black)

This commit is contained in:
jacob1 2013-07-16 13:08:57 -04:00
parent 5773e6afb5
commit 6f29926b96
5 changed files with 65 additions and 24 deletions

View File

@ -152,7 +152,7 @@ int VideoBuffer::AddCharacter(int x, int y, int c, int r, int g, int b, int a)
VideoBuffer::~VideoBuffer()
{
delete[] Buffer;
};
}
/**
* Common graphics functions, mostly static methods that provide

View File

@ -3,22 +3,59 @@
#define DECORATIONTOOL_H_
#include "Tool.h"
#include "graphics/Graphics.h"
class DecorationTool: public Tool
{
public:
enum ToolType { BlendAdd = DECO_ADD, BlendRemove = DECO_SUBTRACT, BlendMultiply = DECO_MULTIPLY, BlendDivide = DECO_DIVIDE, BlendSet = DECO_DRAW, BlendSmudge = DECO_SMUDGE, Remove = DECO_CLEAR };
ToolType decoMode;
unsigned char Red;
unsigned char Green;
unsigned char Blue;
unsigned char Alpha;
DecorationTool(ToolType decoMode_, string name, string description, int r, int g, int b, std::string identifier):
Tool(0, name, description, r, g, b, identifier),
decoMode(decoMode_),
VideoBuffer * GetIcon(int toolID, int width, int height)
{
VideoBuffer * newTexture = new VideoBuffer(width, height);
for (int y=0; y<height; y++)
{
for (int x=0; x<width; x++)
{
//if (toolID == DECO_LIGH)
// vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = PIXRGB(PIXR(pc)-10*j, PIXG(pc)-10*j, PIXB(pc)-10*j);
//else if (toolID == DECO_DARK)
// vid_buf[(XRES+BARSIZE)*(y+j)+(x+i)] = PIXRGB(PIXR(pc)+10*j, PIXG(pc)+10*j, PIXB(pc)+10*j);
if (toolID == DECO_SMUDGE)
newTexture->SetPixel(x, y, 0, 255-5*x, 255+5*x, 255);
else
newTexture->SetPixel(x, y, Red, Green, Blue, Alpha);
}
}
int reverseRed = (Red+127)%256;
int reverseGreen = (Green+127)%256;
int reverseBlue = (Blue+127)%256;
if (toolID == DECO_CLEAR)
{
for (int y=4; y<12; y++)
{
newTexture->SetPixel(y+5, y-1, reverseRed, reverseGreen, reverseBlue, 255);
newTexture->SetPixel(y+6, y-1, reverseRed, reverseGreen, reverseBlue, 255);
newTexture->SetPixel(20-y, y-1, reverseRed, reverseGreen, reverseBlue, 255);
newTexture->SetPixel(21-y, y-1, reverseRed, reverseGreen, reverseBlue, 255);
}
}
else if (toolID == DECO_ADD)
newTexture->AddCharacter(11, 4, '+', reverseRed, reverseGreen, reverseBlue, 255);
else if (toolID == DECO_SUBTRACT)
newTexture->AddCharacter(11, 4, '-', reverseRed, reverseGreen, reverseBlue, 255);
else if (toolID == DECO_MULTIPLY)
newTexture->AddCharacter(11, 3, 'x', reverseRed, reverseGreen, reverseBlue, 255);
else if (toolID == DECO_DIVIDE)
newTexture->AddCharacter(11, 4, '/', reverseRed, reverseGreen, reverseBlue, 255);
return newTexture;
}
DecorationTool(int decoMode, string name, string description, int r, int g, int b, std::string identifier):
Tool(decoMode, name, description, r, g, b, identifier),
Red(0),
Green(0),
Blue(0),
@ -27,13 +64,13 @@ public:
}
virtual ~DecorationTool() {}
virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){
sim->ApplyDecorationPoint(position.X, position.Y, Red, Green, Blue, Alpha, decoMode, brush);
sim->ApplyDecorationPoint(position.X, position.Y, Red, Green, Blue, Alpha, toolID, brush);
}
virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2, bool dragging) {
sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, decoMode, brush);
sim->ApplyDecorationLine(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, toolID, brush);
}
virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
sim->ApplyDecorationBox(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, decoMode);
sim->ApplyDecorationBox(position1.X, position1.Y, position2.X, position2.Y, Red, Green, Blue, Alpha, toolID);
}
virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {

View File

@ -327,13 +327,13 @@ void GameModel::BuildMenus()
menuList[SC_TOOL]->AddTool(new SampleTool(this));
//Add decoration tools to menu
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendAdd, "ADD", "Colour blending: Add", 0, 0, 0, "DEFAULT_DECOR_ADD"));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendRemove, "SUB", "Colour blending: Subtract", 0, 0, 0, "DEFAULT_DECOR_SUB"));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendMultiply, "MUL", "Colour blending: Multiply", 0, 0, 0, "DEFAULT_DECOR_MUL"));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendDivide, "DIV", "Colour blending: Divide" , 0, 0, 0, "DEFAULT_DECOR_DIV"));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSmudge, "SMDG", "Smudge colour", 0, 0, 0, "DEFAULT_DECOR_SMDG"));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::BlendSet, "SET", "Set colour (No blending)", 0, 0, 0, "DEFAULT_DECOR_SET"));
menuList[SC_DECO]->AddTool(new DecorationTool(DecorationTool::Remove, "CLR", "Clear any set decoration", 0, 0, 0, "DEFAULT_DECOR_CLR"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_ADD, "ADD", "Colour blending: Add", 0, 0, 0, "DEFAULT_DECOR_ADD"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_SUBTRACT, "SUB", "Colour blending: Subtract", 0, 0, 0, "DEFAULT_DECOR_SUB"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_MULTIPLY, "MUL", "Colour blending: Multiply", 0, 0, 0, "DEFAULT_DECOR_MUL"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_DIVIDE, "DIV", "Colour blending: Divide" , 0, 0, 0, "DEFAULT_DECOR_DIV"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_SMUDGE, "SMDG", "Smudge colour", 0, 0, 0, "DEFAULT_DECOR_SMDG"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_DRAW, "SET", "Set colour (No blending)", 0, 0, 0, "DEFAULT_DECOR_SET"));
menuList[SC_DECO]->AddTool(new DecorationTool(DECO_CLEAR, "CLR", "Clear any set decoration", 0, 0, 0, "DEFAULT_DECOR_CLR"));
decoToolset[0] = GetToolFromIdentifier("DEFAULT_DECOR_SET");
decoToolset[1] = GetToolFromIdentifier("DEFAULT_DECOR_CLR");
decoToolset[2] = GetToolFromIdentifier("DEFAULT_UI_SAMPLE");
@ -762,7 +762,6 @@ bool GameModel::GetColourSelectorVisibility()
void GameModel::SetColourSelectorColour(ui::Colour colour_)
{
colour = colour_;
notifyColourSelectorColourChanged();
vector<Tool*> tools = GetMenuList()[SC_DECO]->GetToolList();
for(int i = 0; i < tools.size(); i++)
@ -772,6 +771,8 @@ void GameModel::SetColourSelectorColour(ui::Colour colour_)
((DecorationTool*)tools[i])->Blue = colour.Blue;
((DecorationTool*)tools[i])->Alpha = colour.Alpha;
}
notifyColourSelectorColourChanged();
}
ui::Colour GameModel::GetColourSelectorColour()

View File

@ -17,6 +17,7 @@
#include "Format.h"
#include "QuickOption.h"
#include "IntroText.h"
#include "DecorationTool.h"
class SplitButton;
@ -656,10 +657,8 @@ void GameView::NotifyLastToolChanged(GameModel * sender)
void GameView::NotifyToolListChanged(GameModel * sender)
{
//int currentY = YRES+MENUSIZE-36;
lastOffset = 0;
int currentX = XRES+BARSIZE-56;
int totalColour;
for(int i = 0; i < menuButtons.size(); i++)
{
if(((MenuAction*)menuButtons[i]->GetActionCallback())->menuID==sender->GetActiveMenu())
@ -680,10 +679,13 @@ void GameView::NotifyToolListChanged(GameModel * sender)
vector<Tool*> toolList = sender->GetToolList();
for(int i = 0; i < toolList.size(); i++)
{
//ToolButton * tempButton = new ToolButton(ui::Point(XRES+1, currentY), ui::Point(28, 15), toolList[i]->GetName());
VideoBuffer * tempTexture = toolList[i]->GetTexture(26, 14);
ToolButton * tempButton;
//get decotool texture manually, since it changes depending on it's own color
if (sender->GetActiveMenu() == SC_DECO)
tempTexture = ((DecorationTool*)toolList[i])->GetIcon(toolList[i]->GetToolID(), 26, 14);
if(tempTexture)
tempButton = new ToolButton(ui::Point(currentX, YRES+1), ui::Point(30, 18), "", toolList[i]->GetDescription());
else
@ -808,6 +810,7 @@ void GameView::NotifyColourSelectorColourChanged(GameModel * sender)
{
colourPicker->Appearance.BackgroundInactive = sender->GetColourSelectorColour();
colourPicker->Appearance.BackgroundHover = sender->GetColourSelectorColour();
NotifyToolListChanged(sender);
}
void GameView::NotifyRendererChanged(GameModel * sender)

View File

@ -26,8 +26,8 @@ public:
virtual void DoMouseDown(int x, int y, unsigned button);
virtual void DoMouseUp(int x, int y, unsigned button) { if(!signMoving) ui::Window::DoMouseUp(x, y, button); }
virtual void DoMouseWheel(int x, int y, int d) { if(!signMoving) ui::Window::DoMouseWheel(x, y, d); }
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyPress(key, character, shift, ctrl, alt); };
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyRelease(key, character, shift, ctrl, alt); };
virtual void DoKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyPress(key, character, shift, ctrl, alt); }
virtual void DoKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(!signMoving) ui::Window::DoKeyRelease(key, character, shift, ctrl, alt); }
virtual ~SignWindow() {}
virtual void OnTryExit(ui::Window::ExitMethod method);
class OkayAction: public ui::ButtonAction