DeerEngine/roe/Editor/shader_explorer.as

45 lines
1.7 KiB
ActionScript

class ShaderExplorer : 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::Shader;
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, cache_currentPath, i));
currentPath = Resource::getDirPathById(resourceType, cache_currentPath, i);
}
UI::textCenter(Resource::getDirNameById(resourceType, cache_currentPath, i));
UI::nextColumn();
}
int meshCount = Resource::getResourceCount(resourceType, cache_currentPath);
for (int i = 0; i < meshCount; i++) {
UI::drawIconCentered("file", 64);
UI::dragDropSource("SHADER",
any(Resource::getResourcePathById(resourceType, cache_currentPath, i)),
Resource::getResourcePathById(resourceType, cache_currentPath, i));
UI::textCenter(Resource::getResourceNameById(resourceType, cache_currentPath, i));
UI::nextColumn();
}
UI::endColumns();
}
}