mirror of
				https://gitlab.com/hashborgir/plugy.git
				synced 2025-10-31 09:03:39 -05:00 
			
		
		
		
	Working, but needs tweak
This commit is contained in:
		| @@ -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<std::wstring> 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 <iostream> | ||||
| #include <sstream> | ||||
| #include <algorithm> | ||||
| #include <vector> | ||||
|  | ||||
| using namespace std; | ||||
|  | ||||
| // Function to break the tip into words | ||||
| vector<string> split(const string& s, char delim) { | ||||
| 	stringstream ss(s); | ||||
| 	string item; | ||||
| 	vector<string> tokens; | ||||
| 	while (getline(ss, item, delim)) { | ||||
| 		tokens.push_back(item); | ||||
| 	} | ||||
| 	return tokens; | ||||
| } | ||||
|  | ||||
| // Function to create sentences from words | ||||
| string makeSentence(vector<string> 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<string> 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<LPWSTR>(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<LPWSTR>(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(); | ||||
|  | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user