// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Scripting/ScriptingObject.h" #include "Engine/Platform/Window.h" #include "Engine/ShadowsOfMordor/Types.h" namespace CSG { class Brush; } /// /// Managed Editor root object /// class ManagedEditor : public ScriptingObject { DECLARE_SCRIPTING_TYPE_NO_SPAWN(ManagedEditor); public: static Guid ObjectID; struct InternalOptions { byte AutoReloadScriptsOnMainWindowFocus = 1; byte ForceScriptCompilationOnStartup = 1; byte UseAssetImportPathRelative = 1; byte AutoRebuildCSG = 1; float AutoRebuildCSGTimeoutMs = 50; byte AutoRebuildNavMesh = 1; float AutoRebuildNavMeshTimeoutMs = 100; }; static InternalOptions ManagedEditorOptions; public: /// /// Initializes a new instance of the class. /// ManagedEditor(); /// /// Finalizes an instance of the class. /// ~ManagedEditor(); public: /// /// Initializes managed editor. /// void Init(); /// /// Updates managed editor. /// void Update(); /// /// Exits managed editor. /// void Exit(); /// /// Gets the main window created by the c# editor. /// /// The main window Window* GetMainWindow(); /// /// Determines whether this managed editor allows reload scripts (based on editor state). /// bool CanReloadScripts(); /// /// Determines whether this managed editor allows to reload scripts by auto (based on editor options). /// bool CanAutoReloadScripts() const { return ManagedEditorOptions.AutoReloadScriptsOnMainWindowFocus != 0; } /// /// Determines whether this managed editor allows auto build CSG mesh on brush modification (based on editor state and settings). /// bool CanAutoBuildCSG(); /// /// Determines whether this managed editor allows auto build navigation mesh on scene modification (based on editor state and settings). /// bool CanAutoBuildNavMesh(); public: /// /// Checks whenever the game viewport is focused by the user (eg. can receive input). /// /// True if game viewport is focused, otherwise false. bool HasGameViewportFocus() const; /// /// Gives focus to the game viewport (game can receive input). /// void FocusGameViewport() const; /// /// Converts the screen-space position to the game viewport position. /// /// The screen-space position. /// The game viewport position. Float2 ScreenToGameViewport(const Float2& screenPos) const; /// /// Converts the game viewport position to the screen-space position. /// /// The game viewport position. /// The screen-space position. Float2 GameViewportToScreen(const Float2& viewportPos) const; /// /// Gets the game window used to simulate game in editor. Can be used to capture input for the game scripts. /// /// True if always get the window, otherwise only if focused. /// The window or null if hidden. Window* GetGameWindow(bool forceGet = false); /// /// Gets the size of the game window output. /// /// The size. Float2 GetGameWindowSize(); /// /// Called when application code calls exit. Editor may end play mode or exit normally. /// /// True if exit engine, otherwise false. bool OnAppExit(); /// /// Requests play mode when the editor is in edit mode ( once ). /// void RequestStartPlayOnEditMode(); private: void OnEditorAssemblyLoaded(MAssembly* assembly); public: // [ScriptingObject] void DestroyManaged() override; };