Misc - Added text and textcolor to buttons, seperate render function.
This commit is contained in:
parent
95e08e84c3
commit
d01acbcbe0
|
@ -21,17 +21,17 @@ namespace DanBias
|
||||||
ButtonEllipse()
|
ButtonEllipse()
|
||||||
: EventButtonGUI(), radius(0)
|
: EventButtonGUI(), radius(0)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true)
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, owner, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, EventFunc func, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true)
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, func, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true)
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, func, owner, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonEllipse(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float textureWidth, float textureHeight, bool resizeToScreenAspectRatio = true)
|
ButtonEllipse(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, func, owner, userData, xPos, yPos, textureWidth, textureHeight, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
virtual ~ButtonEllipse()
|
virtual ~ButtonEllipse()
|
||||||
{}
|
{}
|
||||||
|
@ -42,8 +42,8 @@ namespace DanBias
|
||||||
//Should come from the InputClass
|
//Should come from the InputClass
|
||||||
float xMouse = input.x, yMouse = input.y;
|
float xMouse = input.x, yMouse = input.y;
|
||||||
|
|
||||||
double normx = (xMouse - xPos) / width;
|
double normx = (xMouse - pos.x) / size.x;
|
||||||
double normy = (yMouse - yPos) / height;
|
double normy = (yMouse - pos.y) / size.y;
|
||||||
|
|
||||||
return (normx * normx + normy * normy) < 0.25;
|
return (normx * normx + normy * normy) < 0.25;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,17 +21,17 @@ namespace DanBias
|
||||||
ButtonRectangle()
|
ButtonRectangle()
|
||||||
: EventButtonGUI(), width(0), height(0)
|
: EventButtonGUI(), width(0), height(0)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, owner, xPos, yPos, width, height, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, func, xPos, yPos, width, height, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, func, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, func, owner, xPos, yPos, width, height, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
ButtonRectangle(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
ButtonRectangle(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButtonGUI(textureName, func, owner, userData, xPos, yPos, width, height, resizeToScreenAspectRatio)
|
: EventButtonGUI(textureName, buttonText, textColor, func, owner, userData, pos, size, resize)
|
||||||
{}
|
{}
|
||||||
virtual ~ButtonRectangle()
|
virtual ~ButtonRectangle()
|
||||||
{}
|
{}
|
||||||
|
@ -42,10 +42,10 @@ namespace DanBias
|
||||||
//Should come from the InputClass
|
//Should come from the InputClass
|
||||||
float xMouse = input.x, yMouse = input.y;
|
float xMouse = input.x, yMouse = input.y;
|
||||||
|
|
||||||
float widthTemp = xPos - width * 0.5f;
|
float widthTemp = pos.x - size.x * 0.5f;
|
||||||
float widthTemp2 = xPos + width * 0.5f;
|
float widthTemp2 = pos.x + size.x * 0.5f;
|
||||||
float heightTemp = yPos - height * 0.5f;
|
float heightTemp = pos.y - size.y * 0.5f;
|
||||||
float heightTemp2 = yPos + height * 0.5f;
|
float heightTemp2 = pos.y + size.y * 0.5f;
|
||||||
//std::cout << p.x << ' ' << p.y << ' ' << widthTemp << ' ' << heightTemp << std::endl;
|
//std::cout << p.x << ' ' << p.y << ' ' << widthTemp << ' ' << heightTemp << std::endl;
|
||||||
|
|
||||||
if(xMouse >= widthTemp && xMouse <= widthTemp2 &&
|
if(xMouse >= widthTemp && xMouse <= widthTemp2 &&
|
||||||
|
|
|
@ -8,40 +8,56 @@
|
||||||
#include "../Misc/EventHandler/EventButton.h"
|
#include "../Misc/EventHandler/EventButton.h"
|
||||||
#include "../OysterGraphics/DllInterfaces/GFXAPI.h"
|
#include "../OysterGraphics/DllInterfaces/GFXAPI.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace DanBias
|
namespace DanBias
|
||||||
{
|
{
|
||||||
namespace Client
|
namespace Client
|
||||||
{
|
{
|
||||||
|
/*Dictates if the texture should be resized based on the screen aspect ratio.
|
||||||
|
|
||||||
|
*/
|
||||||
|
enum ResizeAspectRatio
|
||||||
|
{
|
||||||
|
ResizeAspectRatio_None,
|
||||||
|
ResizeAspectRatio_Width,
|
||||||
|
ResizeAspectRatio_Height,
|
||||||
|
|
||||||
|
ResizeAspectRatio_Count,
|
||||||
|
ResizeAspectRatio_Unknown = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Owner>
|
template <typename Owner>
|
||||||
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
|
class EventButtonGUI : public Oyster::Event::EventButton<Owner>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventButtonGUI()
|
EventButtonGUI()
|
||||||
: EventButton(), xPos(0), yPos(0), width(0), height(0), texture(NULL)
|
: EventButton(), pos(0, 0), size(0, 0), texture(NULL), buttonText(""), textColor(0, 0, 0)
|
||||||
{}
|
{}
|
||||||
EventButtonGUI(std::wstring textureName, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButton(owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
|
: EventButton(owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resizeToScreenAspectRatio) ResizeWithAspectRatio();
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
EventButtonGUI(std::wstring textureName, EventFunc func, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButton(func), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
|
: EventButton(func), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resizeToScreenAspectRatio) ResizeWithAspectRatio();
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButton(func, owner), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
|
: EventButton(func, owner), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resizeToScreenAspectRatio) ResizeWithAspectRatio();
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
EventButtonGUI(std::wstring textureName, EventFunc func, Owner owner, void* userData, float xPos, float yPos, float width, float height, bool resizeToScreenAspectRatio = true)
|
EventButtonGUI(std::wstring textureName, std::wstring buttonText, Oyster::Math::Float3 textColor, EventFunc func, Owner owner, void* userData, Oyster::Math::Float3 pos, Oyster::Math::Float2 size, ResizeAspectRatio resize = ResizeAspectRatio_Height)
|
||||||
: EventButton(func, owner, userData), xPos(xPos), yPos(yPos), width(width), height(height), texture(NULL)
|
: EventButton(func, owner, userData), pos(pos), size(size), texture(NULL), buttonText(buttonText), textColor(textColor)
|
||||||
{
|
{
|
||||||
CreateTexture(textureName);
|
CreateTexture(textureName);
|
||||||
if(resizeToScreenAspectRatio) ResizeWithAspectRatio();
|
if(resize != ResizeAspectRatio_None) ResizeWithAspectRatio(resize);
|
||||||
}
|
}
|
||||||
virtual ~EventButtonGUI()
|
virtual ~EventButtonGUI()
|
||||||
{
|
{
|
||||||
|
@ -55,7 +71,7 @@ namespace DanBias
|
||||||
texture = Oyster::Graphics::API::CreateTexture(textureName);
|
texture = Oyster::Graphics::API::CreateTexture(textureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Render()
|
virtual void RenderTexture()
|
||||||
{
|
{
|
||||||
if(EventButton<Owner>::Enabled())
|
if(EventButton<Owner>::Enabled())
|
||||||
{
|
{
|
||||||
|
@ -64,32 +80,48 @@ namespace DanBias
|
||||||
|
|
||||||
if(EventButton<Owner>::GetState() == ButtonState_None)
|
if(EventButton<Owner>::GetState() == ButtonState_None)
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
|
Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 1.0f, 1.0f));
|
||||||
}
|
}
|
||||||
else if(EventButton<Owner>::GetState() == ButtonState_Hover)
|
else if(EventButton<Owner>::GetState() == ButtonState_Hover)
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(0.0f, 1.0f, 0.0f));
|
Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(0.0f, 1.0f, 0.0f));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Oyster::Graphics::API::RenderGuiElement(texture, Oyster::Math::Float2(xPos, yPos), Oyster::Math::Float2(width, height), Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
Oyster::Graphics::API::RenderGuiElement(texture, pos.xy, size, Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResizeWithAspectRatio()
|
virtual void RenderText()
|
||||||
|
{
|
||||||
|
if(buttonText.size() > 0)
|
||||||
|
{
|
||||||
|
Oyster::Graphics::API::RenderText(buttonText, pos.xy, size, textColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ResizeWithAspectRatio(ResizeAspectRatio resize)
|
||||||
{
|
{
|
||||||
RECT r;
|
RECT r;
|
||||||
GetClientRect(WindowShell::GetHWND(), &r);
|
GetClientRect(WindowShell::GetHWND(), &r);
|
||||||
height *= (float)r.right/(float)r.bottom;
|
|
||||||
|
if(resize == ResizeAspectRatio_Height)
|
||||||
|
size.y *= (float)r.right/(float)r.bottom;
|
||||||
|
else if(resize == ResizeAspectRatio_Width)
|
||||||
|
size.x *= (float)r.bottom/(float)r.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float xPos, yPos;
|
Oyster::Math::Float3 pos;
|
||||||
float width, height;
|
Oyster::Math::Float2 size;
|
||||||
|
|
||||||
Oyster::Graphics::API::Texture texture;
|
Oyster::Graphics::API::Texture texture;
|
||||||
|
|
||||||
|
std::wstring buttonText;
|
||||||
|
Oyster::Math::Float3 textColor;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,23 +109,33 @@ bool LoginState::Init(Oyster::Network::NetworkClient* nwClient)
|
||||||
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
InitCamera(Oyster::Math::Float3(0,0,5.4f));
|
||||||
|
|
||||||
//Create menu buttons
|
//Create menu buttons
|
||||||
//privData->collection = new EventButtonCollection;
|
|
||||||
EventHandler::Instance().AddCollection(&privData->collection);
|
EventHandler::Instance().AddCollection(&privData->collection);
|
||||||
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.2f, 0.1f, 0.1f));
|
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", L"Hej", Oyster::Math::Float3(1, 1, 0), &LoginState::ButtonCallback, this,
|
||||||
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.3f, 0.1f, 0.1f));
|
(void*)Options, Oyster::Math::Float3(0.2f, 0.2f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width));
|
||||||
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.4f, 0.1f, 0.1f));
|
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", &LoginState::ButtonCallback, this, (void*)Options, 0.2f, 0.5f, 0.1f, 0.1f));
|
(void*)Options, Oyster::Math::Float3(0.2f, 0.3f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width));
|
||||||
|
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
|
(void*)Options, Oyster::Math::Float3(0.2f, 0.4f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width));
|
||||||
|
privData->collection.AddButton(new ButtonEllipse<LoginState*>(L"circle.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
|
(void*)Options, Oyster::Math::Float3(0.2f, 0.5f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f), ResizeAspectRatio_Width));
|
||||||
|
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.15f, 0.05f, 0.1f, 0.1f));
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.25f, 0.05f, 0.1f, 0.1f));
|
(void*)Options, Oyster::Math::Float3(0.15f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f)));
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.35f, 0.05f, 0.1f, 0.1f));
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Options, 0.45f, 0.05f, 0.1f, 0.1f));
|
(void*)Options, Oyster::Math::Float3(0.25f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f)));
|
||||||
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
|
(void*)Options, Oyster::Math::Float3(0.35f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f)));
|
||||||
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
|
(void*)Options, Oyster::Math::Float3(0.45f, 0.05f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f)));
|
||||||
|
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Create, 0.5f, 0.5f, 0.3f, 0.3f));
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"Create Game", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
|
(void*)Create, Oyster::Math::Float3(0.5f, 0.5f, 0.0f), Oyster::Math::Float2(0.3f, 0.3f)));
|
||||||
|
|
||||||
//Incr/decr buttons .
|
//Incr/decr buttons .
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Incr, 0.85f, 0.2f, 0.1f, 0.1f));
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", &LoginState::ButtonCallback, this, (void*)Decr, 0.55f, 0.2f, 0.1f, 0.1f));
|
(void*)Incr, Oyster::Math::Float3(0.85f, 0.2f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f)));
|
||||||
|
privData->collection.AddButton(new ButtonRectangle<LoginState*>(L"button.png", L"Hej", Oyster::Math::Float3(1, 0, 0), &LoginState::ButtonCallback, this,
|
||||||
|
(void*)Decr, Oyster::Math::Float3(0.55f, 0.2f, 0.0f), Oyster::Math::Float2(0.1f, 0.1f)));
|
||||||
|
|
||||||
privData->createGame = false;
|
privData->createGame = false;
|
||||||
privData->testNumber = 0;
|
privData->testNumber = 0;
|
||||||
|
@ -236,7 +246,7 @@ bool LoginState::Render(float dt)
|
||||||
|
|
||||||
//Render buttons
|
//Render buttons
|
||||||
Oyster::Graphics::API::StartGuiRender();
|
Oyster::Graphics::API::StartGuiRender();
|
||||||
EventHandler::Instance().Render();
|
EventHandler::Instance().RenderTexture();
|
||||||
|
|
||||||
std::wstring number;
|
std::wstring number;
|
||||||
wchar_t temp[10];
|
wchar_t temp[10];
|
||||||
|
@ -244,6 +254,7 @@ bool LoginState::Render(float dt)
|
||||||
number = temp;
|
number = temp;
|
||||||
|
|
||||||
Oyster::Graphics::API::StartTextRender();
|
Oyster::Graphics::API::StartTextRender();
|
||||||
|
EventHandler::Instance().RenderText();
|
||||||
Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7f, 0.2f), Oyster::Math::Float2(0.1f, 0.1f*(1008.0f/730.0f)), Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
Oyster::Graphics::API::RenderText(number, Oyster::Math::Float2(0.7f, 0.2f), Oyster::Math::Float2(0.1f, 0.1f*(1008.0f/730.0f)), Oyster::Math::Float3(1.0f, 0.0f, 0.0f));
|
||||||
|
|
||||||
Oyster::Graphics::API::EndFrame();
|
Oyster::Graphics::API::EndFrame();
|
||||||
|
|
|
@ -43,13 +43,24 @@ void EventButtonCollection::Update(MouseInput& input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventButtonCollection::Render()
|
void EventButtonCollection::RenderTexture()
|
||||||
{
|
{
|
||||||
if(this->collectionState == EventCollectionState_Enabled)
|
if(this->collectionState == EventCollectionState_Enabled)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < (int)buttons.size(); i++)
|
for(int i = 0; i < (int)buttons.size(); i++)
|
||||||
{
|
{
|
||||||
buttons[i]->Render();
|
buttons[i]->RenderTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventButtonCollection::RenderText()
|
||||||
|
{
|
||||||
|
if(this->collectionState == EventCollectionState_Enabled)
|
||||||
|
{
|
||||||
|
for(int i = 0; i < (int)buttons.size(); i++)
|
||||||
|
{
|
||||||
|
buttons[i]->RenderText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ namespace Oyster
|
||||||
~EventButtonCollection();
|
~EventButtonCollection();
|
||||||
|
|
||||||
void Update(MouseInput& input);
|
void Update(MouseInput& input);
|
||||||
void Render();
|
void RenderTexture();
|
||||||
|
void RenderText();
|
||||||
|
|
||||||
/*Add a button to the collection when a button is added to the collection you are not allowed to delete it.
|
/*Add a button to the collection when a button is added to the collection you are not allowed to delete it.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -35,11 +35,19 @@ void EventHandler::Update(MouseInput& input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventHandler::Render()
|
void EventHandler::RenderTexture()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < (int)collections.size(); i++)
|
for(int i = 0; i < (int)collections.size(); i++)
|
||||||
{
|
{
|
||||||
collections.at(i)->Render();
|
collections.at(i)->RenderTexture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventHandler::RenderText()
|
||||||
|
{
|
||||||
|
for(int i = 0; i < (int)collections.size(); i++)
|
||||||
|
{
|
||||||
|
collections.at(i)->RenderText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@ namespace Oyster
|
||||||
void Clean();
|
void Clean();
|
||||||
|
|
||||||
void Update(MouseInput& input);
|
void Update(MouseInput& input);
|
||||||
void Render();
|
void RenderTexture();
|
||||||
|
void RenderText();
|
||||||
|
|
||||||
/*Add a collection to the EventHandler will only add collections not already present in the list.
|
/*Add a collection to the EventHandler will only add collections not already present in the list.
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
virtual ~IEventButton(){}
|
virtual ~IEventButton(){}
|
||||||
|
|
||||||
virtual void Render() = 0;
|
virtual void RenderTexture() = 0;
|
||||||
|
virtual void RenderText() = 0;
|
||||||
|
|
||||||
virtual void Update(MouseInput& input) = 0;
|
virtual void Update(MouseInput& input) = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue