Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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: 7 additions & 0 deletions .github/workflows/vcpkg_restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,10 @@ jobs:

- name: Install nethost
run: vcpkg install nethost:x64-windows-release

- name: Install scintilla
run: vcpkg install scintilla:x64-windows-release

- name: Install lexilla
run: vcpkg install lexilla:x64-windows-release

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -392,3 +392,11 @@ desktop.ini
out/
3DRadSpace/Data/RecentProjects.txt
3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCa07792
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCa05476
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCa10992
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCb05476
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCb10992
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCc05476
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCd05476
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCe05476
/3DRadSpace/3DRadSpace_Editor_WindowsDX11/RCf05476
7 changes: 6 additions & 1 deletion 3DRadSpace/3DRadSpace.slnx
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
<Solution />
<Solution>
<Configurations>
<Platform Name="x64" />
</Configurations>
<Project Path="Dummy/Dummy.vcxproj" Id="d87f5240-7a4a-fb1f-f513-330b76252c7e" />
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ using namespace Engine3DRadSpace::Math;
void AngelScriptWrapper_MessageCallback(const asSMessageInfo* msg, void* param)
{
if(msg->type == asMSGTYPE_WARNING)
SetLastWarning(std::format("({}, {}) : Warning {}", msg->section, msg->row, msg->col, msg->message));
PrintWarning(std::format("({}, {}) : Warning {}", msg->section, msg->row, msg->col, msg->message));
else if(msg->type == asMSGTYPE_INFORMATION)
SetLastMessage(std::format("({}, {}) : Information {}", msg->section, msg->row, msg->col, msg->message));
PrintMessage(std::format("({}, {}) : Information {}", msg->section, msg->row, msg->col, msg->message));
if(msg->type == asMSGTYPE_ERROR)
SetLastWarning(std::format("({}, {}) : Error {}", msg->section, msg->row, msg->col, msg->message));
PrintWarning(std::format("({}, {}) : Error {}", msg->section, msg->row, msg->col, msg->message));
}

static void v2ctor_def(Vector2* self)
Expand Down
3 changes: 3 additions & 0 deletions 3DRadSpace/3DRadSpace_CSharp/3DRadSpace_CSharp.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="3DRadSpace_CSharp.csproj" />
</Solution>
76 changes: 64 additions & 12 deletions 3DRadSpace/3DRadSpace_CSharp/Internal/ScriptManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static int LoadScript(IntPtr scriptPath, IntPtr className, IntPtr ownerOb

if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(classNameStr))
{
SetWarning("Invalid script path or class name");
PrintWarning("Invalid script path or class name");
return -1;
}

Expand All @@ -38,7 +38,7 @@ public static int LoadScript(IntPtr scriptPath, IntPtr className, IntPtr ownerOb
if (!result.Success)
{
string errors = string.Join("\n", result.Errors);
SetWarning($"Script compilation failed:\n{errors}");
PrintWarning($"Script compilation failed:\n{errors}");
return -1;
}

Expand All @@ -50,14 +50,14 @@ public static int LoadScript(IntPtr scriptPath, IntPtr className, IntPtr ownerOb
}
catch (Exception ex)
{
SetWarning($"Failed to create instance: {ex.Message}");
PrintWarning($"Failed to create instance: {ex.Message}");
result.Unload();
return -1;
}

if (instance == null)
{
SetWarning("Failed to create script instance");
PrintWarning("Failed to create script instance");
result.Unload();
return -1;
}
Expand All @@ -82,7 +82,7 @@ public static int LoadScript(IntPtr scriptPath, IntPtr className, IntPtr ownerOb
}
catch (Exception ex)
{
SetWarning($"Exception in LoadScript: {ex.Message}");
PrintWarning($"Exception in LoadScript: {ex.Message}");
return -1;
}
}
Expand All @@ -105,7 +105,7 @@ public static byte UpdateScript(int scriptId)
}
catch(Exception ex)
{
SetWarning($"Exception in UpdateScript: {ex.Message}");
PrintWarning($"Exception in UpdateScript: {ex.Message}");
return 0;
}
}
Expand Down Expand Up @@ -167,10 +167,10 @@ public static byte InvokeScriptMethod(int scriptId, IntPtr methodName)
/// <summary>
/// Sets a warning message in the engine's logging system.
/// </summary>
private static void SetWarning(string message)
private static void PrintWarning(string message)
{
var warning = new Warning(message, 0, 1, IntPtr.Zero);
Warning.SetLastWarning(ref warning);
Warning.PrintWarning(ref warning);
}

private class ScriptInstance
Expand Down Expand Up @@ -216,10 +216,62 @@ public static int LoadScriptFromSource(string source, string className)
return scriptId;
}

/// <summary>
/// Gets the script instance by ID (for use from managed code).
/// </summary>
public static object? GetScriptInstance(int scriptId)
[UnmanagedCallersOnly]
public static byte CompileScript(IntPtr scriptPath, IntPtr className)
Comment thread
NicusorN5 marked this conversation as resolved.
{
try
{
string? path = Marshal.PtrToStringUTF8(scriptPath);
string? classNameStr = Marshal.PtrToStringUTF8(className);

if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(classNameStr))
{
PrintWarning("Invalid script path or class name");
return 0;
}

var result = CsCompiler.CompileFromFile(path);

if (!result.Success)
{
string errors = string.Join("\n", result.Errors);
PrintWarning($"Script compilation failed:\n{errors}");
return 0;
}

// Try to create an instance
object? instance;
try
{
instance = result.CreateInstance(classNameStr);
}
catch (Exception ex)
{
PrintWarning($"Failed to create instance: {ex.Message}");
result.Unload();
return 0;
}

if (instance == null)
{
PrintWarning("Failed to create script instance");
result.Unload();
return 0;
}
}
catch (Exception ex)
{
PrintWarning($"Exception in LoadScript: {ex.Message}");
Comment thread
NicusorN5 marked this conversation as resolved.
Outdated
return 0;
}

return 1;
Comment thread
NicusorN5 marked this conversation as resolved.
}

/// <summary>
/// Gets the script instance by ID (for use from managed code).
/// </summary>
public static object? GetScriptInstance(int scriptId)
{
return _loadedScripts.TryGetValue(scriptId, out var instance) ? instance.Instance : null;
}
Expand Down
4 changes: 2 additions & 2 deletions 3DRadSpace/3DRadSpace_CSharp/Logging/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public Message(string details, int code, IntPtr extra)
Extra = extra;
}

[DllImport("3DRadSpace.FFI.dll", CharSet = CharSet.Ansi, EntryPoint = "E3DRSP_SetLastMessage")]
public extern static void SetLastMessage(ref Message msg);
[DllImport("3DRadSpace.FFI.dll", CharSet = CharSet.Ansi, EntryPoint = "E3DRSP_PrintMessage")]
public extern static void PrintMessage(ref Message msg);
}
4 changes: 2 additions & 2 deletions 3DRadSpace/3DRadSpace_CSharp/Logging/Warning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public Warning(string details, int code, int severity, IntPtr extra)
Extra = extra;
}

[DllImport("3DRadSpace.FFI.dll", CharSet = CharSet.Ansi, EntryPoint = "E3DRSP_SetLastWarning")]
public extern static void SetLastWarning(ref Warning wrn);
[DllImport("3DRadSpace.FFI.dll", CharSet = CharSet.Ansi, EntryPoint = "E3DRSP_PrintWarning")]
public extern static void PrintWarning(ref Warning wrn);
}
51 changes: 50 additions & 1 deletion 3DRadSpace/3DRadSpace_Compiler/3DRadSpace_Compiler.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "winres.h"
#include <Windows.h>
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)

/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x0L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "3DRadSpace"
VALUE "FileDescription", "3DRadSpace Compiler"
VALUE "FileVersion", "0.0.1.0"
VALUE "InternalName", "3DRadSpace.Compiler.exe"
VALUE "LegalCopyright", "Copyright (C) 2026"
VALUE "OriginalFilename", "3DRadSpace.Compiler.exe"
VALUE "ProductName", "3DRadSpace Compiler"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// English (United Kingdom) resources

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "NumericTextbox.hpp"
#include <exception>
#include <Engine3DRadSpace/Logging/Exception.hpp>

WNDPROC NumericTextbox::editProc = nullptr;

Expand Down Expand Up @@ -76,7 +76,7 @@ NumericTextbox::NumericTextbox(HWND owner, HINSTANCE hInstance, int x, int y, in
hInstance,
nullptr
);
if (window == nullptr) throw std::exception("Failed to create a edit/textbox control for a NumericTextbox!");
if (window == nullptr) throw Engine3DRadSpace::Logging::Exception("Failed to create a edit/textbox control for a NumericTextbox!");

editProc = reinterpret_cast<WNDPROC>(SetWindowLongPtrW(window, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(NumericTextBoxProc)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
#include "..\..\resource.h"
#include <CommCtrl.h>
#include <Engine3DRadSpace/Objects/Impl/Objects.hpp>
#include <psapi.h>
#include <Engine3DRadSpace/Plugins/CustomObject.hpp>
#include "EditObject.hpp"
#include <Engine3DRadSpace/Logging/Exception.hpp>
#include <Engine3DRadSpace/Logging/Message.hpp>

using namespace Engine3DRadSpace;
using namespace Engine3DRadSpace::Objects;
Expand Down Expand Up @@ -51,8 +56,10 @@ INT_PTR WINAPI AddObjectDialog_DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARA

if(item->iItem >= 0)
{
EditObjectDialog dialog(hwnd, aod->hInstance, e3drsp_internal_objects_list[item->iItem], aod->_content);
EndDialog(hwnd, reinterpret_cast<INT_PTR>(dialog.ShowDialog()));
auto& list = Engine3DRadSpace::Internal::GetInternalObjectsList();
Logging::PrintMessage(std::format("AddObj: e3drsp_internal_objects_list 0x{:x}", reinterpret_cast<uintptr_t>(list.data())));
auto obj = EditObject(hwnd, aod->hInstance, list[item->iItem], aod->_content);
EndDialog(hwnd, reinterpret_cast<INT_PTR>(obj));
}
break;
}
Expand Down Expand Up @@ -116,17 +123,17 @@ struct objectItem

void AddObjectDialog::createForms()
{
auto& Objects = e3drsp_internal_objects_list;
auto& Objects = Engine3DRadSpace::Internal::GetInternalObjectsList();

//Create the list view control
listView = CreateWindowExA(0, "SysListView32", "", WS_VISIBLE | WS_CHILD | LVS_ALIGNTOP, 0, 0, 800, 600, window, nullptr, hInstance, nullptr);
if (listView == nullptr) throw std::exception("Failed to create a list view control!");
if (listView == nullptr) throw Engine3DRadSpace::Logging::Exception("Failed to create a list view control!");
SendMessageA(listView, LVM_ENABLEGROUPVIEW, true, 0);
SendMessageA(listView, LVM_SETITEMCOUNT, Objects.size(), LVSICF_NOSCROLL);

//Create the image list
imageList = ImageList_Create(64, 64, ILC_COLOR32, 20, 5);
if (imageList == nullptr) throw std::exception("Failed to create a image list!");
if (imageList == nullptr) throw Engine3DRadSpace::Logging::Exception("Failed to create a image list!");

//Assign the image list to the list view
SendMessageA(listView, LVM_SETIMAGELIST, LVSIL_NORMAL, reinterpret_cast<LPARAM>(imageList));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#pragma once

#include <Engine3DRadSpace/Reflection/Reflection.hpp>
#include <Engine3DRadSpace/Content/ContentManager.hpp>
#include "..\Controls\Dialog.hpp"
#include "EditObjectDialog.hpp"
#include "EditObject.hpp"

class AddObjectDialog : public Dialog
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void AssetManagerDialog::_loadAssetIcons()

if (!std::filesystem::exists(asset.Path))
{
throw std::exception("Asset is not located in the executable root directory!");
throw Logging::Exception("Asset is not located in the executable root directory!");
}

imagePath = appdataPath + (R"(\3DRadSpace\AssetImages\)" + assetPath.string()) + ".png";
Expand Down Expand Up @@ -271,7 +271,7 @@ void AssetManagerDialog::_loadAssetIcons()
image = loadImageFromFile("Data//NoAsset.png", w, h);

if (image == nullptr)
throw std::exception("default image not found!");
throw Logging::Exception("default image not found!");

//resize image to 64x64 using GDI
HDC screenDC = GetDC(nullptr);
Expand Down
Loading
Loading