Skip to content

Commit

Permalink
Merge pull request #30 from ClonkAndre/dev
Browse files Browse the repository at this point in the history
Move dev into main
  • Loading branch information
ClonkAndre authored Dec 20, 2024
2 parents 1fbc670 + 9406431 commit 378a255
Show file tree
Hide file tree
Showing 21 changed files with 6,095 additions and 350 deletions.
4 changes: 2 additions & 2 deletions IVSDKDotNetWrapper/AssemblyInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ using namespace System::Security::Permissions;
[assembly:AssemblyConfigurationAttribute(L"")];
[assembly:AssemblyCompanyAttribute(L"ItsClonkAndre")];
[assembly:AssemblyProductAttribute(L"IVSDKDotNetWrapper")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) ItsClonkAndre 2022 - 2024")];
[assembly:AssemblyCopyrightAttribute(L"Copyright (c) ItsClonkAndre 2022 - 2025")];
[assembly:AssemblyTrademarkAttribute(L"")];
[assembly:AssemblyCultureAttribute(L"")];

[assembly:AssemblyVersionAttribute(L"1.8.0.0")];
[assembly:AssemblyVersionAttribute(L"1.8.1.0")];

[assembly:ComVisible(false)];
141 changes: 93 additions & 48 deletions IVSDKDotNetWrapper/CLRBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,24 @@ namespace CLR
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseTick();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseTick();
}
void CLRBridge::InvokeGameLoadEvents()
{
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseGameLoad();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseGameLoad();
}
void CLRBridge::InvokeGameLoadPriorityEvents()
{
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseGameLoadPriority();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseGameLoadPriority();

// Initialize native function hooks
Native::Hooks::Initialize();
Expand All @@ -223,67 +223,105 @@ namespace CLR
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseMountDevice();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseMountDevice();
}
void CLRBridge::InvokeDrawingEvents()
{
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseDrawing();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseDrawing();
}
void CLRBridge::InvokeProcessCameraEvents()
{
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseProcessCamera();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseProcessCamera();
}
void CLRBridge::InvokeProcessAutomobileEvents(uint32_t* vehPtr)
{
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseProcessAutomobile(UIntPtr(vehPtr));
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseProcessAutomobile(UIntPtr(vehPtr));
}
void CLRBridge::InvokeProcessPadEvents(uint32_t* padPtr)
{
if (CLRBridge::IsBridgeDisabled)
return;
if (!ManagerScript::HasInstance())
return;

if (ManagerScript::s_Instance)
// Disable inputs if ImGui wants text input
if ((ImGuiIV::DisableMouseInput || ImGuiIV::DisableKeyboardInput) && !ManagerScript::GetInstance()->IsUsingController())
{
// Disable inputs if ImGui wants text input
if (DisableInputs && !ManagerScript::GetInstance()->IsUsingController())
CPad* pad = reinterpret_cast<CPad*>(padPtr);

for (int i = 0; i < 187; i++)
{
CPad* pad = reinterpret_cast<CPad*>(padPtr);
tPadValues* values = &pad->m_aValues[i];
IVSDKDotNet::Enums::ePadControls control = (IVSDKDotNet::Enums::ePadControls)i;

for (int i = 0; i < 187; i++)
if (ImGuiIV::DisableMouseInput)
{
tPadValues* values = &pad->m_aValues[i];
IVSDKDotNet::Enums::ePadControls control = (IVSDKDotNet::Enums::ePadControls)i;
switch (control)
{
// All of these have to be set to 128, otherwise they can produce some ugly results
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_DOWN:

uint8_t newCurrentValue = 0;
uint8_t newLastValue = 0;
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_GUN_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_GUN_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_GUN_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_GUN_DOWN:

case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_AXIS_X:
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_AXIS_Y:
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_RIGHT_AXIS_X:
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_RIGHT_AXIS_Y:

case IVSDKDotNet::Enums::ePadControls::INPUT_MOUSE_UD:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOUSE_LR:

case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_KEY_STUNTJUMP:

case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_AXIS_UD:
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_AXIS_LR:
values->m_nCurrentValue = 128;
values->m_nLastValue = 128;
break;

// Do nothing with these
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_DOWN:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_DOWN:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_LEFT_2:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_RIGHT_2:
break;
}
}
if (ImGuiIV::DisableKeyboardInput)
{
switch (control)
{
// All of these have to be set to 128, otherwise they can produce some ugly results

case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_DOWN:

case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_DOWN:

case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_UP:
Expand All @@ -299,46 +337,53 @@ namespace CLR
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_RIGHT_AXIS_X:
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_RIGHT_AXIS_Y:

case IVSDKDotNet::Enums::ePadControls::INPUT_MOUSE_UD:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOUSE_LR:

case IVSDKDotNet::Enums::ePadControls::INPUT_MOVE_KEY_STUNTJUMP:

case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_AXIS_UD:
case IVSDKDotNet::Enums::ePadControls::INPUT_FRONTEND_AXIS_LR:

case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_LEFT_2:
case IVSDKDotNet::Enums::ePadControls::INPUT_VEH_MOVE_RIGHT_2:
values->m_nCurrentValue = 128;
values->m_nLastValue = 128;
break;

newCurrentValue = 128;
newLastValue = 128;
// Do nothing with these
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_LEFT:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_RIGHT:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_UP:
case IVSDKDotNet::Enums::ePadControls::INPUT_LOOK_DOWN:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOUSE_UD:
case IVSDKDotNet::Enums::ePadControls::INPUT_MOUSE_LR:
break;

// Set all the other stuff to 0
default:
values->m_nCurrentValue = 0;
values->m_nLastValue = 0;
break;
}

values->m_nCurrentValue = newCurrentValue;
values->m_nLastValue = newLastValue;
}
}
}

// ManagerScript things
if (ManagerScript::s_Instance->SwitchImGuiForceCursorProperty)
{
ImGuiIV::ForceCursor = !ImGuiIV::ForceCursor;
ManagerScript::s_Instance->SwitchImGuiForceCursorProperty = false;
}

// Raise event for all subscribers
ManagerScript::s_Instance->RaiseProcessPad(UIntPtr(padPtr));
// ManagerScript things
if (ManagerScript::GetInstance()->SwitchImGuiForceCursorProperty)
{
ImGuiIV::ForceCursor = !ImGuiIV::ForceCursor;
ManagerScript::GetInstance()->SwitchImGuiForceCursorProperty = false;
}

// Raise event for all subscribers
ManagerScript::GetInstance()->RaiseProcessPad(UIntPtr(padPtr));
}
void CLRBridge::InvokeIngameStartupEvent()
{
if (CLRBridge::IsBridgeDisabled)
return;

if (ManagerScript::s_Instance)
ManagerScript::s_Instance->RaiseIngameStartup();
if (ManagerScript::HasInstance())
ManagerScript::GetInstance()->RaiseIngameStartup();
}

bool CLRBridge::DoEarlyChecks()
Expand Down
20 changes: 1 addition & 19 deletions IVSDKDotNetWrapper/CLRBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,6 @@ namespace CLR
}
}

/// <summary>
/// Will get set to true when any ImGui window is open and it wants text input.
/// </summary>
static property bool DisableInputs
{
public:
bool get()
{
return m_bDisableInputs;
}
internal:
void set(bool value)
{
m_bDisableInputs = value;
}
}

/// <summary>
/// Gets the current version of IV-SDK .NET
/// </summary>
Expand Down Expand Up @@ -281,10 +264,9 @@ namespace CLR
static bool m_bCanTerminate = false;
static bool m_bShuttingDown = false;
static bool m_bDisableScriptHookDotNetLoading = false;
static bool m_bDisableInputs = false;
static bool m_bHasMinHookInitialized = false;

static String^ m_sVersion = "1.8";
static String^ m_sVersion = "1.8.1";
static String^ m_sLogFileName;
static String^ m_sIVSDKDotNetPath;
static String^ m_sIVSDKDotNetManagerPath;
Expand Down
4 changes: 2 additions & 2 deletions IVSDKDotNetWrapper/DirectInputHook.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ static HRESULT __stdcall DInput8DeviceGetDeviceStateHook(IDirectInputDevice8* de
{
HRESULT hr = g_sDInput8DeviceGetDeviceStateOriginal(device, cbData, lpvData);

if ((cbData == sizeof(DIMOUSESTATE) || cbData == sizeof(DIMOUSESTATE2)) && CLR::CLRBridge::DisableInputs)
if ((cbData == sizeof(DIMOUSESTATE) || cbData == sizeof(DIMOUSESTATE2)) && ImGuiIV::DisableMouseInput)
device->Unacquire();

return hr;
}
static HRESULT __stdcall DInput8DeviceAcquireHook(IDirectInputDevice8* device)
{
if (CLR::CLRBridge::DisableInputs)
if (ImGuiIV::DisableMouseInput)
return DI_OK;

return g_sDInput8DeviceAcquireOriginal(device);
Expand Down
6 changes: 6 additions & 0 deletions IVSDKDotNetWrapper/IVSDKDotNetWrapper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@
<ClInclude Include="ImGui\ImGuiIncludes.h" />
<ClInclude Include="ImGui\imgui_extensions.h" />
<ClInclude Include="ImGui\imgui_hex.h" />
<ClInclude Include="ImGui\imgui_knobs.h" />
<ClInclude Include="ImGui\imspinner.h" />
<ClInclude Include="IVControlledByInfo.h" />
<ClInclude Include="IVDrawRadioHudTextDC.h" />
<ClInclude Include="IVEpisodes.h" />
Expand Down Expand Up @@ -316,6 +318,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="GameHooks.cpp" />
<ClCompile Include="ImGuiIV.cpp" />
<ClCompile Include="ImGui\imgui_extensions.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
Expand All @@ -325,6 +328,9 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="ImGui\imgui_knobs.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="IVControlledByInfo.cpp" />
<ClCompile Include="IVDrawRadioHudTextDC.cpp" />
<ClCompile Include="IVEpisodes.cpp" />
Expand Down
12 changes: 12 additions & 0 deletions IVSDKDotNetWrapper/IVSDKDotNetWrapper.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,12 @@
<ClInclude Include="IVEpisodes.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ImGui\imspinner.h">
<Filter>Header Files\ImGuiIV\ImGui</Filter>
</ClInclude>
<ClInclude Include="ImGui\imgui_knobs.h">
<Filter>Header Files\ImGuiIV\ImGui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="MemoryAccess.cpp">
Expand Down Expand Up @@ -1154,6 +1160,12 @@
<ClCompile Include="IVEpisodes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ImGui\imgui_knobs.cpp">
<Filter>Source Files\ImGui</Filter>
</ClCompile>
<ClCompile Include="ImGuiIV.cpp">
<Filter>Source Files\ImGui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc">
Expand Down
4 changes: 3 additions & 1 deletion IVSDKDotNetWrapper/ImGui/ImGuiIncludes.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
#include "imgui_impl_win32.h"
#include "imgui_impl_dx9_shader.h"
#include "imgui_extensions.h"
#include "imgui_hex.h"
#include "imgui_hex.h"
#include "imgui_knobs.h"
#include "imspinner.h"
6 changes: 6 additions & 0 deletions IVSDKDotNetWrapper/ImGui/imgui_impl_dx9_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ bool ImGui_ImplDX9_CreateFontsTexture()
pixels = (unsigned char*)dst_start;
}
#endif

// If texture already exists then we release it first
if (bd->FontTexture)
{
bd->FontTexture->Release();
}

// Upload texture to graphics system
bd->FontTexture = nullptr;
Expand Down
Loading

0 comments on commit 378a255

Please sign in to comment.