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.


Topics - starkhorn

Pages: 1 [2] 3
16
Help requests / v0.7 error when trying to add radio button
« on: 05 September 2015, 23:44:26 »
So I am trying to add radio buttons using the black.txt file.
I've setup the theme as per the themes tutorial. (https://tgui.eu/tutorials/v0.7/using-themes/)

I have been able to create panels and labels without issue, but the radiobutton throws an error. I am using visual studio 2013 and I don't have a tgui.pdb so when it fails, I don't see the exact source line it fails. I get a Expression: pFirstBlock ==pHead error in the dbgheap.c.

My function is below and it fails at the "tgui::RadioButton::Ptr radioButton = theme->load("RadioButton");" line.

Code: (cpp) [Select]
void Test::setupRadioButton(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_colour, vector<string> stringList, tgui::Container::Ptr container)
{
int yposIncrementer = 0;

for (int i = 0; i < stringList.size(); i++)
{
if (container != NULL && container->get(stringList[i]) == NULL)
{
tgui::RadioButton::Ptr radioButton = theme->load("RadioButton");
radioButton->setPosition(pos.x, pos.y + yposIncrementer);
radioButton->setSize(size.x, size.y);
radioButton->getRenderer()->setTextColor(passed_colour);
if (stringList.size() > 0)
{
radioButton->setText(stringList[i]);
}
container->add(radioButton, stringList[i]);
yposIncrementer += size.y;
}
}
}

Here is a full working example. The drawLoadingScreen method which uses a panel with labels works fine. However the drawMainMenu fails when I try to add a radiobutton. Am I doing something wrong here?

Code: (cpp) [Select]
#include <TGUI/TGUI.hpp>
#include <string>
#include <math.h>
#define THEME_CONFIG_FILE "C:\\Programming\\Debug\\widgets\\Black.txt"

using namespace std;

class Test
{
public:

Test();

sf::RenderWindow gameWindow;
sf::VideoMode desktop;
sf::Event event;
tgui::Callback callback;
tgui::Gui gui;
sf::Texture mainMenuBackGround;

tgui::Theme::Ptr theme;
tgui::Layout windowWidth;
tgui::Layout windowHeight;
string mainPanelName;

void setThemeConfigFile(string passed_filename);
void initBackGroundTextures();
void initMainMenuPanel(sf::Vector2i pos, sf::Vector2i size);
void setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture = NULL);
void setupLabel(sf::Vector2i pos, int passed_TextSize, sf::Color passed_colour, string labelText, tgui::Container::Ptr container = NULL);
void setupRadioButton(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_colour, vector<string> stringList, tgui::Container::Ptr container = NULL);
bool drawLoadingScreenGUI();
bool drawMainMenuGUI(bool mainMenu); //main menu
};

Test::Test()
{
desktop = sf::VideoMode::getDesktopMode();
gameWindow.create(sf::VideoMode(desktop.width, desktop.height, desktop.bitsPerPixel), "Test");
gameWindow.setPosition(sf::Vector2i(0, 0));
gui.setWindow(gameWindow);
gui.setGlobalFont("C:\\Programming\\Debug\\inputfiles\\fonts\\DejaVuSans.ttf");
initBackGroundTextures();
setThemeConfigFile(THEME_CONFIG_FILE);
mainPanelName = "mainPanel";
}

void Test::setThemeConfigFile(string passed_filename)
{
// Load the black theme
theme = std::make_shared<tgui::Theme>(passed_filename);

// Get a bound version of the window size
// Passing this to setPosition or setSize will make the widget automatically update when the view of the gui changes
windowWidth = tgui::bindWidth(gui);
windowHeight = tgui::bindHeight(gui);
}

void Test::initBackGroundTextures()
{
if (!mainMenuBackGround.loadFromFile("C:\\Users\\mcgoldrickb\\Documents\\Visual Studio 2013\\Projects\\rome_vs2013\\Debug\\images\\loading_screen.png"))
{
std::cout << "Failed to load mainMenuBackGround image!" << std::endl;
}
}

void Test::initMainMenuPanel(sf::Vector2i pos, sf::Vector2i size)
{
setupPanel(pos, size, sf::Color::Black, mainPanelName, &mainMenuBackGround);
}

void Test::setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture)
{

if (gui.get(passed_panelName) == NULL)
{
auto mainMenuPanel = std::make_shared<tgui::Panel>();
mainMenuPanel->setPosition(pos.x, pos.y);
mainMenuPanel->setSize(size.x, size.y);
mainMenuPanel->setBackgroundColor(passed_backGroundColour);
if (passed_texture != NULL)
{
mainMenuPanel->add(std::make_shared<tgui::Picture>(*passed_texture));
//mainMenuPanel->getRenderer()->setBackgroundTexture(passed_texture);
}
gui.add(mainMenuPanel, passed_panelName);
}
}

void Test::setupLabel(sf::Vector2i pos, int passed_TextSize, sf::Color passed_colour, string labelText, tgui::Container::Ptr container)
{
if (container->get(labelText) == NULL)
{
tgui::Label::Ptr label = theme->load("Label");
container->add(label, labelText);
label->setPosition(pos.x, pos.y);
label->setTextSize(passed_TextSize);
label->setTextColor(passed_colour);
label->setText(labelText);
}
}

void Test::setupRadioButton(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_colour, vector<string> stringList, tgui::Container::Ptr container)
{
int yposIncrementer = 0;

for (int i = 0; i < stringList.size(); i++)
{
if (container != NULL && container->get(stringList[i]) == NULL)
{
tgui::RadioButton::Ptr radioButton = theme->load("RadioButton");
radioButton->setPosition(pos.x, pos.y + yposIncrementer);
radioButton->setSize(size.x, size.y);
radioButton->getRenderer()->setTextColor(passed_colour);
if (stringList.size() > 0)
{
radioButton->setText(stringList[i]);
}
container->add(radioButton, stringList[i]);
yposIncrementer += size.y;
}
}
}

bool Test::drawLoadingScreenGUI()
{
sf::Vector2i pos, size((gameWindow.getSize().x), (gameWindow.getSize().y));
initMainMenuPanel(pos, size);

//Setup LoadingScreen Label
setupLabel(pos, 100, sf::Color::Red, "Roman Empire", gui.get<tgui::Container>(mainPanelName));


//This is the main menu instructions Label
pos.x = 25;
pos.y = gui.get(mainPanelName)->getSize().y - 100;
setupLabel(pos, 50, sf::Color::Red, "Loading game...", gui.get<tgui::Container>(mainPanelName));


gameWindow.clear();
gui.draw();
gameWindow.display();

return true;
}

bool Test::drawMainMenuGUI(bool mainMenu)
{
vector<string> widgetStrList;

//Initialize the main menu panel
sf::Vector2i pos, size((gameWindow.getSize().x), (gameWindow.getSize().y));
setupPanel(pos, size, sf::Color::Black, mainPanelName, &mainMenuBackGround);
sf::Vector2i panelSize(gui.get(mainPanelName)->getSize().x, gui.get(mainPanelName)->getSize().y);


//This is the main menu Title
pos.x = 25;
pos.y = 50;
setupLabel(pos, 100, sf::Color::Red, "Roman Empire - Main Menu", gui.get<tgui::Container>(mainPanelName));



//Setup Main Menu Radio Buttons
pos.y = 50 + 70;
size.x = 35;
size.y = 35;

widgetStrList.push_back("\tQuit Game");
widgetStrList.push_back("\tStart New Game");
widgetStrList.push_back("\tLoad Old Game");

if (mainMenu == true)
{
setupRadioButton(pos, size, sf::Color::Red, widgetStrList, gui.get<tgui::Container>(mainPanelName));
}
else if (mainMenu == false)
{
widgetStrList.push_back("\tSave Current Game");
widgetStrList.push_back("\tExit Main Menu");
setupRadioButton(pos, size, sf::Color::Red, widgetStrList, gui.get<tgui::Container>(mainPanelName));
}

widgetStrList.clear();

gameWindow.clear();

gui.draw();
gameWindow.display();
return true;
}


17
So what I am trying to do here is first setup a main menu panel where I had a background. I then want to put various widgets into the panel such as labels, radio buttons etc.

So I can create the panel without any issues.
Then the draw menu screen, I have a setupLabel function where one of the parameters to pass in is the tgui::Container::Ptr.
Now I use the gui.get to retrieve the panel but this returns type widget::ptr and so i get a compile error. I tried calling getparent but obviously this just returns gui.

Is there any to search the gui for the widget name and get the container back? Note right now it is a panel, but I also want to use setupLabel for say child windows or other container types.

Here is a full working example of what I'm trying to do.

See the drawLoadingScreenGUI() method.
It calls initMainMenuPanel() which adds a panel to gui. I now want to call setupLabel and pass in a ptr to the panel.
As you can see I'm calling gui.get("mainPanel") which does return the widget::ptr but I cannot add a label to a widget, I assume I need a container type?

Code: (cpp) [Select]

#include <TGUI/TGUI.hpp>
#include <string>
#include <math.h>
#define THEME_CONFIG_FILE "C:\\programming\\rome_vs2013\\Debug\\widgets\\Black.txt"

using namespace std;

class Test
{
public:

Test();

sf::RenderWindow gameWindow;
sf::VideoMode desktop;
sf::Event event;
tgui::Callback callback;
tgui::Gui gui;
sf::Texture mainMenuBackGround;

tgui::Theme::Ptr theme;
tgui::Layout windowWidth;
tgui::Layout windowHeight;

void setThemeConfigFile(string passed_filename);
void initBackGroundTextures();
void initMainMenuPanel(sf::Vector2i pos, sf::Vector2i size);
void setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture = NULL);
void setupLabel(sf::Vector2i pos, int passed_TextSize, sf::Color passed_colour, string labelText, tgui::Container::Ptr container = NULL);
bool drawLoadingScreenGUI();
};

Test::Test()
{
desktop = sf::VideoMode::getDesktopMode();
gameWindow.create(sf::VideoMode(desktop.width, desktop.height, desktop.bitsPerPixel), "Test");
gameWindow.setPosition(sf::Vector2i(0, 0));
gui.setWindow(gameWindow);
gui.setGlobalFont("C:\\programming\\rome_vs2013\\Debug\\inputfiles\\fonts\\DejaVuSans.ttf");
initBackGroundTextures();
setThemeConfigFile(THEME_CONFIG_FILE);
}

void Test::setThemeConfigFile(string passed_filename)
{
// Load the black theme
theme = std::make_shared<tgui::Theme>(passed_filename);

// Get a bound version of the window size
// Passing this to setPosition or setSize will make the widget automatically update when the view of the gui changes
windowWidth = tgui::bindWidth(gui);
windowHeight = tgui::bindHeight(gui);
}

void Test::initBackGroundTextures()
{
if (!mainMenuBackGround.loadFromFile("C:\\progamming\\rome_vs2013\\Debug\\images\\loading_screen.png"))
{
std::cout << "Failed to load mainMenuBackGround image!" << std::endl;
}
}

void Test::initMainMenuPanel(sf::Vector2i pos, sf::Vector2i size)
{
setupPanel(pos, size, sf::Color::Black, "mainPanel", &mainMenuBackGround);
}

void Test::setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture)
{

if (gui.get(passed_panelName) == NULL)
{
auto mainMenuPanel = std::make_shared<tgui::Panel>();
mainMenuPanel->setPosition(pos.x, pos.y);
mainMenuPanel->setSize(size.x, size.y);
mainMenuPanel->setBackgroundColor(passed_backGroundColour);
if (passed_texture != NULL)
{
mainMenuPanel->add(std::make_shared<tgui::Picture>(*passed_texture));
}
gui.add(mainMenuPanel, passed_panelName);
}
}

void Test::setupLabel(sf::Vector2i pos, int passed_TextSize, sf::Color passed_colour, string labelText, tgui::Container::Ptr container)
{
if (container->get(labelText) == NULL)
{
tgui::Label::Ptr label = theme->load("Label");
container->add(label, labelText);
label->setPosition(pos.x, pos.y);
label->setTextSize(passed_TextSize);
label->setTextColor(passed_colour);
label->setText(labelText);
}
}

bool Test::drawLoadingScreenGUI()
{
sf::Vector2i pos, size((gameWindow.getSize().x), (gameWindow.getSize().y));
initMainMenuPanel(pos, size);

//Setup LoadingScreen Label
setupLabel(pos, 100, sf::Color::Red, "Roman Empire", gui.get("mainPanel"));



gameWindow.clear();
gui.draw();
gameWindow.display();

return true;
}


int main()
{
Test testClass;

    // Main loop
while (testClass.gameWindow.isOpen())
    {
        sf::Event event;
while (testClass.gameWindow.pollEvent(event))
        {
            // When the window is closed, the application ends
            if (event.type == sf::Event::Closed)
testClass.gameWindow.close();


            // Pass the event to all the widgets
testClass.gui.handleEvent(event);
        }

testClass.drawLoadingScreenGUI();

}

return 0;
}


18
Help requests / v0.7 panel background textures
« on: 05 September 2015, 00:40:36 »
Hey,

I was trying to set the background texture for a panel.

I tried the line below, but there doesn't appear to be a setbackgroundtexture method. I don't see any panel renderer class? Is this coming in a later version? Any recommendations to get around this currently?

Code: (cpp) [Select]
void drawEngine::setupPanel(sf::Vector2i pos, sf::Vector2i size, sf::Color passed_backGroundColour, string passed_panelName, sf::Texture *passed_texture)
{

if (gui.get(passed_panelName) == NULL)
{
tgui::Panel::Ptr mainMenuPanel = theme->load(themeConfFile);
mainMenuPanel->setPosition(pos.x, pos.y);
mainMenuPanel->setSize(size.x, size.y);
mainMenuPanel->setBackgroundColor(passed_backGroundColour);
if (passed_texture != NULL)
{
mainMenuPanel->getRenderer()->setBackgroundTexture(passed_texture);
}
}
}

19
Help requests / v0.7 signals
« on: 04 September 2015, 22:28:37 »
Hi,

Ok so I tried v0.7 for the first time today. I put in my v0.69 code and had zillions of compile errors as alot has changed. :)

Most are pretty easy to understand/modify, i.e. there is the renderer class and also there is no load method but we need to use the theme->load etc

However one thing that I am confused about is the change to signals.

In v0.69 there was the below in order to know when a button had been pressed with the left mouse button.

Code: (cpp) [Select]
    button->bindCallback(tgui::Button::LeftMouseClicked);
    button->setCallbackId(1);

Now in v0.70, I get a compile error that tgui::Button::LeftMouseClicked does not exist.

I see in the v0.7 example code that it uses the connect method.

Code: (cpp) [Select]
    // Call the login function when the button is pressed
    button->connect("pressed", login, editBoxUsername, editBoxPassword);

Ok seems simple enough but what I do not get there is how does the button widget know that this function gets triggered when the left mouse button is clicked. what if I wanted to do something if the right mouse button is clicked or if the middle button etc ?

I am sure I am missing something obvious here but I just don't quite get it. :)

20
Help requests / Defining chatbox via a class
« on: 01 September 2015, 01:06:35 »
Ok, I feel a bit silly here but I'm confused and I'm looking for a bit of help.

So I have a class where one of the data items is a chatbox

Code: [Select]

class Test
{
public:
Test();

sf::RenderWindow gameWindow;
tgui::Gui gui;
tgui::ChatBox::Ptr chatbox;
};



Now in the class constructor, I want to set the chatbox container so that it is in the gui, i.e. like below.


Code: [Select]
tgui::ChatBox::Ptr chatbox(gui);

Now obviously if I do this in the class definition, it does not compile. So I'm assuming there is a method that I call call in the Test class constructor but I cannot for the life figure out which method to call.


21
Help requests / The new renderer classes in v0.7
« on: 27 August 2015, 01:19:09 »
Hi Texus,

So I'm using v0.6.9 and I was looking to change the background image of a chatbox. I realized that there was no method for that but I spotted in the v0.7 docs that there is something called a chatbox renderer with such a method.

Now I am curious that is something new/different between v0.6.9 and v0.7 and I can see that lots of other widgets have such a class as well. So I was wondering how the renderer class would work/differ in v0.7?

I saw the below example code where we have to call the getRenderer() method. So just to confirm my understanding that from v0.7 onwards, all widget display methods need to go through the getRenderer() method first?

https://tgui.eu/example-code/v07/simple-console/

22
Help requests / Accessing textures
« on: 04 July 2015, 04:45:21 »
In the theme conf file for child window, there is the setting for title bar where you specify the titlebar image file. I'm assuming tgui loads that in and stores it as a texture?

Now say I wanted to access that same texture again. For example say I want to sub divide the child window so I want to draw that titlebar again. Is there a way I can access that texture so I can assign it to a sf::sprite? Note I list childwindow as an example. I'd also be interested on how to access say the button png texture or radio button etc.


23
Help requests / m_callback size
« on: 30 June 2015, 02:11:12 »
Hi Texus,

Sorry for another question......I have a few radio buttons and each radio button has it's own callback ID. Within my gui.pollCallback(callback) function, I check if the radio callback id is the one. Then I return true from the function...so basically I'm jumping out of the gui.pollCallback loop early here.

However I've realized that when i next call that pollCallback function, the radio button callback ID is still triggered. EVentually I realized that the gui.m_callback size is usually has 3-400 callback IDs...all of them the ID of the radio button. I'm not sure how/why this is the case?

Anyway, I wrote the below to clear out the m_callback queue when I no longer want to check for new events.

Code: (cpp) [Select]
void drawEngine::clearCallBackQueue()
{
while (gui.pollCallback(callback))
{

}
}

I was wondering if there was any way to add a gui.m_callback.clear() instead as it would be a little faster? I cannot do that as m_callback is a private parameter.

24
Help requests / Different buttons
« on: 22 June 2015, 10:29:01 »
Hey,

I've started playing with the config files to develop my own theme. One of the things that I'm wondering is that I want lots of different images for my buttons. For example, I have a button that is for finance so I want the image to be a png that has coins. Then say I've another button for armies so I want the image to an army png etc etc.

So I can see quite easily how to change the image in the config files, but what if I wanted several different types of buttons? i.e. as above. the functionality is the same, i.e. you click on them and bind callbacks to them etc. I just want a different image.

Is there a way to do this easily via the theme config file?

25
Help requests / Canvas overwrites child window background image
« on: 16 June 2015, 09:41:02 »
So I create a child window with a background image. I then want to display an image on the child window which can divide up the child window in different sections. Then exact position will change depending on the data - so I decided to use a canvas.

First I create the child window with these 2 functions. initPos and initSize are just structs that have x and y values. There is a childwindow vector of all childwindows within the class.

Code: (cpp) [Select]
void drawEngine::initSubMenuChildWin()
{
initPos.setPos(gameWindow.getSize().x * 0.5, gameWindow.getSize().y * 0);
initSize.setPos((gameWindow.getSize().x - (gameWindow.getSize().x * 0.5)), getLowerScreenPos().getPosY());
setupChildWindow("Finance Menu", sf::Color::Red, financeChildWin, &subMenuBackGround);
}

void drawEngine::setupChildWindow(string title_text, sf::Color titleText_Color, string passed_childName, sf::Texture *passed_texture)
{
int listPreSize = childWindowList.size();

if (!IsChildWinAlreadyInChildList(passed_childName))
{
childWindowList.push_back(tgui::ChildWindow::Ptr(gui, passed_childName));
}

for (int i = listPreSize; i < childWindowList.size(); i++)
{
childWindowList[i]->load(themeConfFile);
childWindowList[i]->setPosition(initPos.getPosX(), initPos.getPosY());
childWindowList[i]->setSize((initSize.getPosX()), (initSize.getPosY()));
childWindowList[i]->setTitleColor(titleText_Color);
childWindowList[i]->setTitle(title_text);
if (passed_texture != NULL)
{
childWindowList[i]->setBackgroundTexture(passed_texture);
}
}
}

tgui::ChildWindow::Ptr drawEngine::getChildWindow(string passed_widgetName)
{
string retrievedWidgetName;

for (int i = 0; i < childWindowList.size(); i++)
    {
if (gui.getWidgetName(childWindowList[i], retrievedWidgetName))
{
if (retrievedWidgetName == passed_widgetName)
{
return childWindowList[i];
}
}
    }
    return NULL;
}


Then in my code I use this to put the canvas in the childwindow and draw the sprite within the canvas.

Code: (cpp) [Select]

initSubMenuChildWin();
float childSizeX = getChildWindow(financeChildWin)->getSize().x;
float childSizeY = getChildWindow(financeChildWin)->getSize().y;

sf::Sprite sprite(largeTitleBar);

tgui::Canvas::Ptr canvas(*getChildWindow(financeChildWin));
canvas->setSize(childSizeX, childSizeY);
canvas->clear();

sprite.setPosition(40, getChildWindow(financeChildWin)->getSize().y * 0.5);
canvas->draw(sprite);
canvas->display();


When I call this the largeTitleBar sprite displays fine, but the background image of the childwindow is gone - i.e. all black.
If I change the above so the canvas size and position are the same as the sprite, the largeTitleBar sprite does not get displayed and instead the black canvas gets displayed.

So I guess I'm struggling to understand how to use canvas properly. Any ideas/suggestions?

26
I'm looking for a way to see if the close button in a child window title bar has been pressed. Is there a hard-coded callback ID for example? Basically as well as just closing the child window, I also want to trigger other events as well.

27
Help requests / Convert panels and childwindows to containers
« on: 09 June 2015, 00:44:33 »
So I've a vector of panels and also a vector of childwindows

Code: (cpp) [Select]
vector<tgui::Panel::Ptr> PanelList;
vector<tgui::ChildWindow::Ptr> childWindowList;

I have a function that wants to check if a panel or child window is already present in either vector. I use the get widgetname function.

Code: (cpp) [Select]
bool drawEngine::isWidgetPresentInContainer(string passed_widgetName, vector<tgui::Container::Ptr> containerList)
{
string retrievedWidgetName;

for (int i=0; i < containerList.size(); i++)
{
if (gui.getWidgetName(containerList[i], retrievedWidgetName))
{
if (retrievedWidgetName == passed_widgetName)
{
return true;
}
}
}
return false;
}

Now as you can see I've defined the parameter in the function as  vector<tgui::Container::Ptr>.
As both panels and childwindows inherit from this class and the method of getWidgetName is within the container class then I kinda hoped that I could write one function regardless whether the vector is a panel or a child window.

However obviously when I call it I get

Code: (cpp) [Select]
215 IntelliSense: no suitable user-defined conversion from "std::vector<tgui::ChildWindow::Ptr, std::allocator<tgui::ChildWindow::Ptr>>" to "tgui::Container::Ptr" exists

Is there any way to do this ?

28
Help requests / Sliders
« on: 03 June 2015, 04:50:22 »
Hi,

I was playing with sliders and I'm trying to understand how they work. Now with scrollbar there is a method called setArrowScrollAmount which controls how big you can scroll up/down the scrollbar. I was looking for something similiar with the slider but there isn't any such method.

Basically what I am trying to achieve is to have a slider which only allows 4 or 5 positions. So you have the first position which is far left. Then if you try to move the slider button right, it will go to the next position which is say 50 pixels to the right etc. So it isn't a smooth movement, but a jump along the slider.

Unsure if this is feasible with a slider or if there is another widget that I should look into instead?

29
Help requests / Highlight background text
« on: 11 April 2015, 05:52:37 »
Is there a way for text that is set for radio or check buttons to be highlighted when the actual checkbox or radio button is selected?

Also, I have same question for labels as well. Basically I have a long list of checkbox but due to the fact I wanted to format the text in neat columns, I displayed them as labels.

I have had a look and I cannot seem to find any such method? Does one exist or are any in the works?

30
Help requests / WidgetTypes
« on: 02 April 2015, 22:14:19 »
Hi Texus,

I have a panel that has labels and the gui that have labels. Depending on what the user clicks, the content of the labels may change. Now rather than try to figure out what label changes and update the text, I've decided at the beginning of each menu call, to remove all label type widgets from the gui and any panels within the gui. Then re-add them with potentially new text.

So essentially it is pretty simple

- if widget type = label then remove widget
- else if widget type = panel then
       - get all widgets assigned to the panel
       - if any panel widgets are label then remove them from the panel


I've written the below which I think will do it? LabelList is a vector of labels that I use to set the position, text etc of the label. I tried just clearing this vector but the gui and panels always seem to retain the widgets. Unsure if there is an easier way to do this?

Code: (cpp) [Select]
void guiEngine::clearLabelWidgets()
{
LabelList.clear();

vector<Widget::Ptr> widgetList = gui.getWidgets();

for (int i = 0; i < widgetList.size(); i++)
{
if (widgetList[i]->getWidgetType() == "Label")
{
gui.remove(widgetList[i]);
}
else if (widgetList[i]->getWidgetType() == "Panel")
{
vector<Widget::Ptr> panelWidgetList = widgetList[i]->getWidgets();

for (int j = 0; j < panelWidgetList.size(); j++)
{
if (widgetList[i]->getWidgetType() == "Label")
{
widgetList[i]->remove(panelWidgetList[j]);
}
}
}
}
}

Anyway, the above doesn't compile as "Label" isn't a valid WidgetType. I've looked at the documentation but it doesn't give a list of each valid i.e.

https://tgui.eu/documentation/v0.6/namespacetgui.html#a6f721be5dfcacf4e5b73b8d3aef75b14

I looked in the source files of widget.cpp but I couldn't see them in there either.

Pages: 1 [2] 3