From f3b0abf9abdec32b6e79b62355283af3b38e83cf Mon Sep 17 00:00:00 2001 From: Hash Borgir Date: Fri, 19 Apr 2024 05:47:43 -0600 Subject: [PATCH] Working, but needs tweak --- PlugY/Interface_Stash.cpp | 74 ++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/PlugY/Interface_Stash.cpp b/PlugY/Interface_Stash.cpp index 1bb2561..9e11ca6 100644 --- a/PlugY/Interface_Stash.cpp +++ b/PlugY/Interface_Stash.cpp @@ -344,7 +344,7 @@ DWORD STDCALL manageBtnUp(sWinMessage* msg) int frame = 0; long nEndTime = 0; int nTip = 0; -long DURATION = 60000; +long DURATION = 5000; std::vector diablo2Tips = { L"Consume spirits like potions to increase Spirits Quaffed stat in character stat sheet page.", L"Cube Souls with Energy Sphere to capture Soul Energy and use it to create powerful items. Recipes will come later.", @@ -1696,17 +1696,72 @@ void OnLoad() { srand(time(NULL)); } -void onDraw() { - if (GetTickCount64() >= nEndTime) { - nEndTime = GetTickCount64() + DURATION; - nTip = rand() % diablo2Tips.size(); + +#include +#include +#include +#include + +using namespace std; + +// Function to break the tip into words +vector split(const string& s, char delim) { + stringstream ss(s); + string item; + vector tokens; + while (getline(ss, item, delim)) { + tokens.push_back(item); + } + return tokens; +} + +// Function to create sentences from words +string makeSentence(vector words, int start, int end) { + stringstream ss; + for (int i = start; i <= end; ++i) { + ss << words[i] << " "; + } + return ss.str(); +} + +// Function to convert string to wide string +wstring stringToWstring(const string& s) { + wstring ws; + for (char c : s) { + ws += (wchar_t)c; + } + return ws; +} + + // Your original code here + + // Modified onDraw function + void onDraw() { + if (GetTickCount64() >= nEndTime) { + nEndTime = GetTickCount64() + DURATION; + nTip = rand() % diablo2Tips.size(); + } + + // Convert wstring to string for manipulation + string strTip = string(diablo2Tips[nTip].begin(), diablo2Tips[nTip].end()); + vector words = split(strTip, ' '); + + // Calculate positions for multiple lines + int yPos = 95; + for (int i = 0; i < words.size(); i += 10) { + // Create a sentence from words and convert it back to wide string + string sentence = makeSentence(words, i, min(i + 9, (int)words.size() - 1)); + wstring wSentence = stringToWstring(sentence); + D2PrintString(const_cast(wSentence.c_str()), 152, yPos, WHITE, 0); + yPos += 10; // Move to the next line + } } - // Print the randomly selected tip using D2PrintString function - D2PrintString(const_cast(diablo2Tips[nTip].c_str()), 152, 95, WHITE, 0); -} + + + void FASTCALL printPageNumber(LPWSTR maxGoldText, DWORD x, DWORD y, DWORD color, DWORD bfalse) { @@ -1781,6 +1836,9 @@ void FASTCALL printPageNumber(LPWSTR maxGoldText, DWORD x, DWORD y, DWORD color, // Print Random Tips + + D2SetFont(6); + onDraw(); }