First Commit on new Git-Base, yey!
This commit is contained in:
181
src/Engine.h
181
src/Engine.h
@@ -12,6 +12,8 @@
|
||||
#include "PhysicsSystem.h"
|
||||
#include "AudioSystem.h"
|
||||
#include "PackageManager.h"
|
||||
#include "ManagedScriptRuntime.h"
|
||||
#include "ThirdParty/ImGuiColorTextEdit/TextEditor.h"
|
||||
#include "../include/Window/Window.h"
|
||||
#include <unordered_map>
|
||||
#include <unordered_set>
|
||||
@@ -22,6 +24,7 @@
|
||||
#include <thread>
|
||||
|
||||
void window_size_callback(GLFWwindow* window, int width, int height);
|
||||
fs::path resolveScriptsConfigPath(const Project& project);
|
||||
|
||||
class Engine {
|
||||
private:
|
||||
@@ -74,7 +77,15 @@ private:
|
||||
bool showConsole = true;
|
||||
bool showProjectBrowser = true; // Now merged into file browser
|
||||
bool showMeshBuilder = false;
|
||||
bool showBuildSettings = false;
|
||||
bool showStyleEditor = false;
|
||||
bool showScriptingWindow = false;
|
||||
bool firstFrame = true;
|
||||
bool playerMode = false;
|
||||
bool autoStartRequested = false;
|
||||
bool autoStartPlayerMode = false;
|
||||
std::string autoStartProjectPath;
|
||||
std::string autoStartSceneName;
|
||||
std::vector<std::string> consoleLog;
|
||||
int draggedObjectId = -1;
|
||||
|
||||
@@ -103,8 +114,34 @@ private:
|
||||
|
||||
char fileBrowserSearch[256] = "";
|
||||
float fileBrowserIconScale = 1.0f; // 0.5 to 2.0 range
|
||||
float fileBrowserSidebarWidth = 220.0f;
|
||||
bool showFileBrowserSidebar = true;
|
||||
std::vector<fs::path> fileBrowserFavorites;
|
||||
std::string uiStylePresetName = "Current";
|
||||
enum class UIAnimationMode {
|
||||
Off = 0,
|
||||
Snappy = 1,
|
||||
Fluid = 2
|
||||
};
|
||||
enum class WorkspaceMode {
|
||||
Default = 0,
|
||||
Animation = 1,
|
||||
Scripting = 2
|
||||
};
|
||||
UIAnimationMode uiAnimationMode = UIAnimationMode::Off;
|
||||
WorkspaceMode currentWorkspace = WorkspaceMode::Default;
|
||||
bool workspaceLayoutDirty = false;
|
||||
bool pendingWorkspaceReload = false;
|
||||
fs::path pendingWorkspaceIniPath;
|
||||
bool editorSettingsDirty = false;
|
||||
bool showEnvironmentWindow = true;
|
||||
bool showCameraWindow = true;
|
||||
bool showAnimationWindow = false;
|
||||
int animationTargetId = -1;
|
||||
int animationSelectedKey = -1;
|
||||
float animationCurrentTime = 0.0f;
|
||||
bool animationIsPlaying = false;
|
||||
float animationLastAppliedTime = -1.0f;
|
||||
bool hierarchyShowTexturePreview = false;
|
||||
bool hierarchyPreviewNearest = false;
|
||||
std::unordered_map<std::string, bool> texturePreviewFilterOverrides;
|
||||
@@ -121,6 +158,8 @@ private:
|
||||
bool gameViewportFocused = false;
|
||||
bool showGameProfiler = true;
|
||||
bool showCanvasOverlay = false;
|
||||
bool showUIWorldGrid = true;
|
||||
bool showSceneGrid3D = false;
|
||||
int gameViewportResolutionIndex = 0;
|
||||
int gameViewportCustomWidth = 1920;
|
||||
int gameViewportCustomHeight = 1080;
|
||||
@@ -139,10 +178,41 @@ private:
|
||||
std::vector<int> meshEditSelectedVertices;
|
||||
std::vector<int> meshEditSelectedEdges; // indices into generated edge list
|
||||
std::vector<int> meshEditSelectedFaces; // indices into mesh faces
|
||||
struct UIAnimationState {
|
||||
float hover = 0.0f;
|
||||
float active = 0.0f;
|
||||
float sliderValue = 0.0f;
|
||||
bool initialized = false;
|
||||
};
|
||||
std::unordered_map<int, UIAnimationState> uiAnimationStates;
|
||||
struct UIWorldCamera2D {
|
||||
glm::vec2 position = glm::vec2(0.0f);
|
||||
float zoom = 100.0f; // pixels per world unit
|
||||
glm::vec2 viewportSize = glm::vec2(0.0f);
|
||||
|
||||
glm::vec2 WorldToScreen(const glm::vec2& world) const {
|
||||
return glm::vec2(
|
||||
(world.x - position.x) * zoom + viewportSize.x * 0.5f,
|
||||
(position.y - world.y) * zoom + viewportSize.y * 0.5f
|
||||
);
|
||||
}
|
||||
|
||||
glm::vec2 ScreenToWorld(const glm::vec2& screen) const {
|
||||
return glm::vec2(
|
||||
(screen.x - viewportSize.x * 0.5f) / zoom + position.x,
|
||||
position.y - (screen.y - viewportSize.y * 0.5f) / zoom
|
||||
);
|
||||
}
|
||||
};
|
||||
bool uiWorldMode = false;
|
||||
bool uiWorldPanning = false;
|
||||
UIWorldCamera2D uiWorldCamera;
|
||||
bool consoleWrapText = true;
|
||||
enum class MeshEditSelectionMode { Vertex = 0, Edge = 1, Face = 2 };
|
||||
MeshEditSelectionMode meshEditSelectionMode = MeshEditSelectionMode::Vertex;
|
||||
ScriptCompiler scriptCompiler;
|
||||
ScriptRuntime scriptRuntime;
|
||||
ManagedScriptRuntime managedRuntime;
|
||||
PhysicsSystem physics;
|
||||
AudioSystem audio;
|
||||
bool showCompilePopup = false;
|
||||
@@ -151,8 +221,58 @@ private:
|
||||
bool lastCompileSuccess = false;
|
||||
std::string lastCompileStatus;
|
||||
std::string lastCompileLog;
|
||||
float compileProgress = 0.0f;
|
||||
std::string compileStage;
|
||||
enum class BuildPlatform {
|
||||
Windows = 0,
|
||||
Linux = 1,
|
||||
Android = 2
|
||||
};
|
||||
struct BuildSceneEntry {
|
||||
std::string name;
|
||||
bool enabled = true;
|
||||
};
|
||||
struct BuildSettings {
|
||||
BuildPlatform platform = BuildPlatform::Windows;
|
||||
std::string architecture = "x86_64";
|
||||
bool developmentBuild = false;
|
||||
bool autoConnectProfiler = false;
|
||||
bool scriptDebugging = false;
|
||||
bool deepProfiling = false;
|
||||
bool scriptsOnlyBuild = false;
|
||||
bool serverBuild = false;
|
||||
std::string compressionMethod = "Default";
|
||||
std::vector<BuildSceneEntry> scenes;
|
||||
};
|
||||
BuildSettings buildSettings;
|
||||
int buildSettingsSelectedIndex = -1;
|
||||
bool buildSettingsDirty = false;
|
||||
struct ExportJobResult {
|
||||
bool success = false;
|
||||
std::string message;
|
||||
fs::path outputDir;
|
||||
};
|
||||
struct ExportJobState {
|
||||
bool active = false;
|
||||
bool done = false;
|
||||
bool success = false;
|
||||
bool cancelled = false;
|
||||
float progress = 0.0f;
|
||||
std::string status;
|
||||
std::string log;
|
||||
fs::path outputDir;
|
||||
bool runAfter = false;
|
||||
std::future<ExportJobResult> future;
|
||||
};
|
||||
ExportJobState exportJob;
|
||||
std::atomic<bool> exportCancelRequested = false;
|
||||
std::mutex exportMutex;
|
||||
bool showExportDialog = false;
|
||||
bool exportRunAfter = false;
|
||||
char exportOutputPath[512] = "";
|
||||
struct ScriptCompileJobResult {
|
||||
bool success = false;
|
||||
bool isManaged = false;
|
||||
fs::path scriptPath;
|
||||
fs::path binaryPath;
|
||||
std::string compiledSource;
|
||||
@@ -168,6 +288,7 @@ private:
|
||||
std::unordered_map<std::string, fs::file_time_type> scriptLastAutoCompileTime;
|
||||
std::deque<fs::path> autoCompileQueue;
|
||||
std::unordered_set<std::string> autoCompileQueued;
|
||||
bool managedAutoCompileQueued = false;
|
||||
double scriptAutoCompileLastCheck = 0.0;
|
||||
double scriptAutoCompileInterval = 0.5;
|
||||
struct ProjectLoadResult {
|
||||
@@ -180,6 +301,16 @@ private:
|
||||
double projectLoadStartTime = 0.0;
|
||||
std::string projectLoadPath;
|
||||
std::future<ProjectLoadResult> projectLoadFuture;
|
||||
bool sceneLoadInProgress = false;
|
||||
float sceneLoadProgress = 0.0f;
|
||||
std::string sceneLoadStatus;
|
||||
std::string sceneLoadSceneName;
|
||||
std::vector<SceneObject> sceneLoadObjects;
|
||||
std::vector<size_t> sceneLoadAssetIndices;
|
||||
size_t sceneLoadAssetsDone = 0;
|
||||
int sceneLoadNextId = 0;
|
||||
int sceneLoadVersion = 9;
|
||||
float sceneLoadTimeOfDay = -1.0f;
|
||||
bool specMode = false;
|
||||
bool testMode = false;
|
||||
bool collisionWireframe = false;
|
||||
@@ -192,6 +323,21 @@ private:
|
||||
};
|
||||
std::vector<UIStylePreset> uiStylePresets;
|
||||
int uiStylePresetIndex = 0;
|
||||
struct ScriptEditorState {
|
||||
fs::path filePath;
|
||||
std::string buffer;
|
||||
bool dirty = false;
|
||||
bool autoCompileOnSave = true;
|
||||
bool hasWriteTime = false;
|
||||
fs::file_time_type lastWriteTime;
|
||||
};
|
||||
ScriptEditorState scriptEditorState;
|
||||
std::vector<fs::path> scriptingFileList;
|
||||
std::vector<std::string> scriptingCompletions;
|
||||
TextEditor scriptTextEditor;
|
||||
bool scriptTextEditorReady = false;
|
||||
char scriptingFilter[128] = "";
|
||||
bool scriptingFilesDirty = true;
|
||||
// Private methods
|
||||
SceneObject* getSelectedObject();
|
||||
glm::vec3 getSelectionCenterWorld(bool worldSpace) const;
|
||||
@@ -222,6 +368,7 @@ private:
|
||||
void renderPlayControlsBar();
|
||||
void renderEnvironmentWindow();
|
||||
void renderCameraWindow();
|
||||
void renderAnimationWindow();
|
||||
void renderHierarchyPanel();
|
||||
void renderObjectNode(SceneObject& obj, const std::string& filter,
|
||||
std::vector<bool>& ancestorHasNext, bool isLast, int depth);
|
||||
@@ -230,12 +377,16 @@ private:
|
||||
void renderInspectorPanel();
|
||||
void renderConsolePanel();
|
||||
void renderViewport();
|
||||
void renderPlayerViewport();
|
||||
void renderGameViewportWindow();
|
||||
void renderBuildSettingsWindow();
|
||||
void renderScriptingWindow();
|
||||
void renderDialogs();
|
||||
void updateCompileJob();
|
||||
void renderProjectBrowserPanel();
|
||||
void renderScriptEditorWindows();
|
||||
void refreshScriptEditorWindows();
|
||||
void refreshScriptingFileList();
|
||||
Camera makeCameraFromObject(const SceneObject& obj) const;
|
||||
void compileScriptFile(const fs::path& scriptPath);
|
||||
void updateAutoCompileScripts();
|
||||
@@ -244,13 +395,38 @@ private:
|
||||
void startProjectLoad(const std::string& path);
|
||||
void pollProjectLoad();
|
||||
void finishProjectLoad(ProjectLoadResult& result);
|
||||
void beginDeferredSceneLoad(const std::string& sceneName);
|
||||
void pollSceneLoad();
|
||||
void finalizeDeferredSceneLoad();
|
||||
void syncPlayerCamera();
|
||||
void updateScripts(float delta);
|
||||
void updatePlayerController(float delta);
|
||||
void updateRigidbody2D(float delta);
|
||||
void updateCameraFollow2D(float delta);
|
||||
void updateSkeletalAnimations(float delta);
|
||||
void updateSkinningMatrices();
|
||||
void rebuildSkeletalBindings();
|
||||
void initUIStylePresets();
|
||||
int findUIStylePreset(const std::string& name) const;
|
||||
const UIStylePreset* getUIStylePreset(const std::string& name) const;
|
||||
void registerUIStylePreset(const std::string& name, const ImGuiStyle& style, bool replace);
|
||||
bool applyUIStylePresetByName(const std::string& name);
|
||||
void applyWorkspacePreset(WorkspaceMode mode, bool rebuildLayout);
|
||||
void buildWorkspaceLayout(WorkspaceMode mode);
|
||||
fs::path getEditorUserSettingsPath() const;
|
||||
fs::path getEditorLayoutPath() const;
|
||||
fs::path getWorkspaceLayoutPath(WorkspaceMode mode) const;
|
||||
void loadEditorUserSettings();
|
||||
void saveEditorUserSettings() const;
|
||||
void exportEditorThemeLayout();
|
||||
void resetBuildSettings();
|
||||
void loadBuildSettings();
|
||||
void saveBuildSettings();
|
||||
bool addSceneToBuildSettings(const std::string& sceneName, bool enabled);
|
||||
void loadAutoStartConfig();
|
||||
void applyAutoStartMode();
|
||||
void startExportBuild(const fs::path& outputDir, bool runAfter);
|
||||
void pollExportBuild();
|
||||
|
||||
void renderFileBrowserToolbar();
|
||||
void renderFileBrowserBreadcrumb();
|
||||
@@ -258,6 +434,7 @@ private:
|
||||
void renderFileBrowserListView();
|
||||
void renderFileContextMenu(const fs::directory_entry& entry);
|
||||
void handleFileDoubleClick(const fs::directory_entry& entry);
|
||||
void openScriptInEditor(const fs::path& path);
|
||||
ImVec4 getFileCategoryColor(FileCategory category) const;
|
||||
const char* getFileCategoryIconText(FileCategory category) const;
|
||||
|
||||
@@ -308,6 +485,10 @@ public:
|
||||
SceneObject* findObjectByName(const std::string& name);
|
||||
SceneObject* findObjectById(int id);
|
||||
fs::path resolveScriptBinary(const fs::path& sourcePath);
|
||||
fs::path resolveManagedAssembly(const fs::path& sourcePath);
|
||||
fs::path getManagedProjectPath() const;
|
||||
fs::path getManagedOutputDll() const;
|
||||
void compileManagedScripts();
|
||||
void markProjectDirty();
|
||||
// Script-accessible logging wrapper
|
||||
void addConsoleMessageFromScript(const std::string& message, ConsoleMessageType type);
|
||||
|
||||
Reference in New Issue
Block a user