1681 lines
50 KiB
C++
1681 lines
50 KiB
C++
// Provenance: AVA2 UserInterface/PythonChat.cpp and PythonChatModule.cpp (__CHAT_SETTINGS__ +
|
|
// ENABLE_MULTILANGUAGE_SYSTEM build). Kept quirks: chat.IsIgnoreCharacter returns None, a chat
|
|
// set's colour slot is its id (sets >= 3 share slot 0), ArrangeShowingChat counts country-muted
|
|
// shout lines when it sizes the window, CreateChatSet / GetLineCount key the line store by BYTE,
|
|
// and CreateWhisper on an existing name leaves the old whisper in place.
|
|
// Not carried: DefaultFont_GetResource / the GM italic font (the text stand-in has no font
|
|
// resource, so no line is dropped for a missing font), CPythonStackController::CheckStackReference
|
|
// and CPythonApplication::ChangeIcon (the Windows taskbar icon behind ENABLE_DISCORD_STUFF).
|
|
#include "python_chat.h"
|
|
#include "python_app.h"
|
|
#include "python_gameplay_modules.h"
|
|
#include "eter_resource/ResourceManager.h"
|
|
#include "shared/common/PythonUtils.h"
|
|
#include <SDL3/SDL_log.h>
|
|
#include <algorithm>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
|
|
namespace ava2 {
|
|
namespace {
|
|
|
|
const float c_fStartDisappearingTime = 5.0f;
|
|
const int c_iMaxLineCount = 5;
|
|
|
|
// CResourceManager::IsFileExist + GetResourcePointer for the shout flag images.
|
|
void SetFlagImage(CGraphicImageInstance& rInstance, const char* c_szFileName)
|
|
{
|
|
CResourceManager* pResourceManager = CResourceManager::InstancePtr();
|
|
if (!pResourceManager)
|
|
return;
|
|
CResource* pResource = pResourceManager->GetResourcePointer(c_szFileName);
|
|
if (pResource && pResource->IsType(CGraphicImage::Type()))
|
|
rInstance.SetImagePointer(static_cast<CGraphicImage*>(pResource));
|
|
}
|
|
|
|
void SetShoutFlags(CPythonChat::TChatLine* pChatLine)
|
|
{
|
|
if (pChatLine->countryIndex != 0)
|
|
{
|
|
const char* langlist[] = { "en", "de", "tr", "pt", "es", "fr", "ro", "pl", "it", "cz", "hu" };
|
|
char buf[128];
|
|
snprintf(buf, sizeof(buf), "d:/ymir work/ui/language_flag/%s.tga", langlist[pChatLine->countryIndex - 1]);
|
|
SetFlagImage(pChatLine->InstanceLang, buf);
|
|
}
|
|
if (pChatLine->empireIndex != 0)
|
|
{
|
|
char buf[128];
|
|
snprintf(buf, sizeof(buf), "d:/ymir work/ui/flag_empire/empire_%d_256.dds", pChatLine->empireIndex);
|
|
SetFlagImage(pChatLine->InstanceEmpire, buf);
|
|
}
|
|
}
|
|
|
|
// EterBase/Stl.cpp split_string.
|
|
int split_string(const std::string& input, const std::string& delimiter, std::vector<std::string>& results, bool includeEmpties)
|
|
{
|
|
int iPos = 0;
|
|
int newPos = -1;
|
|
const UINT sizeS2 = UINT(delimiter.size());
|
|
const UINT isize = UINT(input.size());
|
|
|
|
if ((isize == 0) || (sizeS2 == 0))
|
|
return 0;
|
|
|
|
std::vector<int> positions;
|
|
newPos = int(input.find(delimiter, 0));
|
|
if (newPos < 0)
|
|
return 0;
|
|
|
|
int numFound = 0;
|
|
while (newPos >= iPos)
|
|
{
|
|
numFound++;
|
|
positions.push_back(newPos);
|
|
iPos = newPos;
|
|
newPos = int(input.find(delimiter, iPos + sizeS2));
|
|
}
|
|
|
|
if (numFound == 0)
|
|
return 0;
|
|
|
|
for (UINT i = 0; i <= positions.size(); ++i)
|
|
{
|
|
std::string s("");
|
|
if (i == 0)
|
|
{
|
|
s = input.substr(i, positions[i]);
|
|
}
|
|
else
|
|
{
|
|
const UINT offset = positions[i - 1] + sizeS2;
|
|
if (offset < isize)
|
|
{
|
|
if (i == positions.size())
|
|
s = input.substr(offset);
|
|
else if (i > 0)
|
|
s = input.substr(positions[i - 1] + sizeS2, positions[i] - positions[i - 1] - sizeS2);
|
|
}
|
|
}
|
|
if (includeEmpties || (s.size() > 0))
|
|
results.push_back(s);
|
|
}
|
|
return numFound;
|
|
}
|
|
|
|
// EterBase/Utils.h htoi: -1 for any non-hex character.
|
|
int htoi(const char* s)
|
|
{
|
|
const char* t = s;
|
|
int x = 0, y = 1;
|
|
s += strlen(s);
|
|
|
|
while (t <= --s)
|
|
{
|
|
if ('0' <= *s && *s <= '9')
|
|
x += y * (*s - '0');
|
|
else if ('a' <= *s && *s <= 'f')
|
|
x += y * (*s - 'a' + 10);
|
|
else if ('A' <= *s && *s <= 'F')
|
|
x += y * (10 + *s - 'A');
|
|
else
|
|
return -1;
|
|
y <<= 4;
|
|
}
|
|
|
|
return x;
|
|
}
|
|
|
|
bool GetItemName(uint32_t dwVnum, std::string* pstrName)
|
|
{
|
|
int iType;
|
|
return GetItemNameAndType(dwVnum, pstrName, &iType);
|
|
}
|
|
|
|
} // namespace
|
|
|
|
int CPythonChat::TChatSet::ms_iChatModeSize = CHAT_TYPE_MAX_NUM;
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
CDynamicPool<CPythonChat::SChatLine> CPythonChat::SChatLine::ms_kPool;
|
|
|
|
CPythonChat& CPythonChat::Instance()
|
|
{
|
|
static CPythonChat s_kChat;
|
|
return s_kChat;
|
|
}
|
|
|
|
DWORD CPythonChat::GetCurrentMillisecond() const
|
|
{
|
|
return m_dwFixedMillisecond ? m_dwFixedMillisecond : GetLocalMSec();
|
|
}
|
|
|
|
void CPythonChat::SetChatColor(UINT eType, UINT r, UINT g, UINT b)
|
|
{
|
|
if (eType >= CHAT_TYPE_MAX_NUM)
|
|
return;
|
|
|
|
DWORD dwColor = (0xff000000) | (r << 16) | (g << 8) | (b);
|
|
m_akD3DXClrChat[eType] = D3DXCOLOR(dwColor);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
CPythonChat::SChatLine* CPythonChat::SChatLine::New()
|
|
{
|
|
return ms_kPool.Alloc();
|
|
}
|
|
|
|
void CPythonChat::SChatLine::Delete(CPythonChat::SChatLine* pkChatLine)
|
|
{
|
|
pkChatLine->Instance.Destroy();
|
|
pkChatLine->InstanceLang.Destroy();
|
|
pkChatLine->InstanceEmpire.Destroy();
|
|
ms_kPool.Free(pkChatLine);
|
|
}
|
|
|
|
void CPythonChat::SChatLine::DestroySystem()
|
|
{
|
|
ms_kPool.Destroy();
|
|
}
|
|
|
|
void CPythonChat::SChatLine::SetColor(DWORD dwID, DWORD dwColor)
|
|
{
|
|
if (dwID >= CHAT_LINE_COLOR_ARRAY_MAX_NUM)
|
|
return;
|
|
|
|
aColor[dwID] = dwColor;
|
|
}
|
|
|
|
void CPythonChat::SChatLine::SetColorAll(DWORD dwColor)
|
|
{
|
|
for (int i = 0; i < CHAT_LINE_COLOR_ARRAY_MAX_NUM; ++i)
|
|
aColor[i] = dwColor;
|
|
}
|
|
|
|
D3DXCOLOR& CPythonChat::SChatLine::GetColorRef(DWORD dwID)
|
|
{
|
|
if (dwID >= CHAT_LINE_COLOR_ARRAY_MAX_NUM)
|
|
return aColor[0];
|
|
|
|
return aColor[dwID];
|
|
}
|
|
|
|
CPythonChat::SChatLine::SChatLine()
|
|
{
|
|
iType = 0;
|
|
fAppendedTime = 0.0f;
|
|
for (int i = 0; i < CHAT_LINE_COLOR_ARRAY_MAX_NUM; ++i)
|
|
aColor[i] = DWORD(0xff0000ff);
|
|
countryIndex = 0;
|
|
empireIndex = 0;
|
|
}
|
|
|
|
CPythonChat::SChatLine::~SChatLine()
|
|
{
|
|
Instance.Destroy();
|
|
InstanceLang.Destroy();
|
|
InstanceEmpire.Destroy();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
int CPythonChat::CreateChatSet(DWORD dwID)
|
|
{
|
|
auto it = m_ChatLineNewDeque.find(BYTE(dwID));
|
|
if (it != m_ChatLineNewDeque.end())
|
|
return dwID;
|
|
|
|
TChatSet pChatSet;
|
|
TChatLineDeque map_vec;
|
|
|
|
auto itChat = m_ChatLineNewDeque.find(0);
|
|
if (itChat != m_ChatLineNewDeque.end())
|
|
{
|
|
for (auto chat = itChat->second.begin(); chat != itChat->second.end(); ++chat)
|
|
{
|
|
SChatLine* chatLine = *chat;
|
|
SChatLine* pChatLine = SChatLine::New();
|
|
|
|
pChatLine->empireIndex = chatLine->empireIndex;
|
|
pChatLine->countryIndex = chatLine->countryIndex;
|
|
if (chatLine->iType == CHAT_TYPE_SHOUT)
|
|
SetShoutFlags(pChatLine);
|
|
|
|
pChatLine->text = chatLine->text;
|
|
pChatLine->iType = chatLine->iType;
|
|
pChatLine->Instance.SetValue(chatLine->text.c_str());
|
|
pChatLine->fAppendedTime = chatLine->fAppendedTime;
|
|
pChatLine->SetColorAll(GetChatColor(pChatLine->iType));
|
|
map_vec.push_back(pChatLine);
|
|
}
|
|
}
|
|
|
|
m_ChatSetMap.emplace(dwID, pChatSet);
|
|
m_ChatLineNewDeque.emplace(BYTE(dwID), map_vec);
|
|
ArrangeShowingChat(dwID);
|
|
return dwID;
|
|
}
|
|
|
|
void CPythonChat::UpdateViewMode(DWORD dwID)
|
|
{
|
|
const float fcurTime = GetGlobalTime();
|
|
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
TChatLineList* pLineList = &(pChatSet->m_ShowingChatLineList);
|
|
int iLineIndex = int(pLineList->size());
|
|
int iHeight = -(int(pLineList->size() + 1) * pChatSet->m_iStep);
|
|
|
|
for (TChatLineList::iterator itor = pLineList->begin(); itor != pLineList->end();)
|
|
{
|
|
TChatLine* pChatLine = (*itor);
|
|
|
|
D3DXCOLOR& rColor = pChatLine->GetColorRef(dwID);
|
|
|
|
const float fElapsedTime = (fcurTime - pChatLine->fAppendedTime);
|
|
if (fElapsedTime >= c_fStartDisappearingTime || iLineIndex >= c_iMaxLineCount)
|
|
{
|
|
rColor.a -= rColor.a / 10.0f;
|
|
|
|
if (rColor.a <= 0.1f)
|
|
itor = pLineList->erase(itor);
|
|
else
|
|
++itor;
|
|
}
|
|
else
|
|
{
|
|
++itor;
|
|
}
|
|
|
|
iHeight += pChatSet->m_iStep;
|
|
--iLineIndex;
|
|
|
|
int iWidth = pChatSet->m_ix;
|
|
if (pChatLine->iType == CHAT_TYPE_SHOUT)
|
|
{
|
|
const bool isAttached = (pChatLine->InstanceLang.GetWidth() > 0 && pChatLine->InstanceEmpire.GetWidth() > 0);
|
|
if (isAttached)
|
|
{
|
|
pChatLine->InstanceLang.SetPosition(float(iWidth), float(pChatSet->m_iy + iHeight + 2));
|
|
iWidth += pChatLine->InstanceLang.GetWidth() + 2;
|
|
|
|
pChatLine->InstanceEmpire.SetPosition(float(iWidth + 4), float(pChatSet->m_iy + iHeight + 2));
|
|
iWidth += pChatLine->InstanceEmpire.GetWidth() + 8;
|
|
}
|
|
}
|
|
pChatLine->Instance.SetPosition(float(iWidth), float(pChatSet->m_iy + iHeight));
|
|
pChatLine->Instance.SetColor(rColor);
|
|
pChatLine->Instance.Update();
|
|
}
|
|
}
|
|
|
|
void CPythonChat::UpdateEditMode(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
const int c_iAlphaLine = std::max(0, GetVisibleLineCount(dwID) - GetEditableLineCount(dwID) + 2);
|
|
|
|
int iLineIndex = 0;
|
|
float fAlpha = 0.0f;
|
|
float fAlphaStep = 0.0f;
|
|
|
|
if (c_iAlphaLine > 0)
|
|
fAlphaStep = 1.0f / float(c_iAlphaLine);
|
|
|
|
TChatLineList* pLineList = &(pChatSet->m_ShowingChatLineList);
|
|
int iHeight = -(int(pLineList->size() + 1) * pChatSet->m_iStep);
|
|
|
|
for (TChatLineList::iterator itor = pLineList->begin(); itor != pLineList->end(); ++itor)
|
|
{
|
|
TChatLine* pChatLine = (*itor);
|
|
|
|
D3DXCOLOR& rColor = pChatLine->GetColorRef(dwID);
|
|
|
|
// iLineIndex is never advanced in the Windows loop, so every line takes the ramp.
|
|
if (iLineIndex < c_iAlphaLine)
|
|
{
|
|
rColor.a += (fAlpha - rColor.a) / 10.0f;
|
|
fAlpha = std::min(fAlpha + fAlphaStep, 1.0f);
|
|
}
|
|
else
|
|
{
|
|
rColor.a = std::min(rColor.a + 0.05f, 1.0f);
|
|
}
|
|
|
|
iHeight += pChatSet->m_iStep;
|
|
int iWidth = pChatSet->m_ix;
|
|
|
|
if (pChatLine->iType == CHAT_TYPE_SHOUT)
|
|
{
|
|
const bool isAttached = (pChatLine->InstanceLang.GetWidth() > 0 && pChatLine->InstanceEmpire.GetWidth() > 0);
|
|
if (isAttached)
|
|
{
|
|
pChatLine->InstanceLang.SetPosition(float(iWidth), float(pChatSet->m_iy + iHeight + 2));
|
|
iWidth += pChatLine->InstanceLang.GetWidth() + 2;
|
|
|
|
pChatLine->InstanceEmpire.SetPosition(float(iWidth + 4), float(pChatSet->m_iy + iHeight + 2));
|
|
iWidth += pChatLine->InstanceEmpire.GetWidth() + 8;
|
|
}
|
|
}
|
|
pChatLine->Instance.SetPosition(float(iWidth), float(pChatSet->m_iy + iHeight));
|
|
pChatLine->Instance.SetColor(rColor);
|
|
pChatLine->Instance.Update();
|
|
}
|
|
}
|
|
|
|
void CPythonChat::UpdateLogMode(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
TChatLineList* pLineList = &(pChatSet->m_ShowingChatLineList);
|
|
int iHeight = 0;
|
|
|
|
for (TChatLineList::reverse_iterator itor = pLineList->rbegin(); itor != pLineList->rend(); ++itor)
|
|
{
|
|
TChatLine* pChatLine = (*itor);
|
|
|
|
iHeight -= pChatSet->m_iStep;
|
|
int iWidth = pChatSet->m_ix;
|
|
|
|
if (pChatLine->iType == CHAT_TYPE_SHOUT)
|
|
{
|
|
const bool isAttached = (pChatLine->InstanceLang.GetWidth() > 0 && pChatLine->InstanceEmpire.GetWidth() > 0);
|
|
if (isAttached)
|
|
{
|
|
pChatLine->InstanceLang.SetPosition(float(iWidth), float(pChatSet->m_iy + iHeight + 2));
|
|
iWidth += pChatLine->InstanceLang.GetWidth() + 2;
|
|
|
|
pChatLine->InstanceEmpire.SetPosition(float(iWidth + 4), float(pChatSet->m_iy + iHeight + 2));
|
|
iWidth += pChatLine->InstanceEmpire.GetWidth() + 8;
|
|
}
|
|
}
|
|
pChatLine->Instance.SetPosition(float(iWidth), float(pChatSet->m_iy + iHeight));
|
|
pChatLine->Instance.SetColor(pChatLine->GetColorRef(dwID));
|
|
pChatLine->Instance.Update();
|
|
}
|
|
}
|
|
|
|
void CPythonChat::Update(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
switch (pChatSet->m_iBoardState)
|
|
{
|
|
case BOARD_STATE_VIEW:
|
|
UpdateViewMode(dwID);
|
|
break;
|
|
case BOARD_STATE_EDIT:
|
|
UpdateEditMode(dwID);
|
|
break;
|
|
case BOARD_STATE_LOG:
|
|
UpdateLogMode(dwID);
|
|
break;
|
|
}
|
|
|
|
const DWORD dwcurTime = GetCurrentMillisecond();
|
|
for (TWaitChatList::iterator itor = m_WaitChatList.begin(); itor != m_WaitChatList.end();)
|
|
{
|
|
TWaitChat& rWaitChat = *itor;
|
|
|
|
if (rWaitChat.dwAppendingTime < dwcurTime)
|
|
{
|
|
AppendChat(rWaitChat.iType, rWaitChat.strChat.c_str());
|
|
itor = m_WaitChatList.erase(itor);
|
|
}
|
|
else
|
|
{
|
|
++itor;
|
|
}
|
|
}
|
|
}
|
|
|
|
void CPythonChat::Render(DWORD dwID)
|
|
{
|
|
TChatLineList* pLineList = GetChatLineListPtr(dwID);
|
|
if (!pLineList)
|
|
return;
|
|
|
|
for (TChatLineList::iterator itor = pLineList->begin(); itor != pLineList->end(); ++itor)
|
|
{
|
|
(*itor)->Instance.Render();
|
|
if ((*itor)->iType == CHAT_TYPE_SHOUT)
|
|
{
|
|
CGraphicImageInstance& lInstance = (*itor)->InstanceLang;
|
|
if (lInstance.GetWidth() > 0)
|
|
lInstance.Render();
|
|
CGraphicImageInstance& eInstance = (*itor)->InstanceEmpire;
|
|
if (eInstance.GetWidth() > 0)
|
|
eInstance.Render();
|
|
}
|
|
}
|
|
}
|
|
|
|
void CPythonChat::SetBoardState(DWORD dwID, int iState)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
pChatSet->m_iBoardState = iState;
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
|
|
void CPythonChat::SetPosition(DWORD dwID, int ix, int iy)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
pChatSet->m_ix = ix;
|
|
pChatSet->m_iy = iy;
|
|
}
|
|
|
|
void CPythonChat::SetHeight(DWORD dwID, int iHeight)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
pChatSet->m_iHeight = iHeight;
|
|
}
|
|
|
|
void CPythonChat::SetStep(DWORD dwID, int iStep)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
pChatSet->m_iStep = iStep;
|
|
}
|
|
|
|
// m_iMode[iMode] is indexed without a range check on Windows; an out-of-range mode only
|
|
// rearranges here instead of writing past the vector.
|
|
void CPythonChat::ToggleChatMode(DWORD dwID, int iMode)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
if (iMode >= 0 && size_t(iMode) < pChatSet->m_iMode.size())
|
|
pChatSet->m_iMode[iMode] = 1 - pChatSet->m_iMode[iMode];
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
|
|
void CPythonChat::EnableChatMode(DWORD dwID, int iMode)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
if (iMode >= 0 && size_t(iMode) < pChatSet->m_iMode.size())
|
|
pChatSet->m_iMode[iMode] = TRUE;
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
|
|
void CPythonChat::DisableChatMode(DWORD dwID, int iMode)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
if (iMode >= 0 && size_t(iMode) < pChatSet->m_iMode.size())
|
|
pChatSet->m_iMode[iMode] = FALSE;
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
|
|
void CPythonChat::SetEndPos(DWORD dwID, float fPos)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
fPos = std::max(0.0f, fPos);
|
|
fPos = std::min(1.0f, fPos);
|
|
if (pChatSet->m_fEndPos != fPos)
|
|
{
|
|
pChatSet->m_fEndPos = fPos;
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
}
|
|
|
|
int CPythonChat::GetVisibleLineCount(DWORD dwID)
|
|
{
|
|
TChatLineList* pLineList = GetChatLineListPtr(dwID);
|
|
if (!pLineList)
|
|
return 0;
|
|
|
|
return int(pLineList->size());
|
|
}
|
|
|
|
int CPythonChat::GetEditableLineCount(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return 0;
|
|
|
|
// A zero step divides by zero on Windows.
|
|
if (pChatSet->m_iStep == 0)
|
|
return 0;
|
|
return pChatSet->m_iHeight / pChatSet->m_iStep + 1;
|
|
}
|
|
|
|
int CPythonChat::GetLineCount(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return 0;
|
|
auto it = m_ChatLineNewDeque.find(BYTE(dwID));
|
|
if (it == m_ChatLineNewDeque.end())
|
|
return 0;
|
|
|
|
int iCount = 0;
|
|
for (DWORD i = 0; i < it->second.size(); ++i)
|
|
{
|
|
if (!pChatSet->CheckMode(it->second[i]->iType))
|
|
continue;
|
|
if (!pChatSet->CheckCountryMode(it->second[i]->countryIndex) && it->second[i]->iType == CHAT_TYPE_SHOUT)
|
|
continue;
|
|
++iCount;
|
|
}
|
|
|
|
return iCount;
|
|
}
|
|
|
|
int CPythonChat::GetLineStep(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return 0;
|
|
|
|
return pChatSet->m_iStep;
|
|
}
|
|
|
|
CPythonChat::TChatLineList* CPythonChat::GetChatLineListPtr(DWORD dwID)
|
|
{
|
|
TChatSetMap::iterator itor = m_ChatSetMap.find(int(dwID));
|
|
if (m_ChatSetMap.end() == itor)
|
|
return nullptr;
|
|
|
|
return &(itor->second.m_ShowingChatLineList);
|
|
}
|
|
|
|
CPythonChat::TChatSet* CPythonChat::GetChatSetPtr(DWORD dwID)
|
|
{
|
|
TChatSetMap::iterator itor = m_ChatSetMap.find(int(dwID));
|
|
if (m_ChatSetMap.end() == itor)
|
|
return nullptr;
|
|
|
|
return &(itor->second);
|
|
}
|
|
|
|
const CPythonChat::TChatSet* CPythonChat::GetChatSet(DWORD dwID) const
|
|
{
|
|
auto itor = m_ChatSetMap.find(int(dwID));
|
|
return itor == m_ChatSetMap.end() ? nullptr : &itor->second;
|
|
}
|
|
|
|
const CPythonChat::TChatLineDeque* CPythonChat::GetChatLineDeque(DWORD dwID) const
|
|
{
|
|
auto itor = m_ChatLineNewDeque.find(BYTE(dwID));
|
|
return itor == m_ChatLineNewDeque.end() ? nullptr : &itor->second;
|
|
}
|
|
|
|
void CPythonChat::ArrangeShowingChat(DWORD dwID)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
pChatSet->m_ShowingChatLineList.clear();
|
|
auto it = m_ChatLineNewDeque.find(BYTE(dwID));
|
|
if (it == m_ChatLineNewDeque.end())
|
|
return;
|
|
|
|
// A zero step divides by zero on Windows.
|
|
if (pChatSet->m_iStep == 0)
|
|
return;
|
|
|
|
// The country check sits after the push on Windows, so muted shout lines still count here.
|
|
TChatLineDeque TempChatLineDeque;
|
|
for (TChatLineDeque::iterator itor = it->second.begin(); itor != it->second.end(); ++itor)
|
|
{
|
|
TChatLine* pChatLine = *itor;
|
|
if (pChatSet->CheckMode(pChatLine->iType))
|
|
TempChatLineDeque.push_back(pChatLine);
|
|
}
|
|
|
|
const int icurLineCount = int(TempChatLineDeque.size());
|
|
const int iVisibleLineCount = std::min(icurLineCount, (pChatSet->m_iHeight + pChatSet->m_iStep) / pChatSet->m_iStep);
|
|
const int iEndLine = iVisibleLineCount + int(float(icurLineCount - iVisibleLineCount - 1) * pChatSet->m_fEndPos);
|
|
|
|
int iHeight = 12;
|
|
for (int i = std::min(icurLineCount - 1, iEndLine); i >= 0; --i)
|
|
{
|
|
if (!pChatSet->CheckMode(TempChatLineDeque[i]->iType))
|
|
continue;
|
|
if (!pChatSet->CheckCountryMode(TempChatLineDeque[i]->countryIndex) && TempChatLineDeque[i]->iType == CHAT_TYPE_SHOUT)
|
|
continue;
|
|
if (pChatSet->m_iHeight + pChatSet->m_iStep <= iHeight)
|
|
break;
|
|
|
|
pChatSet->m_ShowingChatLineList.push_front(TempChatLineDeque[i]);
|
|
|
|
iHeight += pChatSet->m_iStep;
|
|
}
|
|
}
|
|
|
|
void CPythonChat::AppendChat(int iType, const char* c_szChat)
|
|
{
|
|
if (strstr(c_szChat, "#ebvs"))
|
|
return;
|
|
|
|
// |Hitem:<hex vnum>:...|h[name]|h: the name is replaced by this client's item name.
|
|
std::string str = c_szChat;
|
|
const std::string findl1 = "|Hitem:";
|
|
for (size_t i = 0; i < str.length(); i++)
|
|
{
|
|
const size_t find1 = str.find(findl1, i);
|
|
if (find1 == std::string::npos)
|
|
break;
|
|
|
|
const size_t pos1 = find1 + findl1.length();
|
|
i = pos1;
|
|
|
|
if (str.length() - pos1 == 0)
|
|
break;
|
|
|
|
const std::string item_vnumabc = str.substr(pos1);
|
|
const size_t pos2 = item_vnumabc.find(':');
|
|
if (pos2 == std::string::npos)
|
|
break;
|
|
const std::string item_vnum = item_vnumabc.substr(0, pos2);
|
|
char* p;
|
|
const long n = strtol(item_vnum.c_str(), &p, 16);
|
|
if (*p != 0)
|
|
{
|
|
SDL_Log("%s a number %s", item_vnum.c_str(), str.c_str());
|
|
}
|
|
else
|
|
{
|
|
const size_t pos_1 = item_vnumabc.find("|h[");
|
|
const size_t pos_2 = item_vnumabc.find("]|h");
|
|
if (pos_1 != std::string::npos && pos_2 != std::string::npos)
|
|
{
|
|
const std::string item_name = item_vnumabc.substr(pos_1 + 3, pos_2 - pos_1 - 3);
|
|
std::string strName;
|
|
if (GetItemName(uint32_t(n), &strName))
|
|
{
|
|
if (strcmp(item_name.c_str(), strName.c_str()) != 0)
|
|
str = str.replace(str.find(item_name), item_name.length(), strName);
|
|
}
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_ChatLineNewDeque.empty())
|
|
return;
|
|
|
|
std::string strContent = str;
|
|
BYTE empireIndex = 0;
|
|
BYTE countryIndex = 0;
|
|
if (iType == CHAT_TYPE_SHOUT)
|
|
{
|
|
// "|lang|N|" and "|empire|N|" prefixes (int positions, as on Windows).
|
|
const std::string isLangFlag("|lang|");
|
|
int position = int(strContent.find(isLangFlag));
|
|
if (position != int(std::string::npos))
|
|
{
|
|
strContent = strContent.substr(position + isLangFlag.length(), strContent.length());
|
|
position = int(strContent.find("|"));
|
|
const std::string c_szLanguage = strContent.substr(0, size_t(position));
|
|
countryIndex = BYTE(atoi(c_szLanguage.c_str()));
|
|
if (countryIndex > 11 || countryIndex == 0)
|
|
countryIndex = 1;
|
|
strContent = strContent.substr(size_t(position + 1), strContent.length());
|
|
}
|
|
const std::string isEmpireFlag("|empire|");
|
|
position = int(strContent.find(isEmpireFlag));
|
|
if (position != int(std::string::npos))
|
|
{
|
|
strContent = strContent.substr(position + isEmpireFlag.length(), strContent.length());
|
|
position = int(strContent.find("|"));
|
|
const std::string c_szEmpire = strContent.substr(0, size_t(position));
|
|
empireIndex = BYTE(atoi(c_szEmpire.c_str()));
|
|
strContent = strContent.substr(size_t(position + 1), strContent.length());
|
|
}
|
|
}
|
|
|
|
for (auto it = m_ChatLineNewDeque.begin(); it != m_ChatLineNewDeque.end(); ++it)
|
|
{
|
|
SChatLine* pChatLine = SChatLine::New();
|
|
|
|
pChatLine->empireIndex = empireIndex;
|
|
pChatLine->countryIndex = countryIndex;
|
|
if (iType == CHAT_TYPE_SHOUT)
|
|
SetShoutFlags(pChatLine);
|
|
|
|
pChatLine->text = strContent;
|
|
pChatLine->iType = iType;
|
|
pChatLine->Instance.SetValue(strContent.c_str());
|
|
pChatLine->fAppendedTime = GetGlobalTime();
|
|
pChatLine->SetColorAll(GetChatColor(iType));
|
|
it->second.push_back(pChatLine);
|
|
if (it->second.size() > CHAT_LINE_MAX_NUM)
|
|
{
|
|
SChatLine* pFrontLine = it->second.front();
|
|
SChatLine::Delete(pFrontLine);
|
|
it->second.pop_front();
|
|
}
|
|
auto itChatSet = m_ChatSetMap.find(it->first);
|
|
if (itChatSet != m_ChatSetMap.end())
|
|
{
|
|
TChatSet* pChatSet = &(itChatSet->second);
|
|
if (BOARD_STATE_EDIT == pChatSet->m_iBoardState)
|
|
ArrangeShowingChat(itChatSet->first);
|
|
else
|
|
{
|
|
pChatSet->m_ShowingChatLineList.push_back(pChatLine);
|
|
if (pChatSet->m_ShowingChatLineList.size() > CHAT_LINE_MAX_NUM)
|
|
pChatSet->m_ShowingChatLineList.pop_front();
|
|
ArrangeShowingChat(itChatSet->first);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
void CPythonChat::AppendChatWithDelay(int iType, const char* c_szChat, int iDelay)
|
|
{
|
|
TWaitChat WaitChat;
|
|
WaitChat.iType = iType;
|
|
WaitChat.strChat = c_szChat;
|
|
WaitChat.dwAppendingTime = GetCurrentMillisecond() + iDelay;
|
|
m_WaitChatList.push_back(WaitChat);
|
|
}
|
|
|
|
DWORD CPythonChat::GetChatColor(int iType)
|
|
{
|
|
if (iType < CHAT_TYPE_MAX_NUM)
|
|
return m_akD3DXClrChat[iType];
|
|
|
|
return D3DXCOLOR(0.0f, 0.0f, 1.0f, 1.0f);
|
|
}
|
|
|
|
void CPythonChat::IgnoreCharacter(const char* c_szName)
|
|
{
|
|
TIgnoreCharacterSet::iterator itor = m_IgnoreCharacterSet.find(c_szName);
|
|
if (m_IgnoreCharacterSet.end() != itor)
|
|
m_IgnoreCharacterSet.erase(itor);
|
|
else
|
|
m_IgnoreCharacterSet.insert(c_szName);
|
|
}
|
|
|
|
BOOL CPythonChat::IsIgnoreCharacter(const char* c_szName)
|
|
{
|
|
return m_IgnoreCharacterSet.find(c_szName) != m_IgnoreCharacterSet.end() ? TRUE : FALSE;
|
|
}
|
|
|
|
CWhisper* CPythonChat::CreateWhisper(const char* c_szName)
|
|
{
|
|
CWhisper* pWhisper = CWhisper::New();
|
|
m_WhisperMap.insert(TWhisperMap::value_type(c_szName, pWhisper));
|
|
return pWhisper;
|
|
}
|
|
|
|
void CPythonChat::AppendWhisper(int iType, const char* c_szName, const char* c_szChat)
|
|
{
|
|
TWhisperMap::iterator itor = m_WhisperMap.find(c_szName);
|
|
|
|
CWhisper* pWhisper;
|
|
if (itor == m_WhisperMap.end())
|
|
{
|
|
pWhisper = CreateWhisper(c_szName);
|
|
pWhisper->lineCount = 0;
|
|
}
|
|
else
|
|
{
|
|
pWhisper = itor->second;
|
|
}
|
|
|
|
pWhisper->AppendChat(iType, c_szChat);
|
|
++pWhisper->lineCount;
|
|
}
|
|
|
|
void CPythonChat::ClearWhisper(const char* c_szName)
|
|
{
|
|
TWhisperMap::iterator itor = m_WhisperMap.find(c_szName);
|
|
|
|
if (itor != m_WhisperMap.end())
|
|
{
|
|
CWhisper::Delete(itor->second);
|
|
m_WhisperMap.erase(itor);
|
|
}
|
|
}
|
|
|
|
BOOL CPythonChat::GetWhisper(const char* c_szName, CWhisper** ppWhisper)
|
|
{
|
|
TWhisperMap::iterator itor = m_WhisperMap.find(c_szName);
|
|
|
|
if (itor == m_WhisperMap.end())
|
|
return FALSE;
|
|
|
|
*ppWhisper = itor->second;
|
|
if (itor->second->lineCount > 0)
|
|
itor->second->lineCount = 0;
|
|
return TRUE;
|
|
}
|
|
|
|
void CPythonChat::RenderWhisper(const char* c_szName, float fx, float fy)
|
|
{
|
|
CWhisper* pWhisper;
|
|
if (GetWhisper(c_szName, &pWhisper))
|
|
pWhisper->Render(fx, fy);
|
|
}
|
|
|
|
void CPythonChat::InitWhisper(PyObject* ppyObject)
|
|
{
|
|
for (TWhisperMap::iterator itor = m_WhisperMap.begin(); itor != m_WhisperMap.end(); ++itor)
|
|
{
|
|
const std::string strName = itor->first;
|
|
PyCallClassMemberFunc(ppyObject, "MakeWhisperButton", Py_BuildValue("(s)", strName.c_str()));
|
|
}
|
|
}
|
|
|
|
void CPythonChat::__DestroyWhisperMap()
|
|
{
|
|
for (TWhisperMap::iterator itor = m_WhisperMap.begin(); itor != m_WhisperMap.end(); ++itor)
|
|
CWhisper::Delete(itor->second);
|
|
m_WhisperMap.clear();
|
|
}
|
|
|
|
void CPythonChat::Close()
|
|
{
|
|
for (TChatSetMap::iterator itor = m_ChatSetMap.begin(); itor != m_ChatSetMap.end(); ++itor)
|
|
{
|
|
TChatLineList* pLineList = &(itor->second.m_ShowingChatLineList);
|
|
for (TChatLineList::iterator line = pLineList->begin(); line != pLineList->end(); ++line)
|
|
(*line)->fAppendedTime = 0.0f;
|
|
}
|
|
}
|
|
|
|
void CPythonChat::Destroy()
|
|
{
|
|
__DestroyWhisperMap();
|
|
|
|
m_ShowingChatLineList.clear();
|
|
m_ChatSetMap.clear();
|
|
m_ChatLineDeque.clear();
|
|
m_ChatLineNewDeque.clear();
|
|
// Not in CPythonChat::Destroy: the delayed lines and ignore set outlive Clear() on Windows too,
|
|
// so they are left alone here.
|
|
SChatLine::DestroySystem();
|
|
CWhisper::DestroySystem();
|
|
|
|
__Initialize();
|
|
}
|
|
|
|
void CPythonChat::__Initialize()
|
|
{
|
|
m_akD3DXClrChat[CHAT_TYPE_TALKING] = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_INFO] = D3DXCOLOR(1.0f, 0.785f, 0.785f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_NOTICE] = D3DXCOLOR(1.0f, 0.902f, 0.730f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_PARTY] = D3DXCOLOR(0.542f, 1.0f, 0.949f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_GUILD] = D3DXCOLOR(0.906f, 0.847f, 1.0f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_COMMAND] = D3DXCOLOR(0.658f, 1.0f, 0.835f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_SHOUT] = D3DXCOLOR(0.658f, 1.0f, 0.835f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_WHISPER] = D3DXCOLOR(DWORD(0xff4AE14A));
|
|
m_akD3DXClrChat[CHAT_TYPE_BIG_NOTICE] = D3DXCOLOR(1.0f, 0.902f, 0.730f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_MONARCH_NOTICE] = D3DXCOLOR(1.0f, 0.902f, 0.730f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_DICE_INFO] = D3DXCOLOR(DWORD(0xFFcc00cc));
|
|
m_akD3DXClrChat[CHAT_TYPE_MISSION] = D3DXCOLOR(1.0f, 0.902f, 0.730f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_EXP_INFO] = D3DXCOLOR(1.0f, 0.785f, 0.785f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_ITEM_INFO] = D3DXCOLOR(1.0f, 0.785f, 0.785f, 1.0f);
|
|
m_akD3DXClrChat[CHAT_TYPE_MONEY_INFO] = D3DXCOLOR(1.0f, 0.785f, 0.785f, 1.0f);
|
|
|
|
TChatLineDeque map_vec;
|
|
m_ChatLineNewDeque.emplace(0, map_vec);
|
|
m_ChatLineNewDeque.emplace(1, map_vec);
|
|
m_ChatSetMap.emplace(0, TChatSet()); // normal chat
|
|
m_ChatSetMap.emplace(1, TChatSet()); // log chat
|
|
}
|
|
|
|
CPythonChat::CPythonChat()
|
|
{
|
|
__Initialize();
|
|
}
|
|
|
|
DWORD CPythonChat::GetNewChatCount()
|
|
{
|
|
DWORD count = 0;
|
|
for (TWhisperMap::iterator itor = m_WhisperMap.begin(); itor != m_WhisperMap.end(); ++itor)
|
|
count += itor->second->lineCount;
|
|
return count;
|
|
}
|
|
|
|
void CPythonChat::DeleteChatSet(DWORD dwID)
|
|
{
|
|
auto it = m_ChatSetMap.find(int(dwID));
|
|
if (it != m_ChatSetMap.end())
|
|
m_ChatSetMap.erase(it);
|
|
|
|
auto itChat = m_ChatLineNewDeque.find(BYTE(dwID));
|
|
if (itChat != m_ChatLineNewDeque.end())
|
|
{
|
|
for (SChatLine* chatLine : itChat->second)
|
|
SChatLine::Delete(chatLine);
|
|
itChat->second.clear();
|
|
m_ChatLineNewDeque.erase(itChat);
|
|
}
|
|
}
|
|
|
|
void CPythonChat::EnableCountryMode(DWORD dwID, int iMode)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
if (iMode >= 0 && size_t(iMode) < pChatSet->m_iCountryMode.size())
|
|
pChatSet->m_iCountryMode[iMode] = TRUE;
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
|
|
void CPythonChat::DisableCountryMode(DWORD dwID, int iMode)
|
|
{
|
|
TChatSet* pChatSet = GetChatSetPtr(dwID);
|
|
if (!pChatSet)
|
|
return;
|
|
|
|
if (iMode >= 0 && size_t(iMode) < pChatSet->m_iCountryMode.size())
|
|
pChatSet->m_iCountryMode[iMode] = FALSE;
|
|
ArrangeShowingChat(dwID);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
CDynamicPool<CWhisper> CWhisper::ms_kPool;
|
|
|
|
CWhisper* CWhisper::New()
|
|
{
|
|
return ms_kPool.Alloc();
|
|
}
|
|
|
|
void CWhisper::Delete(CWhisper* pkWhisper)
|
|
{
|
|
pkWhisper->Destroy();
|
|
ms_kPool.Free(pkWhisper);
|
|
}
|
|
|
|
void CWhisper::DestroySystem()
|
|
{
|
|
ms_kPool.Destroy();
|
|
|
|
SChatLine::DestroySystem();
|
|
}
|
|
|
|
void CWhisper::SetPosition(float fPosition)
|
|
{
|
|
m_fcurPosition = fPosition;
|
|
__ArrangeChat();
|
|
}
|
|
|
|
void CWhisper::SetBoxSize(float fWidth, float fHeight)
|
|
{
|
|
m_fWidth = fWidth;
|
|
m_fHeight = fHeight;
|
|
|
|
for (TChatLineDeque::iterator itor = m_ChatLineDeque.begin(); itor != m_ChatLineDeque.end(); ++itor)
|
|
(*itor)->Instance.SetLimitWidth(fWidth);
|
|
}
|
|
|
|
void CWhisper::AppendChat(int iType, const char* c_szChat)
|
|
{
|
|
SChatLine* pChatLine = SChatLine::New();
|
|
pChatLine->Instance.SetValue(c_szChat);
|
|
pChatLine->Instance.SetLimitWidth(m_fWidth);
|
|
pChatLine->Instance.SetMultiLine(TRUE);
|
|
|
|
switch (iType)
|
|
{
|
|
case CPythonChat::WHISPER_TYPE_SYSTEM:
|
|
pChatLine->Instance.SetColor(D3DXCOLOR(1.0f, 0.785f, 0.785f, 1.0f));
|
|
break;
|
|
case CPythonChat::WHISPER_TYPE_GM:
|
|
pChatLine->Instance.SetColor(D3DXCOLOR(1.0f, 0.632f, 0.0f, 1.0f));
|
|
break;
|
|
case CPythonChat::WHISPER_TYPE_CHAT:
|
|
default:
|
|
pChatLine->Instance.SetColor(D3DXCOLOR(DWORD(0xffffffff)));
|
|
break;
|
|
}
|
|
|
|
m_ChatLineDeque.push_back(pChatLine);
|
|
|
|
__ArrangeChat();
|
|
}
|
|
|
|
void CWhisper::__ArrangeChat()
|
|
{
|
|
for (TChatLineDeque::iterator itor = m_ChatLineDeque.begin(); itor != m_ChatLineDeque.end(); ++itor)
|
|
(*itor)->Instance.Update();
|
|
}
|
|
|
|
void CWhisper::Render(float fx, float fy)
|
|
{
|
|
float fHeight = fy + m_fHeight;
|
|
|
|
const int iViewCount = int(m_fHeight / m_fLineStep) - 1;
|
|
const int iLineCount = int(m_ChatLineDeque.size());
|
|
int iStartLine = -1;
|
|
if (iLineCount > iViewCount)
|
|
iStartLine = int(float(iLineCount - iViewCount) * m_fcurPosition) + iViewCount - 1;
|
|
else if (!m_ChatLineDeque.empty())
|
|
iStartLine = iLineCount - 1;
|
|
|
|
const RECT Rect = { LONG(fx), LONG(fy), LONG(fx + m_fWidth), LONG(fy + m_fHeight) };
|
|
|
|
// The Windows assert(i < size) is compiled out; a position above 1.0 starts past the end.
|
|
iStartLine = std::min(iStartLine, iLineCount - 1);
|
|
for (int i = iStartLine; i >= 0; --i)
|
|
{
|
|
TChatLine* pChatLine = m_ChatLineDeque[i];
|
|
|
|
const WORD wLineCount = WORD(pChatLine->Instance.GetTextLineCount());
|
|
fHeight -= wLineCount * m_fLineStep;
|
|
|
|
pChatLine->Instance.SetPosition(fx, fHeight);
|
|
pChatLine->Instance.Render(&Rect);
|
|
|
|
if (fHeight < fy)
|
|
break;
|
|
}
|
|
}
|
|
|
|
void CWhisper::__Initialize()
|
|
{
|
|
m_fLineStep = 15.0f;
|
|
m_fWidth = 300.0f;
|
|
m_fHeight = 120.0f;
|
|
m_fcurPosition = 1.0f;
|
|
}
|
|
|
|
void CWhisper::Destroy()
|
|
{
|
|
std::for_each(m_ChatLineDeque.begin(), m_ChatLineDeque.end(), SChatLine::Delete);
|
|
m_ChatLineDeque.clear();
|
|
m_ShowingChatLineList.clear();
|
|
}
|
|
|
|
// lineCount is left uninitialised by Windows for chat.CreateWhisper; it starts at 0 here.
|
|
CWhisper::CWhisper() : lineCount(0)
|
|
{
|
|
__Initialize();
|
|
}
|
|
|
|
CWhisper::~CWhisper()
|
|
{
|
|
Destroy();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
CDynamicPool<CWhisper::SChatLine> CWhisper::SChatLine::ms_kPool;
|
|
|
|
CWhisper::SChatLine* CWhisper::SChatLine::New()
|
|
{
|
|
return ms_kPool.Alloc();
|
|
}
|
|
|
|
void CWhisper::SChatLine::Delete(CWhisper::SChatLine* pkChatLine)
|
|
{
|
|
pkChatLine->Instance.Destroy();
|
|
ms_kPool.Free(pkChatLine);
|
|
}
|
|
|
|
void CWhisper::SChatLine::DestroySystem()
|
|
{
|
|
ms_kPool.Destroy();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
// PythonChatModule.cpp
|
|
|
|
namespace {
|
|
|
|
PyObject* chatSetChatColor(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iType))
|
|
return Py_BuildException();
|
|
int r;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &r))
|
|
return Py_BuildException();
|
|
int g;
|
|
if (!PyTuple_GetInteger(poArgs, 2, &g))
|
|
return Py_BuildException();
|
|
int b;
|
|
if (!PyTuple_GetInteger(poArgs, 3, &b))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().SetChatColor(iType, r, g, b);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatClear(PyObject*, PyObject*)
|
|
{
|
|
CPythonChat::Instance().Destroy();
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatClose(PyObject*, PyObject*)
|
|
{
|
|
CPythonChat::Instance().Close();
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatCreateChatSet(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", CPythonChat::Instance().CreateChatSet(iID));
|
|
}
|
|
|
|
PyObject* chatUpdate(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().Update(iID);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatRender(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().Render(iID);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetBoardState(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iState;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iState))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().SetBoardState(iID, iState);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetPosition(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int ix;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &ix))
|
|
return Py_BuildException();
|
|
int iy;
|
|
if (!PyTuple_GetInteger(poArgs, 2, &iy))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().SetPosition(iID, ix, iy);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetHeight(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iHeight;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iHeight))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().SetHeight(iID, iHeight);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetStep(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iStep;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iStep))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().SetStep(iID, iStep);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatToggleChatMode(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iType))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().ToggleChatMode(iID, iType);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatEnableChatMode(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iType))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().EnableChatMode(iID, iType);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatDisableChatMode(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iType))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().DisableChatMode(iID, iType);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetEndPos(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
float fPos;
|
|
if (!PyTuple_GetFloat(poArgs, 1, &fPos))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().SetEndPos(iID, fPos);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatGetLineCount(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", CPythonChat::Instance().GetLineCount(iID));
|
|
}
|
|
|
|
PyObject* chatGetVisibleLineCount(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", CPythonChat::Instance().GetVisibleLineCount(iID));
|
|
}
|
|
|
|
PyObject* chatGetLineStep(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
return Py_BuildValue("i", CPythonChat::Instance().GetLineStep(iID));
|
|
}
|
|
|
|
PyObject* chatAppendChat(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iType))
|
|
return Py_BuildException();
|
|
char* szChat;
|
|
if (!PyTuple_GetString(poArgs, 1, &szChat))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().AppendChat(iType, szChat);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatAppendChatWithDelay(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iType))
|
|
return Py_BuildException();
|
|
char* szChat;
|
|
if (!PyTuple_GetString(poArgs, 1, &szChat))
|
|
return Py_BuildException();
|
|
int iDelay;
|
|
if (!PyTuple_GetInteger(poArgs, 2, &iDelay))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().AppendChatWithDelay(iType, szChat, iDelay);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatArrangeShowingChat(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().ArrangeShowingChat(iID);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatIgnoreCharacter(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().IgnoreCharacter(szName);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
// Windows discards the result and returns None.
|
|
PyObject* chatIsIgnoreCharacter(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().IsIgnoreCharacter(szName);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatCreateWhisper(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().CreateWhisper(szName);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatAppendWhisper(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iType))
|
|
return Py_BuildException();
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 1, &szName))
|
|
return Py_BuildException();
|
|
char* szChat;
|
|
if (!PyTuple_GetString(poArgs, 2, &szChat))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().AppendWhisper(iType, szName, szChat);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatRenderWhisper(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
float fx;
|
|
if (!PyTuple_GetFloat(poArgs, 1, &fx))
|
|
return Py_BuildException();
|
|
float fy;
|
|
if (!PyTuple_GetFloat(poArgs, 2, &fy))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().RenderWhisper(szName, fx, fy);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetWhisperBoxSize(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
float fWidth;
|
|
if (!PyTuple_GetFloat(poArgs, 1, &fWidth))
|
|
return Py_BuildException();
|
|
float fHeight;
|
|
if (!PyTuple_GetFloat(poArgs, 2, &fHeight))
|
|
return Py_BuildException();
|
|
|
|
CWhisper* pWhisper;
|
|
if (CPythonChat::Instance().GetWhisper(szName, &pWhisper))
|
|
pWhisper->SetBoxSize(fWidth, fHeight);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatSetWhisperPosition(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
float fPosition;
|
|
if (!PyTuple_GetFloat(poArgs, 1, &fPosition))
|
|
return Py_BuildException();
|
|
|
|
CWhisper* pWhisper;
|
|
if (CPythonChat::Instance().GetWhisper(szName, &pWhisper))
|
|
pWhisper->SetPosition(fPosition);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatClearWhisper(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szName;
|
|
if (!PyTuple_GetString(poArgs, 0, &szName))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().ClearWhisper(szName);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatInitWhisper(PyObject*, PyObject* poArgs)
|
|
{
|
|
PyObject* poInterface;
|
|
if (!PyTuple_GetObject(poArgs, 0, &poInterface))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().InitWhisper(poInterface);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatGetLinkFromHyperlink(PyObject*, PyObject* poArgs)
|
|
{
|
|
char* szHyperlink;
|
|
if (!PyTuple_GetString(poArgs, 0, &szHyperlink))
|
|
return Py_BuildException();
|
|
|
|
std::string stHyperlink(szHyperlink);
|
|
std::vector<std::string> results;
|
|
split_string(stHyperlink, ":", results, false);
|
|
|
|
// A link without ':' leaves results empty; Windows reads results[0] regardless.
|
|
if (!results.empty() && 0 == results[0].compare("item"))
|
|
{
|
|
if (results.size() < 6)
|
|
return Py_BuildValue("s", "");
|
|
|
|
std::string strName;
|
|
if (GetItemName(uint32_t(htoi(results[1].c_str())), &strName))
|
|
{
|
|
char buf[1024] = { 0 };
|
|
char itemlink[256];
|
|
int len;
|
|
bool isAttr = false;
|
|
|
|
len = snprintf(itemlink, sizeof(itemlink), "item:%x:%x:%x:%x:%x",
|
|
htoi(results[1].c_str()),
|
|
htoi(results[2].c_str()),
|
|
htoi(results[3].c_str()),
|
|
htoi(results[4].c_str()),
|
|
htoi(results[5].c_str()));
|
|
|
|
if (results.size() >= 8)
|
|
{
|
|
// An odd attribute count reads past results on Windows; the missing value is 0.
|
|
for (size_t i = 6; i < results.size(); i += 2)
|
|
{
|
|
if (len >= int(sizeof(itemlink)))
|
|
break;
|
|
len += snprintf(itemlink + len, sizeof(itemlink) - len, ":%x:%d",
|
|
htoi(results[i].c_str()),
|
|
i + 1 < results.size() ? atoi(results[i + 1].c_str()) : 0);
|
|
isAttr = true;
|
|
}
|
|
}
|
|
|
|
if (isAttr)
|
|
snprintf(buf, sizeof(buf), "|cffffc700|H%s|h[%s]|h|r", itemlink, strName.c_str());
|
|
else
|
|
snprintf(buf, sizeof(buf), "|cfff1e6c0|H%s|h[%s]|h|r", itemlink, strName.c_str());
|
|
|
|
return Py_BuildValue("s", buf);
|
|
}
|
|
}
|
|
|
|
return Py_BuildValue("s", "");
|
|
}
|
|
|
|
PyObject* chatDeleteChatSet(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().DeleteChatSet(iID);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatEnableCountryMode(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iType))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().EnableCountryMode(iID, iType);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
PyObject* chatDisableCountryMode(PyObject*, PyObject* poArgs)
|
|
{
|
|
int iID;
|
|
if (!PyTuple_GetInteger(poArgs, 0, &iID))
|
|
return Py_BuildException();
|
|
int iType;
|
|
if (!PyTuple_GetInteger(poArgs, 1, &iType))
|
|
return Py_BuildException();
|
|
|
|
CPythonChat::Instance().DisableCountryMode(iID, iType);
|
|
return Py_BuildNone();
|
|
}
|
|
|
|
} // namespace
|
|
|
|
void initChat()
|
|
{
|
|
static PyMethodDef s_methods[] =
|
|
{
|
|
{ "SetChatColor", chatSetChatColor, METH_VARARGS, nullptr },
|
|
{ "Clear", chatClear, METH_VARARGS, nullptr },
|
|
{ "Close", chatClose, METH_VARARGS, nullptr },
|
|
|
|
{ "CreateChatSet", chatCreateChatSet, METH_VARARGS, nullptr },
|
|
{ "Update", chatUpdate, METH_VARARGS, nullptr },
|
|
{ "Render", chatRender, METH_VARARGS, nullptr },
|
|
|
|
{ "SetBoardState", chatSetBoardState, METH_VARARGS, nullptr },
|
|
{ "SetPosition", chatSetPosition, METH_VARARGS, nullptr },
|
|
{ "SetHeight", chatSetHeight, METH_VARARGS, nullptr },
|
|
{ "SetStep", chatSetStep, METH_VARARGS, nullptr },
|
|
{ "ToggleChatMode", chatToggleChatMode, METH_VARARGS, nullptr },
|
|
{ "EnableChatMode", chatEnableChatMode, METH_VARARGS, nullptr },
|
|
{ "DisableChatMode", chatDisableChatMode, METH_VARARGS, nullptr },
|
|
{ "SetEndPos", chatSetEndPos, METH_VARARGS, nullptr },
|
|
|
|
{ "GetLineCount", chatGetLineCount, METH_VARARGS, nullptr },
|
|
{ "GetVisibleLineCount", chatGetVisibleLineCount, METH_VARARGS, nullptr },
|
|
{ "GetLineStep", chatGetLineStep, METH_VARARGS, nullptr },
|
|
|
|
// Chat
|
|
{ "AppendChat", chatAppendChat, METH_VARARGS, nullptr },
|
|
{ "AppendChatWithDelay", chatAppendChatWithDelay, METH_VARARGS, nullptr },
|
|
{ "ArrangeShowingChat", chatArrangeShowingChat, METH_VARARGS, nullptr },
|
|
|
|
// Ignore
|
|
{ "IgnoreCharacter", chatIgnoreCharacter, METH_VARARGS, nullptr },
|
|
{ "IsIgnoreCharacter", chatIsIgnoreCharacter, METH_VARARGS, nullptr },
|
|
|
|
// Whisper
|
|
{ "CreateWhisper", chatCreateWhisper, METH_VARARGS, nullptr },
|
|
{ "AppendWhisper", chatAppendWhisper, METH_VARARGS, nullptr },
|
|
{ "RenderWhisper", chatRenderWhisper, METH_VARARGS, nullptr },
|
|
{ "SetWhisperBoxSize", chatSetWhisperBoxSize, METH_VARARGS, nullptr },
|
|
{ "SetWhisperPosition", chatSetWhisperPosition, METH_VARARGS, nullptr },
|
|
{ "ClearWhisper", chatClearWhisper, METH_VARARGS, nullptr },
|
|
{ "InitWhisper", chatInitWhisper, METH_VARARGS, nullptr },
|
|
|
|
// Link
|
|
{ "GetLinkFromHyperlink", chatGetLinkFromHyperlink, METH_VARARGS, nullptr },
|
|
{ "DeleteChatSet", chatDeleteChatSet, METH_VARARGS, nullptr },
|
|
{ "EnableCountryMode", chatEnableCountryMode, METH_VARARGS, nullptr },
|
|
{ "DisableCountryMode", chatDisableCountryMode, METH_VARARGS, nullptr },
|
|
|
|
{ nullptr, nullptr, 0, nullptr },
|
|
};
|
|
|
|
PyObject* poModule = Py_InitModule("chat", s_methods);
|
|
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_TALKING", CPythonChat::CHAT_TYPE_TALKING);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_INFO", CPythonChat::CHAT_TYPE_INFO);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_NOTICE", CPythonChat::CHAT_TYPE_NOTICE);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_PARTY", CPythonChat::CHAT_TYPE_PARTY);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_GUILD", CPythonChat::CHAT_TYPE_GUILD);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_COMMAND", CPythonChat::CHAT_TYPE_COMMAND);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_SHOUT", CPythonChat::CHAT_TYPE_SHOUT);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_WHISPER", CPythonChat::CHAT_TYPE_WHISPER);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_BIG_NOTICE", CPythonChat::CHAT_TYPE_BIG_NOTICE);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_MONARCH_NOTICE", CPythonChat::CHAT_TYPE_MONARCH_NOTICE);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_DICE_INFO", CPythonChat::CHAT_TYPE_DICE_INFO);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_EXP_INFO", CPythonChat::CHAT_TYPE_EXP_INFO);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_ITEM_INFO", CPythonChat::CHAT_TYPE_ITEM_INFO);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_MONEY_INFO", CPythonChat::CHAT_TYPE_MONEY_INFO);
|
|
PyModule_AddIntConstant(poModule, "CHAT_TYPE_MISSION", CPythonChat::CHAT_TYPE_MISSION);
|
|
|
|
PyModule_AddIntConstant(poModule, "WHISPER_TYPE_CHAT", CPythonChat::WHISPER_TYPE_CHAT);
|
|
PyModule_AddIntConstant(poModule, "WHISPER_TYPE_SYSTEM", CPythonChat::WHISPER_TYPE_SYSTEM);
|
|
PyModule_AddIntConstant(poModule, "WHISPER_TYPE_GM", CPythonChat::WHISPER_TYPE_GM);
|
|
|
|
PyModule_AddIntConstant(poModule, "BOARD_STATE_VIEW", CPythonChat::BOARD_STATE_VIEW);
|
|
PyModule_AddIntConstant(poModule, "BOARD_STATE_EDIT", CPythonChat::BOARD_STATE_EDIT);
|
|
PyModule_AddIntConstant(poModule, "BOARD_STATE_LOG", CPythonChat::BOARD_STATE_LOG);
|
|
|
|
PyModule_AddIntConstant(poModule, "CHAT_SET_CHAT_WINDOW", 0);
|
|
PyModule_AddIntConstant(poModule, "CHAT_SET_LOG_WINDOW", 1);
|
|
}
|
|
|
|
} // namespace ava2
|