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 - Aiiro

#1
Alright I'll give you a bit of context.
So I have the Widgets class, which has all the widgets I need for my game.
I call the loadMainMenu function of the widget class and then I only call other loadWidgets class with events that start in loadMainMenu, so that's the only thing that I have in my main about the Widgets class.
After the Main menu I press a button and then have other steps before going into a form where I would want the AnimatedSprite there. I also have a combobox where I have a list of name and when I select another item, the Animatedsprite should change according to what was selected..
What my main function looks like (without includes) :
RenderWindow window(VideoMode(1080, 720), "CatherineIA");
    window.setFramerateLimit(60);
    tgui::Gui gui(window);

    Widgets widgetHandler;

    widgetHandler.loadMainMenu(gui);

    sf::Music music;
    music.openFromFile("Music_&_Sounds/Music_Wally.ogg");
    music.setLoop(true);
    music.setVolume(50);
    music.play();

    while (window.isOpen())
    {

        sf::Event event;

        while (window.pollEvent(event))
        {

            if (event.type == sf::Event::Closed)
            {

                window.close();

            } else if (event.type == sf::Event::Resized)
            {
                window.setView(sf::View(sf::FloatRect(0, 0, event.size.width, event.size.height)));
                gui.setView(window.getView());
            }

            gui.handleEvent(event);


        }


        window.clear();

        gui.draw();

        window.display();

    }


Thanks for your help.
#2
I forgot to add windowWidth and windowHeight in the code I gave you, but it's not what causes the issue.
#3
Yes, sorry I didn't make much sense. Here is how I do it :
void Widgets::pkmAnim(Gui& gui, string pkmName)
{

    sf::Texture textTest;
    if (!textTest.loadFromFile("Sprites/" + pkmName + "/" + pkmName + ".png"))
    {
        cout << "Failed to load spritesheet" << endl;
    }

    Animation pkmAnim;
    pkmAnim.setSpriteSheet(textTest);

    string line;

    fstream txtFile;
    txtFile.open("Sprites/" + pkmName + "/" + pkmName + ".txt");

    string val1, val2, val3, val4, val5, val6;
    int i;

    while(getline(txtFile, line))
    {
        istringstream isstream(line);

        getline(isstream,val1, ' ');
        getline(isstream,val2, ' ');
        getline(isstream,val3, ' ');
        getline(isstream,val4, ' ');
        getline(isstream,val5, ' ');
        getline(isstream,val6, ' ');

        pkmAnim.addFrame(IntRect(stoi(val3), stoi(val4), stoi(val5), stoi(val6)));
        i++;
    }

    AnimatedSprite animatedSprite(sf::seconds(0.05), true, false);

    sf::Clock frameClock;

    sf::Time frameTime = frameClock.restart();

    animatedSprite.play(pkmAnim);

    animatedSprite.update(frameTime);

    auto panel = std::make_shared<tgui::Panel>(windowWidth / 5, windowHeight * 2/10);
    panel->setBackgroundColor(sf::Color::Black);
    panel->setPosition(windowWidth / 20, windowHeight * 0.3/10);

    auto canvasAnim = std::make_shared<tgui::Canvas>(windowWidth / 5, windowHeight * 2/10);
    canvasAnim->setPosition(windowWidth / 20, windowHeight * 0.4/10);
    panel->add(canvasAnim);
    gui.add(panel);

    canvasAnim->clear();
    canvasAnim->draw(animatedSprite);
    canvasAnim->display();

}
#4
Hello again.

I have a question about the class AnimatedSprite (https://github.com/SFML/SFML/wiki/Source:-AnimatedSprite) in SFML and TGUI.
So I created the class AnimatedSprite and tested it, it works well with a SFML window, however it doesn't work in a TGUI window. I suppose it's because TGUI only draw the widgets once and don't update unless an event is trigerred.
Do you know a way to add animated sprites in a TGUI window or it's just impossible ?

Thanks in advance,
Aiiro
#5
Alright, no problems, I think it would be a great addition if you have the time to.
I'll look into Windows API since it won't be used on another platform.

Thanks for the information.
#6
Hello,

So I need to ask the user on where he wants to save a file or open one, I already tried to see with wxWidgets, but I don't really know how to implemant tgui with this.
Anyone already had done this before ?

Thanks in advance,

Aiiro
#7
Alright, so I compiled everything myself with a MinGW compilator that I downloaded apart from Code::Blocks.

And it seems to work !

It was just a problem with my compilator version, I guess.
Anyway, thanks for your help.

Keep up the good work, this library is really well-done !
#8
Here is what I get :
Using built-in specs.
COLLECT_GCC=mingw32-g++.exe
COLLECT_LTO_WRAPPER=c:/program files (x86)/codeblocks/mingw/bin/../libexec/gcc/m
ingw32/4.7.1/lto-wrapper.exe
Target: mingw32
Configured with: ../../src/gcc-4.7.1/configure --build=mingw32 --enable-language
s=c,c++,ada,fortran,objc,obj-c++ --enable-threads=win32 --enable-libgomp --enabl
e-lto --enable-fully-dynamic-string --enable-libstdcxx-debug --enable-version-sp
ecific-runtime-libs --with-gnu-ld --disable-nls --disable-win32-registry --disab
le-symvers --disable-build-poststage1-with-cxx --disable-werror --prefix=/mingw3
2tdm --with-local-prefix=/mingw32tdm --enable-cxx-flags='-fno-function-sections
-fno-data-sections' --with-pkgversion=tdm-1 --enable-sjlj-exceptions --with-bugu
rl=https://tdm-gcc.tdragon.net/bugs
Thread model: win32
gcc version 4.7.1 (tdm-1)
#9
I downloaded the precompiled for MinGW compiler (default one in Code Blocks)
I followed the tutorials on TGUI and SFML official websites to set up the libs in Code::Blocks, so it should be okay (I also checked more than once if everything was alright and everything seems fine).

It worked once some months ago and then it stopped working for some reasons (I didn't change anything in the settings and nothing in the code that could have break it) but it was on another PC, so not the same Code Blocks, I actually reinstalled everything again yesterday.

Thanks again
#10
Yes, it doesn't work, I saw your little change in the code.
It's really strange...

Thanks again
#11
Thanks for the reply.
I was in a rush, so I couldn't do a proper example code, sorry about that.

So I tried the code you provided me and it still doesn't work.
I really don't know what is wrong with all of it :/

Thanks again
#12
Hello,

I have issues with callbacks with my buttons in my project :
Button::Ptr quit(gui);
    quit->load("widgets/White.conf");
    quit->setText("Quit");
    quit->setSize(230,50);
    quit->setCallbackId(12);
    quit->bindCallback(tgui::Button::LeftMouseClicked);
    quit->setPosition(800,600);

This is a bit of code in one of my functions, but all buttons are the same (with different callback IDs of course) and here it is how I handle it :
while (window.isOpen())
    {

        sf::Event event;

        while (window.pollEvent(event))
        {

            if (event.type == sf::Event::Closed)
            {

                window.close();

            }

            gui.handleEvent(event);


        }

            tgui::Callback callback;
            while (gui.pollCallback(callback))
            {

                if (callback.id == 12)
                {

                    window.close();

                }

Again it's a just a bit of code, but all other callbacks are handled the same way.
The thing is that I can't even click on the buttons, it's not like nothing is appearing when I click on them, I don't even see I click on them.
I tried a lot of things, but I just can't figure out why it is not working.

Thanks for your help.