MRMJ-1: Messenger & Skills fixes
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
#include "PythonWindow.h"
|
||||
#include "PythonSlotWindow.h"
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
#include "UserInterface/PythonSkill.h"
|
||||
#include "UserInterface/PythonPlayer.h"
|
||||
#endif
|
||||
|
||||
//#define __RENDER_SLOT_AREA__
|
||||
|
||||
using namespace UI;
|
||||
@@ -204,6 +209,14 @@ void CSlotWindow::SetSlotType(DWORD dwType)
|
||||
m_dwSlotType = dwType;
|
||||
}
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
DWORD CSlotWindow::GetSlotType() const
|
||||
{
|
||||
return m_dwSlotType;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void CSlotWindow::SetSlotStyle(DWORD dwStyle)
|
||||
{
|
||||
m_dwSlotStyle = dwStyle;
|
||||
@@ -499,6 +512,7 @@ void CSlotWindow::SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount)
|
||||
void CSlotWindow::SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsedTime)
|
||||
{
|
||||
TSlot * pSlot;
|
||||
|
||||
if (!GetSlotPointer(dwIndex, &pSlot))
|
||||
return;
|
||||
|
||||
@@ -506,9 +520,94 @@ void CSlotWindow::SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsed
|
||||
pSlot->fStartCoolTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
|
||||
}
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
void CSlotWindow::StoreSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex, float fCoolTime, float fElapsedTime)
|
||||
{
|
||||
std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[dwKey].find(dwSlotIndex);
|
||||
|
||||
if (it != m_CoolDownStore[dwKey].end())
|
||||
{
|
||||
it->second.fCoolTime = fCoolTime;
|
||||
it->second.fElapsedTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
|
||||
it->second.bActive = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
SStoreCoolDown m_storeCoolDown;
|
||||
|
||||
m_storeCoolDown.fCoolTime = fCoolTime;
|
||||
m_storeCoolDown.fElapsedTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime;
|
||||
m_storeCoolDown.bActive = false;
|
||||
|
||||
m_CoolDownStore[dwKey].insert(std::map<DWORD, SStoreCoolDown>::value_type(dwSlotIndex, m_storeCoolDown));
|
||||
}
|
||||
}
|
||||
|
||||
void CSlotWindow::RestoreSlotCoolTime(DWORD dwKey)
|
||||
{
|
||||
for (std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[dwKey].begin(); it != m_CoolDownStore[dwKey].end(); it++)
|
||||
{
|
||||
TSlot* pSlot;
|
||||
|
||||
if (!GetSlotPointer(it->first, &pSlot))
|
||||
return;
|
||||
|
||||
pSlot->fCoolTime = it->second.fCoolTime;
|
||||
pSlot->fStartCoolTime = it->second.fElapsedTime;
|
||||
|
||||
if (it->second.bActive)
|
||||
ActivateSlot(it->first);
|
||||
else
|
||||
DeactivateSlot(it->first);
|
||||
}
|
||||
}
|
||||
|
||||
void CSlotWindow::TransferSlotCoolTime(DWORD dwIndex1, DWORD dwIndex2)
|
||||
{
|
||||
std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[CPythonSkill::SKILL_TYPE_ACTIVE].find(dwIndex1);
|
||||
|
||||
if (it != m_CoolDownStore[CPythonSkill::SKILL_TYPE_ACTIVE].end())
|
||||
{
|
||||
TSlot* pSlot1;
|
||||
|
||||
if (!GetSlotPointer(dwIndex1, &pSlot1))
|
||||
return;
|
||||
|
||||
TSlot* pSlot2;
|
||||
|
||||
if (!GetSlotPointer(dwIndex2, &pSlot2))
|
||||
return;
|
||||
|
||||
// Replacing the cooldown from slot 1 to slot 2 and removing the slot 1 from the map.
|
||||
SStoreCoolDown slotCooldown = it->second;
|
||||
|
||||
int iDestSkillGrade = CPythonPlayer::Instance().GetSkillGrade(dwIndex2);
|
||||
int iDestSkillLevel = CPythonPlayer::Instance().GetSkillLevel(dwIndex2);
|
||||
|
||||
m_CoolDownStore[CPythonSkill::SKILL_TYPE_ACTIVE][dwIndex2] = slotCooldown;
|
||||
m_CoolDownStore[CPythonSkill::SKILL_TYPE_ACTIVE].erase(dwIndex1);
|
||||
|
||||
// Removing the cooldown from the slot 1.
|
||||
pSlot1->fCoolTime = 0;
|
||||
pSlot1->fStartCoolTime = 0;
|
||||
|
||||
if (slotCooldown.bActive)
|
||||
ActivateSlot(dwIndex2);
|
||||
|
||||
if (iDestSkillLevel > 0)
|
||||
{
|
||||
// Setting the cooldown from slot 1 to slot 2.
|
||||
pSlot2->fCoolTime = slotCooldown.fCoolTime;
|
||||
pSlot2->fStartCoolTime = slotCooldown.fElapsedTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CSlotWindow::ActivateSlot(DWORD dwIndex)
|
||||
{
|
||||
TSlot * pSlot;
|
||||
|
||||
if (!GetSlotPointer(dwIndex, &pSlot))
|
||||
return;
|
||||
|
||||
@@ -518,20 +617,36 @@ void CSlotWindow::ActivateSlot(DWORD dwIndex)
|
||||
{
|
||||
__CreateSlotEnableEffect();
|
||||
}
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[1].find(dwIndex);
|
||||
|
||||
if (it != m_CoolDownStore[1].end())
|
||||
it->second.bActive = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSlotWindow::DeactivateSlot(DWORD dwIndex)
|
||||
{
|
||||
TSlot * pSlot;
|
||||
|
||||
if (!GetSlotPointer(dwIndex, &pSlot))
|
||||
return;
|
||||
|
||||
pSlot->bActive = FALSE;
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
std::map<DWORD, SStoreCoolDown>::iterator it = m_CoolDownStore[1].find(dwIndex);
|
||||
|
||||
if (it != m_CoolDownStore[1].end())
|
||||
it->second.bActive = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
void CSlotWindow::ClearSlot(DWORD dwIndex)
|
||||
{
|
||||
TSlot * pSlot;
|
||||
|
||||
if (!GetSlotPointer(dwIndex, &pSlot))
|
||||
return;
|
||||
|
||||
@@ -1262,6 +1377,17 @@ void CSlotWindow::ReserveDestroyCoolTimeFinishEffect(DWORD dwSlotIndex)
|
||||
m_ReserveDestroyEffectDeque.push_back(dwSlotIndex);
|
||||
}
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
void CSlotWindow::ClearStoredSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex)
|
||||
{
|
||||
std::map<DWORD, SStoreCoolDown>& store = m_CoolDownStore[dwKey];
|
||||
std::map<DWORD, SStoreCoolDown>::iterator it = store.find(dwSlotIndex);
|
||||
|
||||
if (it != store.end())
|
||||
store.erase(it);
|
||||
}
|
||||
#endif
|
||||
|
||||
DWORD CSlotWindow::Type()
|
||||
{
|
||||
static int s_Type = GetCRC32("CSlotWindow", strlen("CSlotWindow"));
|
||||
@@ -1383,6 +1509,11 @@ void CSlotWindow::__Initialize()
|
||||
m_dwSlotStyle = SLOT_STYLE_PICK_UP;
|
||||
m_dwToolTipSlotNumber = SLOT_NUMBER_NONE;
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
m_CoolDownStore.clear();
|
||||
#endif
|
||||
|
||||
|
||||
m_isUseMode = FALSE;
|
||||
m_isUsableItem = FALSE;
|
||||
|
||||
|
||||
@@ -75,6 +75,10 @@ namespace UI
|
||||
} TSlot;
|
||||
typedef std::list<TSlot> TSlotList;
|
||||
typedef TSlotList::iterator TSlotListIterator;
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
typedef struct SStoreCoolDown { float fCoolTime; float fElapsedTime; bool bActive; };
|
||||
#endif
|
||||
|
||||
|
||||
public:
|
||||
CSlotWindow(PyObject * ppyObject);
|
||||
@@ -84,6 +88,9 @@ namespace UI
|
||||
|
||||
// Manage Slot
|
||||
void SetSlotType(DWORD dwType);
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
DWORD GetSlotType() const;
|
||||
#endif
|
||||
void SetSlotStyle(DWORD dwStyle);
|
||||
|
||||
void AppendSlot(DWORD dwIndex, int ixPosition, int iyPosition, int ixCellSize, int iyCellSize);
|
||||
@@ -107,6 +114,11 @@ namespace UI
|
||||
void SetSlotCount(DWORD dwIndex, DWORD dwCount);
|
||||
void SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount);
|
||||
void SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsedTime = 0.0f);
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
void StoreSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex, float fCoolTime, float fElapsedTime = .0f);
|
||||
void RestoreSlotCoolTime(DWORD dwKey);
|
||||
void TransferSlotCoolTime(DWORD dwIndex1, DWORD dwIndex2);
|
||||
#endif
|
||||
void ActivateSlot(DWORD dwIndex);
|
||||
void DeactivateSlot(DWORD dwIndex);
|
||||
void RefreshSlot();
|
||||
@@ -150,6 +162,10 @@ namespace UI
|
||||
// CallBack
|
||||
void ReserveDestroyCoolTimeFinishEffect(DWORD dwSlotIndex);
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
void ClearStoredSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void __Initialize();
|
||||
void __CreateToggleSlotImage();
|
||||
@@ -199,6 +215,9 @@ namespace UI
|
||||
std::list<DWORD> m_dwSelectedSlotIndexList;
|
||||
TSlotList m_SlotList;
|
||||
DWORD m_dwToolTipSlotNumber;
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
std::map<DWORD, std::map<DWORD, SStoreCoolDown>> m_CoolDownStore;
|
||||
#endif
|
||||
|
||||
BOOL m_isUseMode;
|
||||
BOOL m_isUsableItem;
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace UI
|
||||
bool HasParent() { return m_pParent ? true : false; }
|
||||
bool HasChild() { return m_pChildList.empty() ? false : true; }
|
||||
int GetChildCount() { return m_pChildList.size(); }
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
const TWindowContainer& GetChildList() const { return m_pChildList; }
|
||||
#endif
|
||||
|
||||
CWindow * GetRoot();
|
||||
CWindow * GetParent();
|
||||
|
||||
@@ -652,6 +652,39 @@ namespace UI
|
||||
m_pRightCaptureWindow = NULL;
|
||||
}
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
void CWindowManager::ClearStoredSlotCoolTimeInAllSlotWindows(DWORD dwKey, DWORD dwSlotIndex)
|
||||
{
|
||||
// recursively walk the window tree starting from layers and clear stored cooldown entries
|
||||
std::function<void(CWindow*)> recurse;
|
||||
|
||||
recurse = [&](CWindow* pWin)
|
||||
{
|
||||
if (!pWin)
|
||||
return;
|
||||
|
||||
// If this is a slot window, call its helper
|
||||
if (pWin->IsType(UI::CSlotWindow::Type()))
|
||||
{
|
||||
UI::CSlotWindow * pSlotWin = static_cast<UI::CSlotWindow*>(pWin);
|
||||
pSlotWin->ClearStoredSlotCoolTime(dwKey, dwSlotIndex);
|
||||
}
|
||||
|
||||
// Visit children
|
||||
for (CWindow* pChild : pWin->GetChildList())
|
||||
{
|
||||
recurse(pChild);
|
||||
}
|
||||
};
|
||||
|
||||
// Walk all layer roots
|
||||
for (CWindow* pLayer : m_LayerWindowList)
|
||||
{
|
||||
recurse(pLayer);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CWindowManager::SetResolution(int hres, int vres)
|
||||
{
|
||||
if (hres<=0 || vres<=0)
|
||||
|
||||
@@ -106,6 +106,10 @@ namespace UI
|
||||
void SetTop(CWindow * pWin);
|
||||
void SetTopUIWindow();
|
||||
void ResetCapture();
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
void ClearStoredSlotCoolTimeInAllSlotWindows(DWORD dwKey, DWORD dwSlotIndex);
|
||||
#endif
|
||||
|
||||
|
||||
void Update();
|
||||
void Render();
|
||||
|
||||
@@ -1254,6 +1254,80 @@ PyObject * wndMgrSetSlotCoolTime(PyObject * poSelf, PyObject * poArgs)
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
PyObject* wndMgrStoreSlotCoolTime(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
UI::CWindow* pWin;
|
||||
if (!PyTuple_GetWindow(poArgs, 0, &pWin))
|
||||
return Py_BuildException();
|
||||
|
||||
int iKey;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iKey))
|
||||
return Py_BuildException();
|
||||
|
||||
int iSlotIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 2, &iSlotIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
float fCoolTime;
|
||||
if (!PyTuple_GetFloat(poArgs, 3, &fCoolTime))
|
||||
return Py_BuildException();
|
||||
|
||||
float fElapsedTime = 0.0f;
|
||||
PyTuple_GetFloat(poArgs, 4, &fElapsedTime);
|
||||
|
||||
if (!pWin->IsType(UI::CSlotWindow::Type()))
|
||||
return Py_BuildException();
|
||||
|
||||
UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;
|
||||
pSlotWin->StoreSlotCoolTime(iKey, iSlotIndex, fCoolTime, fElapsedTime);
|
||||
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject* wndMgrRestoreSlotCoolTime(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
UI::CWindow* pWin;
|
||||
if (!PyTuple_GetWindow(poArgs, 0, &pWin))
|
||||
return Py_BuildException();
|
||||
|
||||
int iKey;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iKey))
|
||||
return Py_BuildException();
|
||||
|
||||
if (!pWin->IsType(UI::CSlotWindow::Type()))
|
||||
return Py_BuildException();
|
||||
|
||||
UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;
|
||||
pSlotWin->RestoreSlotCoolTime(iKey);
|
||||
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject* wndMgrTransferSlotCoolTime(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
UI::CWindow* pWin;
|
||||
if (!PyTuple_GetWindow(poArgs, 0, &pWin))
|
||||
return Py_BuildException();
|
||||
|
||||
int iIndex1;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iIndex1))
|
||||
return Py_BuildException();
|
||||
|
||||
int iIndex2;
|
||||
if (!PyTuple_GetInteger(poArgs, 2, &iIndex2))
|
||||
return Py_BuildException();
|
||||
|
||||
if (!pWin->IsType(UI::CSlotWindow::Type()))
|
||||
return Py_BuildException();
|
||||
|
||||
UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;
|
||||
pSlotWin->TransferSlotCoolTime(iIndex1, iIndex2);
|
||||
|
||||
return Py_BuildNone();
|
||||
}
|
||||
#endif
|
||||
|
||||
PyObject * wndMgrSetToggleSlot(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
assert(!"wndMgrSetToggleSlot");
|
||||
@@ -2423,6 +2497,11 @@ void initwndMgr()
|
||||
{ "SetSlotCount", wndMgrSetSlotCount, METH_VARARGS },
|
||||
{ "SetSlotCountNew", wndMgrSetSlotCountNew, METH_VARARGS },
|
||||
{ "SetSlotCoolTime", wndMgrSetSlotCoolTime, METH_VARARGS },
|
||||
#ifdef FIX_REFRESH_SKILL_COOLDOWN
|
||||
{ "StoreSlotCoolTime", wndMgrStoreSlotCoolTime, METH_VARARGS },
|
||||
{ "RestoreSlotCoolTime", wndMgrRestoreSlotCoolTime, METH_VARARGS },
|
||||
{ "TransferSlotCoolTime", wndMgrTransferSlotCoolTime, METH_VARARGS },
|
||||
#endif
|
||||
{ "SetToggleSlot", wndMgrSetToggleSlot, METH_VARARGS },
|
||||
{ "ActivateSlot", wndMgrActivateSlot, METH_VARARGS },
|
||||
{ "DeactivateSlot", wndMgrDeactivateSlot, METH_VARARGS },
|
||||
|
||||
Reference in New Issue
Block a user