Skip to content

Commit

Permalink
Code Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonzkiller committed Oct 29, 2024
1 parent 1ffe31c commit e4f349a
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 59 deletions.
2 changes: 0 additions & 2 deletions src/d3d12/D3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "common/D3D12Downlevel.h"
#include "window/Window.h"

extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

using TPresentD3D12Downlevel = HRESULT(ID3D12CommandQueueDownlevel*, ID3D12GraphicsCommandList*, ID3D12Resource*, HWND, D3D12_DOWNLEVEL_PRESENT_FLAGS);
using TCreateCommittedResource =
HRESULT(ID3D12Device*, const D3D12_HEAP_PROPERTIES*, D3D12_HEAP_FLAGS, const D3D12_RESOURCE_DESC*, D3D12_RESOURCE_STATES, const D3D12_CLEAR_VALUE*, const IID*, void**);
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/D3D12_Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ void D3D12::PrepareUpdate()

for (auto i = 0; i < drawData.CmdListsCount; ++i)
copiedDrawLists[i] = drawData.CmdLists[i]->CloneOutput();
drawData.CmdLists = copiedDrawLists;
drawData.CmdLists = std::move(copiedDrawLists);

std::swap(m_imguiDrawDataBuffers[1], m_imguiDrawDataBuffers[2]);
}
Expand Down
2 changes: 2 additions & 0 deletions src/imgui_impl/imgui_user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// global declaration "Enable ImGui Assertions"
extern bool g_ImGuiAssertionsEnabled;

#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD

// runtime assertions which can be enabled/disabled inside CET options
void ImGuiAssert(wchar_t const* acpMessage, wchar_t const* acpFile, unsigned aLine);

Expand Down
6 changes: 0 additions & 6 deletions src/imgui_impl/win32.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown();
IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(SIZE aOutSize);

// Win32 message handler your application need to call.
// - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on <windows.h> from this helper.
// - You should COPY the line below into your .cpp code to forward declare the function and then you can call it.
// - Call from your application's message handler. Keep calling your message handler unless this function returns TRUE.

#if 0
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
#endif

// DPI-related helpers (optional)
// - Use to enable DPI awareness without having to create an application manifest.
Expand Down
17 changes: 10 additions & 7 deletions src/overlay/widgets/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ Settings::Settings(Options& aOptions, LuaVM& aVm)

WidgetResult Settings::OnPopup()
{
const auto ret = UnsavedChangesPopup(
"Settings", m_openChangesModal, m_madeChanges, [this] { Save(); }, [this] { Load(); });
const auto ret = UnsavedChangesPopup("Settings", m_openChangesModal, m_madeChanges, [this] { Save(); }, [this] { Load(); });
m_madeChanges = ret == TChangedCBResult::CHANGED;
m_popupResult = ret;

Expand Down Expand Up @@ -54,7 +53,7 @@ void Settings::OnUpdate()
m_madeChanges = false;
if (ImGui::CollapsingHeader("Patches", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::TreePush((void*)nullptr);
ImGui::TreePush("##PATCHES");
if (ImGui::BeginTable("##SETTINGS_PATCHES", 2, ImGuiTableFlags_Sortable | ImGuiTableFlags_SizingStretchSame, ImVec2(-ImGui::GetStyle().IndentSpacing, 0)))
{
const auto& patchesSettings = m_options.Patches;
Expand All @@ -78,7 +77,9 @@ void Settings::OnUpdate()
UpdateAndDrawSetting(
"Disable Boundary Teleport", "Allows players to access out-of-bounds locations (requires restart to take effect).", m_patches.DisableBoundaryTeleport,
patchesSettings.DisableBoundaryTeleport);
UpdateAndDrawSetting("Disable V-Sync (Windows 7 only)", "Disables VSync on Windows 7 to bypass the 60 FPS limit (requires restart to take effect).", m_patches.DisableWin7Vsync, patchesSettings.DisableWin7Vsync);
UpdateAndDrawSetting(
"Disable V-Sync (Windows 7 only)", "Disables VSync on Windows 7 to bypass the 60 FPS limit (requires restart to take effect).", m_patches.DisableWin7Vsync,
patchesSettings.DisableWin7Vsync);
UpdateAndDrawSetting(
"Fix Minimap Flicker", "Fixes Minimap flicker caused by some mods (requires restart to take effect).", m_patches.MinimapFlicker,
patchesSettings.MinimapFlicker);
Expand All @@ -89,7 +90,7 @@ void Settings::OnUpdate()
}
if (ImGui::CollapsingHeader("CET Development Settings", ImGuiTreeNodeFlags_DefaultOpen))
{
ImGui::TreePush((void*)nullptr);
ImGui::TreePush("##DEV");
if (ImGui::BeginTable("##SETTINGS_DEV", 2, ImGuiTableFlags_Sortable | ImGuiTableFlags_SizingStretchSame, ImVec2(-ImGui::GetStyle().IndentSpacing, 0)))
{
const auto& developerSettings = m_options.Developer;
Expand All @@ -108,8 +109,10 @@ void Settings::OnUpdate()
"Dump Game Options", "Dumps all game options into main log file (requires restart to take effect).", m_developer.DumpGameOptions,
developerSettings.DumpGameOptions);
UpdateAndDrawSetting(
"Enable JIT for Lua", "Enables JIT compiler for Lua VM, which may majorly speed up the mods. Disable it in case you experience issues as a troubleshooting step (requires restart to take effect).", m_developer.EnableJIT,
developerSettings.EnableJIT);
"Enable JIT for Lua",
"Enables JIT compiler for Lua VM, which may majorly speed up the mods. Disable it in case you experience issues as a troubleshooting step (requires restart to "
"take effect).",
m_developer.EnableJIT, developerSettings.EnableJIT);

ImGui::EndTable();
}
Expand Down
63 changes: 21 additions & 42 deletions src/sol_imgui/sol_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

namespace sol_ImGui
{

// Version
inline std::string GetVersion()
{
return std::string(ImGui::GetVersion());
}

// Windows
inline bool Begin(const std::string& name)
{
Expand Down Expand Up @@ -50,6 +43,15 @@ inline bool BeginChild(const std::string& name, float sizeX, float sizeY)
{
return ImGui::BeginChild(name.c_str(), {sizeX, sizeY});
}
inline bool BeginChild(const std::string& name, float sizeX, float sizeY, int child_flags)
{
return ImGui::BeginChild(name.c_str(), {sizeX, sizeY}, static_cast<ImGuiChildFlags>(child_flags));
}

inline bool BeginChild(const std::string& name, float sizeX, float sizeY, int child_flags, int window_flags)
{
return ImGui::BeginChild(name.c_str(), {sizeX, sizeY}, static_cast<ImGuiChildFlags>(child_flags), static_cast<ImGuiWindowFlags>(window_flags));
}

// DEPRECATED
inline bool BeginChild(const std::string& name, float sizeX, float sizeY, bool border)
Expand All @@ -61,17 +63,6 @@ inline bool BeginChild(const std::string& name, float sizeX, float sizeY, bool b
return ImGui::BeginChild(name.c_str(), {sizeX, sizeY}, border, flags);
}

// new
inline bool BeginChild(const std::string& name, float sizeX, float sizeY, int child_flags)
{
return ImGui::BeginChild(name.c_str(), {sizeX, sizeY}, static_cast<ImGuiChildFlags>(child_flags));
}

inline bool BeginChild(const std::string& name, float sizeX, float sizeY, int child_flags, int window_flags)
{
return ImGui::BeginChild(name.c_str(), {sizeX, sizeY}, static_cast<ImGuiChildFlags>(child_flags), static_cast<ImGuiWindowFlags>(window_flags));
}

inline void EndChild()
{
ImGui::EndChild();
Expand Down Expand Up @@ -2676,30 +2667,25 @@ inline int GetKeyPressedAmount(int key_index, float repeat_delay, float rate)
{
return ImGui::GetKeyPressedAmount(static_cast<ImGuiKey>(key_index), repeat_delay, rate);
}
inline void SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard_value)
{
ImGui::SetNextFrameWantCaptureKeyboard(want_capture_keyboard_value);
}

// DEPRECATED
inline int GetKeyIndex(int imgui_key)
{
return ImGui::GetKeyIndex(static_cast<ImGuiKey>(imgui_key));
}

// DEPRECATED
inline void CaptureKeyboardFromApp()
{
ImGui::SetNextFrameWantCaptureKeyboard(true);
}
// DEPRECTED
inline void CaptureKeyboardFromApp(bool want_capture_keyboard_value)
{
ImGui::SetNextFrameWantCaptureKeyboard(want_capture_keyboard_value);
}

// new
inline void SetNextFrameWantCaptureKeyboard(bool want_capture_keyboard_value)
{
ImGui::SetNextFrameWantCaptureKeyboard(want_capture_keyboard_value);
}

// Inputs Utilities: Mouse

inline bool IsMouseDown(int button)
Expand Down Expand Up @@ -2784,23 +2770,21 @@ inline void SetMouseCursor(int cursor_type)
{
ImGui::SetMouseCursor(static_cast<ImGuiMouseCursor>(cursor_type));
}
inline void SetNextFrameWantCaptureMouse(bool want_capture_mouse_value)
{
ImGui::SetNextFrameWantCaptureMouse(want_capture_mouse_value);
}

// DEPRECATED
inline void CaptureMouseFromApp()
{
ImGui::SetNextFrameWantCaptureMouse(true);
}
// DEPRECATED
inline void CaptureMouseFromApp(bool want_capture_mouse_value)
{
ImGui::SetNextFrameWantCaptureMouse(want_capture_mouse_value);
}

inline void SetNextFrameWantCaptureMouse(bool want_capture_mouse_value)
{
ImGui::SetNextFrameWantCaptureMouse(want_capture_mouse_value);
}

// Clipboard Utilities
inline std::string GetClipboardText()
{
Expand Down Expand Up @@ -3128,13 +3112,12 @@ inline void InitEnums(sol::table luaGlobals)

#pragma region Selectable Flags
luaGlobals.new_enum(
"ImGuiSelectableFlags", "None", ImGuiSelectableFlags_None, "NoAutoClosePopups", ImGuiSelectableFlags_NoAutoClosePopups, "SpanAllColumns", ImGuiSelectableFlags_SpanAllColumns,
"AllowDoubleClick", ImGuiSelectableFlags_AllowDoubleClick, "Disabled", ImGuiSelectableFlags_Disabled, "AllowOverlap", ImGuiSelectableFlags_AllowOverlap,
"ImGuiSelectableFlags", "None", ImGuiSelectableFlags_None, "NoAutoClosePopups", ImGuiSelectableFlags_NoAutoClosePopups, "SpanAllColumns",
ImGuiSelectableFlags_SpanAllColumns, "AllowDoubleClick", ImGuiSelectableFlags_AllowDoubleClick, "Disabled", ImGuiSelectableFlags_Disabled, "AllowOverlap",
ImGuiSelectableFlags_AllowOverlap,

// DEPRECATED
"DontClosePopups", ImGuiSelectableFlags_DontClosePopups,
"AllowItemOverlap", ImGuiSelectableFlags_AllowItemOverlap
);
"DontClosePopups", ImGuiSelectableFlags_DontClosePopups, "AllowItemOverlap", ImGuiSelectableFlags_AllowItemOverlap);
#pragma endregion Selectable Flags

#pragma region Popup Flags
Expand Down Expand Up @@ -3269,10 +3252,6 @@ inline void InitBindings(sol::state& lua, sol::table luaGlobals)

sol::table ImGui(lua, sol::create);

#pragma region Version
ImGui.set_function("GetVersion", GetVersion);
#pragma endregion Version

#pragma region Windows
ImGui.set_function(
"Begin", sol::overload(
Expand Down
2 changes: 1 addition & 1 deletion xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ target("RED4ext.SDK")
on_install(function() end)

target("cyber_engine_tweaks")
add_defines("WIN32_LEAN_AND_MEAN", "NOMINMAX", "WINVER=0x0601", "SOL_ALL_SAFETIES_ON", "SOL_LUAJIT=1", "SOL_EXCEPTIONS_SAFE_PROPAGATION", "SPDLOG_WCHAR_TO_UTF8_SUPPORT", "SPDLOG_WCHAR_FILENAMES", "SPDLOG_WCHAR_SUPPORT", "IMGUI_USER_CONFIG=\""..imguiUserConfig.."\", IMGUI_IMPL_WIN32_DISABLE_GAMEPAD") -- WINVER=0x0601 == Windows 7xmake
add_defines("WIN32_LEAN_AND_MEAN", "NOMINMAX", "WINVER=0x0601", "SOL_ALL_SAFETIES_ON", "SOL_LUAJIT=1", "SOL_EXCEPTIONS_SAFE_PROPAGATION", "SPDLOG_WCHAR_TO_UTF8_SUPPORT", "SPDLOG_WCHAR_FILENAMES", "SPDLOG_WCHAR_SUPPORT", "IMGUI_USER_CONFIG=\""..imguiUserConfig.."\"") -- WINVER=0x0601 == Windows 7xmake
set_pcxxheader("src/stdafx.h")
set_kind("shared")
set_filename("cyber_engine_tweaks.asi")
Expand Down

0 comments on commit e4f349a

Please sign in to comment.