klepto2 Posted December 22, 2023 Share Posted December 22, 2023 I want to add some additional handling to some files. (lets say i want to add support for a certain kind of filetype) I can succesfully hook into the EVENT_WIDGETACTION when the "Open File" menu is clicked, but how do i get the item and the needed info for what this is "Open File"-action is triggered? this is the simple hook i use: function extension.hook(event, extension) if event.id == EVENT_WIDGETACTION then local widget = Widget(event.source) if widget ~= nil and event.text == "Open File" and event.extra ~= nil then local obj = Widget(event.extra) Print(event.text) return true end end end Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted December 23, 2023 Share Posted December 23, 2023 So you want to get the file path the user selects? Or do you want to override the file requester with your own? Or just add some additional extensions to the dialog? This is how the code works: else if (text == "Open") { auto filter = GetFilePattern(FILECATEGORY_SCENE); auto file = RequestFile(L"Open File", CurrentDir() + L"/Maps/", filter, 10000); if (not file.empty()) { The get file pattern function creates the file pattern string for a category of files. For textures, it will iterate through the loaded plugins and return a file pattern that includes all of them, plus the natively supported format DDS and RAW. For maps (FILECATEGORY_SCENE) the routine just returns a hard-coded string for Ultra maps and Leadwerks maps. I have not yet thought about how additional scene loading formats should be handled. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted December 23, 2023 Author Share Posted December 23, 2023 I want to hook directly into the open file action or double-check event and retrieve the path from the object which has triggered the action. ( in the map tab) . Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted December 23, 2023 Share Posted December 23, 2023 Okay...so I guess you want to override some file types, and let the editor still load the defaults? Is this for loading a new map file format? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted December 23, 2023 Author Share Posted December 23, 2023 No, I want to open a certain window if the file type is of a certain type. (lets just assume its a shader file ) like you do by opening the modelviewer when you double click on a model. Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Josh Posted December 23, 2023 Share Posted December 23, 2023 Why not open it from the asset browser, like a texture or model? Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
klepto2 Posted December 23, 2023 Author Share Posted December 23, 2023 That is exactly what i want to do. But currently there is no way to do it. (no access to most functions or to retreive the actual node which was selected) Quote Windows 10 Pro 64-Bit-Version NVIDIA Geforce 1080 TI Link to comment Share on other sites More sharing options...
Solution Josh Posted December 23, 2023 Solution Share Posted December 23, 2023 Check for this: EmitEvent(EVENT_OPENASSET, Self(), 0, 0, 0, 0, 0, filepath->package, filepath->path); EVENT_OPENASSET is not currently exposed, but it equals 11011. Self() is the asset browser object, but there's only one of those so you can just specify nil for the source in ListenEvent(). 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.