Recent Posts

Pages: 1 2 [3] 4 5 ... 10
Help requests / Re: EditBox acts strange.
« Last post by krolik on 07 January 2019, 21:03:20 »
Thanks! I managed to pull this off. Didn't need to change much tho, I had gameState variable, which changed depending on where I am in the game, my game loop has only switch instruction on current gameState:
while (window.isOpen())
                sf::Event event;
                switch (menu.getGameState())
                case 0:
                case 1:
                        std::cout << "LvlChoose" << std::endl;
                case 2:
                case 3:
                        std::cout << "Play" << std::endl;
                case 4:
                        std::cout << "Auto" << std::endl;
                case 5:
And I changed fuctions to look like this:
void Menu::showEdit(sf::Event & event)
        while (window.pollEvent(event))
                if (event.type == sf::Event::Closed)
        window.clear(sf::Color::White); // clear window with white color
I think I actually tried that before, but I must've made some mistake along the way. Thanks again :)
Help requests / Re: EditBox acts strange.
« Last post by texus on 07 January 2019, 08:27:35 »
You should probably restructure your code. Clearing and drawing shouldn't happen in the event loop. You should also pass all events to editGui.handleEvent, not just TextEntered ones. This is likely why backspace doesn't work, it relies on KeyPressed.
If showEdit is being called multiple times then the issue must be in the code where you are calling it.

There are probably many ways to redesign the code, here is one:
You should try to only have a single main loop which handles events and draws to the screen. Depending on the state of your program (e.g. whether in main menu or somewhere else), you call a different function for handling the event and for drawing (e.g. you use a pointer to a State class that has virtual handleEvent and draw functions). You can choose to either give each state its own Gui object or just have a single Gui object that you use everywhere and just put every screen in a Group (or Panel) and just show and hide this group when switch state.
Help requests / EditBox acts strange.
« Last post by krolik on 06 January 2019, 23:28:02 »
I'm making a game using sfml + tgui, and for my level creator I need EditBoxes, so I made new tgui::Gui object for creator menu and loaded Widgets using loadWidgetsFromFile() function.
These Widget declarations in .txt file look like this:
EditBox.width {
    Position = (10, 40);
    DefaultText = "Number of cols...";
then, when in main menu I click button directing me to creator I'm calling this function in a loop:
void Menu::showEdit(sf::Event & event)
        if (event.type == sf::Event::Closed)
                window.clear(sf::Color::White); // clear window with white color
                editGui.draw(); // drawing loaded widgets
But with this code it doesn't work like it should, when I press any key loop manages to execute few times and I get a few characters instead of one, in addition, backspace doesn't work. I think I should change something in EditBok drawing, but I have run out of ideas, nothing seems to work so far. Could you give me some advice? I'm using TGUI 0.8. Thanks in advance :)
Installation help / Re: Exseption std::bad_array_new_length
« Last post by alexsey on 05 January 2019, 08:21:08 »
I found a solution, my bad
Installation help / Re: Exseption std::bad_array_new_length
« Last post by texus on 02 January 2019, 22:17:21 »
You should double check that you aren't linking debug libraries in release mode or the other way around.
If that isn't the problem (and I hope it is because it is the only explanation that I currently have for such a crash) then I will need a bit more info:
Is the setSize call or the parameter to the create function required to get the crash?
Which version of SFML and TGUI libraries are you using?
What compiler are you using?
Did you download the SFML and TGUI libraries or did you compile them yourself with cmake?
Installation help / Exseption std::bad_array_new_length
« Last post by alexsey on 02 January 2019, 21:24:50 »
after i linked Tgui i tried start a test project, but i got an exseption in row  gui.add(picture);
piece of cod:
auto picture = tgui::Picture::create("start_button.png");
   picture->setSize({ "100%", "100%" });

An unhandled exception occurred at 0x00007FF9B35E8E6C в Test_TGUI.exe: exseption Microsoft C++: std::bad_array_new_length to memory address 0x00000090CDACCC00.,
Feature requests / Re: Checkbox future improvments
« Last post by billarhos on 30 December 2018, 13:14:27 »
Didn't know or think both of them. Thank you Texus.
Feature requests / Re: Checkbox future improvments
« Last post by texus on 30 December 2018, 12:38:39 »
Can't you just call the connect function after reading the data?

It's a bit more verbose than "changed", but you can do the following:
pCheckBox->connect("Checked Unchecked", [=](bool) {});

The bool parameter is optional, you can still use a function without parameters if you don't care about the new state.
Feature requests / Checkbox future improvments
« Last post by billarhos on 30 December 2018, 12:29:32 »
I am trying to set initial value to checkbox without sending to me back a signal event. This is happening on initializing. It is important for me this two callbacks not to be triggered
in initializing progress. Only to set the visible part of checkbox (On/Off).

Now it is ok because i am using some booleans to avoid this.

This can be prevented by adding a "SetState(bool onOff)" function without triggering any callbacks in it.

Code: [Select]
pCheckBox = GAME_MANAGER->getGuiTheme()->load("CheckBox");
pCheckBox->setPosition(GAME_MANAGER->layoutWidth(450), GAME_MANAGER->layoutHeight(280));
pCheckBox->setSize(GAME_MANAGER->layoutWidth(100), GAME_MANAGER->layoutHeight(50));

pCheckBox->connect("Checked", [=]()
//do something here but only when user check this

pCheckBox->connect("Unchecked", [=]()
//do something here but only when user uncheck this

if (MEMORY_MANAGER->readDataBool(MemoryMain::checkBoxStatus))

Also a general callback with the name "changed"  it would be a good idea.

thank you

Help requests / Re: Getting an error after drawing a widget
« Last post by JerzyP on 29 December 2018, 23:03:56 »
Thanks, finally all works. I had to add some .lib files to both Debug and Release folders.
Pages: 1 2 [3] 4 5 ... 10