Cursor for a modified dll?

Page:1 2  

  • Morfevzi

    Hi people! So I've made a modified game dll for the original Crysis but I'm unable to add this white cursor provided with the source code so the normal Windows cursor shows up when I load up my mod. Does anyone know how I can make the white cursor show up? Thanks everyone

    ❤️ 0
  • Comrade

    Hello, ModSDK doesn't contain a complete CryGame source code. Crytek removed some stuff from there. For example, the whole startup code, mod loader, WindowProc (yes, it's in CryGame for some strange reason). To fix the problem, open Menus/OptionsManager.cpp and add the following into the empty COptionsManager::SetCrysisProfileColor function: // DllMain.cpp extern void* g_hInst; HCURSOR cursor = LoadCursorA(g_hInst, MAKEINTRESOURCEA(IDC_CURSOR1)); if (cursor) { HWND window = static_cast<HWND>(gEnv->pRenderer->GetHWND()); SetClassLongPtrA(window, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor)); SetCursor(cursor); } Also don't forget to include the evil <windows.h> and "resource.h", which contains IDC_CURSOR1.

    ❤️ 0
  • Comrade

    Code blocks don't work now apparently. Sorry for that :D

    ❤️ 0
  • Morfevzi

    Hello! Thank you for answering. I tried to add the code you provided but I get the following errors: c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(55) : error C2144: syntax error : 'void' should be preceded by ';' c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(55) : error C2761: 'void COptionsManager::SetCrysisProfileColor(const char *)' : member function redeclaration not allowed c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(57) : error C2146: syntax error : missing ';' before identifier 'cursor' c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(57) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(57) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(57) : error C2065: 'IDC_CURSOR1' : undeclared identifier c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(57) : error C3861: 'LoadCursorA': identifier not found c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(57) : error C3861: 'MAKEINTRESOURCEA': identifier not found c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(58) : error C2059: syntax error : 'if' c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(59) : error C2143: syntax error : missing ';' before '{' c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(59) : error C2447: '{' : missing function header (old-style formal list?) This is how the current code looks like: https://imgur.com/a/ya0M8P3

    ❤️ 0
  • Comrade

    Missing {} as function body. Here's how the whole function should look like: void COptionsManager::SetCrysisProfileColor(const char* value) { // DllMain.cpp extern void* g_hInst; HCURSOR cursor = LoadCursorA(g_hInst, MAKEINTRESOURCEA(IDC_CURSOR1)); if (cursor) { HWND window = static_cast<HWND>(gEnv->pRenderer->GetHWND()); SetClassLongPtrA(window, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor)); SetCursor(cursor); } }

    ❤️ 0
  • Comrade

    And it seems you didn't include the headers, so also add the following somewhere at the beginning of the file: #include <windows.h> #include "resource.h"

    ❤️ 0
  • Morfevzi

    Thank you so much for trying to help me with this. I did it as you've instructed but this time I got the following error: 1>c:\program files (x86)\origin games\crysis\mods\morfevzi\code\menus\optionsmanager.cpp(60) : error C2664: 'LoadCursorA' : cannot convert parameter 1 from 'void *' to 'HINSTANCE' 1> Conversion from 'void*' to pointer to non-'void' requires an explicit cast Again thank you so much for taking the time to help me

    ❤️ 0
  • Comrade

    Ah yes, the first argument of LoadCursorA needs to be HINSTANCE, so: void COptionsManager::SetCrysisProfileColor(const char* value) { // DllMain.cpp extern void* g_hInst; HCURSOR cursor = LoadCursorA(static_cast<HINSTANCE>(g_hInst), MAKEINTRESOURCEA(IDC_CURSOR1)); if (cursor) { HWND window = static_cast<HWND>(gEnv->pRenderer->GetHWND()); SetClassLongPtrA(window, GCLP_HCURSOR, reinterpret_cast<LONG_PTR>(cursor)); SetCursor(cursor); } } Now it should be ok finally.

    ❤️ 0
  • Morfevzi

    Thank you so much! The cursor now shows up when I load up my mod. Can I also share this solution on Reddit as well (by giving you credit of course)? I also made a post there asking the same question and I think it would be nice if I could add the solution to that post so that anyone having the same trouble could find the solution more easily. Again thank you so much for helping me.

    ❤️ 0
  • Comrade

    No problem. And the code is open-source already. It's just a slightly adapted snippet from our multiplayer client: https://github.com/crymp-net/client-server/blob/4ce22b9cf5395103b54e8ba7e90ccb9bcaa75f49/Code/CrySystem/GameWindow.cpp#L282-L329

    ❤️ 0
Page:1 2