need help with loading buttons

Started by DTSCode, 30 October 2013, 07:46:08

DTSCode

in the following code, it acts as if im not drawing anything. i cant figure it out


/*
              Program: uploader
              Version: 2.1
            Author(s): DTSCode
                 Date: N/A
              Compile: $g++ main.cpp -o uploader -std=c++11 -ltgui
                            -lsfml-graphics -lsfml-window -lsfml-system
            Target OS: Windows 7
    Special Thanks To: Cire
                       naraku9333
          Description: Upload statuses to facebook. Used by Micheal
*/

/*
    special thanks to:
        cire
        naraku9333
*/

#include <TGUI/TGUI.hpp>

int main()
{
    sf::RenderWindow   App          (sf::VideoMode(800, 600), "Fuck it. Uploads Happen.");
    tgui::Gui          Gui          (App);
    tgui::Picture::Ptr Background   (Gui, "BackgroundImage");
    tgui::EditBox::Ptr Picture      (Gui, "PictureFolder"),
                       Status       (Gui, "StatusList");
    tgui::Label::Ptr   PictureLabel (Gui),
                       StatusLabel  (Gui);
    tgui::Button::Ptr  Button       (Gui);

    if(!Gui.setGlobalFont("font/Exo-Light.otf")) return -1;

    App.setPosition              (sf::Vector2i(125, 75));
    Background   ->load          ("Background.jpg");
    Picture      ->load          ("widgets/EditBox/White");
    Picture      ->setSize       (400, 40);
    Picture      ->setPosition   (200, 140);
    Status       ->load          ("widgets/EditBox/White");
    Status       ->setSize       (400, 40);
    Status       ->setPosition   (200, 290);
    PictureLabel ->setText       ("Pictures:");
    PictureLabel ->setPosition   (200, 100);
    StatusLabel  ->setText       ("Status:");
    StatusLabel  ->setPosition   (200, 250);
    Button       ->load          ("widgets/White.conf");
    Button       ->setSize       (260, 60);
    Button       ->setPosition   (270, 440);
    Button       ->setText       ("Start");
    Button       ->bindCallback  (tgui::Button::LeftMouseClicked);
    Button       ->setCallbackId (1);

    while(App.isOpen())
    {
        sf::Event Event;

        while(App.pollEvent(Event))
        {
            if(Event.type == sf::Event::Closed)                                               App.close();
            if(Event.type == sf::Event::KeyPressed && Event.key.code == sf::Keyboard::Escape) App.close();

            Gui.handleEvent(Event);
        }   

        tgui::Callback Callback;

        while(Gui.pollCallback(Callback))
        {
            if (Callback.id == 1)
            {
                tgui::EditBox::Ptr PicturesBox = Gui.get("PictureFolder");
                tgui::EditBox::Ptr StatusBox   = Gui.get("StatusList");

                sf::String PictureFolder = PicturesBox ->getText();
                sf::String StatusList    = StatusBox   ->getText();
            }
        }

        App.clear();

        Gui.draw();

        App.display();
    }

    return 0;
}

texus

"widgets/EditBox/White" should be "widgets/White.conf".

The code gets into an endless loop trying to read from a folder instead of a text file.

DTSCode

thanks. new problem: i fixed that but now it gives these errors upon running (and doesnt show the edit boxes or the button)
TGUI error: Failed to parse value for NormalImage_L in section EditBox in widgets/White.conf.
TGUI error: Failed to parse value for NormalImage_L in section EditBox in widgets/White.conf.
TGUI error: Failed to parse value for NormalImage_L in section Button in widgets/White.conf.

texus

This might be caused when the images can't be loaded.
Make sure that the file given by the value of NormalImage_L ("Button/White/Normal.png" I guess) exists.
The path is relative from the config file (so the Button folder has to be in the same folder as White.conf).

I guess the errors could be more clear. I'll change that later today.