#include "UserInterface.h"
UserInterface::UserInterface(tgui::Window* pWindow)
{
window = pWindow;
rect.setPosition(0, 500);
rect.setFillColor(sf::Color(50,50,50));
rect.setPosition(0, 500);
rect.setSize(sf::Vector2f(800, 100));
}
void UserInterface::loadUI()
{
// MAIN MENU
tgui::Label* creationLabel = window->add<tgui::Label>("CreationLabel");
creationLabel->setText("General");
creationLabel->setPosition(20, 510);
creationLabel->setSize(100, 20);
creationLabel->setTextSize(14);
tgui::Button* newMapButton = window->add<tgui::Button>("SaveMap");
newMapButton->load("TGUI/objects/Button/Black");
newMapButton->setSize(100, 20);
newMapButton->setPosition(20, 530);
newMapButton->setText("Save Map");
newMapButton->callbackID = 1;
tgui::Button* loadMapButton = window->copy(newMapButton, "LoadMap");
loadMapButton->setPosition(20, 560);
loadMapButton->setText("Load Map");
loadMapButton->callbackID = 2;
tgui::Button* predefEventButton = window->copy(newMapButton, "EditEvents");
predefEventButton->setPosition(160, 530);
predefEventButton->setText("Edit Events");
predefEventButton->setSize(180, 20);
predefEventButton->callbackID = 3;
tgui::Button* makeEventButton = window->copy(newMapButton, "MakeEvent");
makeEventButton->setPosition(160, 560);
makeEventButton->setText("Add Event to Map");
makeEventButton->setSize(180, 20);
makeEventButton->callbackID = 4;
tgui::Checkbox* collisionBox = window->add<tgui::Checkbox>("ShowCollisionLayer");
collisionBox->load("TGUI/objects/Checkbox/Black");
collisionBox->setPosition(350, 530);
collisionBox->setText(" Show Collision Layer");
collisionBox->setTextSize(14);
collisionBox->setSize(15, 15);
tgui::Checkbox* dCollisionBox = window->copy(collisionBox, "DrawCollisionLayer");
dCollisionBox->setPosition(350, 560);
dCollisionBox->setText(" Draw on Collision Layer");
tgui::Button* toggleTileButton = window->copy(newMapButton, "ToggleTiles");
toggleTileButton->setPosition(540, 530);
toggleTileButton->setText("Toggle Tile List");
toggleTileButton->setSize(180, 20);
toggleTileButton->callbackID = 6;
tgui::Button* propertiesButton = window->copy(newMapButton, "Properties");
propertiesButton->setPosition(540, 560);
propertiesButton->setText("Map Properties");
propertiesButton->setSize(180, 20);
propertiesButton->callbackID = 7;
}
void UserInterface::adjustUI(sf::Event& event)
{
// MAIN MENU
tgui::Button* newMapButton = window->get<tgui::Button>("SaveMap");
tgui::Button* loadMapButton = window->get<tgui::Button>("LoadMap");
tgui::Label* creationLabel = window->get<tgui::Label>("CreationLabel");
tgui::Checkbox* collisionBox = window->get<tgui::Checkbox>("ShowCollisionLayer");
tgui::Checkbox* dCollisionBox = window->get<tgui::Checkbox>("DrawCollisionLayer");
tgui::Button* predefEventButton = window->get<tgui::Button>("EditEvents");
tgui::Button* makeEventButton = window->get<tgui::Button>("MakeEvent");
tgui::Button* toggleTileButton = window->get<tgui::Button>("ToggleTiles");
tgui::Button* propertiesButton = window->get<tgui::Button>("Properties");
creationLabel->setPosition(20, event.size.height - 90);
newMapButton->setPosition(20, event.size.height - 70);
loadMapButton->setPosition(20, event.size.height - 40);
collisionBox->setPosition(350, event.size.height - 70);
dCollisionBox->setPosition(350, event.size.height - 40);
predefEventButton->setPosition(160, event.size.height - 70);
makeEventButton->setPosition(160, event.size.height - 40);
toggleTileButton->setPosition(540, event.size.height - 70);
propertiesButton->setPosition(540, event.size.height - 40);
rect.setPosition(0, event.size.height - 100);
rect.setSize(sf::Vector2f(event.size.width, 100));
}
void UserInterface::handleCallback(tgui::Callback& callback)
{
// Make sure tha callback comes from the button
if (callback.callbackID == 1)
{
// Make sure the button was pressed
if (callback.trigger == tgui::Callback::mouseClick)
{
}
}
}
bool UserInterface::abortClick(int x, int y)
{
// TODO
}
void UserInterface::drawBackground()
{
window->draw(rect);
}