Nothing too fancy(for now....mwa ha ha), but its a start.
add somewhere to Game.h
void DrawGUIButton(std::string caption, int posX, int posY, int sizeX, int sizeY, int r, int g, int b);
and the function
Code: Select all
//added GUI
void Game::DrawGUIButton(std::string caption, int posX, int posY, int sizeX, int sizeY, int r, int g, int b)
{
//draw button border
gfx.DrawRectangle(posX, posY, sizeX+6, sizeY+6, r, g, b);
//todo: draw button highlight border
//todo position (if & center) text inside buttons
//center_caption (using total len of string)
int textPosX = posX+4;
int textPosY = posY+4;
gfx.WriteString(Consolas, caption, textPosX, textPosY, D3DCOLOR_XRGB(r, g, b));
}
Anyways, here's the implementation.
Code: Select all
//Play Online Button Code
if (IsMouseInRectangle(100, 200, 169, 224))
{
// gfx.DrawImage(100, 200, Sprite_Button_PlayOnline_HL); //commented out
DrawGUIButton("Engage!", 100, 200, 169, 224, 35, 35, 200);
if (UserClicksLeftClick())
{
CurrentScreen = Screen_LoginScreen;
}
}
else
// gfx.DrawImage(100, 200, Sprite_Button_PlayOnline); //commented out
DrawGUIButton("PlayOnline", 100, 200, 169, 224, 255, 0, 0);