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

#1576
Seems like the wav file is currupted. Try with another file and see if it works.
#1577
Does it print something in the command prompt? Its probably going to say that cat.wav can't be found.

If I remember correctly, then for Visual Studio you have to place the file in either "C:\Users\corleone\Documents\Visual Studio 2010\Projects\MySfml\MySfml\Debug" or "C:\Users\corleone\Documents\Visual Studio 2010\Projects\MySfml\MySfml\Release" depending on whether you are building in debug or release mode.
#1578
Help requests / Re: callback not triggered
09 September 2013, 16:23:02
The callback id does get set, but it is the binding that doesn't happen.
So in your code you should have this:
gui.get("btnName")->bindCallback(tgui::Button::LeftMouseClicked);

Thats the part that isn't done automatically yet when loading from a file.
#1579
Help requests / Re: callback not triggered
09 September 2013, 16:00:10
Take a look at this topic for my answer: https://forum.tgui.eu/index.php/topic,134.0.html
#1580
You are recreating the SoundBuffer every frame.

The sound is temporary as well.
else {
    sf::Sound sound;        // <-  Sound object gets created
    sound.setBuffer(buffer);
    sound.play();
}   // <- Sound object gets destroyed as it goes out of scope


You should declare the SoundBuffer and Sound objects at the beginning of the main function.
So these lines should be moved to earlier in your program (anywhere above the main loop).
sf::SoundBuffer buffer;
sf::Sound sound;
#1581
I think I can write your assignment in less than 100 lines, so I can't give to many details (otherwise I will be making half of your assignment).

You need to load the sounds with sfml.
Then insert the names of the animals into the list box with the addItem function.
When receiving callback from the button (see part 3 of introcuction tutorial for more information about callbacks), you should check which animal is selected with the getSelectedItem function. And depending on the string that the function returns you should play the corresponding sound.
#1582
Good to hear that it is working now.

But I changed my forum settings now so you can no longer delete posts, its really confusing if posts are suddenly missing.
#1583
The error is quite clear, so I can only ask one thing: "Are you 100% sure that that file exists?"

Try with "C:/Users/corleone/Documents/Visual Studio 2010/Projects/MySfml/MySfml/TGUI-0.6-alpha2-Visual-C++10-2010-32-bits/TGUI-0.6-alpha2/widgets/Black.conf", which is the default style and should work. If that works then you can try with creating your own config file. But if this is just a small test project then you might want to keep the default Black style until you have more experience with tgui.

Edit: Did you just delete your previous post?
#1584
Obviously your program should be able to find the files.

It is looking for "TGUI/fonts/DejaVuSans.ttf" and if I am not mistaking then VS look for it next to the executable. So you need a folder called TGUI next to your executable (in the Debug or Release folder). Or use a full path like you were using, but then the program doesn't work on other computers.

Edit: In your current setup it should be something like "../TGUI-0.6-alpha2/fonts/DejaVuSans.ttf" at the moment.
#1585
You are creating a button every frame. You should only create it once.
You should also call the window.clear function (you should uncomment it). In sfml you must redraw every frame entirely.

The code should look more like this:
#include <SFML/Audio.hpp>
#include <TGUI/TGUI.hpp>
#include <conio.h>

int main()
{
    // Create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "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");

    tgui::Button::Ptr button(gui);
    button->load("TGUI/widgets/Black.conf");

    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 (if there would be widgets)
            gui.handleEvent(event);
        }

        window.clear();

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

        window.display();
}
return EXIT_SUCCESS;
}



What errors are you getting in the command prompt?

To create a list box, just do like you would create a button:
tgui::ListBox::Ptr listBox(gui);
listBox->load("TGUI/widgets/Black.conf");

And then use setSize to give it the correct size, addItem function to add items to it, ...
Here is the list of other function you can call on the listbox: https://tgui.eu/dcmtn/v0.6/classtgui_1_1ListBox.html.
#1586
Ah, thanks for pointing that out. Its a small mistake in the tutorial (the tutorials were written while v0.5 was still being changed and it seems like I forgot to update that part of the tutorial after changing the add function).
It has been fixed now.

You should put most trust in the example code, it was updated more regulary.
#1587
Where did you find that code exactly? That is code for tgui v0.4, while you are either using v0.5 or v0.6.

tgui v0.5:
Code (cpp) Select
tgui::Button* button = window.add<tgui::Button>();
button->load("TGUI/objects/Button/Black");


tgui v0.6:
Code (cpp) Select
tgui::Button::Ptr button(gui);
button->load("TGUI/widgets/Black.conf");
#1588
You have added the widgets, but you don't remove them.
When returning from the function you should also call w.removeAllObjects().

Otherwise the widgets from player1 are still drawn behind the ones from player2.
#1589
Feature requests / Re: Logo for TGUI=)
07 September 2013, 16:16:29
I would use a button or checkbox as logo. Something that can be associated with a gui.
The only words I think of at the moment are simple and easy.
#1590
Feature requests / Re: Logo for TGUI=)
07 September 2013, 13:40:31
That would indeed be nice.

But I'm not sure if anyone is going to volunteer to make a logo, and I'm not creative enough to do draw one myself.