- gr2: BitKnit2 decompression, 64-bit LE files, compressed curves - net: remaining GamePhase handlers, generated GC packet table - python: event/chat/chr/minimap/guild/quest/messenger/shop-search and other native modules ported against the AVA2 Windows client - render: D3D8 fixed-function lighting in Gr2ModelRenderer, terrain without baked shade; cape/NPC equipment attachment - tests + audits updated; docs/PORT-PLAN.md and WINDOWS-PARITY.md Batch 4 (render pipeline: background.*, app.RenderGame/UpdateGame, camera bindings, main.cpp fake-content removal) is still in progress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
308 lines
8.3 KiB
C++
308 lines
8.3 KiB
C++
#pragma once
|
|
// CPythonChat / CWhisper: the chat line store behind the "chat" module and the server chat path.
|
|
// Provenance: AVA2 UserInterface/PythonChat.{h,cpp} and PythonChatModule.cpp, compiled with
|
|
// __CHAT_SETTINGS__, ENABLE_MULTILANGUAGE_SYSTEM, ENABLE_DICE_SYSTEM, dracaryS_DUNGEON_LIB and
|
|
// ENABLE_DISCORD_STUFF (Locale_inc.h); LINK_IN_CHAT is off.
|
|
#include "eter_ui/PythonWindow.h"
|
|
#include "eter_image/GrpImageInstance.h"
|
|
#include "shared/common/DynamicPool.h"
|
|
#include <Python.h>
|
|
#include <deque>
|
|
#include <list>
|
|
#include <map>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ava2 {
|
|
|
|
class CWhisper
|
|
{
|
|
public:
|
|
typedef UI::CGraphicTextInstance CGraphicTextInstance;
|
|
|
|
typedef struct SChatLine
|
|
{
|
|
CGraphicTextInstance Instance;
|
|
|
|
SChatLine() {}
|
|
~SChatLine() { Instance.Destroy(); }
|
|
|
|
static void DestroySystem();
|
|
|
|
static SChatLine* New();
|
|
static void Delete(SChatLine* pkChatLine);
|
|
|
|
static CDynamicPool<SChatLine> ms_kPool;
|
|
} TChatLine;
|
|
|
|
typedef std::deque<TChatLine*> TChatLineDeque;
|
|
typedef std::list<TChatLine*> TChatLineList;
|
|
|
|
public:
|
|
CWhisper();
|
|
~CWhisper();
|
|
|
|
void Destroy();
|
|
|
|
void SetPosition(float fPosition);
|
|
void SetBoxSize(float fWidth, float fHeight);
|
|
void AppendChat(int iType, const char* c_szChat);
|
|
void Render(float fx, float fy);
|
|
DWORD lineCount;
|
|
|
|
// Test access.
|
|
const TChatLineDeque& GetLines() const { return m_ChatLineDeque; }
|
|
float GetWidth() const { return m_fWidth; }
|
|
float GetHeight() const { return m_fHeight; }
|
|
float GetCurPosition() const { return m_fcurPosition; }
|
|
|
|
protected:
|
|
void __Initialize();
|
|
void __ArrangeChat();
|
|
|
|
protected:
|
|
float m_fLineStep;
|
|
float m_fWidth;
|
|
float m_fHeight;
|
|
float m_fcurPosition;
|
|
|
|
TChatLineDeque m_ChatLineDeque;
|
|
TChatLineList m_ShowingChatLineList;
|
|
|
|
public:
|
|
static void DestroySystem();
|
|
|
|
static CWhisper* New();
|
|
static void Delete(CWhisper* pkWhisper);
|
|
|
|
static CDynamicPool<CWhisper> ms_kPool;
|
|
};
|
|
|
|
class CPythonChat
|
|
{
|
|
public:
|
|
typedef UI::CGraphicTextInstance CGraphicTextInstance;
|
|
|
|
enum EChatType
|
|
{
|
|
CHAT_TYPE_TALKING,
|
|
CHAT_TYPE_INFO,
|
|
CHAT_TYPE_NOTICE,
|
|
CHAT_TYPE_PARTY,
|
|
CHAT_TYPE_GUILD,
|
|
CHAT_TYPE_COMMAND,
|
|
CHAT_TYPE_SHOUT,
|
|
CHAT_TYPE_WHISPER,
|
|
CHAT_TYPE_BIG_NOTICE,
|
|
CHAT_TYPE_MONARCH_NOTICE,
|
|
CHAT_TYPE_DICE_INFO,
|
|
CHAT_TYPE_EXP_INFO,
|
|
CHAT_TYPE_ITEM_INFO,
|
|
CHAT_TYPE_MONEY_INFO,
|
|
CHAT_TYPE_MISSION,
|
|
CHAT_TYPE_MAX_NUM,
|
|
};
|
|
|
|
enum EWhisperType
|
|
{
|
|
WHISPER_TYPE_CHAT = 0,
|
|
WHISPER_TYPE_NOT_EXIST = 1,
|
|
WHISPER_TYPE_TARGET_BLOCKED = 2,
|
|
WHISPER_TYPE_SENDER_BLOCKED = 3,
|
|
WHISPER_TYPE_ERROR = 4,
|
|
WHISPER_TYPE_GM = 5,
|
|
WHISPER_TYPE_SYSTEM = 0xFF
|
|
};
|
|
|
|
enum EBoardState
|
|
{
|
|
BOARD_STATE_VIEW,
|
|
BOARD_STATE_EDIT,
|
|
BOARD_STATE_LOG,
|
|
};
|
|
|
|
enum
|
|
{
|
|
CHAT_LINE_MAX_NUM = 300,
|
|
CHAT_LINE_COLOR_ARRAY_MAX_NUM = 3,
|
|
};
|
|
|
|
typedef struct SChatLine
|
|
{
|
|
int iType;
|
|
float fAppendedTime;
|
|
D3DXCOLOR aColor[CHAT_LINE_COLOR_ARRAY_MAX_NUM];
|
|
CGraphicTextInstance Instance;
|
|
CGraphicImageInstance InstanceLang;
|
|
CGraphicImageInstance InstanceEmpire;
|
|
SChatLine();
|
|
virtual ~SChatLine();
|
|
BYTE countryIndex;
|
|
BYTE empireIndex;
|
|
std::string text;
|
|
void SetColor(DWORD dwID, DWORD dwColor);
|
|
void SetColorAll(DWORD dwColor);
|
|
D3DXCOLOR& GetColorRef(DWORD dwID);
|
|
static void DestroySystem();
|
|
|
|
static SChatLine* New();
|
|
static void Delete(SChatLine* pkChatLine);
|
|
|
|
static CDynamicPool<SChatLine> ms_kPool;
|
|
} TChatLine;
|
|
|
|
typedef struct SWaitChat
|
|
{
|
|
int iType;
|
|
std::string strChat;
|
|
|
|
DWORD dwAppendingTime;
|
|
} TWaitChat;
|
|
|
|
typedef std::deque<TChatLine*> TChatLineDeque;
|
|
typedef std::list<TChatLine*> TChatLineList;
|
|
|
|
typedef std::map<std::string, CWhisper*> TWhisperMap;
|
|
typedef std::set<std::string> TIgnoreCharacterSet;
|
|
typedef std::list<TWaitChat> TWaitChatList;
|
|
|
|
typedef struct SChatSet
|
|
{
|
|
int m_ix;
|
|
int m_iy;
|
|
int m_iHeight;
|
|
int m_iStep;
|
|
float m_fEndPos;
|
|
|
|
int m_iBoardState;
|
|
std::vector<int> m_iMode;
|
|
|
|
TChatLineList m_ShowingChatLineList;
|
|
std::vector<int> m_iCountryMode;
|
|
bool CheckCountryMode(DWORD dwType)
|
|
{
|
|
if (dwType >= m_iCountryMode.size())
|
|
return false;
|
|
return m_iCountryMode[dwType] ? true : false;
|
|
}
|
|
bool CheckMode(DWORD dwType)
|
|
{
|
|
if (dwType >= m_iMode.size())
|
|
return false;
|
|
|
|
return m_iMode[dwType] ? true : false;
|
|
}
|
|
|
|
SChatSet()
|
|
{
|
|
m_iBoardState = BOARD_STATE_VIEW;
|
|
|
|
m_ix = 0;
|
|
m_iy = 0;
|
|
m_fEndPos = 1.0f;
|
|
m_iHeight = 0;
|
|
m_iStep = 15;
|
|
|
|
m_iMode.clear();
|
|
m_iMode.resize(ms_iChatModeSize, 1);
|
|
m_iCountryMode.clear();
|
|
m_iCountryMode.resize(15, 1);
|
|
}
|
|
|
|
static int ms_iChatModeSize;
|
|
} TChatSet;
|
|
|
|
typedef std::map<int, TChatSet> TChatSetMap;
|
|
|
|
public:
|
|
static CPythonChat& Instance();
|
|
|
|
void SetChatColor(UINT eType, UINT r, UINT g, UINT b);
|
|
|
|
void Destroy();
|
|
void Close();
|
|
DWORD GetNewChatCount();
|
|
int CreateChatSet(DWORD dwID);
|
|
void Update(DWORD dwID);
|
|
void Render(DWORD dwID);
|
|
void RenderWhisper(const char* c_szName, float fx, float fy);
|
|
|
|
void SetBoardState(DWORD dwID, int iState);
|
|
void SetPosition(DWORD dwID, int ix, int iy);
|
|
void SetHeight(DWORD dwID, int iHeight);
|
|
void SetStep(DWORD dwID, int iStep);
|
|
void ToggleChatMode(DWORD dwID, int iMode);
|
|
void EnableChatMode(DWORD dwID, int iMode);
|
|
void DisableChatMode(DWORD dwID, int iMode);
|
|
void SetEndPos(DWORD dwID, float fPos);
|
|
void DeleteChatSet(DWORD dwID);
|
|
void EnableCountryMode(DWORD dwID, int iMode);
|
|
void DisableCountryMode(DWORD dwID, int iMode);
|
|
int GetVisibleLineCount(DWORD dwID);
|
|
int GetEditableLineCount(DWORD dwID);
|
|
int GetLineCount(DWORD dwID);
|
|
int GetLineStep(DWORD dwID);
|
|
|
|
// Chat
|
|
void AppendChat(int iType, const char* c_szChat);
|
|
void AppendChatWithDelay(int iType, const char* c_szChat, int iDelay);
|
|
void ArrangeShowingChat(DWORD dwID);
|
|
|
|
// Ignore
|
|
void IgnoreCharacter(const char* c_szName);
|
|
BOOL IsIgnoreCharacter(const char* c_szName);
|
|
|
|
// Whisper
|
|
CWhisper* CreateWhisper(const char* c_szName);
|
|
void AppendWhisper(int iType, const char* c_szName, const char* c_szChat);
|
|
void ClearWhisper(const char* c_szName);
|
|
BOOL GetWhisper(const char* c_szName, CWhisper** ppWhisper);
|
|
void InitWhisper(PyObject* ppyObject);
|
|
|
|
// CTimer stand-in: 0 follows the real clock (CTimer with m_bUseRealTime); tests pin a value.
|
|
// GetGlobalTime is the same clock in seconds, as CPythonApplication samples it per frame.
|
|
void SetCurrentMillisecond(DWORD dwTime) { m_dwFixedMillisecond = dwTime; }
|
|
DWORD GetCurrentMillisecond() const;
|
|
float GetGlobalTime() const { return float(GetCurrentMillisecond()) / 1000.0f; }
|
|
|
|
// Test access.
|
|
const TChatSet* GetChatSet(DWORD dwID) const;
|
|
const TChatLineDeque* GetChatLineDeque(DWORD dwID) const;
|
|
const TWhisperMap& GetWhisperMap() const { return m_WhisperMap; }
|
|
size_t GetWaitChatCount() const { return m_WaitChatList.size(); }
|
|
DWORD GetChatColorValue(int iType) { return GetChatColor(iType); }
|
|
|
|
protected:
|
|
CPythonChat();
|
|
|
|
void __Initialize();
|
|
void __DestroyWhisperMap();
|
|
|
|
TChatLineList* GetChatLineListPtr(DWORD dwID);
|
|
TChatSet* GetChatSetPtr(DWORD dwID);
|
|
|
|
void UpdateViewMode(DWORD dwID);
|
|
void UpdateEditMode(DWORD dwID);
|
|
void UpdateLogMode(DWORD dwID);
|
|
|
|
DWORD GetChatColor(int iType);
|
|
|
|
protected:
|
|
TChatLineDeque m_ChatLineDeque;
|
|
TChatLineList m_ShowingChatLineList;
|
|
TChatSetMap m_ChatSetMap;
|
|
TWhisperMap m_WhisperMap;
|
|
TIgnoreCharacterSet m_IgnoreCharacterSet;
|
|
TWaitChatList m_WaitChatList;
|
|
|
|
std::map<BYTE, TChatLineDeque> m_ChatLineNewDeque;
|
|
D3DXCOLOR m_akD3DXClrChat[CHAT_TYPE_MAX_NUM];
|
|
|
|
DWORD m_dwFixedMillisecond = 0;
|
|
};
|
|
|
|
void initChat();
|
|
|
|
} // namespace ava2
|