Skip to content

Commit

Permalink
[Interface/FileWidget] Added missing file types & their extensions
Browse files Browse the repository at this point in the history
- Supporting Lua scripts, glTF/GLB meshes, shaders, and all new image formats

- Added a placeholder text to file widgets

- Added missing include file patterns
  • Loading branch information
Razakhel committed Jun 1, 2024
1 parent 85b538a commit 1670a3e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ set(
src/RaZor/Interface/Component/*.cpp

include/RaZor/*.hpp
include/RaZor/*.inl
include/RaZor/Interface/*.hpp
include/RaZor/Interface/*.inl
include/RaZor/Interface/Component/*.hpp
include/RaZor/Interface/Component/*.inl

assets/resources/resources.qrc
)
Expand Down
4 changes: 3 additions & 1 deletion include/RaZor/Interface/FileWidget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
#include <QLineEdit>

enum class FileType {
MESH,
IMAGE,
LUA_SCRIPT,
MESH,
SHADER,
SOUND
};

Expand Down
23 changes: 16 additions & 7 deletions include/RaZor/Interface/FileWidget.inl
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ namespace {

template <FileType FileT>
std::vector<std::string_view> recoverFileFormats() {
if constexpr (FileT == FileType::MESH)
return { "obj", "fbx", "off" };
else if constexpr (FileT == FileType::IMAGE)
return { "png", "tga" };
if constexpr (FileT == FileType::IMAGE)
return { "bmp", "gif", "hdr", "jpeg", "jpg", "pgm", "pic", "png", "ppm", "psd", "tga" };
else if constexpr (FileT == FileType::LUA_SCRIPT)
return { "lua" };
else if constexpr (FileT == FileType::MESH)
return { "fbx", "glb", "gltf", "obj", "off" };
else if constexpr (FileT == FileType::SHADER)
return { "comp", "frag", "geom", "glsl", "tesc", "tese", "vert" };
else if constexpr (FileT == FileType::SOUND)
return { "wav" };
}
Expand All @@ -44,6 +48,7 @@ template <FileType FileT>
FileWidget<FileT>::FileWidget(QWidget* parent) : QLineEdit(parent) {
setAcceptDrops(true);
setReadOnly(true);
setPlaceholderText("No file");
}

template <FileType FileT>
Expand All @@ -67,10 +72,14 @@ void FileWidget<FileT>::mousePressEvent(QMouseEvent* event) {

QString formatsStr;

if constexpr (FileT == FileType::MESH)
formatsStr += tr("Mesh");
else if constexpr (FileT == FileType::IMAGE)
if constexpr (FileT == FileType::IMAGE)
formatsStr += tr("Image");
else if constexpr (FileT == FileType::LUA_SCRIPT)
formatsStr += tr("Lua script");
else if constexpr (FileT == FileType::MESH)
formatsStr += tr("Mesh");
else if constexpr (FileT == FileType::SHADER)
formatsStr += "Shader";
else if constexpr (FileT == FileType::SOUND)
formatsStr += tr("Sound");

Expand Down

0 comments on commit 1670a3e

Please sign in to comment.