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

#1
Feature requests / Re: Layouts in Files
16 November 2015, 16:11:56
Cool, I will definetly download the latest version. Good on you that you found the bugs (y)
#2
Thanks so much, that was exactly what I needed :)
#3
So I'm having this weird issue where I'm trying to load a container from a file, and tgui throws an assertion failed error at me:


Assertion failed: container != nullptr, file ../WidgetLoader.cpp, line 149

(note that I got the modified version of WidgetLoader we talked about yesterday, so the line might not match yours, but it's the first line of function loadContainer())

Here's the file I'm trying to load:

Container.MM
{
position: (100, 100);
size: (100, 100);
visible: true;
enabled: true;
opacity: 1;
}


I couldn't find anything on the markup of Containers or if they're even allowed in files, hope you can solve this one for me ;)

Thanks for your help in advance.
#4
Feature requests / Re: Layouts in Files
24 October 2015, 01:27:36
Awesome!

Looking forward to see the saving work and yeah I didn't test if Layout.hpp was actually necessary ;)

Unfortunately I don't have a github account. But I'm glad that I could contribute a tiny bit to your project.

Keep up the good work!
#5
Feature requests / Layouts in Files
23 October 2015, 14:14:24
Hey there,

so I've been playing around with TGUI lately and I couldn't figure out how to load layouts from a file, for example:

position: "{&.w - 50, &.h + 5}";


I then implemented it myself and it works like a charm, so I thought you guys would be interested and it might even be implemented into TGUI in the future.

Here are the changes I made (only one file - WidgetLoader.cpp)

First the include:

#include <TGUI/Layout.hpp>


Other than that I only changed the function parseVector2f:

tgui::Layout2d parseVector2f(std::string str)
    {
if (str.empty())
throw tgui::Exception{ "Failed to parse position. String empty." };

if (str.front() == '(' && str.back() == ')'){
// it's a vector
str = str.substr(1, str.length() - 2);

auto commaPos = str.find(',');
if (commaPos == std::string::npos)
throw tgui::Exception{ "Failed to parse position '" + str + "'. Expected numbers separated with a comma." };

if (str.find(',', commaPos + 1) != std::string::npos)
throw tgui::Exception{ "Failed to parse position '" + str + "'. Expected only one comma." };

return{ tgui::stof(str.substr(0, commaPos)), tgui::stof(str.substr(commaPos + 1)) };
}
else if (str.front() == '"' && str.back() == '"'){
// it's a layout
str = str.substr(1, str.length() - 2);

return{ str };
}
else
throw tgui::Exception{"Failed to parse position '" + str + "'. Malformed."};
    }


It would be appropriate to change the name of the function, but I couldn't come up with a good name ;P

Cheers,
Jervy