PLUGIN_API VOID SetGameState(DWORD GameState) { DebugSpew("MQ2ChatWnd::SetGameState()"); if (GameState==GAMESTATE_CHARSELECT) { if (bNoCharSelect) { // destroy chatwnd at charselect if NoCharSelect=on DestroyChatWnd(); } else { AddMQ2KeyBind("MQ2CSCHAT",DoMQ2ChatBind); KeyCombo Combo; ParseKeyCombo("/",Combo); SetMQ2KeyBind("MQ2CSCHAT",FALSE,Combo); } } else { if (GameState!=GAMESTATE_CHARCREATE) RemoveMQ2KeyBind("MQ2CSCHAT"); if (GameState==GAMESTATE_INGAME && !MQChatWnd) { // we entered the game, set up shop DebugTry(CreateChatWindow()); } } }
void EQGamestateService(bool Broadcast, unsigned int MSG, void *lpData) { if (MSG == GAMESTATESERVICE_CHANGED) { DWORD GameState = (DWORD)lpData; if (GameState == GAMESTATE_CHARSELECT) { AddMQ2KeyBind("MQ2CSCHAT", DoMQ2ChatBind); KeyCombo Combo; ParseKeyCombo("/", Combo); SetMQ2KeyBind("MQ2CSCHAT", 0, Combo); } else { RemoveMQ2KeyBind("MQ2CSCHAT"); if (GameState == GAMESTATE_INGAME && !MQChatWnd) { // we entered the game, set up shop DebugTry(CreateChatWindow()); } } } }
void PulseService(bool Broadcast, unsigned int MSG, void *lpData) { if (MSG == PULSE_PULSE) { if (GetGameState() == GAMESTATE_CHARSELECT && !MQChatWnd) { CreateChatWindow(); } if (MQChatWnd && PendingChatLines) { bool doscroll = (((CXWnd*)MQChatWnd->OutputBox)->VScrollPos == (MQChatWnd->OutputBox->VScrollMax)); DWORD ThisPulse = PendingChatLines; if (ThisPulse > LINES_PER_FRAME) { ThisPulse = LINES_PER_FRAME; } PendingChatLines -= ThisPulse; MQChatWnd->OutBoxLines += ThisPulse; if (MQChatWnd->OutBoxLines > MAX_CHAT_SIZE) { DWORD Diff = (MQChatWnd->OutBoxLines - MAX_CHAT_SIZE) + LINES_PER_FRAME; MQChatWnd->OutBoxLines -= Diff; Benchmark(bmStripFirstStmlLines, MQChatWnd->OutputBox->StripFirstSTMLLines(Diff)); } for (DWORD N = 0 ; N < ThisPulse ; N++) { DebugTry(MQChatWnd->OutputBox->AppendSTML( pPendingChat->Text)); ChatBuffer *pNext = pPendingChat->pNext; delete pPendingChat; pPendingChat = pNext; } if (!pPendingChat) { pPendingChatTail = 0; } if (doscroll || MQChatWnd->AutoScroll) { DebugTry(((CXWnd*)MQChatWnd->OutputBox)->SetVScrollPos(MQChatWnd->OutputBox->VScrollMax)); } } } }
PLUGIN_API VOID OnPulse() { if (gGameState==GAMESTATE_CHARSELECT && !MQChatWnd && !bNoCharSelect) { CreateChatWindow(); } //if (CXWnd *krwnd = FindMQ2Window("TaskOverlayWnd")) { // Sleep(0); //} if (MQChatWnd) { switch (gGameState) { case GAMESTATE_CHARSELECT: { if (MQChatWnd->ZLayer != 1) MQChatWnd->ZLayer = 1; break; } case GAMESTATE_INGAME: { if (MQChatWnd->ZLayer != 0) MQChatWnd->ZLayer = 0; break; } } if(PendingChatLines) { // set 'old' to current ulOldVScrollPos=MQChatWnd->OutputBox->VScrollPos; // scroll down if autoscroll enabled, or current position is the bottom of chatwnd bool bScrollDown=bAutoScroll?true:(MQChatWnd->OutputBox->VScrollPos==MQChatWnd->OutputBox->VScrollMax?true:false); DWORD ThisPulse=PendingChatLines; if (ThisPulse>LINES_PER_FRAME) { ThisPulse=LINES_PER_FRAME; } PendingChatLines-=ThisPulse; MQChatWnd->OutBoxLines+=ThisPulse; if (MQChatWnd->OutBoxLines>MAX_CHAT_SIZE) { DWORD Diff=(MQChatWnd->OutBoxLines-MAX_CHAT_SIZE)+LINES_PER_FRAME; MQChatWnd->OutBoxLines-=Diff; Benchmark(bmStripFirstStmlLines,MQChatWnd->OutputBox->StripFirstSTMLLines(Diff)); } for (DWORD N=0 ; N<ThisPulse ; N++) { if(pPendingChat) { DebugTry(MQChatWnd->OutputBox->AppendSTML(pPendingChat->Text)); ChatBuffer *pNext=pPendingChat->pNext; delete pPendingChat; pPendingChat=pNext; } //DebugSpew("NEW: max %u - pos: %u",MQChatWnd->OutputBox->VScrollMax,MQChatWnd->OutputBox->VScrollPos); } if (!pPendingChat) { pPendingChatTail=0; } if(bScrollDown) { // set current vscroll position to bottom DebugTry(((CXWnd*)MQChatWnd->OutputBox)->SetVScrollPos(MQChatWnd->OutputBox->VScrollMax)); } else { // autoscroll is disabled and current vscroll position was not at the bottom, retain position // note: if the window is full (VScrollMax value between 9793 and 9835), this will not adjust with // the flushing of buffer that keeps window a certain max size DebugTry(((CXWnd*)MQChatWnd->OutputBox)->SetVScrollPos(ulOldVScrollPos)); } } if(InHoverState()) { ((CXWnd*)MQChatWnd)->DoAllDrawing(); } } }
PLUGIN_API VOID OnReloadUI() { DebugSpewAlways("MQ2ChatWnd::OnReloadUI()"); // redraw window when you load/reload UI DebugTry(CreateChatWindow()); }