1
SFML projects / ParabolaEngine - 2D Game Framework
« on: February 01, 2011, 07:50:30 am »
This is intense. I'd be glad to use this. Once you start having the major releases, I can host you at my site.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Thank you, I'll have a look but I think I won't use it – I prefer do it myself even I it takes time because I don't want external dependences, but this may be to be discussed if it is very adapted to SFML joystick backend, of course.
#include <SFML/Graphics.hpp>
#include "sfui/sfui.h"
#include <iostream>
void printPressedCallback(void* n)
{
bool *bScreen = (bool*)n;
if(*bScreen)
*bScreen = false;
else
*bScreen = true;
std::cout << "printPressedCallback" << std::endl;
}
void printHeldCallback(void* n)
{
std::cout << "printHeldCallback" << std::endl;
}
void printReleasedCallback(void* n)
{
std::cout << "printReleasedCallback" << std::endl;
}
void printUntouchedCallback(void* n)
{
std::cout << "printUntouchedCallback" << std::endl;
}
void printHoverEnterCallback(void* n)
{
std::cout << "printHoverEnterCallback" << std::endl;
}
void printHoveringCallback(void* n)
{
std::cout << "printHoveringCallback" << std::endl;
}
void printHoverLeaveCallback(void* n)
{
std::cout << "printHoverLeaveCallback" << std::endl;
}
void printNoHoverCallback(void* n)
{
std::cout << "printNoHoverCallback" << std::endl;
}
int main()
{
bool bScreen = false;
sf::ui::Gui *gui = new sf::ui::Gui(sf::Color(255,255,0), sf::Color(0,0,0),sf::Color(255,255,255), 13.);
sf::ui::UIButton *button = new sf::ui::UIButton("Switch!",13.);
sf::ui::UIButton *button2 = new sf::ui::UIButton("Switch!",13.);
sf::ui::UIButton *button3 = new sf::ui::UIButton("Button 3",13.);
sf::ui::UIButton *button4 = new sf::ui::UIButton("Button 4",13.);
sf::ui::UILabel *label = new sf::ui::UILabel("Label:",13.);
sf::ui::UICheckbox *checkbox = new sf::ui::UICheckbox(true);
sf::ui::UITextField *textbox = new sf::ui::UITextField("TextField ",18., false, 300);
button2->setX(10);
button2->setY(60);
button->setX(10);
button->setY(120);
button3->setX(10);
button3->setY(150);
button4->setX(10);
button4->setY(300);
button4->setWidth(50);
button4->setHeight(50);
textbox->setX(10);
textbox->setY(5);
label->setX(10);
label->setY(250);
checkbox->setX(10);
checkbox->setY(180);
button->setPressedCallBack (new sf::ui::UICallBackStruct(&printPressedCallback,&bScreen));
button2->setPressedCallBack (new sf::ui::UICallBackStruct(&printPressedCallback,&bScreen));
button->setHeldCallBack (new sf::ui::UICallBackStruct(&printHeldCallback));
button->setReleasedCallBack (new sf::ui::UICallBackStruct(&printReleasedCallback));
button->setUnTouchedCallBack (new sf::ui::UICallBackStruct(&printUntouchedCallback));
button->setHoverEnterCallBack (new sf::ui::UICallBackStruct(&printHoverEnterCallback));
button->setHoveringCallBack (new sf::ui::UICallBackStruct(&printHoveringCallback));
button->setHoverLeaveCallBack (new sf::ui::UICallBackStruct(&printHoverLeaveCallback));
button->setNoHoverCallBack (new sf::ui::UICallBackStruct(&printNoHoverCallback));
// Create main window
sf::RenderWindow App(sf::VideoMode(500, 300), "SFUI");
App.EnableKeyRepeat(true);
gui->addWindow("[Main]",&App);
gui->addObject("[Main]","[Button]:One:Two",button);
gui->addObject("[Main]","[Button]:One:Two:Three",button3);
gui->addObject("[Main]","[Button]:One:Two:Four",button4);
gui->addObject("[Main]","[Button]:One:Three",button2);
gui->addObject("[Main]","[Button]:One:Two:Label",label);
gui->addObject("[Main]","[Button]:One:Three:Checkbox",checkbox);
gui->addObject("[Main]","[Button]:One:Three:textbox",textbox);
button->setColor(sf::Color(100,200,100));
button->setTextColor(sf::Color(255,255,0));
sf::ui::UICheckbox* ch = (sf::ui::UICheckbox*)gui->getObject("[Main]","[Button]:One:Two:Checkbox");
while (App.IsOpened())
{
sf::Event Event;
while (App.GetEvent(Event))
{
if (Event.Type == sf::Event::Closed)
App.Close();
}
App.Clear(sf::Color(170,175,180));
gui->poll("[Main]");
if(bScreen)
{
gui->process("[Main]","[Button]:One:Three");
gui->draw("[Main]","[Button]:One:Three");
}else {
gui->process("[Main]","[Button]:One:Two");
gui->draw("[Main]","[Button]:One:Two");
}
App.Display();
}
delete gui;
return EXIT_SUCCESS;
}