Skip to content
Closed
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
30 changes: 30 additions & 0 deletions CMake/ThirdParty.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,33 @@ function(Find3rdPackage)
)
endif()
endfunction()

function(Setup3rdPackage)
cmake_parse_arguments(PARAMS "" "NAME;PLATFORM;VERSION" "HASH" ${ARGN})

set(NAME "${PARAMS_NAME}")
if (DEFINED PARAMS_PLATFORM)
if ((NOT (${PARAMS_PLATFORM} STREQUAL "All")) AND (NOT (${PARAMS_PLATFORM} STREQUAL ${CMAKE_SYSTEM_NAME})))
return()
endif()
set(FULL_NAME "${PARAMS_NAME}-${PARAMS_PLATFORM}-${PARAMS_VERSION}")
else()
set(FULL_NAME "${PARAMS_NAME}-${CMAKE_SYSTEM_NAME}-${PARAMS_VERSION}")
endif()
set(URL "${3RD_REPO}/${FULL_NAME}.7z")
set(ZIP "${3RD_ZIP_DIR}/${FULL_NAME}.7z")
set(SOURCE_DIR "${3RD_SOURCE_DIR}/${FULL_NAME}")

Get3rdPlatformValue(
OUTPUT HASH_VALUE
INPUT ${PARAMS_HASH}
)
DownloadAndExtract3rdPackage(
URL ${URL}
SAVE_AS ${ZIP}
EXTRACT_TO ${SOURCE_DIR}
HASH ${HASH_VALUE}
)

set(${PARAMS_NAME}_SOURCE_DIR ${SOURCE_DIR})
endfunction()
5 changes: 5 additions & 0 deletions Editor/QML/launcher.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import QtQuick

Rectangle {
color: 'red'
}
Binary file removed Editor/Resource/logo.png
Binary file not shown.
42 changes: 25 additions & 17 deletions Editor/Source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
file(GLOB_RECURSE RESOURCES ../Resource/*)
foreach(R ${RESOURCES})
string(REGEX REPLACE ".*Resource/" "" FILENAME ${R})
list(APPEND FINAL_RESOURCES ${R}->../Resource/${FILENAME})
endforeach()
set(CMAKE_PREFIX_PATH ${QT_LIB_PREFIX})
find_package(
Qt6 ${QT_VERSION}
COMPONENTS Core Gui Widgets Quick
REQUIRED
)

qt_standard_project_setup(REQUIRES ${QT_VERSION})

file(GLOB_RECURSE SOURCES Src/*.cpp)
AddExecutable(
NAME Editor
SRC ${SOURCES}
INC Include
LIB Qt Core RHI Runtime
RES ${FINAL_RESOURCES}
)
qt_add_executable(Editor ${SOURCES})
target_include_directories(Editor PRIVATE Include)
target_link_libraries(Editor PRIVATE Core RHI Runtime Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Quick)

file(GLOB_RECURSE QML_SOURCES ../QML/*.qml)
file(GLOB_RECURSE RESOURCES ../Resource/*)

list(APPEND RESOURCES_PENDING_SET_ALIAS ${QML_SOURCES} ${RESOURCES})
foreach (RESOURCE ${RESOURCES_PENDING_SET_ALIAS})
get_filename_component(FILENAME ${RESOURCE} NAME)
set_source_files_properties(${RESOURCE} PROPERTIES QT_RESOURCE_ALIAS ${FILENAME})
endforeach ()

set_target_properties(
Editor PROPERTIES
AUTOMOC ON
AUTORCC ON
AUTOUIC ON
qt_add_qml_module(
Editor
URI editor
QML_FILES ${QML_SOURCES}
RESOURCES ${RESOURCES}
)
5 changes: 1 addition & 4 deletions Editor/Source/Include/Editor/EditorModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,10 @@
#include <Runtime/Engine.h>

namespace Editor {
class EditorModule final : public Runtime::IGameModule {
class EditorModule final : public Runtime::IEngineModule {
public:
void OnUnload() override;
::Core::ModuleType Type() const override;
Runtime::Engine* CreateEngine(const Runtime::EngineInitParams&) override;

private:
Common::UniqueRef<Runtime::Engine> engine;
};
}
28 changes: 28 additions & 0 deletions Editor/Source/Include/Editor/QmlHotReload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Created by Kindem on 2024/12/31.
//

#pragma once

#include <unordered_set>

#include <QQuickView>

namespace Editor {
class QmlHotReloadEngine {
public:
static QmlHotReloadEngine& Get();

~QmlHotReloadEngine();

void Start();
void Stop();
void Register(QQuickView* inView);
void Unregister(QQuickView* inView);

private:
QmlHotReloadEngine();

std::unordered_set<QQuickView*> liveQuickViews;
};
}
30 changes: 0 additions & 30 deletions Editor/Source/Include/Editor/Resource.h

This file was deleted.

37 changes: 0 additions & 37 deletions Editor/Source/Include/Editor/Theme.h

This file was deleted.

11 changes: 2 additions & 9 deletions Editor/Source/Include/Editor/Widget/Launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,13 @@

#pragma once

#include <QMainWindow>
#include <QVBoxLayout>
#include <Editor/Widget/QmlWidget.h>

namespace Editor {
class Launcher final : public QWidget {
class Launcher final : public QmlWidget {
Q_OBJECT

public:
Launcher();

void SetWindowProperties();
void CreateMainCol();
void CreateLogoRow() const;

QVBoxLayout* mainCol;
};
}
24 changes: 24 additions & 0 deletions Editor/Source/Include/Editor/Widget/QmlWidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// Created by Kindem on 2024/12/31.
//

#pragma once

#include <QQuickView>
#include <QWidget>

namespace Editor {
class QmlWidget : public QWidget {
Q_OBJECT

public:
explicit QmlWidget(const std::string& qmlFileName, QWidget* parent = nullptr);

QQuickView* GetQuickView();
const QUrl& GetQmlUrl() const;

private:
QUrl url;
QQuickView* quickView;
};
}
2 changes: 2 additions & 0 deletions Editor/Source/Src/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace Editor {

void Core::Cleanup() // NOLINT
{
Runtime::EngineHolder::Unload();
engine = nullptr;
::Core::ModuleManager::Get().Unload("Runtime");
}

Expand Down
5 changes: 1 addition & 4 deletions Editor/Source/Src/EditorModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace Editor {
void EditorModule::OnUnload()
{
Runtime::EngineHolder::Unload();
engine.Reset();
}

::Core::ModuleType EditorModule::Type() const
Expand All @@ -19,9 +18,7 @@ namespace Editor {

Runtime::Engine* EditorModule::CreateEngine(const Runtime::EngineInitParams& inParams)
{
Assert(engine == nullptr);
engine = new EditorEngine(inParams);
return engine.Get();
return new EditorEngine(inParams);
}
}

Expand Down
5 changes: 5 additions & 0 deletions Editor/Source/Src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <QApplication>
#include <Editor/Core.h>
#include <Editor/QmlHotReload.h>
#include <Editor/Widget/Launcher.h>

int main(int argc, char* argv[])
Expand All @@ -19,7 +20,11 @@ int main(int argc, char* argv[])
// TODO editor main
}
mainWindow->show();

auto& qmlHotReloadEngine = Editor::QmlHotReloadEngine::Get();
qmlHotReloadEngine.Start();
const int execRes = QApplication::exec();
qmlHotReloadEngine.Stop();

mainWindow = nullptr;
Editor::Core::Get().Cleanup();
Expand Down
37 changes: 37 additions & 0 deletions Editor/Source/Src/QmlHotReload.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// Created by Kindem on 2024/12/31.
//

#include <Editor/QmlHotReload.h>

namespace Editor {
QmlHotReloadEngine& QmlHotReloadEngine::Get()
{
static QmlHotReloadEngine engine;
return engine;
}

QmlHotReloadEngine::QmlHotReloadEngine() = default;

QmlHotReloadEngine::~QmlHotReloadEngine() = default;

void QmlHotReloadEngine::Start()
{
// TODO
}

void QmlHotReloadEngine::Stop()
{
// TODO
}

void QmlHotReloadEngine::Register(QQuickView* inView)
{
liveQuickViews.emplace(inView);
}

void QmlHotReloadEngine::Unregister(QQuickView* inView)
{
liveQuickViews.erase(inView);
}
} // namespace Editor
40 changes: 0 additions & 40 deletions Editor/Source/Src/Resource.cpp

This file was deleted.

Loading
Loading