Game Development Community

GuiBitmapButtonCtrl bitmap path problems

by Steven Chiu · in Torque Game Engine Advanced · 04/29/2008 (9:07 pm) · 7 replies

After browsing a file and bring back the file path, I strip the suffixes from the path and press enter, then the gui automatically add the prefix to the file path and also strip the first character, e.g.

Before

scriptsAndAssets/client/ui/button_h.png

After

../../../../../criptsAndAssets/client/ui/button


So the bitmap don't appear unless I edit the gui script to correct it.

Edit: I use vista sp1.

#1
04/29/2008 (9:15 pm)
You must remove "_h.png"

like this:

scriptsAndAssets/client/ui/button
or
~/client/ui/button
#2
04/29/2008 (10:29 pm)
Yes that's just what I did and press enter.
#3
04/30/2008 (6:14 am)
Paths are relative to the location of the script being exec'd, unless you use the "~" shorthand to say "start at my mod folder". If the gui script and the button pngs are in the same folder, just use "./button"

Or perhaps, as you suggest, the TGEA Gui editor has a conversion bug.

In general, putting stuff off in some side file heirarchy like it seems you are doing may be the hard way of getting things done. The resource manager searches through the loaded mod folders for all resources. If your resources aren't in the folders it searches, I'm not sure what sorts of chaos will ensue.
#4
04/30/2008 (10:32 am)
For the button to have different states, I need to edit the path and here is the problem.
#5
05/10/2008 (6:13 pm)
I had this problem also. There is a bug in the following function, which is designed to create relative paths from absolute paths: StringTableEntry Platform::makeRelativePathName(const char *path, const char *to)

It tries to operate on relative paths, and messes up. The fix is easy - modify the function so it only works on absolute paths.

in PlatformFileIO.cpp:

StringTableEntry Platform::makeRelativePathName(const char *path, const char *to)
{
   char buffer[1024];

   if (path[1] != ':')  // is it not an absolute path?
       return StringTable->insert(path); // let's leave!
#6
05/10/2008 (6:18 pm)
Hmm - you could also use

if (!Platform::isFullPath(path) )

to check, that would make it mac/linux compatible also.
#7
05/10/2008 (9:31 pm)
That fix the problem, thanks.