DeerEngine/roe/Editor/mesh_explorer.as

47 lines
1.8 KiB
ActionScript

class MeshExplorer : DockPanel {
string currentPath = "";
void onRender() {
UI::setupAutomaticColumns(128);
// To avoid problems we will cache the current path
const string cache_currentPath = currentPath;
if (cache_currentPath != "") {
UI::drawIconCentered("folder", 64);
if (UI::isItemClicked(0) and UI::isMouseDoubleClicked(0)) {
currentPath = "";
}
UI::textCenter(cache_currentPath + "/..");
UI::nextColumn();
}
ResourceType resourceType = ResourceType::Mesh;
int dirCount = Resource::getDirCount(resourceType, cache_currentPath);
for (int i = 0; i < dirCount; i++) {
UI::drawIconCentered("folder", 64);
if (UI::isItemClicked(0) and UI::isMouseDoubleClicked(0)) {
Engine::print(Resource::getDirPathById(ResourceType::Mesh, cache_currentPath, i));
currentPath = Resource::getDirPathById(ResourceType::Mesh, cache_currentPath, i);
}
UI::textCenter(Resource::getDirNameById(ResourceType::Mesh, cache_currentPath, i));
UI::nextColumn();
}
int meshCount = Resource::getResourceCount(ResourceType::Mesh, cache_currentPath);
for (int i = 0; i < meshCount; i++) {
UI::drawIconCentered("file", 64);
UI::dragDropSource("MESH",
any(Resource::getResourcePathById(ResourceType::Mesh, cache_currentPath, i)),
Resource::getResourcePathById(ResourceType::Mesh, cache_currentPath, i));
UI::textCenter(Resource::getResourceNameById(ResourceType::Mesh, cache_currentPath, i));
UI::nextColumn();
}
UI::endColumns();
}
}