bool ResourceOps::CheckCreate2DLevel(const String& resourcePath, const String& resourceName, bool reportError) { Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); String fullpath = resourcePath + resourceName; if (!resourceName.EndsWith(".tmx")) fullpath += ".tmx"; FileSystem* fs = GetSubsystem<FileSystem>(); if (fs->FileExists(fullpath)) { if (reportError) { String errorMsg; errorMsg.AppendWithFormat("The level:\n\n%s\n\nalready exists", fullpath.CString()); editor->PostModalError("Create 2D Level Error", errorMsg); } return false; } return true; }
void CEJavascript::HandleFileChanged(StringHash eventType, VariantMap& eventData) { Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); if (!project) return; using namespace FileChanged; const String& fileName = eventData[P_FILENAME].GetString(); //const String& resourceName = eventData[P_RESOURCENAME].GetString(); if (GetExtension(fileName) != ".js") return; if (modifiedJS_.Contains(fileName)) return; String componentsPath = AddTrailingSlash(project->GetComponentsPath()); String scriptsPath = AddTrailingSlash(project->GetScriptsPath()); String modulesPath = AddTrailingSlash(project->GetModulesPath()); if (fileName.StartsWith(componentsPath) || fileName.StartsWith(scriptsPath) || fileName.StartsWith(modulesPath)) { modifiedJS_.Push(fileName); } }
UINewProject::UINewProject(Context* context): UIModalOpWindow(context) { Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); TBUI* tbui = GetSubsystem<TBUI>(); window_->SetText("Project Type"); tbui->LoadResourceFile(window_->GetContentRoot(), "AtomicEditor/editor/ui/newproject.tb.txt"); window_->ResizeToFitContent(); Center(); }
bool ResourceOps::CheckCreateScript(const String& resourcePath, const String& resourceName, bool reportError) { Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); String fullpath = resourcePath + resourceName; if (!resourceName.EndsWith(".js")) fullpath += ".js"; FileSystem* fs = GetSubsystem<FileSystem>(); if (fs->FileExists(fullpath)) { if (reportError) { String errorMsg; errorMsg.AppendWithFormat("The script:\n\n%s\n\nalready exists", fullpath.CString()); editor->PostModalError("Create Script Error", errorMsg); } return false; } if (!project->IsScriptsDirOrFile(resourcePath)) { if (reportError) { String errorMsg; errorMsg.AppendWithFormat("Scripts must reside in or in a subfolder of the Scripts folder"); editor->PostModalError("Create Script Error", errorMsg); } return false; } return true; }
void BuildIOS::Initialize() { Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); #ifdef ATOMIC_PLATFORM_WINDOWS String bundleResources = fileSystem->GetProgramDir(); #else String bundleResources = fileSystem->GetAppBundleResourceFolder(); #endif String projectResources = project->GetResourcePath(); String coreDataFolder = bundleResources + "CoreData/"; AddResourceDir(coreDataFolder); AddResourceDir(projectResources); BuildResourceEntries(); }
bool CEJavascript::CheckJSErrors(bool fullCheck) { errors_.Clear(); Editor* editor = GetSubsystem<Editor>(); Project* project = editor->GetProject(); FileSystem* fileSystem = GetSubsystem<FileSystem>(); if (!project) { modifiedJS_.Clear(); return true; } Vector<String>& filesToCheck = modifiedJS_; Vector<String> allFiles; if (fullCheck) { filesToCheck = allFiles; String componentsPath = AddTrailingSlash(project->GetComponentsPath()); String scriptsPath = AddTrailingSlash(project->GetScriptsPath()); String modulesPath = AddTrailingSlash(project->GetModulesPath()); Vector<String> files; fileSystem->ScanDir(files, componentsPath, "*.js", SCAN_FILES, true ); for (unsigned i = 0; i < files.Size(); i++) allFiles.Push(componentsPath + files[i]); fileSystem->ScanDir(files, scriptsPath, "*.js", SCAN_FILES, true ); for (unsigned i = 0; i < files.Size(); i++) allFiles.Push(scriptsPath + files[i]); fileSystem->ScanDir(files, modulesPath, "*.js", SCAN_FILES, true ); for (unsigned i = 0; i < files.Size(); i++) allFiles.Push(modulesPath + files[i]); } bool ok = true; for (unsigned j = 0; j < filesToCheck.Size(); j++) { String source; String fullpath = filesToCheck[j]; ReadZeroTerminatedSourceFile(fullpath, source); duk_get_global_string(ctx_, "__clockwork_parse_error_check"); duk_push_string(ctx_, source.CString()); if (duk_pcall(ctx_, 1)) { printf("Error: %s\n", duk_safe_to_string(ctx_, -1)); } else { if (duk_is_boolean(ctx_, -1)) { // error if (duk_to_boolean(ctx_, -1)) ok = false; } else if (duk_is_object(ctx_, -1)) { ok = false; JSError error; error.fullpath = fullpath; duk_get_prop_string(ctx_, -1, "message"); error.message = duk_to_string(ctx_, -1); duk_pop(ctx_); duk_get_prop_string(ctx_, -1, "loc"); duk_get_prop_string(ctx_, -1, "line"); error.line = duk_to_number(ctx_, -1); duk_get_prop_string(ctx_, -2, "column"); error.column = duk_to_number(ctx_, -1); duk_get_prop_string(ctx_, -4, "raisedAt"); error.tokenPos = duk_to_number(ctx_, -1); duk_pop_3(ctx_); errors_.Push(error); } else { // what to do? } } // ignore result duk_pop(ctx_); } modifiedJS_.Clear(); return !ok; }