MonoObject* ScriptEditorApplication::internal_SaveScene(MonoString* path) { Path nativePath = MonoUtil::monoToString(path); HSceneObject sceneRoot = gSceneManager().getRootNode(); SPtr<ProjectResourceMeta> resMeta = gProjectLibrary().findResourceMeta(nativePath); HPrefab scene; if (resMeta != nullptr) { if (resMeta->getTypeID() != TID_Prefab) return nullptr; scene = static_resource_cast<Prefab>(gProjectLibrary().load(nativePath)); scene->update(sceneRoot); gProjectLibrary().saveEntry(scene); } else { scene = Prefab::create(sceneRoot); gProjectLibrary().createEntry(scene, nativePath); } ScriptResourceBase* scriptPrefab = ScriptResourceManager::instance().getScriptResource(scene, true); return scriptPrefab->getManagedInstance(); }
void GUIResourceTreeView::dragAndDropEnded(TreeElement* overTreeElement) { if(overTreeElement != nullptr && mDraggedResources != nullptr) { ResourceTreeElement* resourceTreeElement = static_cast<ResourceTreeElement*>(overTreeElement); Path destDir = resourceTreeElement->mFullPath; if(FileSystem::isFile(destDir)) destDir = destDir.getParent(); for(UINT32 i = 0; i < mDraggedResources->numObjects; i++) { WString filename = mDraggedResources->resourcePaths[i].getWFilename(); Path currentParent = mDraggedResources->resourcePaths[i].getParent(); if(currentParent != destDir) { Path newPath = destDir; newPath.append(filename); gProjectLibrary().moveEntry(mDraggedResources->resourcePaths[i], findUniquePath(newPath)); } } } }
void GUIResourceTreeView::renameTreeElement(GUITreeView::TreeElement* element, const WString& name) { ResourceTreeElement* resourceTreeElement = static_cast<ResourceTreeElement*>(element); Path oldPath = resourceTreeElement->mFullPath; Path newPath = oldPath.getParent(); newPath.append(name); gProjectLibrary().moveEntry(oldPath, findUniquePath(newPath)); }
GUIResourceTreeView::GUIResourceTreeView(const String& backgroundStyle, const String& elementBtnStyle, const String& foldoutBtnStyle, const String& highlightBackgroundStyle, const String& selectionBackgroundStyle, const String& editBoxStyle, const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUIDimensions& dimensions) :GUITreeView(backgroundStyle, elementBtnStyle, foldoutBtnStyle, highlightBackgroundStyle, selectionBackgroundStyle, editBoxStyle, dragHighlightStyle, dragSepHighlightStyle, dimensions), mDraggedResources(nullptr), mCurrentWindow(nullptr), mDropTarget(nullptr), mDropTargetDragActive(false) { ResourceTreeViewLocator::_provide(this); gProjectLibrary().onEntryAdded.connect(std::bind(&GUIResourceTreeView::entryAdded, this, _1)); gProjectLibrary().onEntryRemoved.connect(std::bind(&GUIResourceTreeView::entryRemoved, this, _1)); const ProjectLibrary::LibraryEntry* rootEntry = gProjectLibrary().getRootEntry(); mRootElement.mFullPath = rootEntry->path; mRootElement.mElementName = mRootElement.mFullPath.getWTail(); expandElement(&mRootElement); updateFromProjectLibraryEntry(&mRootElement, rootEntry); }
void EditorApplication::saveProject() { if (!isProjectLoaded()) return; Path buildDataPath = getProjectPath(); buildDataPath.append(BUILD_DATA_PATH); BuildManager::instance().save(buildDataPath); saveWidgetLayout(EditorWidgetManager::instance().getLayout()); saveEditorSettings(); saveProjectSettings(); gProjectLibrary().saveLibrary(); }
void GUIResourceTreeView::entryAdded(const Path& path) { Path parentPath = path.getParent(); ResourceTreeElement* parentElement = findTreeElement(parentPath); assert(parentElement != nullptr); ResourceTreeElement* newElement = addTreeElement(parentElement, path); sortTreeElement(parentElement); ProjectLibrary::LibraryEntry* libEntry = gProjectLibrary().findEntry(path); assert(libEntry != nullptr); updateFromProjectLibraryEntry(newElement, libEntry); _markLayoutAsDirty(); }
void EditorApplication::unloadProject() { if (!isProjectLoaded()) return; saveProject(); mProjectSettings = bs_shared_ptr_new<ProjectSettings>(); BuildManager::instance().clear(); UndoRedo::instance().clear(); EditorWidgetManager::instance().closeAll(); gProjectLibrary().unloadLibrary(); Resources::instance().unloadAllUnused(); gSceneManager().clearScene(); mProjectPath = Path::BLANK; mProjectName = StringUtil::BLANK; mIsProjectLoaded = false; }
void EditorApplication::loadProject(const Path& projectPath) { unloadProject(); mProjectPath = projectPath; mProjectName = projectPath.getTail(); mIsProjectLoaded = true; loadProjectSettings(); Path buildDataPath = getProjectPath(); buildDataPath.append(BUILD_DATA_PATH); BuildManager::instance().load(buildDataPath); gProjectLibrary().loadLibrary(); // Do this before restoring windows to ensure types are loaded ScriptManager::instance().reload(); SPtr<EditorWidgetLayout> layout = loadWidgetLayout(); if (layout != nullptr) EditorWidgetManager::instance().setLayout(layout); }
void GUIResourceTreeView::deleteTreeElement(TreeElement* element) { ResourceTreeElement* resourceTreeElement = static_cast<ResourceTreeElement*>(element); gProjectLibrary().deleteEntry(resourceTreeElement->mFullPath); }