#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS 1
#include "ImGUI\imgui.h"
#include "ImGUI\imgui_impl_dx9.h"
#include "ImGUI\imgui_impl_win32.h"
#include <d3d9.h>
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
#include <tchar.h>
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
#include <windows.h>
#include <string>
#include <assert.h>
#include <process.h>
#include "SAMPFUNCS_API.h"
#include "game_api\game_api.h"
bool activew = true;
SAMPFUNCS *SF = new SAMPFUNCS();
bool CALLBACK Present(CONST RECT *pSourceRect, CONST RECT *pDestRect, HWND hDestWindowOverride, CONST RGNDATA *pDirtyRegion)
{
if (SUCCEEDED(SF->getRender()->BeginRender()))
{
ImGui_ImplDX9_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
if (activew)
{
ImGui::Begin("ImGui меню", &activew, ImVec2(305, 160), 0.8f, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize);
{
ImGui::Text("Hello world!");
}
ImGui::End();
}
ImGui::EndFrame();
ImGui::Render();
ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
SF->getRender()->EndRender();
}
return true;
}
HRESULT CALLBACK Reset(D3DPRESENT_PARAMETERS* pPresentationParameters)
{
ImGui_ImplDX9_InvalidateDeviceObjects();
return true;
}
bool CALLBACK WndProcHandler(HWND hwd, UINT msg, WPARAM wParam, LPARAM lParam)
{
ImGui_ImplWin32_WndProcHandler(hwd, msg, wParam, lParam);
return true;
}
void CALLBACK PluginFree()
{
ImGui_ImplDX9_Shutdown();
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
}
void CALLBACK mainloop()
{
static bool init = false;
if (!init)
{
if (GAME == nullptr)
return;
if (GAME->GetSystemState() != eSystemState::GS_PLAYING_GAME)
return;
if (!SF->getSAMP()->IsInitialized())
return;
SF->getSAMP()->getChat()->AddChatMessage(D3DCOLOR_XRGB(0, 0xAA, 0), "SAMPFUNCS Plugin loaded.");
SF->getGame()->registerGameDestructorCallback(PluginFree);
SF->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_PRESENT, Present);
SF->getRender()->registerD3DCallback(eDirect3DDeviceMethods::D3DMETHOD_RESET, Reset);
SF->getGame()->registerWndProcCallback(SFGame::MEDIUM_CB_PRIORITY, WndProcHandler);
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
ImGui_ImplWin32_Init(GetActiveWindow());
ImGui_ImplDX9_Init(SF->getRender()->getD3DDevice());
init = true;
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReasonForCall, LPVOID lpReserved)
{
switch (dwReasonForCall)
{
case DLL_PROCESS_ATTACH:
SF->initPlugin(mainloop, hModule);
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}