Own property
« on: 07 June 2016, 11:15:38 »
Hello! I want to get a text-property from my style-file. I've been tried many ways: from creating individual class-name to include my property into exists class like 'Label' and something. I've been used syntax like "theme->getProperty(classname, property)" but it too not works. So how i can read a text property from my style-file? I've need to do this because I've need to set label text from file. Sorry for my bad english, Thanks!

*

texus

  • *****
  • 1161
    • View Profile
    • Texus's Blog
Re: Own property
« Reply #1 on: 07 June 2016, 12:03:57 »
The theme files only allow changing the look of the widget, not e.g. the text of a label. That is outside the scope of the Theme class.

If you really need to read a specific property from such a file then you can use the tgui::DataIO::parse class directly. You would have to read the file yourself, convert it to a stringstream, pass this to DataIO::parse and the returned value will be a tree of nodes containing all widgets and their properties.

But since you want to load the label text from a file I don't think reading a property from a style file is what you really need. There exist two kinds of files that can be loaded: theme files (which only contain the look and thus can't access properties in Label) and widget files (which save and load entire widgets to text files). These widget files can be loaded with gui.loadWidgetsFromFile and this is probably what you need. The file would contain the entire Label, both its look and other properties like its text. Since there are still no tutorials for this or any documentation for which properties the file can contain, you should just create a Label in c++, call gui.saveWidgetsToFile and then edit that output to what you want to load.