Skip to content

Commit 4f2f1e4

Browse files
committed
Editor: External Editor/IDE Support #1199 #1208
1 parent e0fa44c commit 4f2f1e4

File tree

9 files changed

+92
-61
lines changed

9 files changed

+92
-61
lines changed

builder/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ int main(int argc, char *argv[]) {
8484
Engine::setPlatformAdaptor(&EditorPlatform::instance());
8585

8686
ProjectSettings::instance()->init(parser.value(sourceFileOption).toStdString(), parser.value(targetDirectoryOption).toStdString());
87+
ProjectSettings::instance()->loadSettings();
8788

8889
PluginManager::instance()->init(&engine);
8990
AssetManager::instance()->init();
9091

91-
ProjectSettings::instance()->loadSettings();
9292
ProjectSettings::instance()->loadPlatforms();
9393

9494
if(!PluginManager::instance()->rescanProject(ProjectSettings::instance()->pluginsPath())) {

engine/src/editor/pluginmanager.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,7 @@ void PluginManager::destroy() {
161161
void PluginManager::init(Engine *engine) {
162162
m_engine = engine;
163163

164-
QString uiKit;
165-
166-
#if defined(Q_OS_UNIX)/* && !defined(Q_OS_MAC)*/
167-
uiKit = QCoreApplication::applicationDirPath() + "/../lib/uikit-editor" + gShared;
168-
#else
169-
uiKit = QCoreApplication::applicationDirPath() + "/uikit-editor" + gShared;
170-
#endif
164+
syncWhiteList();
171165

172166
loadPlugin((QCoreApplication::applicationDirPath() + "/uikit-editor" + gShared).toStdString());
173167
rescanPath((QCoreApplication::applicationDirPath() + "/plugins").toStdString());

engine/src/editor/viewport/viewport.cpp

Lines changed: 49 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -83,42 +83,44 @@ void Viewport::init() {
8383
m_rhiWindow->installEventFilter(this);
8484
layout()->addWidget(QWidget::createWindowContainer(m_rhiWindow));
8585

86-
PipelineContext *pipelineContext = m_renderSystem->pipelineContext();
87-
m_guiLayer = pipelineContext->renderTasks().back();
86+
PipelineContext *ctx = m_renderSystem->pipelineContext();
87+
if(!ctx->renderTasks().empty()) {
88+
m_guiLayer = ctx->renderTasks().back();
8889

89-
m_color = pipelineContext->resultTexture();
90-
m_color->setFlags(m_color->flags() | Texture::Feedback);
90+
m_color = ctx->resultTexture();
91+
m_color->setFlags(m_color->flags() | Texture::Feedback);
9192

92-
m_debugRender = new DebugRender;
93+
m_debugRender = new DebugRender;
9394

94-
if(!m_gameView) {
95-
m_gridRender = new GridRender;
96-
m_gridRender->setController(m_controller);
97-
m_gridRender->setInput(0, m_guiLayer->output(0));
98-
m_gridRender->setInput(1, pipelineContext->textureBuffer("depthMap"));
95+
if(!m_gameView) {
96+
m_gridRender = new GridRender;
97+
m_gridRender->setController(m_controller);
98+
m_gridRender->setInput(0, m_guiLayer->output(0));
99+
m_gridRender->setInput(1, ctx->textureBuffer("depthMap"));
99100

100-
m_outlinePass = new Outline;
101-
m_outlinePass->setController(m_controller);
102-
m_outlinePass->setInput(0, m_guiLayer->output(0));
101+
m_outlinePass = new Outline;
102+
m_outlinePass->setController(m_controller);
103+
m_outlinePass->setInput(0, m_guiLayer->output(0));
103104

104-
m_gizmoRender = new GizmoRender;
105-
m_gizmoRender->setController(m_controller);
106-
m_gizmoRender->setInput(0, m_guiLayer->output(0));
107-
m_gizmoRender->setInput(1, pipelineContext->textureBuffer("depthMap"));
105+
m_gizmoRender = new GizmoRender;
106+
m_gizmoRender->setController(m_controller);
107+
m_gizmoRender->setInput(0, m_guiLayer->output(0));
108+
m_gizmoRender->setInput(1, ctx->textureBuffer("depthMap"));
108109

109-
if(m_controller) {
110-
m_controller->init(this);
111-
}
110+
if(m_controller) {
111+
m_controller->init(this);
112+
}
112113

113-
pipelineContext->insertRenderTask(m_gridRender, m_guiLayer);
114-
pipelineContext->insertRenderTask(m_outlinePass, m_guiLayer);
115-
pipelineContext->insertRenderTask(m_gizmoRender);
114+
ctx->insertRenderTask(m_gridRender, m_guiLayer);
115+
ctx->insertRenderTask(m_outlinePass, m_guiLayer);
116+
ctx->insertRenderTask(m_gizmoRender);
116117

117-
Handles::init();
118-
}
118+
Handles::init();
119+
}
119120

120-
pipelineContext->insertRenderTask(m_debugRender, m_guiLayer);
121-
pipelineContext->subscribePost(Viewport::readPixels, this);
121+
ctx->insertRenderTask(m_debugRender, m_guiLayer);
122+
ctx->subscribePost(Viewport::readPixels, this);
123+
}
122124
}
123125
}
124126

@@ -279,33 +281,45 @@ void Viewport::setGameView(bool enabled) {
279281
}
280282

281283
void Viewport::setGridEnabled(bool enabled) {
282-
m_gridRender->setEnabled(enabled);
284+
if(m_gridRender) {
285+
m_gridRender->setEnabled(enabled);
286+
}
283287
}
284288
void Viewport::setGizmoEnabled(bool enabled) {
285-
m_gizmoRender->setEnabled(enabled);
289+
if(m_gizmoRender) {
290+
m_gizmoRender->setEnabled(enabled);
291+
}
286292
}
287293
void Viewport::setOutlineEnabled(bool enabled) {
288-
m_outlinePass->setEnabled(enabled);
294+
if(m_outlinePass) {
295+
m_outlinePass->setEnabled(enabled);
296+
}
289297
}
290298
void Viewport::setGuiEnabled(bool enabled) {
291-
m_guiLayer->setEnabled(enabled);
299+
if(m_guiLayer) {
300+
m_guiLayer->setEnabled(enabled);
301+
}
292302
}
293303

294304
void Viewport::showCube(bool enabled) {
295-
m_gizmoRender->showCube(enabled);
305+
if(m_gizmoRender) {
306+
m_gizmoRender->showCube(enabled);
307+
}
296308
}
297309

298310
void Viewport::showGizmos(bool enabled) {
299-
m_gizmoRender->showGizmos(enabled);
311+
if(m_gizmoRender) {
312+
m_gizmoRender->showGizmos(enabled);
313+
}
300314
}
301315

302316
void Viewport::onInProgressFlag(bool flag) {
303317
m_frameInProgress = flag;
304318
}
305319

306320
void Viewport::addRenderTask(PipelineTask *task) {
307-
PipelineContext *pipelineContext = m_renderSystem->pipelineContext();
308-
pipelineContext->insertRenderTask(task, pipelineContext->renderTasks().front());
321+
PipelineContext *ctx = m_renderSystem->pipelineContext();
322+
ctx->insertRenderTask(task, ctx->renderTasks().empty() ? nullptr : ctx->renderTasks().front());
309323
}
310324

311325
void Viewport::readPixels(void *object) {

engine/src/pipelinecontext.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ void PipelineContext::draw(Camera *camera) {
8888
}
8989
}
9090

91-
m_finalMaterial->setTexture(gTexture, resultTexture());
91+
if(m_finalMaterial) {
92+
m_finalMaterial->setTexture(gTexture, resultTexture());
9293

93-
// Finish
94-
m_buffer->setRenderTarget(m_defaultTarget);
95-
m_buffer->drawMesh(defaultPlane(), 0, Material::Opaque, *m_finalMaterial);
94+
// Finish
95+
m_buffer->setRenderTarget(m_defaultTarget);
96+
m_buffer->drawMesh(defaultPlane(), 0, Material::Opaque, *m_finalMaterial);
97+
}
9698

9799
for(auto it : m_postObservers) {
98100
(*it.first)(it.second);
@@ -297,7 +299,9 @@ Mesh *PipelineContext::defaultCube() {
297299
static Mesh *cube = nullptr;
298300
if(cube == nullptr) {
299301
cube = Engine::loadResource<Mesh>(".embedded/cube.fbx/Box001");
300-
cube->incRef();
302+
if(cube) {
303+
cube->incRef();
304+
}
301305
}
302306
return cube;
303307
}

modules/editor/buildtools/templates/windows/project-editor.vcxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
9797
</Midl>
9898
<Link>
99-
<AdditionalDependencies>uikit-editor.lib;angel-editor.lib;bullet-editor.lib;media-editor.lib;motiontools.lib;network-editor.lib;particletools.lib;pipelinetools.lib;qbstools.lib;rendergl-editor.lib;shadertools.lib;spineimporter.lib;texteditor.lib;texturetools.lib;tiledimporter.lib;timeline.lib;webtools.lib;next-editor.lib;engine-editor.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
99+
<AdditionalDependencies>uikit-editor.lib;angel-editor.lib;bullet-editor.lib;media-editor.lib;motiontools.lib;network-editor.lib;particletools.lib;pipelinetools.lib;rendergl-editor.lib;shadertools.lib;spineimporter.lib;texteditor.lib;texturetools.lib;tiledimporter.lib;timeline.lib;webtools.lib;next-editor.lib;engine-editor.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
100100
<AdditionalLibraryDirectories>${sdkPath}/windows/x86_64/lib;${sdkPath}/windows/x86_64/bin;${sdkPath}/windows/x86_64/bin/plugins;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
101101
<AdditionalOptions>%(AdditionalOptions) /machine:x64</AdditionalOptions>
102102
<DataExecutionPrevention>
@@ -160,7 +160,7 @@
160160
<ProxyFileName>%(Filename)_p.c</ProxyFileName>
161161
</Midl>
162162
<Link>
163-
<AdditionalDependencies>uikit-editor.lib;angel-editor.lib;bullet-editor.lib;media-editor.lib;motiontools.lib;network-editor.lib;particletools.lib;pipelinetools.lib;qbstools.lib;rendergl-editor.lib;shadertools.lib;spineimporter.lib;texteditor.lib;texturetools.lib;tiledimporter.lib;timeline.lib;webtools.lib;next-editor.lib;engine-editor.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
163+
<AdditionalDependencies>uikit-editor.lib;angel-editor.lib;bullet-editor.lib;media-editor.lib;motiontools.lib;network-editor.lib;particletools.lib;pipelinetools.lib;rendergl-editor.lib;shadertools.lib;spineimporter.lib;texteditor.lib;texturetools.lib;tiledimporter.lib;timeline.lib;webtools.lib;next-editor.lib;engine-editor.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;comdlg32.lib;advapi32.lib</AdditionalDependencies>
164164
<AdditionalLibraryDirectories>${sdkPath}/windows/x86_64/lib;${sdkPath}/windows/x86_64/bin;${sdkPath}/windows/x86_64/bin/plugins;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
165165
<AdditionalOptions>%(AdditionalOptions) /machine:x64</AdditionalOptions>
166166
<DataExecutionPrevention>
@@ -183,7 +183,7 @@
183183
</ProjectReference>
184184
</ItemDefinitionGroup>
185185
<ItemGroup>
186-
<ClCompile Include="plugin.cpp" />
186+
<ClCompile Include="../generated/plugin.cpp" />
187187
${FilesList}
188188
</ItemGroup>
189189
<ItemGroup />

thirdparty/next/inc/os/aprocess.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class NEXT_LIBRARY_EXPORT Process : public Object {
7575
int exitCode() const;
7676
bool isRunning() const;
7777

78+
static bool openUrl(const TString &url);
7879
static bool startDetached(const TString &program, const StringList &arguments, const TString &workingDirectory, const ProcessEnvironment &environment);
7980

8081
public: // signals

thirdparty/next/src/os/aprocess.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#endif
1717

1818
#include "processenvironment.h"
19-
#include "log.h"
2019

2120
class ProcessPrivate {
2221
public:
@@ -251,6 +250,21 @@ bool Process::start(const TString &program, const StringList &arguments) {
251250
return true;
252251
}
253252

253+
bool Process::openUrl(const TString &url) {
254+
StringList args;
255+
#ifdef _WIN32
256+
TString command(url);
257+
#elif __APPLE__
258+
TString command("open");
259+
args.push_back(url);
260+
#else
261+
TString command("xdg-open");
262+
args.push_back(url);
263+
#endif
264+
265+
return startDetached(command, args, TString(), ProcessEnvironment::systemEnvironment());
266+
}
267+
254268
bool Process::startDetached(const TString &program, const StringList &arguments, const TString &workingDirectory, const ProcessEnvironment &environment) {
255269
#ifdef _WIN32
256270
TString commandLine = program + " ";

worldeditor/src/main/documentmodel.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#include <editor/projectsettings.h>
99
#include <editor/pluginmanager.h>
1010

11+
#include <os/aprocess.h>
12+
1113
DocumentModel::DocumentModel() {
1214
for(auto &it : PluginManager::instance()->extensions("editor")) {
1315
addEditor(reinterpret_cast<AssetEditor *>(PluginManager::instance()->getPluginObject(it)));
@@ -48,7 +50,7 @@ void DocumentModel::newFile(AssetEditor *editor) {
4850
}
4951
}
5052

51-
AssetEditor *DocumentModel::openFile(const QString &path) {
53+
AssetEditor *DocumentModel::openFile(const QString &path) {
5254
QDir dir(ProjectSettings::instance()->contentPath().data());
5355
AssetConverterSettings *settings = AssetManager::instance()->fetchSettings(dir.absoluteFilePath(path).toStdString());
5456

@@ -81,10 +83,14 @@ AssetEditor *DocumentModel::openFile(const QString &path) {
8183
}
8284
}
8385

84-
if(editor && settings) {
85-
editor->loadAsset(settings);
86-
if(std::find(m_documents.begin(), m_documents.end(), editor) == m_documents.end()) {
87-
m_documents.push_back(editor);
86+
if(settings) {
87+
if(editor) {
88+
editor->loadAsset(settings);
89+
if(std::find(m_documents.begin(), m_documents.end(), editor) == m_documents.end()) {
90+
m_documents.push_back(editor);
91+
}
92+
} else {
93+
Process::openUrl(settings->source());
8894
}
8995
}
9096

worldeditor/src/main/mainwindow.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ void MainWindow::setGameMode(bool mode) {
293293
void MainWindow::onOpenProject(const QString &path) {
294294
ProjectModel::addProject(path.toStdString());
295295
m_projectSettings->init(path.toStdString());
296+
m_projectSettings->loadSettings();
296297

297298
PluginManager::instance()->init(m_engine);
298299

@@ -301,7 +302,6 @@ void MainWindow::onOpenProject(const QString &path) {
301302

302303
AssetManager::instance()->init();
303304

304-
m_projectSettings->loadSettings();
305305
m_projectSettings->loadPlatforms();
306306
// Read settings early for converters
307307
m_editorSettings->loadSettings();
@@ -334,7 +334,7 @@ void MainWindow::onImportFinished() {
334334
m_preview = new Preview(this);
335335

336336
m_editorSettings->loadSettings();
337-
m_projectSettings->loadSettings();
337+
338338
m_editorSettingsBrowser->init();
339339
m_projectSettingsBrowser->init();
340340

@@ -641,8 +641,6 @@ void MainWindow::build(QString platform) {
641641
args << "-p" << platform;
642642
}
643643

644-
qDebug() << args.join(" ");
645-
646644
m_builder->start("Builder", args);
647645
if(!m_builder->waitForStarted()) {
648646
aError() << qPrintable(m_builder->errorString());

0 commit comments

Comments
 (0)