-
-
Notifications
You must be signed in to change notification settings - Fork 4
feat: C# scripting improvements #10
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
Changes from 1 commit
890e28a
25976bd
faf405b
5954f0d
3f63c62
becdb0d
f7b98a1
2c9f726
70374ee
e02632c
35a0f20
3edde01
1761147
63b299c
b7daa01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| <Solution /> | ||
| <Solution> | ||
| <Configurations> | ||
| <Platform Name="x64" /> | ||
| </Configurations> | ||
| <Project Path="D:/Projects/3D_Rad_Space/3DRadSpace/Dummy/Dummy.vcxproj" Id="d87f5240-7a4a-fb1f-f513-330b76252c7e" /> | ||
| </Solution> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| #include "EditObject.hpp" | ||
| #include "..\..\resource.h" | ||
| #include <CommCtrl.h> | ||
| #include <Engine3DRadSpace/Objects/Impl/Objects.hpp> | ||
| #include <psapi.h> | ||
|
|
||
| using namespace Engine3DRadSpace; | ||
| using namespace Engine3DRadSpace::Content; | ||
| using namespace Engine3DRadSpace::Reflection; | ||
| using namespace Engine3DRadSpace::Objects; | ||
|
|
||
| std::unordered_map<std::string, Plugins::ObjectCustomWindow> customWindowFunctions; | ||
|
|
||
| void* EditObject(HWND hwnd, HINSTANCE hInstance, void* pRefl, void* pContent, void* pObj) | ||
| { | ||
| auto refl = static_cast<ReflectedObject*>(pRefl); | ||
| auto content = static_cast<ContentManager*>(pContent); | ||
| auto obj = static_cast<IObject*>(pObj); | ||
|
|
||
| bool useDefaultWindow = true; | ||
| std::string customWindowFnName; | ||
|
|
||
| for (auto field : *refl) | ||
| { | ||
| if (Attribute* attribute = dynamic_cast<Attribute*>(field); attribute != nullptr) | ||
| { | ||
| if (attribute->FieldName() == "CustomWindow") | ||
| { | ||
| customWindowFnName = attribute->FieldDesc(); | ||
|
|
||
| useDefaultWindow = false; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if (useDefaultWindow) | ||
| { | ||
| EditObjectDialog dialog(hwnd, hInstance, refl, content); | ||
| return dialog.ShowDialog(); | ||
| } | ||
| else | ||
| { | ||
| if (customWindowFunctions.find(customWindowFnName) != customWindowFunctions.end()) | ||
| { | ||
| auto customWindowFn = customWindowFunctions[customWindowFnName]; | ||
| return customWindowFn(hwnd, hInstance, refl, content, obj); | ||
| } | ||
|
|
||
| std::vector<HMODULE> modules; | ||
| modules.emplace_back(nullptr); | ||
|
|
||
| DWORD neededSize = 0; | ||
| EnumProcessModules(GetCurrentProcess(), modules.data(), sizeof(HMODULE), &neededSize); | ||
|
|
||
| modules.resize(neededSize / sizeof(HMODULE)); | ||
|
|
||
| auto r = EnumProcessModules(GetCurrentProcess(), modules.data(), neededSize, &neededSize); | ||
|
|
||
| if (!r) throw std::exception("Failed to enumerate process modules!"); | ||
|
NicusorN5 marked this conversation as resolved.
Outdated
|
||
|
|
||
| for (auto module : modules) | ||
| { | ||
| auto customWindowFn = reinterpret_cast<Plugins::ObjectCustomWindow>(GetProcAddress(module, customWindowFnName.c_str())); | ||
|
|
||
| if (customWindowFn != nullptr) | ||
| { | ||
| customWindowFunctions[customWindowFnName] = customWindowFn; | ||
| return customWindowFn(hwnd, hInstance, refl, content, obj); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| throw std::runtime_error("Custom window procedure not found: " + customWindowFnName); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #pragma once | ||
| #include "EditObjectDialog.hpp" | ||
| #include <Engine3DRadSpace/Plugins/CustomObject.hpp> | ||
|
|
||
| void* EditObject(HWND hwnd, HINSTANCE hInstance, void* refl, void* content, void* obj = nullptr); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -964,16 +964,13 @@ LRESULT __stdcall EditorWindow_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA | |
| { | ||
| IObject *obj = gEditorWindow->editor->Objects->operator[](objID.second.value()); | ||
|
|
||
| EditObjectDialog eod( | ||
| gEditorWindow->_mainWindow, | ||
| //update the list view. | ||
| IObject* new_obj = static_cast<IObject*>(EditObject(gEditorWindow->_mainWindow, | ||
| gEditorWindow->_hInstance, | ||
| Internal::GetReflDataFromUUID(obj->GetUUID()), | ||
| gEditorWindow->GetContentManager(), | ||
| obj | ||
| ); | ||
|
|
||
| //update the list view. | ||
| auto new_obj = eod.ShowDialog(); | ||
| )); | ||
| if(new_obj != reinterpret_cast<void *>(IDCANCEL) && new_obj != nullptr) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 HIGH RISK Directly comparing a pointer to
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to be fixed later |
||
| { | ||
| TVITEMA item{}; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <ItemGroup Label="ProjectConfigurations"> | ||
| <ProjectConfiguration Include="Debug|x64"> | ||
| <Configuration>Debug</Configuration> | ||
| <Platform>x64</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Release|x64"> | ||
| <Configuration>Release</Configuration> | ||
| <Platform>x64</Platform> | ||
| </ProjectConfiguration> | ||
| </ItemGroup> | ||
| <PropertyGroup Label="Globals"> | ||
| <ProjectGuid>{D87F5240-7A4A-FB1F-F513-330B76252C7E}</ProjectGuid> | ||
| <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" /> | ||
| <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <EnableASAN>true</EnableASAN> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <ConfigurationType>Application</ConfigurationType> | ||
| <PlatformToolset>v145</PlatformToolset> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <PreferredToolArchitecture>x64</PreferredToolArchitecture> | ||
| </PropertyGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <ClCompile> | ||
| <AdditionalIncludeDirectories>D:\Projects\3D_Rad_Space\3DRadSpace\out\build\x64-Release\Include; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
|
NicusorN5 marked this conversation as resolved.
Outdated
NicusorN5 marked this conversation as resolved.
Outdated
|
||
| <LanguageStandard>stdcpplatest</LanguageStandard> | ||
| <LanguageStandard_C>stdclatest</LanguageStandard_C> | ||
| </ClCompile> | ||
| <Link> | ||
| <AdditionalLibraryDirectories>D:\Projects\3D_Rad_Space\3DRadSpace\out\build\x64-Release\Bin\Windows-x64\Debug; %(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
| <AdditionalDependencies>3DRadSpace.Core.lib;3DRadSpace.Math.lib;3DRadSpace.Audio.lib;3DRadSpace.Content.lib;3DRadSpace.Content.Assets.lib;3DRadSpace.Games.lib;3DRadSpace.Graphics.lib;3DRadSpace.Graphics.DirectX11.lib;3DRadSpace.Graphics.Null.lib;3DRadSpace.Graphics.Primitives.lib;3DRadSpace.Graphics.Rendering.lib;3DRadSpace.Input.lib;3DRadSpace.Logging.lib;3DRadSpace.Native.lib;3DRadSpace.Objects.lib;3DRadSpace.Objects.Impl.lib;3DRadSpace.Physics.lib;3DRadSpace.Physics.NVPhysX.lib;3DRadSpace.Physics.Objects.lib;3DRadSpace.Projects.lib;3DRadSpace.Reflection.lib;3DRadSpace.Scripting.lib; %(AdditionalDependencies) </AdditionalDependencies> | ||
| </Link> | ||
| <PostBuildEvent> | ||
| <Command>xcopy /y /d "D:\Projects\3D_Rad_Space\3DRadSpace\out\build\x64-Release\Bin\Windows-x64\Debug\*.dll" "$(TargetDir)"</Command> | ||
| </PostBuildEvent> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <ClCompile> | ||
| <AdditionalIncludeDirectories>D:\Projects\3D_Rad_Space\3DRadSpace\out\build\x64-Release\Include\; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
| <LanguageStandard>stdcpplatest</LanguageStandard> | ||
| </ClCompile> | ||
| <Link> | ||
| <AdditionalDependencies>3DRadSpace.Core.lib;3DRadSpace.Math.lib;3DRadSpace.Audio.lib;3DRadSpace.Content.lib;3DRadSpace.Content.Assets.lib;3DRadSpace.Games.lib;3DRadSpace.Graphics.lib;3DRadSpace.Graphics.DirectX11.lib;3DRadSpace.Graphics.Null.lib;3DRadSpace.Graphics.Primitives.lib;3DRadSpace.Graphics.Rendering.lib;3DRadSpace.Input.lib;3DRadSpace.Logging.lib;3DRadSpace.Native.lib;3DRadSpace.Objects.lib;3DRadSpace.Objects.Impl.lib;3DRadSpace.Physics.lib;3DRadSpace.Physics.NVPhysX.lib;3DRadSpace.Physics.Objects.lib;3DRadSpace.Projects.lib;3DRadSpace.Reflection.lib;3DRadSpace.Scripting.lib; %(AdditionalDependencies)</AdditionalDependencies> | ||
| <AdditionalLibraryDirectories>D:\Projects\3D_Rad_Space\3DRadSpace\out\build\x64-Release\Bin\Windows-x64\Release; %(AdditionalLibraryDirectories) </AdditionalLibraryDirectories> | ||
| </Link> | ||
| <PostBuildEvent> | ||
| <Command>xcopy /y /d "D:\Projects\3D_Rad_Space\3DRadSpace\out\build\x64-Release\Bin\Windows-x64\Release\*.dll" "$(TargetDir)"</Command> | ||
| </PostBuildEvent> | ||
| </ItemDefinitionGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
| <ItemGroup> | ||
| <ClCompile Include="main.cpp" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ResourceCompile Include="..\3DRadSpace_Compiler\3DRadSpace_Compiler.rc"> | ||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | ||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | ||
| </ResourceCompile> | ||
| <ResourceCompile Include="..\3DRadSpace_Editor_WindowsDX11\3DRadSpace_Editor_WindowsDX11.rc"> | ||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | ||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | ||
| </ResourceCompile> | ||
| <ResourceCompile Include="..\Engine3DRadSpace\Scripting\CSharp\Resources.rc"> | ||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> | ||
| <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> | ||
| </ResourceCompile> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClInclude Include="..\Engine3DRadSpace\Scripting\CSharp\resource.h" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Image Include="..\Engine3DRadSpace\Scripting\CSharp\OBJ_Script.ico" /> | ||
| <Image Include="OBJ_Script.ico" /> | ||
| </ItemGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" /> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| //This project is used to edit RC files because of an limitation inside VS2026 using CMake | ||
| int main() {} |
Uh oh!
There was an error while loading. Please reload this page.