I made this for me, not to have to put any link in my txt gui descriptions files, I made this feature that allows you to handle a ressourcePath. It could be improved by make it work not only with loaded files.
It's an attribute in more to the Container class, very similar to "m_GlobalFont", I just made setters, no getters, and initialized it to "" in Container constructor.
The only really changed part is in Container.cpp in
at the end it becomes :
Just adding the ressource path if the property is about Filename or ConfigFile
Modified files : Gui.cpp Gui.hpp Container.cpp Container.hpp
https://dl.dropboxusercontent.com/u/89706975/miniChanges.zip
Exemple, this is useful when you use sfml on a mac because apps have very complicated ressource directories.
form.txt becomes :
It's an attribute in more to the Container class, very similar to "m_GlobalFont", I just made setters, no getters, and initialized it to "" in Container constructor.
The only really changed part is in Container.cpp in
Code Select
bool loadWidgetsFromFile(const std::string& filename)
at the end it becomes :
Code Select
//Using the provided Ressource Path
std::string filepath = line.substr(equalSignPosition + 1);
if(line.substr(0, equalSignPosition) == "configfile" || line.substr(0, equalSignPosition) == "filename")
filepath = m_RessourcePath + line.substr(equalSignPosition + 1);
if(!widgetPtr.back()->setProperty(line.substr(0, equalSignPosition), filepath))
failed = true;
Just adding the ressource path if the property is about Filename or ConfigFile
Modified files : Gui.cpp Gui.hpp Container.cpp Container.hpp
https://dl.dropboxusercontent.com/u/89706975/miniChanges.zip
Exemple, this is useful when you use sfml on a mac because apps have very complicated ressource directories.
Code Select
...
gui.setRessourcePath(resourcePath());
gui.loadWidgetsFromFile(resourcePath()+"form.txt");
...
form.txt becomes :
Code Select
Window:
{
Picture: ""
{
Filename = "xubuntu_bg_aluminium.jpg"
Left = 0
Top = 0
Width = 800
Height = 600
Visible = true
Enabled = true
Transparency = 255
CallbackId = 0
Smooth = false
}
Label: ""
{
ConfigFile = ""
Left = 200
Top = 100
Width = 161
Height = 30
Visible = true
Enabled = true
Transparency = 255
CallbackId = 0
Text = "Username:"
TextColor = (255,255,255,255)
TextSize = 30
BackgroundColor = (0,0,0,0)
AutoSize = true
}
Label: ""
{
ConfigFile = ""
Left = 200
Top = 250
Width = 150
Height = 30
Visible = true
Enabled = true
Transparency = 255
CallbackId = 0
Text = "Password:"
TextColor = (255,255,255,255)
TextSize = 30
BackgroundColor = (0,0,0,0)
AutoSize = true
}
EditBox: "Username"
{
ConfigFile = "confs/Black.conf"
Left = 200
Top = 140
Width = 400
Height = 40
Visible = true
Enabled = true
Transparency = 255
CallbackId = 0
Text = ""
TextSize = 25
MaximumCharacters = 0
Borders = (6,4,6,4)
TextColor = (200,200,200,255)
SelectedTextColor = (255,255,255,255)
SelectedTextBackgroundColor = (10,110,255,255)
SelectionPointColor = (110,110,255,255)
LimitTextWidth = false
SelectionPointWidth = 2
NumbersOnly = false
}
EditBox: "Password"
{
ConfigFile = "confs/Black.conf"
Left = 200
Top = 290
Width = 400
Height = 40
Visible = true
Enabled = true
Transparency = 255
CallbackId = 0
Text = ""
TextSize = 25
PasswordCharacter = *
MaximumCharacters = 0
Borders = (6,4,6,4)
TextColor = (200,200,200,255)
SelectedTextColor = (255,255,255,255)
SelectedTextBackgroundColor = (10,110,255,255)
SelectionPointColor = (110,110,255,255)
LimitTextWidth = false
SelectionPointWidth = 2
NumbersOnly = false
}
Button: ""
{
ConfigFile = "confs/Black.conf"
Left = 270
Top = 440
Width = 260
Height = 60
Visible = true
Enabled = true
Transparency = 255
Callback = LeftMouseClicked
CallbackId = 1
Text = "Login"
TextColor = (200,200,200,255)
TextSize = 40
}
}