TGUI Forum

General Category => Help requests => Topic started by: Charsmud on 12 January 2014, 01:44:08

Title: Set a sf::RenderWindow from other class
Post by: Charsmud on 12 January 2014, 01:44:08
Hello!  I am trying to set up a GUI system.  However, my RenderWindow instance is inside of a different class than what I am trying to access it from, and I can only access it via a RenderWindow*.  Is there a way to set the tgui::Gui to the RenderWindow* that I have, or do I need to do something else?  (Sorry if this is a little noob, I'm not that awesome at C++)
Title: Re: Set a sf::RenderWindow from other class
Post by: texus on 12 January 2014, 11:56:30
If I understand the question correctly then this is indeed about a basic part of c++.

With some basic type:
int i1 = 0; // Create an integer
int* p = &i1; // Create a pointer with the address of i1
int i2 = *p; // Dereference the pointer (get the value of i1)

You are in the exact same situation as the last line, you need a RenderWindow while you only have a RenderWindow* (just like you needed an int and had an int*).
So you can just initialize the gui like this:
tgui::Gui gui(*renderWindowPointer);
Title: Re: Set a sf::RenderWindow from other class
Post by: Charsmud on 12 January 2014, 17:00:25
Thanks, this worked!  xD 

Also, because I couldn't find it anywhere else, how do you skin the buttons?  I haven't really found a tutorial by the developer or any third party that shows how to do this. 
Title: Re: Set a sf::RenderWindow from other class
Post by: texus on 12 January 2014, 19:10:15
You should take a look here: https://tgui.eu/tutorials/v06/config-files/ (https://tgui.eu/tutorials/v06/config-files/).

You should just try to have a look at the existing styles and try to learn how it workes by just changing some parameters and look at the results. But feel free to ask if you have a more specific question.