Jump to content

Fix Chat History Update


xP3NG3Rx

Recommended Posts

  • Honorable Member

Hello everyone.

Here is a little snippet for the chat history. I made this to turn back the "All" state if you turn off every each button.

 

Spoiler

1. Open PythonChat.h and add the following function declaration to the public list of the PythonChat class:



BOOL GetChatMode(DWORD dwID, int * iSum);

2. Open PythonChat.cpp and paste the next function anywhere you want:



BOOL CPythonChat::GetChatMode(DWORD dwID, int * iSum)
{
	TChatSet * pChatSet = GetChatSetPtr(dwID);
	if (!pChatSet)
		return FALSE;

#ifdef ENABLE_DICE_SYSTEM
	BYTE byChatHistoryLogModes[7] = { CHAT_TYPE_TALKING, CHAT_TYPE_INFO, CHAT_TYPE_NOTICE, CHAT_TYPE_PARTY, CHAT_TYPE_GUILD, CHAT_TYPE_SHOUT, CHAT_TYPE_DICE_INFO };
#else
	BYTE byChatHistoryLogModes[6] = { CHAT_TYPE_TALKING, CHAT_TYPE_INFO, CHAT_TYPE_NOTICE, CHAT_TYPE_PARTY, CHAT_TYPE_GUILD, CHAT_TYPE_SHOUT };
#endif

	int iRet = 0;
	for (BYTE i = 0; i < sizeof(byChatHistoryLogModes) / sizeof(*byChatHistoryLogModes); i++)
	{
		if (pChatSet->CheckMode(byChatHistoryLogModes[i]))
			iRet += 1 << byChatHistoryLogModes[i];
	}
	*iSum = iRet;
	return (iRet > 0) ? TRUE : FALSE;
}

3. Open PythonChatModule.cpp and add the following function:



PyObject * chatGetChatMode(PyObject* poSelf, PyObject* poArgs)
{
	int iID;
	if (!PyTuple_GetInteger(poArgs, 0, &iID))
		return Py_BuildException();

	int iSum;
	BOOL bRet = CPythonChat::Instance().GetChatMode(iID, &iSum);
	return Py_BuildValue("ii", bRet, iSum);
}

//[...]

		{ "GetChatMode",			chatGetChatMode,			METH_VARARGS },

4. Open uiChat.py and replace the whole function by name; ToggleChatMode with this:



	def ToggleChatMode(self, mode):
		if self.allChatMode:
			self.allChatMode = False
			for i in self.CHAT_MODE_INDEX:
				chat.DisableChatMode(self.chatID, i)
			chat.EnableChatMode(self.chatID, mode)
			self.btnAll.SetUp()
		else:
			chat.ToggleChatMode(self.chatID, mode)
			ison, modeflag = chat.GetChatMode(self.chatID)
			if not ison:
				self.btnAll.Down()
				self.ToggleAllChatMode()

 

 

 

  • Metin2 Dev 1
  • Love 1
  • Love 9
Link to comment
Share on other sites

33 minutes ago, metin2-factory said:

ison, modeflag = chat.GetChatMode(self.chatID)

what is the modeflag variable used for?

is it needed anywhere or you added it just for debugging your code?

because i can't see it being used anywhere

Maybe he was want to do something with the sum.

Should look like that:

Spoiler

//PythonChat.h
BOOL GetChatMode(DWORD dwID);

//PythonChat.cpp
BOOL CPythonChat::GetChatMode(DWORD dwID)
{
	TChatSet * pChatSet = GetChatSetPtr(dwID);
	if (!pChatSet)
		return FALSE;

	BYTE byChatHistoryLogModes[] = {
		CHAT_TYPE_TALKING, CHAT_TYPE_INFO, CHAT_TYPE_NOTICE, CHAT_TYPE_PARTY, CHAT_TYPE_GUILD, CHAT_TYPE_SHOUT,
		#ifdef ENABLE_DICE_SYSTEM
		CHAT_TYPE_DICE_INFO
		#endif
	};

	int iRet = 0;
	for (BYTE i = 0; i < _countof(byChatHistoryLogModes); i++)
	{
		if (pChatSet->CheckMode(byChatHistoryLogModes[i]))
			iRet += 1 << byChatHistoryLogModes[i];
	}

	return iRet > 0;
}

//PythonChatModule.cpp
PyObject * chatGetChatMode(PyObject* poSelf, PyObject* poArgs)
{
	int iID;
	if (!PyTuple_GetInteger(poArgs, 0, &iID))
		return Py_BuildException();

	return Py_BuildValue("b", CPythonChat::Instance().GetChatMode(iID));
}

//Python
	def ToggleChatMode(self, mode):
		if self.allChatMode:
			self.allChatMode = False

			for i in self.CHAT_MODE_INDEX:
				chat.DisableChatMode(self.chatID, i)

			chat.EnableChatMode(self.chatID, mode)
			self.btnAll.SetUp()
		else:
			chat.ToggleChatMode(self.chatID, mode)

			if not chat.GetChatMode(self.chatID):
				self.btnAll.Down()
				self.ToggleAllChatMode()

 

 

Link to comment
Share on other sites

8 hours ago, Tasho said:

Maybe he was want to do something with the sum.

Should look like that:

  Hide contents


//PythonChat.h
BOOL GetChatMode(DWORD dwID);

//PythonChat.cpp
BOOL CPythonChat::GetChatMode(DWORD dwID)
{
	TChatSet * pChatSet = GetChatSetPtr(dwID);
	if (!pChatSet)
		return FALSE;

	BYTE byChatHistoryLogModes[] = {
		CHAT_TYPE_TALKING, CHAT_TYPE_INFO, CHAT_TYPE_NOTICE, CHAT_TYPE_PARTY, CHAT_TYPE_GUILD, CHAT_TYPE_SHOUT,
		#ifdef ENABLE_DICE_SYSTEM
		CHAT_TYPE_DICE_INFO
		#endif
	};

	int iRet = 0;
	for (BYTE i = 0; i < _countof(byChatHistoryLogModes); i++)
	{
		if (pChatSet->CheckMode(byChatHistoryLogModes[i]))
			iRet += 1 << byChatHistoryLogModes[i];
	}

	return iRet > 0;
}

//PythonChatModule.cpp
PyObject * chatGetChatMode(PyObject* poSelf, PyObject* poArgs)
{
	int iID;
	if (!PyTuple_GetInteger(poArgs, 0, &iID))
		return Py_BuildException();

	return Py_BuildValue("b", CPythonChat::Instance().GetChatMode(iID));
}

//Python
	def ToggleChatMode(self, mode):
		if self.allChatMode:
			self.allChatMode = False

			for i in self.CHAT_MODE_INDEX:
				chat.DisableChatMode(self.chatID, i)

			chat.EnableChatMode(self.chatID, mode)
			self.btnAll.SetUp()
		else:
			chat.ToggleChatMode(self.chatID, mode)

			if not chat.GetChatMode(self.chatID):
				self.btnAll.Down()
				self.ToggleAllChatMode()

 

 

well, since iRet is just for debug, this will be better.

 

BOOL CPythonChat::IsChatModeEnabled(DWORD dwID)
{
	TChatSet * pChatSet = GetChatSetPtr(dwID);
	if (!pChatSet)
		return FALSE;

	for (BYTE i = 0; i < CHAT_TYPE_MAX_NUM; i++)
	{
		if (pChatSet->CheckMode(i))
			return TRUE;
	}
	return FALSE;
}
isModeEnabled = chat.IsChatModeEnabled(self.chatID)
if not isModeEnabled:
	self.btnAll.Down()
	self.ToggleAllChatMode()

 

 

But anyway, it's not a big deal. everyone has its own style :P

Link to comment
Share on other sites

  • 5 months later...

Did you see that bug, when you choose a chat mode in chat history dialog and after you open the chat edit dialog (Enter) you can see first four chat messages don't show in chat list if those four chat message's modes are same with selected chat mode, but if you don't set top it (click for the chat edit dialog), it works everytime.

It is tipical bug, this bug is in orignal Metin2 too.

Can somebody to fix it?

I tryed it, but i dont know to how to fix it.

Link to comment
Share on other sites

  • 7 months later...

The biggest bug in the history of Metin2 chat interface is when you switch keyboard languages. Some clients do not even clear the textbox... But no one has fixed that so far

EDIT: I don't know why but I'm getting this error:

networkModule.SetSelectCharacterPhase - <type 'exceptions.SyntaxError'>:invalid syntax (uiChat.py, line 1059)

I've checked tabulations and code compatibility. It hits at self.btnAll.Down() which I've checked and confirmed that is valid.

Link to comment
Share on other sites

  • 4 years later...

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.