Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.09 KB | None | 0 0
  1. #include "plugin.h"
  2. #include "plugin_vc.h"
  3.  
  4. #include "vendors/imgui/imgui.h"
  5. #include "vendors/imgui/imgui_impl_dx9.h"
  6. #include "vendors/imgui/imgui_impl_win32.h"
  7.  
  8. #include "rwd3d9.h"
  9. #include <d3d9.h>
  10.  
  11. #include "CHud.h"
  12. #include <iostream>
  13.  
  14. using namespace plugin;
  15.  
  16. bool ImGUIWindow = 0;
  17. bool bInitalized = 0;
  18. bool first = 1;
  19. extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  20. LRESULT WINAPI HookedWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  21. {
  22.     ImGuiIO& io = ImGui::GetIO();
  23.     ShowCursor(1);
  24.     io.MouseDrawCursor = 1;
  25.     ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam);
  26.     return DefWindowProc(hWnd, msg, wParam, lParam);
  27. }
  28.  
  29. class gtcvc {
  30. public:
  31.     gtcvc() {
  32.  
  33.  
  34.         AllocConsole();
  35.         freopen("CONOUT$", "w", stdout);
  36.  
  37.         Events::initGameEvent += [] {
  38.             SetWindowLongPtr(RsGlobal.ps->window , GWLP_WNDPROC, (LONG_PTR)HookedWndProc);
  39.         };
  40.         Events::gameProcessEvent += [] {
  41.             if (first) {
  42.                 std::cout << "gameEvent called" << std::endl;
  43.                 if (!bInitalized) {
  44.                     // Setup Dear ImGui binding
  45.                     IMGUI_CHECKVERSION();
  46.                     ImGui::CreateContext();
  47.                    
  48.                     //io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;  // Enable Keyboard Controls
  49.                     ImGui_ImplWin32_Init(*(HWND*)0x7897A4);
  50.                     if (RwD3D9Supported()) {
  51.                         ImGui_ImplDX9_Init((IDirect3DDevice9*)RwD3D9GetCurrentD3DDevice());
  52.                     }
  53.  
  54.                
  55.                     // Setup style
  56.                     ImGui::StyleColorsDark();
  57.                     bInitalized = true;
  58.                     first = false;
  59.                     CHud::SetHelpMessage("Don't forget to press F9 to play co-op campagin!", 0, 0);
  60.  
  61.                 }
  62.             }
  63.  
  64.         };
  65.         Events::drawingEvent += [] {
  66.             if (bInitalized) {
  67.                 //SetWindowLongPtr(*(HWND*)0x7897A4, GWLP_WNDPROC, (LONG_PTR)WndProc);
  68.  
  69.                 ImGui_ImplDX9_NewFrame();
  70.                 ImGui_ImplWin32_NewFrame();
  71.                 ImGui::NewFrame();
  72.                 //ImGui::SetNextWindowPosCenter();
  73.  
  74.                 ImGui::Begin("Grand Theft CO-OP: Vice City");
  75.                 ImGui::Text("Text Test");
  76.  
  77.                 ImGui::End();
  78.  
  79.                 ImGui::EndFrame();
  80.                 ImGui::Render();
  81.                 ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData());
  82.             }
  83.  
  84.         };
  85.     }
  86. } _gtcvc;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement