Hi Texus,
Ok I tried the below which is pretty much as per one of tutorials and example codes.
Here is my new widget config file - rest of the txt file is unchanged and i did not change the Button section at all. I thought maybe it couldn't find the png as it was in a different folder, so I copied it into the same folder as the rome.txt file and removed the ..\..\ lines but same thing.
Note when I change to just below then it works fine
tgui::Button::Ptr button = theme->load("Button");
Button {
NormalImage : "Black.png" Part( 0, 64, 45, 50) Middle(10, 0, 25, 50);
HoverImage : "Black.png" Part(45, 64, 45, 50) Middle(10, 0, 25, 50);
DownImage : "Black.png" Part(90, 64, 45, 50) Middle(10, 0, 25, 50);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
Button.CustomButtonRomeAR {
NormalImage : "romeNationIcon_v2.png" Part( 248, 0, 48, 64);
HoverImage : "romeNationIcon_v2.png" Part( 248, 65, 48, 64);
DownImage : "romeNationIcon_v2.png" Part( 248, 129, 48, 64);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
Button.CustomButtonRomeCMD {
NormalImage : "romeNationIcon_v2.png" Part( 296, 0, 48, 64);
HoverImage : "romeNationIcon_v2.png" Part( 296, 65, 48, 64);
DownImage : "romeNationIcon_v2.png" Part( 296, 129, 48, 64);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
Button.CustomButtonRomeHC {
NormalImage : "romeNationIcon_v2.png" Part( 152, 0, 48, 64);
HoverImage : "romeNationIcon_v2.png" Part( 152, 65, 48, 64);
DownImage : "romeNationIcon_v2.png" Part( 152, 129, 48, 64);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
Button.CustomButtonRomeHI {
NormalImage : "romeNationIcon_v2.png" Part( 56, 0, 48, 64);
HoverImage : "romeNationIcon_v2.png" Part( 56, 65, 48, 64);
DownImage : "romeNationIcon_v2.png" Part( 56, 129, 48, 64);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
Button.CustomButtonRomeLC {
NormalImage : "romeNationIcon_v2.png" Part( 200, 0, 48, 64);
HoverImage : "romeNationIcon_v2.png" Part( 200, 65, 48, 64);
DownImage : "romeNationIcon_v2.png" Part( 200, 129, 48, 64);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
Button.CustomButtonRomeLI {
NormalImage : "romeNationIcon_v2.png" Part( 104, 0, 48, 64);
HoverImage : "romeNationIcon_v2.png" Part( 104, 65, 48, 64);
DownImage : "romeNationIcon_v2.png" Part( 104, 129, 48, 64);
TextColorNormal : rgb(190, 190, 190);
TextColorHover : rgb(250, 250, 250);
TextColorDown : rgb(250, 250, 250);
}
#include <TGUI/TGUI.hpp>
#include <string>
#include <math.h>
#define THEME_CONFIG_FILE "C:\\programming\\Debug\\widgets\\rome.txt"
using namespace std;
void buttonFunction()
{
std::cout << "Button pressed" << std::endl;
}
void loadWidgets(tgui::Gui& gui)
{
// Load the black theme
tgui::Theme::Ptr theme = std::make_shared<tgui::Theme>(THEME_CONFIG_FILE);
// Create the login button
tgui::Button::Ptr button = theme->load("Button.CustomButtonRomeHI");
button->setSize(100, 40);
button->setPosition(50, 50);
button->setText("Test");
button->connect("pressed", buttonFunction);
gui.add(button);
// Call the login function when the button is pressed
}
int main()
{
sf::RenderWindow gameWindow;
sf::VideoMode desktop;
sf::Event event;
tgui::Gui gui;
desktop = sf::VideoMode::getDesktopMode();
gameWindow.create(sf::VideoMode(desktop.width, desktop.height, desktop.bitsPerPixel), "Test");
gameWindow.setPosition(sf::Vector2i(0, 0));
gui.setWindow(gameWindow);
gui.setGlobalFont("C:\\programming\\Debug\\inputfiles\\fonts\\DejaVuSans.ttf");
loadWidgets(gui);
// Main loop
while (gameWindow.isOpen())
{
while (gameWindow.pollEvent(event))
{
// When the window is closed, the application ends
if (event.type == sf::Event::Closed)
gameWindow.close();
// Pass the event to all the widgets
gui.handleEvent(event);
}
gameWindow.clear();
gui.draw();
gameWindow.display();
}
return 0;
}