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

#1
Awesome, everything works! I saw that parameter, but stupidly concluded I needed to pass in true to do what I wanted instead of false.
#2
That's probably what I will do. Using old code feels scary now  :'(
#3
Wow, so a lot has changed. What is the new equivalent of bindCallbackEx ?
#4
Hmm, I don't seem to have that function, and gui.getWindow()->setView(view) doesn't work either :/ Guess I gotta go grab the latest.  :P
#5
Help requests / Resizing Window Skews Buttons
07 April 2016, 05:46:54
When resizing the window, the buttons become squished, as you can image. However, resetting the windows view before drawing them does not fix it, and resetting the gui window doesn't either.
Code (cpp) Select

//doesnt fix it
theResizedWindow.setView(recalculatedDefaultView);
gui.draw()

//doesnt fix it
gui.setWindow(theResizedWindow);

I also tried both at once.
Should these work, or is there something else I need to be doing?
#6
Haha thanks, I could always use an old version of TGUI, or do it the way you intend, which is to bind a function to each callback possibility (right?)
#7
It's complicated :P

I have wrappers for various tgui things such as editboxes, buttons, panels, because I have a gamewide eventing system for my game, which I want the tgui stuff to use (and it does and works great)

I put a bunch of logic in a base class, and one thing that I wanted to put in there was the f_callback (binded) function.

Code (cpp) Select
void WidgetBase::f_callback(const tgui::Callback& callback)
{
if(callbackHook(callback))
{

}
else if(callback.trigger == tgui::Widget::WidgetCallbacks::MouseEntered)
{
f_MouseEntered();
}
else if(callback.trigger == tgui::Widget::WidgetCallbacks::MouseLeft)
{
f_MouseLeft();
}
else if(callback.trigger == tgui::ClickableWidget::LeftMouseClicked)
{
f_LeftMouseClicked();
}
else if(callback.trigger == tgui::ClickableWidget::LeftMousePressed)
{
f_LeftMousePressed();
}
else if(callback.trigger == tgui::ClickableWidget::LeftMouseReleased)
{
f_LeftMouseReleased();
}
}
void WidgetBase::f_MouseEntered()
{
sf::Packet pack;
mouseEnteredHook(pack);
m_io.event(EventType::MouseEntered, 0, pack);
}


Then, derived classes can override
Code (cpp) Select
bool callbackHook(const tgui::Callback& callback);
to see if they want to handle the callback.

There are also hooks on the event functions such as mouseEnteredHook which some of the classes do special things with.
So essentially, the derived classes can only handle special events if the function was binded to recieve all events, because the widgetbase binds the function
Code (cpp) Select

void WidgetBase::f_assign(tgui::Widget* pWidget)
{
m_pWidget->bindCallbackEx(&WidgetBase::f_callback, this, 4095);
}
#8
It doesnt get called for editbox callbacks, such as tgui::EditBox::ReturnKeyPressed

Basically I am calling that bind on a base pointer to the widget, and I have a function that I want to get called for all possible triggers that would trigger the derived widget. For instance, m_pWidget could be a tgui::EditBox::Ptr or tgui::Button::Ptr.
#9
Help requests / Bind this function for all callbacks
16 September 2015, 21:44:25
Code (cpp) Select
m_pWidget->bindCallbackEx(&WidgetBase::f_callback, this, tgui::ClickableWidget::AllClickableWidgetCallbacks);
I want to bind this so that it will call f_callback for ALL possible callback triggers. How can I do this?
Can I bind it to multiple triggers?
#10
Quote from: texus on 21 October 2014, 10:21:03If you have multiple sfml and tgui folders you should remove them to make sure that you can't be using the wrong one accidentally. And make sure that all dll files are coming from these folders.

We actually went through and did exactly that step :/ I we will go through again though just to make sure.

Quote from: texus on 21 October 2014, 10:21:03There must still be a configuration mistake on his pc then.

Here are all the things I know how to check:
All CMake settings (we checked Advanced too)
Code::Blocks Compiler settings: Settings->Compiler->Toolchain Executables (his match mine)
Path Environment Variables: I understand what these do, should I check for anything? In the past he had a misconfigured MinGW directory, which was causing a different problem, so we made the only MinGW/bin variable point at the new correct one.

What other things can I check for?

And thank you both for your input!
#11
Strangely, it works fine in Debug mode, but not in Release. Only his computer has this problem.
#12
Ok, so since we were compiling with the same compiler, we assumed our libs would be the same (as you indicated correctly) so I was trying to use his libs, so we were both getting the error.
I rebuilt my libs, and everything works on my machine.

We looked at the file sizes of the libs he was building, and his sfml-window-2.dll file was 146KB, while mine is 830KB. Everything else was different too, shouldn't they be the same? Also, he is Windows 8, I'm windows 7.

We double, triple, and quadruple checked his CMake settings. I also had him download the exact same SFML source I downloaded. We are currently working on getting everything in debug mode to get the callstack.
#13
I really like TGUI, so great job on it  ;D

I just switched to using this as my compiler: https://sourceforge.net/projects/mingw-w64
After rebuilding SFML and TGUI, SFML works fine, but if I try and do anything with TGUI, I get a crash in the SFML Graphics library:


There was a bunch of steps that lead up to this post, which can be seen in this SFML thread:
https://en.sfml-dev.org/forums/index.php?topic=16579.0

I'm pretty sure (can I get a confirmation?) that this compiler uses DW2. I thought that rebuilding TGUI would allow it to work. What is the problem?
Thanks
#14
Help requests / Re: Draggable Panel
10 April 2014, 19:24:51
Works perfectly! Here it is if you want to see it.

            if (rEvent.key.code == sf::Keyboard::F1)
            {
                m_pCPT->setState(PlayerState::Editing);
            }

// somewhere else in the code:

else if(m_pCPT->getState() == PlayerState::Editing)
        {
            if (rEvent.type == sf::Event::MouseButtonPressed)
            {
                tgui::Widget::Ptr widget = f_MouseOnWhichWidget(rEvent.mouseButton.x, rEvent.mouseButton.y, m_rGui.getWidgets());
                if(widget != nullptr)
                {
                    if(widget->getWidgetType() == tgui::WidgetTypes::Type_Panel)
                    {
                        if(f_MouseOnWhichWidget(rEvent.mouseButton.x, rEvent.mouseButton.y, tgui::Panel::Ptr(widget)->getWidgets()) == nullptr)
                        {
                            m_pDraggingWidget = widget;
                            m_pDraggingPosition = sf::Vector2f(rEvent.mouseButton.x, rEvent.mouseButton.y);
                        }
                    }
                }
            }
            else if (rEvent.type == sf::Event::MouseButtonReleased)
            {
                m_pDraggingWidget = nullptr;
            }
            else if (rEvent.type == sf::Event::MouseMoved)
            {
                if (m_pDraggingWidget != nullptr)
                {
                    m_pDraggingWidget->setPosition(m_pDraggingWidget->getPosition().x + rEvent.mouseMove.x - m_pDraggingPosition.x,
                                                   m_pDraggingWidget->getPosition().y + rEvent.mouseMove.y - m_pDraggingPosition.y);

                    m_pDraggingPosition = sf::Vector2f(rEvent.mouseMove.x, rEvent.mouseMove.y);
                }
            }
        }
#15
Help requests / Re: Draggable Panel
09 April 2014, 01:17:14
tgui::Widget::Ptr MouseOnWhichWidget(float x, float y, std::vector<tgui::Widget::Ptr>& widgets)
{
    for (std::vector<tgui::Widget::Ptr>::reverse_iterator it = widgets.rbegin(); it != widgets.rend(); ++it)
        if (((*it)->isVisible()) && ((*it)->isEnabled()) && ((*it)->mouseOnWidget(x, y)))
            return *it;

    return nullptr;
};
#16
Help requests / Re: Draggable Panel
09 April 2014, 01:06:06
Awesome! And thanks for writing that code for me! :) Glad you found a bug before it caused any trouble!

I changed this part though, still look good?:
            if (rEvent.type == sf::Event::MouseButtonPressed)
            {
                tgui::Widget::Ptr widget = MouseOnWhichWidget(rEvent.mouseButton.x, rEvent.mouseButton.y, m_rGui.getWidgets());
                if(widget != nullptr)//======changed this
                {
                    if(widget->getWidgetType() == tgui::WidgetTypes::Type_Panel)//======and changed this
                    {
                        if(MouseOnWhichWidget(rEvent.mouseButton.x, rEvent.mouseButton.y, tgui::Panel::Ptr(widget)->getWidgets()) == nullptr)
                        {
                            m_pDraggingWidget = widget;
                            m_pDraggingPosition = sf::Vector2f(rEvent.mouseButton.x, rEvent.mouseButton.y);
                        }
                    }
                }
            }


Also I don't understand part of this, I commented the part:
tgui::Widget::Ptr MouseOnWhichWidget(float x, float y, std::vector<tgui::Widget::Ptr>& widgets)
{
    bool widgetFound = false;
    tgui::Widget::Ptr widget = nullptr;
    // Loop through all widgets
    for (std::vector<tgui::Widget::Ptr>::reverse_iterator it = widgets.rbegin(); it != widgets.rend(); ++it)
    {
        if (((*it)->isVisible()) && ((*it)->isEnabled()))
        {
            if (widgetFound == false)//  <---why have this? read more down
            {
                if ((*it)->mouseOnWidget(x, y))
                {
                    widget = *it;
                    widgetFound = true;// <---since we already found a widget, why keep going, why not break out of loop; ?
                }
            }
            else
                (*it)->mouseNotOnWidget();
        }
    }
    return widget;
};
#17
Help requests / Re: Draggable Panel
08 April 2014, 19:58:17
The reason I'm asking is that for a game I wanted to have HUD contents, like health, inventory ect, that can be moved around the screen during the game(for convenience), if the player presses a button, then they go into the moving mode, so they can move the containers of these objects.

1. First idea was panels, but they can't be moved around without me doing stuff with them, and I'd rather just do solution 4 than have to deal with panels that overlap, are invisible, and or are disabled.
2. Second idea was child windows, but they have a top tab that is always showing and would look bad in game.
3. Make child windows transparent and disabled when not in moving mode. Unfortunately when transparent, the child window (logically) makes its contents transparent too.
4. Have them only be able to edit the positions of the panels when not in game, in the game's options.

Are there options I didn't see? If not that's fine, just want to make sure.
#18
Help requests / Draggable Panel
08 April 2014, 00:33:39
I know that a Child Window can be dragged around with the top part, but I was hoping to get a panel like object, could be a window, that can be dragged around by clicking and dragging any part of the panel that isn't another object. Is something like that available or do I need to implement that myself?
#19
Help requests / Re: MenuBar Item bindCallback
29 March 2014, 15:22:36
menu->bindCallbackEx(std::bind(&MyClass::function, &mc), tgui::MenuBar::MenuItemClicked);
Doesn't work. Gives errors in "functional" file.
I looked at the documentation of TGUI though, and realized this:
menu->bindCallbackEx(&MyClass::function, &mc, tgui::MenuBar::MenuItemClicked);
does work, I don't really understand what bind does though, and I have never learned this lambda stuff (is it something I should know?)
Either way I have a working callback so thanks!
#20
Help requests / MenuBar Item bindCallback
29 March 2014, 07:30:32
Can I bind a function for MenuBar? So rather than have to go the "pollCallback" route, bind a function to each specific menu option:
In the example I would do:
    tgui::MenuBar::Ptr menu(gui);
    menu->load(THEME_CONFIG_FILE);
    menu->setSize(window.getSize().x, 20);
    menu->addMenu("File");
    menu->addMenuItem("File", "Load");
    menu->addMenuItem("File", "Save");
    menu->addMenuItem("File", "Exit");
    menu->bindCallback(&sf::Window::close, ptr, tgui::MenuBar::MenuItemClicked);

That would close the window when ANY menu item is clicked, but could I make it close it only when "Exit" was clicked? I know how to do it via callback, but I find binding functions is nicer when possible.
#21
Help requests / Re: Internal Button Events
13 March 2014, 18:09:05
Cool, and thanks a bunch  :D.
Is there anywhere else I could have known that's the purpose of a Panel class? The documentation just says its a container for widgets. If not, you should put it in the doc maybe? And how should tabs be utilized? Enabling and disabling panels?

Sorry if these are stupid questions, but for someone like me who has never really dealt with GUI before, I tend to try and solve problems that already have a designated solution, like the Panel,  and or I don't understand how the design is intended to work.
#22
Help requests / Re: Internal Button Events
13 March 2014, 13:58:05
It's not that bad, I just have to make around 10 classes that are pretty much the same.

And thanks, I think!  ;) I'm pretty far along with my game, ill post it here, and other places, and give credit!
I made some pretty advanced game levels in Source SDK(Half-Life 2 Editor basically), and Source's Input Output system was really great, but actually lacked things which I plan to have. I could also theoretically do this more efficiently with function pointers, but that would mean things would start to get weird, and this works out nicer. My levels are still up on a Garrys-Mod server, getting played possibly right now!

Another question, maybe this should be another topic, but:

What is the intended way to have multiple GUI's in existence at the same time?
Is it to use Child-Windows? But if someone closes out of a window, I want to keep the window in memory for the next time it opens. So then what?
Another solution I thought was to have multiple GUI instances. So while playing the game, the HUD-GUI would be displayed and take input. But if the player presses escape, the hud GUI no longer accepts input, and the new Menu is displayed on top of that. And then if they select "Options" from that menu, Another pops up, but on top of that. It's pretty easy to have multiple GUI instances, and to store them in 3 vectors of GUI pointers.
1 Vector holds the active GUI's that accept input.
1 Vector holds the GUIs that are displayed, but not accepting input.
1 Vector holds the GUIS that are not displayed and not accepting input.
I did this and it worked... but two fully active GUI's at the same time caused occasional strange things to happen, which is solved by just having a single active GUI.
#23
Help requests / Re: Internal Button Events
12 March 2014, 23:23:05
I also need the widget instance, like a button, to store what message or messages it plans to send and what its target is.

My plan is later to have a text file with something like this in it, for a game.(this is a very simple version)
Entity_Human
{
targetName = "player_1"
health = 100
}

Entity_Human
{
targetName = "enemy_1"
health = 100
outputs = {onHealth, <, 50, "enemy_1", setHealth, 0; onHealth, <, 50, "enemy_2", setHealth, 0; onHealth, <, 50, "button_1", disable}
}

Entity_Human
{
targetName = "enemy_2"
health = 130
}

Button
{
targetName = "enemy_2"
outputs = {onClicked, "enemy_1", setHealth, 500; onClicked, "enemy_2", setHealth, 300}
}

Slider
{
targetName = "enemy_2"
outputs = {onChanged, "enemy_1", setHealth, getData1}
}


So if you click the button, it sets the health of the enemies to 500 and 300, And if you move the slider, it sets enemy_1 health to whatever the sliders value at the time it gets sent. Also, if your health drops below 50, the button gets disabled, and the enemies killed. I already have this system working by the way, just not tgui. If you'd like more explanation, I can give it. I'm basically doing this: https://developer.valvesoftware.com/wiki/Inputs_and_Outputs
#24
Help requests / Re: Internal Button Events
12 March 2014, 21:54:07
Callback bind being better than polling was what I was hoping to hear.
And to use Composition instead of Inheritance was also the answer I needed, so Thanks :)

As for the Observer Pattern, that's essentially what I'm doing right?
I have objects which store messages, and conditions to go with them, and when something in the object changes, they check themselves for related output messages that need to be sent depending on what changed. If they have them, and the condition of the message got satisfied, they send a Message to the target, which then receives it and does something. I have been using Observer Pattern, I thought.


All my classes start with Caps, I just quickly typed myButton.
Also, any recommendations for how to name my stuff? Because I plan to do this with all the types: Buttons, Sliders, ect. And I thought I should put some sort of differentiation between my Buttons and the tgui buttons. The namespace solves it, but still.
#25
Help requests / Internal Button Events
12 March 2014, 04:09:04
I wanted to make a messaging system that is working with a bunch of other stuff, and I figured I could just have everything inherit from a class called IOBase, which would have virtual send(Message) and recieve(Message) functions. Then, each class could override the function to decide how to interpret the message. So I wanted to know whether this was a good solution or not.

class myButton :  public IOBase, public tgui::Button //<---should that be tgui::Button::Ptr????
{
public:
    void send()
    {
        otherThing->getTarget(target).recieve(message);
    };

private:
    Message message;
    string target;
    IOBase* target;
};

Then later in code
myButtonInstancePtr->bindCallback(&myButton::send, &gui, tgui::Button::LeftMouseClicked);

Is this the BEST way for my button to accomplish that? I know I can do it using callBackId() but I think that's worse.

I would also like to say that this https://github.com/texus/TGUI/blob/master/examples/FullExample/FullExample.cpp, or something like it should be linked in the tutorials. Examples are the most useful thing in the world, and the tutorial only goes over a few things.