Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install binutils libgl1-mesa-dev zlib1g-dev libzstd-dev p7zip-full xorg-dev libopenal-dev
sudo apt install binutils libgl1-mesa-dev zlib1g-dev libzstd-dev p7zip-full xorg-dev libopenal-dev libgtk-3-dev

- name: Install Qt
run: |
Expand Down
1 change: 1 addition & 0 deletions engine/engine.qbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Project {
"../thirdparty/next/inc/math",
"../thirdparty/next/inc/core",
"../thirdparty/next/inc/anim",
"../thirdparty/next/inc/os",
"../thirdparty/physfs/src",
"../thirdparty/glfw/include",
"../thirdparty/glfm/include",
Expand Down
4 changes: 4 additions & 0 deletions engine/includes/editor/asseteditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ENGINE_EXPORT AssetEditor : public QWidget {

virtual StringList suffixes() const = 0;

virtual TString assetType() const = 0;

virtual StringList componentGroups() const;

virtual QMenu *hierarchyContextMenu(Object *object);
Expand Down Expand Up @@ -74,6 +76,8 @@ public slots:
virtual void onPasteAction();

virtual void onNewAsset();
virtual void onOpenAsset();

virtual void onSave();
virtual void onSaveAs();

Expand Down
62 changes: 43 additions & 19 deletions engine/src/editor/asseteditor.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
#include "editor/asseteditor.h"

#include <QMessageBox>
#include <QFileDialog>

#include <url.h>
#include <filedialog.h>

#include "editor/projectsettings.h"
#include "editor/assetmanager.h"
#include "editor/undostack.h"

AssetEditor::AssetEditor() :
m_undoRedo(new UndoStack) {

}

AssetEditor::~AssetEditor() {

}
Expand All @@ -21,6 +23,28 @@ void AssetEditor::onNewAsset() {
m_undoRedo->clear();
}

void AssetEditor::onOpenAsset() {
FileDialog dialog;

dialog.setMode(FileDialog::OpenFile);
dialog.setWindowTitle(TString("Save ") + assetType());

StringList list;
for(auto &it : suffixes()) {
list.push_back(TString("*.") + it);
}

dialog.addFilter(assetType(), list);
dialog.setDirectory(ProjectSettings::instance()->contentPath());

if(dialog.exec()) {
TString path(dialog.getSelectedFile());
if(!path.isEmpty()) {
loadAsset(AssetManager::instance()->fetchSettings(path));
}
}
}

void AssetEditor::loadAsset(AssetConverterSettings *settings) {
m_settings = { settings };
m_undoRedo->clear();
Expand Down Expand Up @@ -57,6 +81,10 @@ AssetEditor *AssetEditor::createInstance() {
return nullptr;
}

StringList AssetEditor::suffixes() const {
return StringList();
}

std::list<AssetConverterSettings *> &AssetEditor::openedDocuments() {
return m_settings;
}
Expand Down Expand Up @@ -130,30 +158,26 @@ void AssetEditor::onSaveAs() {
}

TString assetType(m_settings.front()->typeName());

std::map<TString, StringList> dictionary;
StringList list;
for(auto &it : suffixes()) {
dictionary[assetType].push_back(it);
list.push_back(TString("*.") + it);
}

StringList filter;
for(auto &it : dictionary) {
TString item = it.first + " (";
for(auto &suffix : it.second) {
item += TString("*.") + suffix;
}
item += ")";
filter.push_back(item);
}
FileDialog dialog;

dialog.setMode(FileDialog::SaveFile);
dialog.setWindowTitle(TString("Save ") + assetType);
dialog.addFilter(assetType, list);

dialog.setDirectory(ProjectSettings::instance()->contentPath());

QString path(QFileDialog::getSaveFileName(nullptr, QString("Save ") + assetType.data(),
ProjectSettings::instance()->contentPath().data(), TString::join(filter, ";;").data()));
if(!path.isEmpty()) {
Url info(path.toStdString());
if(dialog.exec()) {
TString path(dialog.getSelectedFile());
Url info(path);
if(info.suffix().isEmpty()) {
path += QString(".") + dictionary.begin()->second.front().data();
path += TString(".") + AssetEditor::suffixes().front();
}
saveAsset(path.toStdString());
saveAsset(path);
}
}

Expand Down
4 changes: 4 additions & 0 deletions modules/editor/motiontools/editor/animationedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ StringList AnimationEdit::suffixes() const {
return result;
}

TString AnimationEdit::assetType() const {
return "Animation";
}

void AnimationEdit::onAddVariable(QAction *action) {
TString name;
Variant value;
Expand Down
1 change: 1 addition & 0 deletions modules/editor/motiontools/editor/animationedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private slots:
void saveAsset(const TString &path) override;

StringList suffixes() const override;
TString assetType() const override;

void changeEvent(QEvent *event) override;

Expand Down
4 changes: 4 additions & 0 deletions modules/editor/particletools/editor/particleedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ StringList ParticleEdit::suffixes() const {
return result;
}

TString ParticleEdit::assetType() const {
return "Visual Effect";
}

void ParticleEdit::onActivated() {
ui->graph->reselect();
}
Expand Down
1 change: 1 addition & 0 deletions modules/editor/particletools/editor/particleedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private slots:
void saveAsset(const TString &path) override;

StringList suffixes() const override;
TString assetType() const override;

void timerEvent(QTimerEvent *) override;
void changeEvent(QEvent *event) override;
Expand Down
8 changes: 6 additions & 2 deletions modules/editor/pipelinetools/editor/pipelineedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
namespace {
const char *gMeshRender("MeshRender");
const char *gDirectLight("DirectLight");
};
}

class PipelineProxy : public Object {
A_OBJECT(PipelineProxy, Object, Proxy)
Expand All @@ -49,7 +49,7 @@ class PipelineProxy : public Object {
}

private:
PipelineEdit *m_editor = nullptr;;
PipelineEdit *m_editor = nullptr;
};

PipelineEdit::PipelineEdit() :
Expand Down Expand Up @@ -106,6 +106,10 @@ StringList PipelineEdit::suffixes() const {
return static_cast<AssetConverter *>(m_builder)->suffixes();
}

TString PipelineEdit::assetType() const {
return "Pipeline";
}

void PipelineEdit::onActivated() {
ui->schemeWidget->reselect();
}
Expand Down
1 change: 1 addition & 0 deletions modules/editor/pipelinetools/editor/pipelineedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ private slots:
void changeEvent(QEvent *event) override;

StringList suffixes() const override;
TString assetType() const override;

private:
Ui::PipelineEdit *ui;
Expand Down
4 changes: 4 additions & 0 deletions modules/editor/shadertools/editor/materialedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ StringList MaterialEdit::suffixes() const {
return {"mtl"}; // Only mtl format represented as node graph to edit
}

TString MaterialEdit::assetType() const {
return "Material";
}

void MaterialEdit::onActivated() {
ui->schemeWidget->reselect();
}
Expand Down
1 change: 1 addition & 0 deletions modules/editor/shadertools/editor/materialedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private slots:
void changeEvent(QEvent *event) override;

StringList suffixes() const override;
TString assetType() const override;

private:
ShaderCodeDialog m_codeDlg;
Expand Down
4 changes: 4 additions & 0 deletions modules/editor/texteditor/editor/textedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ StringList TextEdit::suffixes() const {
return {"cpp", "h", "as", "txt", "json", "html", "htm", "xml", "shader", "vert", "frag"};
}

TString TextEdit::assetType() const {
return "Text Document";
}

void TextEdit::on_actionFind_triggered() {
ui->findWidget->show();
ui->lineFind->setFocus();
Expand Down
1 change: 1 addition & 0 deletions modules/editor/texteditor/editor/textedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private slots:
void cleanModified() const override;

StringList suffixes() const override;
TString assetType() const override;

Ui::TextEdit *ui;
};
Expand Down
6 changes: 0 additions & 6 deletions modules/editor/texteditor/editor/textwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@
#include <syntaxhighlighter.h>
#include <theme.h>

#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QFileDialog>
#include <QFontDatabase>
#include <QMenu>
#include <QPainter>
#include <QPalette>
Expand Down Expand Up @@ -383,8 +379,6 @@ void TextWidget::paintEvent(QPaintEvent *event) {
continue;
}
if(r.bottom() >= er.top() && r.top() <= er.bottom()) {
QTextBlockFormat blockFormat = block.blockFormat();

QVector<QTextLayout::FormatRange> selections;

int blpos = block.position();
Expand Down
4 changes: 4 additions & 0 deletions modules/editor/texturetools/editor/spriteedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ StringList SpriteEdit::suffixes() const {
return static_cast<AssetConverter *>(m_converter)->suffixes();
}

TString SpriteEdit::assetType() const {
return "Sprite";
}

void SpriteEdit::onUpdateTemplate() {
if(!m_settings.empty()) {
m_converter->convertTexture(static_cast<TextureImportSettings *>(m_settings.front()));
Expand Down
1 change: 1 addition & 0 deletions modules/editor/texturetools/editor/spriteedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class SpriteEdit : public AssetEditor {
bool allowSaveAs() const override { return false; }

StringList suffixes() const override;
TString assetType() const override;

void changeEvent(QEvent *event) override;

Expand Down
1 change: 1 addition & 0 deletions modules/uikit/includes/editor/uiedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ private slots:

StringList suffixes() const override;
StringList componentGroups() const override;
TString assetType() const override;

void changeParent(const Object::ObjectList &objects, Object *parent, int position = -1) override;

Expand Down
4 changes: 4 additions & 0 deletions modules/uikit/src/editor/uiedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ StringList UiEdit::componentGroups() const {
return {"Actor", "Components/UI"};
}

TString UiEdit::assetType() const {
return "UI Document";
}

void UiEdit::changeParent(const Object::ObjectList &objects, Object *parent, int position) {
m_undoRedo->push(new ParentWidget(objects, parent, position, m_controller));
}
Expand Down
65 changes: 65 additions & 0 deletions thirdparty/next/inc/os/filedialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
This file is part of Thunder Next.

Copyright 2008-2026 Evgeniy Prikazchikov

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef FILEDIALOG_H
#define FILEDIALOG_H

#include <astring.h>
#include <memory>

class FileDialogPrivate;

class NEXT_LIBRARY_EXPORT FileDialog {
public:
enum Mode {
OpenFile,
SaveFile,
OpenDirectory,
OpenFiles
};

FileDialog();
~FileDialog();

FileDialog(const FileDialog&) = delete;
FileDialog &operator=(const FileDialog&) = delete;

FileDialog(FileDialog&&) noexcept;
FileDialog &operator=(FileDialog&&) noexcept;

void setMode(Mode m);
void setShowHidden(bool show);
void setDefaultSuffix(const TString &suffix);
void setWindowTitle(const TString &title);

void addFilter(const TString &name, const StringList &extensions);
void clearFilters();

void setDirectory(const TString &dir);

TString getSelectedFile() const;
StringList getSelectedFiles() const;

bool exec();

private:
FileDialogPrivate *m_ptr;

};

#endif // FILEDIALOG_H
Loading
Loading