mizukami
Member
|
UID to file-path.
In EE editor.
When got project elements (codes below).
----
Edit.EditorInterface EI;
Memc<Edit.Elm> elms; // list of project elements
....
EI.getElms(elms); // get a list of project elements
----
I want to know how to convert each id(UID) to file path (located at "Game" folder).
"src_file" of "Edit.Elm" is unreliable. The file might be moved already other place.
|
|
03-30-2016 05:59 AM |
|
Esenthel
Administrator
|
RE: UID to file-path.
Hi,
This should help you out:
Code:
struct EditorInterface
{
static Str ElmFileName(C UID &elm_id, C Str &data_path=S) {return elm_id.valid() ? Str(data_path).tailSlash(true)+EncodeFileName(elm_id) : S;} // get path to the element file, you can use it to access resources in read-only mode, do not write to the files under no condition
// following methods operate on currently opened project
// settings
Str dataPath(); // get project game data path, you can use it to access resources in read-only mode, do not write data to the path under no condition, "" on fail
You can call ElmFileName with the element ID and previously obtained EI.dataPath()
Or you can more simply set:
DataPath(EI.dataPath())
and after that you can access elements directly through their ID:
ImagePtr image=UID(..);
Additionally, if your application is in the same project as you want to access, then this DataPath is already setup for you in EE_INIT function which should be called in InitPre.
So you don't need to setup DataPath, but already skip to the direct ID access:
ImagePtr image=UID(..);
|
|
03-30-2016 07:00 AM |
|
mizukami
Member
|
RE: UID to file-path.
Thank you for quick reply.
I've got file_id!
Problem had solved completely.
|
|
03-30-2016 07:31 AM |
|