1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
| #define RAYGUI_IMPLEMENTATION #include "raylib.h" #include "IPlugin.h" #include <vector> #ifndef _DEBUG #pragma comment(lib, "raylib.lib") #pragma comment(lib, "winmm.lib") #endif
void SearchOnInit() { TraceLog(LOG_INFO, "[SearchBox DLL] Plugin Initialized."); }
extern void* GetRaylibFunction(const char* funcName); extern void LogToDebugger(const char* msg);
typedef void (*DrawRectangleRecPtr)(Rectangle, Color); typedef void (*DrawRectangleLinesExPtr)(Rectangle, float, Color); typedef void (*DrawTextPtr)(const char*, int, int, int, Color); typedef int (*GetScreenWidthPtr)(); typedef int (*GetCharPressedPtr)(); typedef bool (*IsKeyPressedPtr)(int); typedef int (*GetScreenWidthPtr)();
static char inputBuffer[65] = "\0"; static int letterCount = 0; static char searchStatus[128] = "Ready"; static int statusTimer = 0; static int framesCounter = 0; extern bool active;
void SearchOnTick() { if (!active) return;
static DrawRectangleRecPtr RemoteDrawRectangleRec = (DrawRectangleRecPtr)GetRaylibFunction("DrawRectangleRec"); static DrawTextPtr RemoteDrawText = (DrawTextPtr)GetRaylibFunction("DrawText"); static GetCharPressedPtr RemoteGetCharPressed = (GetCharPressedPtr)GetRaylibFunction("GetCharPressed"); static IsKeyPressedPtr RemoteIsKeyPressed = (IsKeyPressedPtr)GetRaylibFunction("IsKeyPressed"); static GetScreenWidthPtr RemoteGetScreenWidth = (GetScreenWidthPtr)GetRaylibFunction("GetScreenWidth");
if (!RemoteDrawRectangleRec || !RemoteDrawText) return;
int key = RemoteGetCharPressed(); while (key > 0) { if ((key >= 32) && (key <= 125) && (letterCount < 64)) { inputBuffer[letterCount] = (char)key; inputBuffer[letterCount + 1] = '\0'; letterCount++; } key = RemoteGetCharPressed(); }
if (RemoteIsKeyPressed(KEY_BACKSPACE)) { if (letterCount > 0) { letterCount--; inputBuffer[letterCount] = '\0'; } }
if (RemoteIsKeyPressed(KEY_ENTER)) { if (letterCount > 0) { strcpy(searchStatus, "Searching: "); strcat(searchStatus, inputBuffer); LogToDebugger("Search triggered!"); LogToDebugger(inputBuffer); statusTimer = 120;
letterCount = 0; inputBuffer[0] = '\0'; active = false; } }
int screenW = RemoteGetScreenWidth ? RemoteGetScreenWidth() : 800; Rectangle box = { (float)screenW / 2.0f - 250, 40, 500, 50 };
RemoteDrawRectangleRec(box, { 0, 0, 0, 220 });
if (letterCount == 0) { RemoteDrawText("Type to search...", (int)box.x + 15, (int)box.y + 15, 20, DARKGRAY); } else { RemoteDrawText(inputBuffer, (int)box.x + 15, (int)box.y + 15, 20, RAYWHITE); }
if (statusTimer > 0) { RemoteDrawText(searchStatus, (int)box.x, (int)box.y + 60, 18, LIME); statusTimer--; } }
void SearchOnUnload() { TraceLog(LOG_INFO, "[SearchBox DLL] Plugin Unloaded."); }
extern "C" __declspec(dllexport) PluginInterface* GetPluginAPI() { static PluginInterface api = { {"Global Search", "1.0"}, SearchOnInit, SearchOnTick, SearchOnUnload }; return &api; }
|