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

#1
Perfect, thanks!
#2
I'm trying to create a label that will automatically centre itself. I'm attempting to do this:
label->setAutoSize(true);
label->setPosition(screenSize.x / 2.f - bindWidth(label)/2.f, YVALUE);


So no matter what I set the text to, in theory, the width should adjust accordingly, and then the position should change based on the width.
However, it seems that bindWidth(label) isn't updating when the length changes, and label has no text value until I change it, bindWidth(label) is always 0.

In the image "Get Ready!!!" is the label.

Any ideas? The width is changing correctly but that doesn't seem to affect the binding.
#3
Thanks, I guess I wasn't reading what was right in front of me. Also I just realised that &game is creating a pointer to a pointer to a gameEngine instance.

buttonQuit->connect("clicked", &gameEngine::Quit, game);

is correct. Thanks.
#4
I tried to follow your tutorial here on signals, but I seem to be making a mistake when trying to connect a  member function to a signal.
Error:'&': illegal operation on bound member function expression

Here is the minimal context:

// stateMainMenu.cpp
void stateMainMenu::Init(gameEngine* game) {
tgui::Button::Ptr buttonQuit = std::make_shared<tgui::Button>();
buttonQuit->connect("clicked", &(game->Quit), &game); // Crash Here
gui.add(buttonQuit, "buttonQuit");
}


and the class definition for gameEngine:


// gameEngine.h
class gameEngine {

public:
//Other Stuff
bool Running() { return isRunning; }
void Quit() { isRunning = false; }

private:
bool isRunning;
};


So far I've tried small stuff I thought would work like making both isRunning and Quit static, or writing a small function in gameEngine.cpp to run game->quit, and then connect that function to the button. The last two work but I want to see if I can get the function pointers working. Any help would be amazing.
#5
Help requests / Re: Theme.txt Syntax
28 February 2016, 13:19:24
Quote from: texus on 28 February 2016, 09:17:45
The values are (LEFT, TOP, width, height) but for the Middle rect it should be noted that it is relative to the Part rect (if Part rect is given).
That's what I meant, thanks :)

Quote from: texus on 28 February 2016, 09:17:45
The Part and Middle rect are both optional, to load the image from a separate file, just write the following:
Code (css) Select
NormalImage : "ThemeNormalImage.png";
Amazing, that'll really speed things up for me. Thanks for the help.
#6
Help requests / Theme.txt Syntax
28 February 2016, 00:38:54
Sorry for all the questions, I really appreciate your help.

I'm trying to figure out the syntax of the Black.txt file included in the download so I can make my own from premade textures. I can't seem to find a description on either the forum or the main site. I assumed that the brackets with 4 values were (top,left,width,height) but that doesn't appear to work.

Also is it possible to do something like this:
Button {
    NormalImage     : "ThemeNormalImage.png" Part(whatever) Middle(whatever);
    HoverImage      : "ThemeHoverImage.png" Part(whatever) Middle(whatever);
    DownImage       : "ThemeDownImage.png" Part(whatever) Middle(whatever);


so that I could load every individual texture from its own file? Granted not safe efficient but I have them split up as it is.
#7
Thanks. I just wanted to be sure that I was using it correctly before I dived headlong into it.

I agree that the bindrange function doesn't have much use, maybe keep it but hide it from the basic tutorial.
#8
I was looking through the tutorials, trying to understand layouts and binding, and I just have no idea what they are or how they work. I assume they're meant to allow fixing the size/position of one widget based on another widget, but then I don't get binding ranges. Is that to make sure it stays within a specific range?

If anyone could just explain this, I would be really grateful. Thanks  :)