Jump to content

Small: handle updates when more slots are in the same position


Recommended Posts

  • Former Staff

Have you ever got in the situation that you had 2 or more slots in the same position? If so, you have noticed that the client always jumps to the first slot even if you want the slot deactivated.

This little change was created to handle this particular situation.

 

The root cause comes from the function GetPickedSlotPointer, which iterates all the slots appended to the slotwindow and doesn't know if a slot should be used or not.

 

root/ui.py:

# Add before def SetSkillSlot(self, renderingSlotNumber, skillIndex, skillLevel) this lines:
	if app.SLOT_WINDOW_PICKABLE:
		def SetPickableSlot(self, slotIndex, value):
			wndMgr.SetPickableSlot(self.hWnd, slotIndex, value)
		def SetUnpickableSlotAll(self):
			wndMgr.SetUnpickableSlotAll(self.hWnd)
			

 

EterBase/ServiceDefs.h:

#define SLOT_WINDOW_PICKABLE

 

EterPythonLib/PythonSlotWindow.cpp

// Add after this:
	ClearSlot(&Slot);
	Slot.dwSlotNumber = dwIndex;
	Slot.dwCenterSlotNumber = dwIndex;
	Slot.ixPosition = ixPosition;
	Slot.iyPosition = iyPosition;
	Slot.ixCellSize = ixCellSize;
	Slot.iyCellSize = iyCellSize;
// this:
#ifdef SLOT_WINDOW_PICKABLE
	Slot.bPickable = TRUE;
#endif
  
// ---------------------------------------------------
  
// Add after this:
  	pSlot->isItem = FALSE;
	pSlot->dwState = 0;
	pSlot->fCoolTime = 0.0f;
	pSlot->fStartCoolTime = 0.0f;
	pSlot->dwCenterSlotNumber = 0xffffffff;
// this:
#ifdef SLOT_WINDOW_PICKABLE
	pSlot->bPickable = TRUE;
#endif
 
// ---------------------------------------------------

// Add after this:
  		if (iyLocal >= rSlot.iyPosition)
		if (ixLocal <= rSlot.ixPosition + ixCellSize)
		if (iyLocal <= rSlot.iyPosition + iyCellSize)
// this:
#ifdef SLOT_WINDOW_PICKABLE
		if (rSlot.bPickable)
#endif
  
// ---------------------------------------------------

// Add this at the end of the file:
#ifdef SLOT_WINDOW_PICKABLE
void CSlotWindow::SetPickableSlot(DWORD dwSlotNumber, BOOL bFlag)
{
	TSlot* pSlot;
	if (!GetSlotPointer(dwSlotNumber, &pSlot))
		return;

	pSlot->bPickable = bFlag;
}

void CSlotWindow::SetUnpickableSlotAll()
{
	for (TSlotListIterator itor = m_SlotList.begin(); itor != m_SlotList.end(); ++itor)
	{
		TSlot& rSlot = *itor;
		rSlot.bPickable = FALSE;
	}
}

BOOL CSlotWindow::IsPickableSlot(DWORD dwSlotNumber)
{
	TSlot* pSlot;
	if (!GetSlotPointer(dwSlotNumber, &pSlot))
		return FALSE;

	return pSlot->bPickable;
}
#endif

EterPythonLib/PythonSlotWindow.h

// Add after this:
CAniImageBox * pFinishCoolTimeEffect;
// this:
#ifdef SLOT_WINDOW_PICKABLE
				BOOL bPickable;
#endif

// --------------------------------------------------------------------------------------------

// Add after this:
			// For Usable Item
			void SetUseMode(BOOL bFlag);
			void SetUsableItem(BOOL bFlag);

// this:
#ifdef SLOT_WINDOW_PICKABLE
			void SetPickableSlot(DWORD dwSlotNumber, BOOL bFlag);
			void SetUnpickableSlotAll();
			BOOL IsPickableSlot(DWORD dwSlotNumber);
#endif

 

EterPythonLib/PythonWindowManagerModule.cpp

// Add before this:
PyObject * wndMgrShowRequirementSign(PyObject * poSelf, PyObject * poArgs)
// this:
#ifdef SLOT_WINDOW_PICKABLE
PyObject* wndMgrSetPickableSlot(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	int iSlotNumber;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotNumber))
		return Py_BuildException();

	BOOL bFlag;
	if (!PyTuple_GetInteger(poArgs, 2, &bFlag))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWindow;
	pSlotWin->SetPickableSlot(iSlotNumber, bFlag);

	return Py_BuildNone();
}

PyObject* wndMgrSetUnpickableSlotAll(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWindow;
	pSlotWin->SetUnpickableSlotAll();

	return Py_BuildNone();
}
#endif

// -------------------------------------------------------------------------------------------------------

// Add after this:
{ "SetPath",						wndNumberSetPath,							METH_VARARGS },
// this:
		{ "SetPickableSlot", 				wndMgrSetPickableSlot, 						METH_VARARGS },
		{ "SetUnpickableSlotAll", 			wndMgrSetUnpickableSlotAll, 				METH_VARARGS },

 

UserInterface/PythonApplicationModule.cpp

// Add after this:
#ifdef ENABLE_COSTUME_SYSTEM
	PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM",	1);
#else
	PyModule_AddIntConstant(poModule, "ENABLE_COSTUME_SYSTEM",	0);
#endif
// this:
#ifdef SLOT_WINDOW_PICKABLE
	PyModule_AddIntConstant(poModule, "SLOT_WINDOW_PICKABLE", 1);
#else
	PyModule_AddIntConstant(poModule, "SLOT_WINDOW_PICKABLE", 1);
#endif

 

 

How to use it?

On a SlotWindow class you can use slotWindow.SetPickableSlot(slotNumber, TRUE/FALSE), when it's true the slot can be pickable, otherwise it won't.

slotWindow.SetUnpickableSlotAll() sets all the slots in the slotwindow to become unpickable.

The default state of a slot is always pickable, please note that clearing the slot (slotWindow.ClearSlot(slotNumber)) will reset the pickable status.

 

Good luck!

  • Good 1
  • Love 4

Everyday you wake up as a Metin2 developer is a bad day...

METIN1 src when

Link to comment
Share on other sites

  • Former Staff
21 minutes ago, xP3NG3Rx said:

I'm trying to picture what is this all about, but I never faced with this problem or I don't remember. 🤔

It's one of those ultra specific changes that you only need when you need to have 3 slots on the same position and it's easier to make a quick patch than fixing the reason you why can't use one slot, which has the 0.00000000000000000000001% chance of happening but I decided to release it anyway perhaps someone can find a reason to use it😂

Edited by arves100

Everyday you wake up as a Metin2 developer is a bad day...

METIN1 src when

Link to comment
Share on other sites

  • Former Staff
2 minutes ago, xP3NG3Rx said:

When can it happen? And how can be 2 or more slots at the same position? I don't get it.

I thought the same then someone asked to keep all the skills in one slots (remove the three skill thing) and rather than changing all the crap relative to that I decided to keep the three slots in the same position (kinda lazy but it was the quickiest fix I could think of)

Edited by arves100

Everyday you wake up as a Metin2 developer is a bad day...

METIN1 src when

Link to comment
Share on other sites

  • Premium
1 hour ago, xP3NG3Rx said:

When can it happen? And how can be 2 or more slots at the same position? I don't get it.

What Mr Arves is trying to say is: if you overlap 3 skills in the same positions (m1,G and P) and you have G and P deactivated they still have a conflict. Like showing tooltips wrong and the active effect if the skill has toggle.

Link to comment
Share on other sites

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.