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

#1531
DotNet / Re: Linux usage
24 September 2013, 17:47:45
I finally had the time to continue with the c# version again.
You were right, if you download the right files then there aren't really any problems with 64bit.

I needed to add two files to get it working. Putting it in app.exe.config doesn't seem to work.
The tutorial will be updated in the next few days to contain this information.

sfmlnet-graphics-2.dll.config
<configuration>
<dllmap dll="csfml-window-2" target="/usr/local/lib/libcsfml-window.so.2.1"/>
<dllmap dll="csfml-graphics-2" target="/usr/local/lib/libcsfml-graphics.so.2.1"/>
</configuration>


Tao.OpenGl.dll.config
<configuration>
<dllmap dll="opengl32.dll" target="/usr/lib/libGL.so.1.2.0"/>
</configuration>
#1532
QuoteI can compile SFML fine.
And it uses the same compiler (h:/MinGW/bin/gcc.exe) ?

The error occurs even before my cmake script gets run which indicates that the problem lies with the compiler or cmake. So I'm even more surprised that you can compile one project and not the other.
#1533
QuoteUsing the CodeBlocks MinGW compiler
QuoteCheck for working C compiler: h:/MinGW/bin/gcc.exe
That is not the compiler from CodeBlocks!
The one from CodeBlocks is in the 'C:\Program Files\CodeBlocks\MinGW\bin' folder.

Why are you on the H drive instead of the C drive anyway? It isn't really the default.
#1534
Right after you started this topic I installed the same CMake version and tried recompiling tgui.
I didn't have any problems, so if reinstalling doesn't work then I have absolutely no idea what could be causing this.

Are you able to compile sfml, or is this only a problem with tgui?
#1535
I doubt that it is going to be a bug in tgui if it happens on all widgets and not in only one widget.
If it doesn't work with sf::Text then there is nothing I can do. All widgets just use sf::Text internally.
#1536
After reading that issue again, it might have been fixed already.
Does it only happen when creating a tgui::Label or also when just drawing an sf::Text? Because I can only help in the first situation.
#1537
This is a limitation in sfml.

"Currently, fonts are always anti-aliased and this cannot be changed."
https://github.com/LaurentGomila/SFML/issues/254
#1538
I didn't have much time earlier, so just ignore my previous answer.

I'm now blocking the update function when the window isn't focused, so any animation (at this point only the flashing caret) will be paused as long as the window is unfocused.

There is only one small thing, I don't know if the window is going to be focused when the program starts. This is something that might be OS-dependant (and I only tested on linux so far) so let me know when the caret doesn't flicker at all.
#1539
This is actually your responsibility. Your program is still running in the background.

When the window loses focus you should ignore all events (and don't call gui.handleEvent) until the window gets focused again.
#1540
You could try reinstalling cmake.
I've seen strange stuff before on windows that was solved by either reinstalling codeblocks or cmake. Although I never had this particular error before.
#1541
I can't test it now, I'm not at home.

Try with your old code and look at what I changed in the part where callback.id is 2.
Maybe I just removed a little too much.
#1542
You commented out too much code when callback.id is 2. You should still add the sound to the list when clicking the 'add animal' button.

I removed some of the commented parts during searching for the mistake.
#include <SFML/Audio.hpp>
#include <TGUI/TGUI.hpp>
#include <fstream>

int main()
{
std::list<sf::SoundBuffer> buffers;
std::list<sf::Sound> sounds;

    sf::RenderWindow window(sf::VideoMode(800, 600), "Window");
    tgui::Gui gui(window);

std::string name;

tgui::ListBox::Ptr listBox(gui);

tgui::EditBox::Ptr editBox(gui);
std::ifstream ifile;
ifile.open("animals.txt");
if(ifile.is_open())
{
while(ifile>>name)
{

ifile.ignore(10,'\n');
listBox->addItem(name);

buffers.push_back(sf::SoundBuffer());
buffers.back().loadFromFile(name + ".wav");

sounds.push_back(sf::Sound());
sounds.back().setBuffer(buffers.back());

}

}
else
{
std::cout<<"ifile.txt does not open properly!"<<std::endl;
}
ifile.close();


    // 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");
button->setPosition(280, 250);
    button->setText("SPEAK");
    button->setSize(200, 40);


listBox->load("TGUI/widgets/Black.conf");
listBox->setSize(150, 120);
    listBox->setItemHeight(30);
    listBox->setPosition(300, 30);
listBox->setCallbackId(3);

tgui ::Callback callback;

button->bindCallback(tgui::Button::LeftMouseClicked);
button->setCallbackId(1);


    editBox->load("TGUI/widgets/Black.conf");
    editBox->setBorders(6, 4, 6, 4);
    editBox->setPosition(230, 350);
    editBox->setText("Add Animal Name Here!");
editBox->setSize(360, 40);

tgui::Button::Ptr button1(gui);
    button1->load("TGUI/widgets/Black.conf");
button1->setPosition(280, 450);
    button1->setText("Add Animal");
    button1->setSize(200, 40);

button1->bindCallback(tgui::Button::LeftMouseClicked);
button1->setCallbackId(2);


    while (window.isOpen())
    {
/////////////////////////////////////////////////////

while (gui.pollCallback(callback))
{

if(callback.id==1)
{
    if (listBox->getSelectedItemIndex() != -1)
                    {
                        auto it = sounds.begin();
                        std::advance(it, listBox->getSelectedItemIndex());
                        it->play();
                    }
}

if(callback.id==2)
{
name=editBox->getText();
listBox->addItem(name);

buffers.push_back(sf::SoundBuffer());
buffers.back().loadFromFile(editBox->getText() + ".wav");

sounds.push_back(sf::Sound());
sounds.back().setBuffer(buffers.back());
sounds.back().setPitch(1.5f);
sounds.back().setVolume(80);
/*
auto it = sounds.begin();
std::advance(it, listBox->getSelectedItemIndex());
it->play();
*/

}


}

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();

}

std::ofstream ofile("animals.txt");
if (ofile.is_open())
{
auto& items = listBox->getItems();
for (auto it = items.cbegin(); it != items.cend(); ++it)
{
ofile << it->toAnsiString() << std::endl;
}
}
else
{
std::cout<<"ofile does not open properly !"<<std::endl;
}
ofile.close();

return EXIT_SUCCESS;
}
#1543
I don't think there are any other, but if you find others than just let me know.

Changes to these functions and the updated documentation will be uploaded in half an hour or so.
#1544
Ah, I though that the problem was that there were two functions with the same name.

So making the remove and focusWidget functions no longer internal (which I needed to do anyway) will solve this whole discussion? I was starting to to get afraid that I would have to change a lot of code.
#1545
The best option that I can think of so far is name the functions like this:
remove(Widget::Ptr);
removeWidget(Widget*);


But I took a look at the get functions and I don't even want to change that.
Although I do realize that the template one could be dropped and that you could type tgui::Button::Ptr(gui.get("widget")) instead of gui.get<tgui::Button>("widget").