Skip to content

Feat: Misc Update #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 8, 2025
Merged
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
7 changes: 4 additions & 3 deletions CMake/Common.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_UNITY_BUILD ON)

option(BUILD_EDITOR "Build Explosion editor" ON)
option(CI "Build in CI" OFF)
option(USE_UNITY_BUILD "Use unity build" OFF)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_UNITY_BUILD ${USE_UNITY_BUILD})

get_cmake_property(GENERATOR_IS_MULTI_CONFIG GENERATOR_IS_MULTI_CONFIG)
if (${GENERATOR_IS_MULTI_CONFIG})
Expand Down
16 changes: 16 additions & 0 deletions Editor/Qml/EFloatInput.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic

ETextField {
property double from: 0.0
property double to: 1.0

id: root
implicitWidth: 100

validator: DoubleValidator {
bottom: root.from
top: root.to
}
}
8 changes: 6 additions & 2 deletions Editor/Qml/ENumberInput.qml → Editor/Qml/EIntegerInput.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ Item {
id: textField
implicitWidth: 40
text: spinBox.textFromValue(spinBox.value)
readOnly: !root.editable
validator: spinBox.validator
onAccepted: {
root.value = spinBox.valueFromText(displayText, Qt.locale())
}
}

down.indicator: Rectangle {
Expand All @@ -33,7 +37,7 @@ Item {
implicitWidth: 25
implicitHeight: textField.implicitHeight
radius: 5
color: spinBox.down.hovered ? ETheme.secondaryBgColor : ETheme.primaryBgColor
color: spinBox.down.hovered ? ETheme.primaryColor : ETheme.primaryBgColor

EIcon {
name: 'minus'
Expand All @@ -47,7 +51,7 @@ Item {
implicitWidth: 25
implicitHeight: textField.implicitHeight
radius: 5
color: spinBox.up.hovered ? ETheme.secondaryBgColor : ETheme.primaryBgColor
color: spinBox.up.hovered ? ETheme.primaryColor : ETheme.primaryBgColor

EIcon {
name: 'add'
Expand Down
3 changes: 3 additions & 0 deletions Editor/Qml/ETextField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import QtQuick.Controls
import QtQuick.Controls.Basic

Item {
readonly property string displayText: textField.displayText
property string placeHolderText: ''
property int wrapMode: TextInput.NoWrap
property string text: textField.text
property bool readOnly: textField.readOnly
property var validator: null

signal accepted()
Expand All @@ -27,6 +29,7 @@ Item {
font.pixelSize: ETheme.contentFontSize
font.family: ETheme.fontFamily
wrapMode: root.wrapMode
readOnly: root.readOnly
validator: root.validator
onAccepted: root.accepted()

Expand Down
4 changes: 2 additions & 2 deletions Editor/Qml/ETheme.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ QtObject {
property color bgColor: Qt.color('#212121')
property color primaryBgColor: Qt.color('#3a3939')
property color primaryColor: Qt.color('#e74c3c')
property color primaryHoverColor: Qt.color('#ce4d40')
property color primaryHoverColor: Qt.color('#f55b4b')
property color primaryFocusColor: Qt.color('#c0392b')
property color primaryDisabledColor: Qt.color('#4b4a49')
property color secondaryColor: Qt.color('#d58845')
property color secondaryHoverColor: Qt.color('#d58845')
property color secondaryHoverColor: Qt.color('#ec9d58')
property color secondaryFocusColor: Qt.color('#9b6a40')
property color secondaryBgColor: Qt.color('#8e8e8e')
property color disabledColor: Qt.color('#676563')
Expand Down
53 changes: 45 additions & 8 deletions Editor/Qml/EWidgetSamples.qml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Rectangle {

RowLayout {
Layout.leftMargin: 5
Layout.topMargin: 35
Layout.topMargin: 15

EText {
text: 'Texts'
Expand Down Expand Up @@ -196,7 +196,7 @@ Rectangle {

RowLayout {
Layout.leftMargin: 5
Layout.topMargin: 35
Layout.topMargin: 15

EText {
text: 'Icons'
Expand Down Expand Up @@ -276,7 +276,7 @@ Rectangle {

RowLayout {
Layout.leftMargin: 5
Layout.topMargin: 35
Layout.topMargin: 15
EText {
text: 'Switches'
style: EText.Style.Title1
Expand Down Expand Up @@ -317,7 +317,7 @@ Rectangle {

RowLayout {
Layout.leftMargin: 5
Layout.topMargin: 35
Layout.topMargin: 15
EText {
text: 'TextInput'
style: EText.Style.Title1
Expand Down Expand Up @@ -393,9 +393,9 @@ Rectangle {

RowLayout {
Layout.leftMargin: 5
Layout.topMargin: 35
Layout.topMargin: 15
EText {
text: 'NumberInput'
text: 'IntegerInput'
style: EText.Style.Title1
}
}
Expand All @@ -404,7 +404,7 @@ Rectangle {
Layout.margins: 5

RowLayout {
ENumberInput {}
EIntegerInput {}

EText {
Layout.leftMargin: 5
Expand All @@ -413,7 +413,7 @@ Rectangle {
}

RowLayout {
ENumberInput {
EIntegerInput {
from: 0
to: 10
}
Expand All @@ -423,6 +423,43 @@ Rectangle {
text: 'Limit 0-10'
}
}

RowLayout {
EIntegerInput {
editable: true
}

EText {
Layout.leftMargin: 5
text: 'Editable'
}
}
}

RowLayout {
Layout.leftMargin: 5
Layout.topMargin: 15
EText {
text: 'FloatInput'
style: EText.Style.Title1
}
}

ColumnLayout {
Layout.margins: 5

RowLayout {
EFloatInput {
onAccepted: {
console.log('value accepted, value=' + text)
}
}

EText {
Layout.leftMargin: 5
text: 'Default'
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Editor/Src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QApplication>

#include <Core/Cmdline.h>
#include <Runtime/Engine.h>
#include <Editor/QmlEngine.h>
#include <Editor/Widget/Editor.h>
#include <Editor/Widget/ProjectHub.h>
Expand Down
4 changes: 3 additions & 1 deletion Editor/Src/Widget/GraphicsSampleWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Created by Kindem on 2025/3/16.
//

#include <QResizeEvent>

#include <Common/Time.h>
#include <Editor/Widget/GraphicsSampleWidget.h>
#include <Editor/Widget/moc_GraphicsSampleWidget.cpp> // NOLINT
Expand All @@ -26,7 +28,7 @@ namespace Editor {
RecreateSwapChain(width(), height());

Render::ShaderCompileOptions shaderCompileOptions;
shaderCompileOptions.includePaths = {"../Shader/Engine"};
shaderCompileOptions.includeDirectories = {"../Shader/Engine"};
shaderCompileOptions.byteCodeType = GetDevice().GetGpu().GetInstance().GetRHIType() == RHI::RHIType::directX12 ? Render::ShaderByteCodeType::dxil : Render::ShaderByteCodeType::spirv;
shaderCompileOptions.withDebugInfo = static_cast<bool>(BUILD_CONFIG_DEBUG); // NOLINT

Expand Down
1 change: 1 addition & 0 deletions Editor/Src/Widget/GraphicsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <Editor/Widget/GraphicsWidget.h>
#include <Editor/Widget/moc_GraphicsWidget.cpp> // NOLINT
#include <Render/RenderModule.h>

namespace Editor {
GraphicsWidget::GraphicsWidget(QWidget* inParent)
Expand Down
18 changes: 14 additions & 4 deletions Engine/Source/Common/Include/Common/Container.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Common {
template <typename T> static size_t SwapWithLastAndDelete(std::vector<T>& vector, size_t index);
template <typename T> static std::vector<T> GetIntersection(const std::vector<T>& lhs, const std::vector<T>& rhs);
template <typename T> static std::vector<T> GetDifferences(const std::vector<T>& lhs, const std::vector<T>& rhs);
template <typename T> static std::vector<T> Combine(const std::vector<T>& lhs, const std::vector<T>& rhs);
};

class SetUtils {
Expand Down Expand Up @@ -335,6 +336,15 @@ namespace Common {
return result;
}

template <typename T>
std::vector<T> VectorUtils::Combine(const std::vector<T>& lhs, const std::vector<T>& rhs)
{
std::vector<T> result;
result.insert(result.end(), lhs.begin(), lhs.end());
result.insert(result.end(), rhs.begin(), rhs.end());
return result;
}

template <typename T>
std::unordered_set<T> SetUtils::GetIntersection(const std::unordered_set<T>& lhs, const std::unordered_set<T>& rhs)
{
Expand Down Expand Up @@ -669,7 +679,7 @@ namespace Common {
} else if constexpr (std::is_copy_assignable_v<T>) {
TypedMemory(i) = TypedMemory(i + 1);
} else {
Assert(false);
QuickFail();
}
}
InplaceDestruct(size - 1);
Expand Down Expand Up @@ -699,7 +709,7 @@ namespace Common {
} else if constexpr (std::is_copy_assignable_v<T>) {
TypedMemory(inIndex) = TypedMemory(size - 1);
} else {
Assert(false);
QuickFail();
}
InplaceDestruct(size - 1);
size--;
Expand Down Expand Up @@ -934,15 +944,15 @@ namespace Common {
} else if constexpr (std::is_copy_constructible_v<T>) {
InplaceConstruct(i, TypedMemory(i - 1));
} else {
Assert(false);
QuickFail();
}
} else {
if constexpr (std::is_move_assignable_v<T>) {
TypedMemory(i) = std::move(TypedMemory(i - 1));
} else if constexpr (std::is_copy_assignable_v<T>) {
TypedMemory(i) = TypedMemory(i - 1);
} else {
Assert(false);
QuickFail();
}
}
}
Expand Down
1 change: 1 addition & 0 deletions Engine/Source/Common/Include/Common/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace Common {
size_t TraverseRecurse(const TraverseFunc& inFunc) const;
void CopyTo(const Path& inPath) const;
void MakeDir() const;
void Fixup();

Path operator/(const Path& inPath) const;
Path operator/(const std::string& inPath) const;
Expand Down
7 changes: 6 additions & 1 deletion Engine/Source/Common/Src/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace Common::Internal {
std::filesystem::path GetUnixStylePath(const std::string& inPath)
{
return Common::StringUtils::Replace(std::filesystem::weakly_canonical(inPath).string(), "\\", "/");
return StringUtils::Replace(inPath, "\\", "/");
}

std::filesystem::path GetUnixStylePath(const std::filesystem::path& inPath)
Expand Down Expand Up @@ -188,4 +188,9 @@ namespace Common {
{
std::filesystem::create_directories(path);
}

void Path::Fixup()
{
path = Internal::GetUnixStylePath(path);
}
} // namespace Common
13 changes: 12 additions & 1 deletion Engine/Source/Core/Include/Core/Paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace Core {
static Common::Path EngineCacheDir();
static Common::Path EngineLogDir();
static Common::Path EnginePluginDir();
static Common::Path EnginePluginDir(const std::string& pluginName);
static Common::Path EnginePluginAssetDir(const std::string& pluginName);
static Common::Path GameRootDir();
static Common::Path GameAssetDir();
Expand All @@ -38,13 +39,23 @@ namespace Core {
static Common::Path GameCacheDir();
static Common::Path GameLogDir();
static Common::Path GamePluginDir();
static Common::Path GamePluginDir(const std::string& pluginName);
static Common::Path GamePluginAssetDir(const std::string& pluginName);
static Common::Path EngineCMakeSourceDir();
static Common::Path EngineCMakeBinaryDir();
#if BUILD_TEST
static Common::Path EngineTestDir();
#endif

static bool IsEnginePath(const Common::Path& inPath);
static bool IsGamePath(const Common::Path& inPath);
static bool IsEnginePluginPath(const Common::Path& inPath);
static bool IsGamePluginPath(const Common::Path& inPath);
#if BUILD_TEST
static Common::Path EngineTest();
static bool IsEngineTestPath(const Common::Path& inPath);
#endif
static Common::Path Translate(const Common::Path& inPath);
static Common::Path TranslateAsset(const Common::Path& inPath);

private:
static Common::Path executablePath;
Expand Down
11 changes: 0 additions & 11 deletions Engine/Source/Core/Include/Core/Uri.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ namespace Core {
class CORE_API FileUriParser {
public:
explicit FileUriParser(const Uri& inUri);
bool IsEngineFile() const;
bool IsGameFile() const;
bool IsRegularFile() const;
Common::Path Parse() const;

private:
Expand All @@ -44,16 +41,8 @@ namespace Core {
class CORE_API AssetUriParser {
public:
explicit AssetUriParser(const Uri& inUri);
bool IsEngineAsset() const;
bool IsGameAsset() const;
bool IsEnginePluginAsset() const;
bool IsGamePluginAsset() const;
Common::Path Parse() const;

#if BUILD_TEST
bool IsEngineTestAsset() const;
#endif

private:
std::string content;
};
Expand Down
Loading