Main Menu
Menu

Show posts

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.

Show posts Menu

Messages - texus

#1826
Help requests / Re: Problem with TGUI basics
13 July 2013, 23:10:39
If the example code doesn't work then the problem doesn't lie in the code.

I would be surprised if this would be caused by a library mismatch because I would expect errors in such case.
However I do see that you are linking to the static sfml libs but to the normal tgui lib (without ths '-s' postfix). The line should be 'libtgui-s.a'.

Edit: Also make sure nothing is being printed in the terminal.
#1827
Help requests / Re: Problem with TGUI basics
13 July 2013, 22:03:26
Very strange.
But you will have to provide some simple code that I can actually debug myself, otherwise I won't be able to help much.

Do you have v0.5.2?
#1828
Help requests / Re: Problem with TGUI basics
13 July 2013, 21:08:10
If nothing would be drawn then the screen would be black, as this is the color you use to clear it. The fact that you get a white screen means that something is being drawn.

I can't find a mistake in such code.
You will either have to provide a minimal and complete code that reproduces it or just give me the full code and images. I just needs something that I can compile and test for myself.

Although there is one scenario that I can think of that would cause your trouble.
Are you sure that the textures u use for your map are not destroyed too early? If you would be completely filling your whole screen with tiles and the texture no longer exist (then sfml draws a white tile) then your screen would be completely white.
#1829
General Discussion / Re: C# binding
13 July 2013, 20:51:23
The code has been fully ported (exept TextBox class as it needs to be rewritten).
There are still a few improvements to make like inheriting from IDisposable class, but everything should already work.

There is however no documentation and no tutorials, just some example code.
I haven't even tested in on another pc or on windows.

I actually paused the development due to the lack of interest, but now that I know someone is interested in it I might continue with it in the next few days.

It can currently be downloaded on from tgui.eu/csharp/.
#1830
I don't think you made a mistake, but if this is caused by my texture manager then I might be able to reduce it.

After a quick calculation, if you store the RGBA value of every pixel like my texture manager does then it could easily take 100mb if the images are 800x530.

Does the following code reproduce the high memory usage?
Code (cpp) Select
#include <SFML/Graphics.hpp>
#include <sstream>

template <typename T>
std::string to_string(T value)
{
    std::ostringstream oss;
    oss << value;
    return oss.str();
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");

    sf::Image images[61];
    sf::Texture textures[61];
    sf::Sprite sprites[61];
    sf::String filenames[61];

    for (unsigned int i = 0; i < 61; ++i)
    {
        if (i < 10)
            filenames[i] = "/home/xwm/Frames/cloud00" + to_string(i+1) + ".jpg";
        else
            filenames[i] = "/home/xwm/Frames/cloud0" + to_string(i+1) + ".jpg";

        images[i].loadFromFile(filenames[i]);
        textures[i].loadFromImage(images[i]);
        sprites[i].setTexture(textures[i]);
    }

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }
}


Does this code reduce the memory usage?
Code (cpp) Select
#include <SFML/Graphics.hpp>
#include <sstream>

template <typename T>
std::string to_string(T value)
{
    std::ostringstream oss;
    oss << value;
    return oss.str();
}

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");

    sf::Texture textures[61];
    sf::Sprite sprites[61];
    sf::String filenames[61];

    for (unsigned int i = 0; i < 61; ++i)
    {
        if (i < 10)
            filenames[i] = "/home/xwm/Frames/cloud00" + to_string(i+1) + ".jpg";
        else
            filenames[i] = "/home/xwm/Frames/cloud0" + to_string(i+1) + ".jpg";

        textures[i].loadFromFile(filenames[i]);
        sprites[i].setTexture(textures[i]);
    }

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.display();
    }
}
#1831
You just need the addFrame function.

Code (cpp) Select
animatedPicture->addFrame("Image.png", sf::milliseconds(100));

First parameter is the image filename, second parameter is how long it should be displayed.
#1832
Feature requests / Re: Child windows again
13 July 2013, 17:37:09
It has been pushed to github.
#1833
Feature requests / Re: Child windows again
13 July 2013, 15:57:27
Good idea.

Looks good (except for the tabs everywhere but that was easily fixed), but I'll still change a few lines.
I'll do that later today.

If I changed the lines, do I need to send you the changes so that you can write a pull request (and have your name next to the commit) or do I just add it to git myself (and add your name in the commit message)?
#1834
Feature requests / Re: Child windows again
13 July 2013, 15:34:11
setPosition has to be virtual for other objects.
But when you call Transformable::setPosition explicitly then the virtual won't bother you, only the code in Transformable will be executed.

I should have asked for a different way to patch, because this diff file is a bit hard to read (its even worse because of the changed whitespace, this is because you used tabs instead of spaces).
Could you perhaps run this?
git clone https://github.com/texus/TGUI.git
cd TGUI
cp -R changed_tgui_folder .
git diff > changes.diff


That should give a better patch that I can even immediately apply.
#1835
Feature requests / Re: Child windows again
13 July 2013, 14:45:44
Or you could send me the changed files and then I'll make the diff myself.

On linux this is super-easy and I only have to type this in the terminal:
diff old_tgui_folder tgui_folder_with_changes > changes.diff

I'm sure there is a similar tool on windows too, but the command prompt isn't really something you open every day.
#1836
Feature requests / Re: Child windows again
13 July 2013, 14:07:36
There is a getDisplaySize function in Container, which was added for exactly this reason.

Widget can't access the window, this is why keepInWindow can't be easily done (and I don't really see a use case for it anyway).
#1837
Feature requests / Re: Child windows again
13 July 2013, 13:00:37
Is the inWindow really necessary? Isn't an inParent and dontKeep enough?

QuoteIf you agree I can submit a simple patch later today. It will be just optional feature and default it will be turned off.
I agree, but I might want to make some small changes on the patch before it gets merged.
If you are going to make a pull request on github then maybe it is better to first post the diff file here so that I can see what you changed exactly and perhaps change a few things. That way I can just merge the pull request immediately.
#1838
QuoteAnd it wont move on the Y Vector. It just load last position and stays there :)
You set the position of the widget and before it is even drawn on the screen you set another position. By the time you draw on the window the button will have already been placed on the last position. It is the same problem that you had with the shaking window. You should do something similar to only change the position of the button once every frame.

AnimatedPicture is not 'animated' as in moving, it is used when the image itself changes. So it is not useful in this situation.
#1839
1)
TGUI won't interact with your database, so you'll have to just load the values from the database yourself and then call the corresponding functions to set the value in the tgui widget. But I've never worked with databases before so I can't help much with this.

2)
If you have one config file in the Data folder, then you should give a relative pathname to the images. So button would have the following property:
NormalImage  = "Buttons/Image.png"

Another option would be to have config files for every type of object. So you have a config file in Data/Buttons that only contains the Button section, and you have another config file in Data/Checkboxes that has the Checkbox section and so on. Then you can just have:
NormalImage  = "Image.png"

So the config files can be seperate files or a single file and they contain a relative path to the images. So it shouldn't be to hard to make different folders. The BabyBlue.conf loads different images from different folders, so you might want to take a look at it to see an example.


About the loading from memory...
This isn't supported yet. I'll look into this to see if it can be done easily. If it isn't too much work then I'll add it to v0.6 but if I would have to make a lot of changes then it will be delayed to the next version.

Edit:
Loading from memory is just not possible with the current design. The whole texture managment is build on top of the fact that images are loaded from files. So I would have to find a new design for the texture managment and I would have to change the config files to support this. I'm not even sure if I will be able to add this to the next version.
#1840
It wasn't a typo :D.
I changed that function yesterday.
#1841
If you no longer need objects then you can use the remove function from Gui to remove them. And then you just create the new objects like you created the old ones.

But it is probably better to use panels. So you create a panel for the login screen and a panel for your other screen. In those panels you add the objects you want (just like you added them to the gui). And then you just hide all panels except the login screen. When the login button is clicked, all that you have to do is hide the panel with your login screen and show the other one.

Edit: Here is a small example of what I am trying to say:
Code (cpp) Select
#include <TGUI/TGUI.hpp>

void loadLoginScreen( tgui::Gui& gui )
{
    tgui::Panel::Ptr loginScreen(gui, "LoginScreen");
    loginScreen->setSize(800, 600);

    // Create the background image
    tgui::Picture::Ptr picture(*loginScreen);
    picture->load("xubuntu_bg_aluminium.jpg");
    picture->setSize(800, 600);

    // Create the username label
    tgui::Label::Ptr labelUsername(*loginScreen);
    labelUsername->setText("Username:");
    labelUsername->setPosition(200, 100);

    // Create the password label
    tgui::Label::Ptr labelPassword(*loginScreen);
    labelPassword->setText("Password:");
    labelPassword->setPosition(200, 250);

    // Create the username edit box
    tgui::EditBox::Ptr editBoxUsername(*loginScreen, "Username");
    editBoxUsername->load("TGUI/widgets/Black.conf");
    editBoxUsername->setSize(400, 40);
    editBoxUsername->setPosition(200, 140);

    // Create the password edit box (we will copy the previously created edit box)
    tgui::EditBox::Ptr editBoxPassword = loginScreen->copy(editBoxUsername, "Password");
    editBoxPassword->setPosition(200, 290);
    editBoxPassword->setPasswordCharacter('*');

    // Create the login button
    tgui::Button::Ptr button(*loginScreen);
    button->load("TGUI/widgets/Black.conf");
    button->setSize(260, 60);
    button->setPosition(270, 440);
    button->setText("Login");
    button->bindCallback(tgui::Button::LeftMouseClicked);
    button->setCallbackId(1);
}

void loadOtherScreen( tgui::Gui& gui )
{
    tgui::Panel::Ptr otherScreen(gui, "OtherScreen");
    otherScreen->setSize(800, 600);

    // Create the background image
    tgui::Picture::Ptr picture(*otherScreen);
    picture->load("xubuntu_bg_aluminium.jpg");
    picture->setSize(800, 600);
}

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI window");
    tgui::Gui gui(window);

    // Load the font (you should check the return value to make sure that it is loaded)
    gui.setGlobalFont("TGUI/fonts/DejaVuSans.ttf");

    // Load the widgets
    loadLoginScreen(gui);
    loadOtherScreen(gui);

    // The login screen is the only panel that should be visible
    gui.get("LoginScreen")->show();
    gui.get("OtherScreen")->hide();

    // Main loop
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();

            // Pass the event to all the widgets
            gui.handleEvent(event);
        }

        // The callback loop
        tgui::Callback callback;
        while (gui.pollCallback(callback))
        {
            // Make sure tha callback comes from the button
            if (callback.id == 1)
            {
                // Get the login screen
                tgui::Panel::Ptr loginScreen = gui.get("LoginScreen");

                // Get the username and password
                tgui::EditBox::Ptr editBoxUsername = loginScreen->get("Username");
                tgui::EditBox::Ptr editBoxPassword = loginScreen->get("Password");

                sf::String username = editBoxUsername->getText();
                sf::String password = editBoxPassword->getText();

                // Show the other screen
                loginScreen->hide();
                gui.get("OtherScreen")->show();
            }
        }

        window.clear();

        // Draw all created widgets
        gui.draw();

        window.display();
    }

    return EXIT_SUCCESS;
}
#1842
You can just use the Picture class instead of Button.
They both inherit from ClickableObject which makes them have the LeftMousePressed, LeftMouseReleased and LeftMouseClicked callbacks.

The numbers behind the "Black.png" is the rectangle to load from the file. If you load the whole image then they can be ommited.
The left part of the normal image of the button starts at (0, 25) in the image and has a width of 50 and a height of 50, hence "(0, 25, 50, 50)".

You shouldn't edit Black.conf. You should make a copy of it and in your code load that copy which you can freely edit.

Edit: There is a small tutorial about the config files.

Edit2: I forgot to answer the question about tooltips. This is not yet possible. I did a poll once about what widget I should add. The first two were MessageBox and MenuBar (which now exist in tgui). ToolTip and PopupMenu came 3th and 4th, but they won't be in v0.6.0. They will probably be the next widgets that will be added but they will have to wait for v0.6.1 or v0.7.
#1843
Help requests / Re: Shaking window
09 July 2013, 19:20:40
I just answered on the sfml forum :).
#1844
Installation help / Re: gcc errors in linux
09 July 2013, 10:51:55
Ok, thanks for testing.

I'll fix those warnings later today.
EDIT: Done
#1845
Installation help / Re: gcc errors in linux
09 July 2013, 00:29:40
Any chance you have nvidea graphics?

If I look for the error then I find this page and this page.
Both aren't exactly the same error (different paths), but they both say that a symbolic link has to be made.
#1846
Installation help / Re: gcc errors in linux
09 July 2013, 00:22:08
Never saw that error before. Did you install  graphics drivers?

You should also try installing tgui 0.5 from the ppa as netrick already suggested. I guess it fits the best with the sfml version from the ppa.
#1847
Installation help / Re: gcc errors in linux
08 July 2013, 23:47:12
The sfml package from the ppa is the sfml2-RC version which only works with tgui v0.4.

The development version in the ppa contains the real sfml2 and tgui v0.5.

The errors about 'sf::Font' conversion to 'sf::Font*' do mean that the sfml version is not up-to-date and is still the RC version.

And tgui v0.4 is indeed very buggy, it shouldn't be used.
#1848
General Discussion / Re: Tgui without Boost
07 July 2013, 20:22:25
Yeah, ubuntu is the reason that I aim at gcc 4.6 instead of 4.7.
If it was up to me I would go for gcc 4.8 which I already have on my arch linux (antergos actually) for some time, but then nobody would use my gui anymore :).

But there is no rush to rewrite it to c++11 as it has no advantages (for the user of my gui) but has the disadvantage of not being supported by older compilers. The only good thing would be that the boost dependency would be removed.
#1849
You have a nice day too.
Its hot here in Antwerp as well :).
#1850
Ok, so the version that I just pushed to github should compile then.

Thanks for taking the time to investigate what was wrong.