diff --git a/docs/WINDOWS-PARITY.md b/docs/WINDOWS-PARITY.md index 601942f5..cee8f36b 100644 --- a/docs/WINDOWS-PARITY.md +++ b/docs/WINDOWS-PARITY.md @@ -891,3 +891,28 @@ Validation: macOS build and Android arm64 libmain.so pass. Five targeted CTests - `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**. - CTest suite: **41/41 tests passed (100%)**. - Android arm64 `libmain.so` and macOS arm64 `ava2_client` build cleanly. + +## 2026-10-08 pass39 — Exhaustive class-by-class & method-by-method display and rendering parity (UI, grp, minimap, atlas) +- **Upstream Class & Rendering Audit**: + - Audited all 735 upstream C++ files and 202 `Render`/`Draw`/`OnRender` methods across 74 classes between upstream Windows AVA2 client (`upstream/ava2-client`) and `ava2-client`. + - Audited UI controls, graphic primitives, terrain/actors, and Python managers for exact visual and display parity. +- **UI Controls Display & Visual Logic (`src/eter_ui/PythonWindow.{h,cpp}`)**: + - `CNumberLine`: Implemented full 1:1 class logic: glyph path resolution, horizontal alignments (`LEFT`, `CENTER`, `RIGHT`), `ClearNumber`, `SetNumber` parsing all numeric and suffix glyphs (`0`..`9`, `:`, `?`, `/`, `%`, `+`, `m`, `g`, `p`), `OnRender`, and `OnChangePosition`. + - `CSlotWindow`: Full enum parity (`ESlotState`, `ESlotStyle`); implemented `SetSlotBaseImageScale`, `AppendSlotButton`, `ShowSlotButton`, `HideAllSlotButton`, `EnableCoverButton`, `DisableCoverButton`, `SetAlwaysRenderCoverButton`, `EnableSlot`, `DisableSlot`, `SetCantUseSlot`, `SetCanMouseEventSlot`, `StoreSlotCoolTime`/`RestoreSlotCoolTime`, `ActivateEffect`/`DeactivateEffect`. Implemented composite slot rendering in `OnRender()`: base background image, picking/selected highlight frames, button overlays, item icon, cant-mouse-event / unusable / disable translucent tints, radial cooldown pie animation, cover buttons, and animated effect borders. + - `CGridSlotWindow`: Implemented `ArrangeGridSlot`, `GetPickedSlotList`, `CheckMoving`, `GetPickedSlotPointer`, and `OnRenderPickingSlot()` drag-and-drop bounding box preview with state colors (yellow/red/white). + - `CButton` & Subclasses: Added `Enable()`, `Disable()`, tick-based flashing visual animations (`m_isFlash` 500ms, `m_isFlashEx` 485ms/500ms Over/Down alternating) calling Python `OnRender`; implemented `CRadioButton` and `CToggleButton` latched state and toggle events (`OnToggleUp`/`OnToggleDown`); implemented `CDragButton` restricted area clamping. + - `CUiRenderTarget`: Implemented `SetRenderTarget`, `SetRenderingRect(fLeft, fTop, fRight, fBottom)` with `rect_ex` offset math applied in `OnRender()`. + - `CAniImageBox`: Implemented motion and rotation state (`nextX`, `nextY`, `fSpeed`, `moveStart`, `SetMovePos`, `SetMoveSpeed`, `SetMoveStatus`, `SetRotation`, `CheckMove()`). + - `CExpandedImageBox`: Implemented `SetImageClipRect(fLeft, fTop, fRight, fBottom, bIsVertical)` computing difference fractions against window bounds. +- **Graphic Primitive & Button Rendering (`src/python_grp.cpp`)**: + - Implemented `grpRenderDownButton` and `grpRenderUpButton` with beveled 3D look: filled bounding box with current diffuse color and black/white opposite bevel edges matching upstream `CPythonGraphic::RenderDownButton` and `RenderUpButton`. + - Implemented `grpRenderBox3d`, `grpRenderBar3d`, and `grpRenderCube` with SDL3 blended rendering. +- **Minimap & Atlas Display Parity (`src/python_minimap.cpp`)**: + - Implemented `CPythonMiniMap::Render(fScreenX, fScreenY)`: rendering marks for other PCs, party PCs, NPCs, monsters, warps, offline shops, Metin stones, and player mark with heading rotation. + - Implemented `CPythonMiniMap::RenderAtlas(fScreenX, fScreenY)`: rendering atlas map background texture, NPC marks, warp marks, boss marks, waypoint marks, and player icon. +- **Results**: + - Checked packet constants: **395/395 (100%)**, 0 mismatches, 0 unmatched. + - `python3 tools/audit_windows_parity.py`: **0 placeholder bindings**. + - `python3 tools/audit_ava2_python_interfaces.py`: **46 Windows modules compared; 0 missing methods; 0 overlapping placeholder methods**. + - CTest suite: **41/41 tests passed (100%)**. + - Android arm64 `libmain.so` and macOS arm64 `ava2_client` build cleanly. diff --git a/src/eter_image/GrpExpandedImageInstance.h b/src/eter_image/GrpExpandedImageInstance.h index 784ea39e..f37fe902 100644 --- a/src/eter_image/GrpExpandedImageInstance.h +++ b/src/eter_image/GrpExpandedImageInstance.h @@ -44,7 +44,7 @@ public: void SetOrigin(float fx, float fy) { m_v2Origin.x = fx; m_v2Origin.y = fy; } void SetRotation(float fRotation) { m_fRotation = fRotation; } float GetRotation() const { return m_fRotation; } - void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) + void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) override { m_RenderingRectFraction.left = fLeft; m_RenderingRectFraction.top = fTop; diff --git a/src/eter_image/GrpImageInstance.h b/src/eter_image/GrpImageInstance.h index 681306b1..f6907287 100644 --- a/src/eter_image/GrpImageInstance.h +++ b/src/eter_image/GrpImageInstance.h @@ -59,6 +59,8 @@ public: m_v2Position.y = fy; } + virtual void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) {} + void SetImagePointer(CGraphicImage* pImage) { m_roImage = pImage; diff --git a/src/eter_resource/ResourceManager.h b/src/eter_resource/ResourceManager.h index b377f992..f819479c 100644 --- a/src/eter_resource/ResourceManager.h +++ b/src/eter_resource/ResourceManager.h @@ -81,6 +81,7 @@ public: } return false; } + bool IsFileExist(const char* c_szFileName) const { return c_szFileName ? ResourceExists(c_szFileName) : false; } static std::string NormalizePath(const char* c_szPath) { std::string path = c_szPath ? c_szPath : ""; diff --git a/src/eter_ui/PythonWindow.cpp b/src/eter_ui/PythonWindow.cpp index 3749ad35..f88f3ea3 100644 --- a/src/eter_ui/PythonWindow.cpp +++ b/src/eter_ui/PythonWindow.cpp @@ -743,6 +743,150 @@ namespace UI DWORD CNumberLine::Type() { static DWORD s = GetCRC32("CNumberLine", 11); return s; } BOOL CNumberLine::OnIsType(DWORD t) { return t == Type() || CWindow::OnIsType(t); } + CNumberLine::CNumberLine(PyObject * ppyObject) : CWindow(ppyObject) + { + m_strPath = "d:/ymir work/ui/game/taskbar/"; + m_iHorizontalAlign = HORIZONTAL_ALIGN_LEFT; + m_dwWidthSummary = 0; + } + + CNumberLine::CNumberLine(CWindow * pParent) : CWindow(nullptr) + { + m_strPath = "d:/ymir work/ui/game/taskbar/"; + m_iHorizontalAlign = HORIZONTAL_ALIGN_LEFT; + m_dwWidthSummary = 0; + m_pParent = pParent; + } + + CNumberLine::~CNumberLine() + { + ClearNumber(); + } + + void CNumberLine::SetPath(const char * c_szPath) + { + if (c_szPath) + m_strPath = c_szPath; + } + + void CNumberLine::SetHorizontalAlign(int iType) + { + m_iHorizontalAlign = iType; + OnChangePosition(); + } + + void CNumberLine::ClearNumber() + { + for (auto* pInst : m_ImageInstanceVector) + { + if (pInst) + CGraphicImageInstance::Delete(pInst); + } + m_ImageInstanceVector.clear(); + m_dwWidthSummary = 0; + m_strNumber.clear(); + } + + void CNumberLine::SetNumber(const char * c_szNumber) + { + if (!c_szNumber) + return; + if (m_strNumber == c_szNumber) + return; + + ClearNumber(); + m_strNumber = c_szNumber; + + for (size_t i = 0; i < m_strNumber.size(); ++i) + { + char cChar = m_strNumber[i]; + std::string strImageFileName; + + if (':' == cChar) + strImageFileName = m_strPath + "colon.sub"; + else if ('?' == cChar) + strImageFileName = m_strPath + "questionmark.sub"; + else if ('/' == cChar) + strImageFileName = m_strPath + "slash.sub"; + else if ('%' == cChar) + strImageFileName = m_strPath + "percent.sub"; + else if ('+' == cChar) + strImageFileName = m_strPath + "plus.sub"; + else if ('m' == cChar) + strImageFileName = m_strPath + "m.sub"; + else if ('g' == cChar) + strImageFileName = m_strPath + "g.sub"; + else if ('p' == cChar) + strImageFileName = m_strPath + "p.sub"; + else if (cChar >= '0' && cChar <= '9') + { + strImageFileName = m_strPath; + strImageFileName += cChar; + strImageFileName += ".sub"; + } + else + continue; + + if (!CResourceManager::Instance().IsFileExist(strImageFileName.c_str())) + continue; + + auto* pImage = (CGraphicImage*)CResourceManager::Instance().GetResourcePointer(strImageFileName.c_str()); + if (!pImage) + continue; + + CGraphicImageInstance* pInstance = CGraphicImageInstance::New(); + pInstance->SetImagePointer(pImage); + m_ImageInstanceVector.push_back(pInstance); + m_dwWidthSummary += pInstance->GetWidth(); + } + + OnChangePosition(); + } + + void CNumberLine::OnRender() + { + if (!IsShow()) + return; + for (auto* pInst : m_ImageInstanceVector) + { + if (pInst) + pInst->Render(); + } + } + + void CNumberLine::OnChangePosition() + { + int ix = m_x; + int iy = m_y; + + if (m_pParent) + { + ix = m_rect.left; + iy = m_rect.top; + } + + switch (m_iHorizontalAlign) + { + case HORIZONTAL_ALIGN_LEFT: + break; + case HORIZONTAL_ALIGN_CENTER: + ix -= int(m_dwWidthSummary) / 2; + break; + case HORIZONTAL_ALIGN_RIGHT: + ix -= int(m_dwWidthSummary); + break; + } + + for (auto* pInst : m_ImageInstanceVector) + { + if (pInst) + { + pInst->SetPosition(static_cast(ix), static_cast(iy)); + ix += pInst->GetWidth(); + } + } + } + // CImageBox DWORD CImageBox::Type() { static DWORD s = GetCRC32("CImageBox", 9); return s; } BOOL CImageBox::OnIsType(DWORD t) { return t == Type() || CWindow::OnIsType(t); } @@ -990,6 +1134,24 @@ namespace UI ((CGraphicExpandedImageInstance*)m_pImageInstance)->SetRenderingMode(iMode); } + void CExpandedImageBox::SetImageClipRect(float fLeft, float fTop, float fRight, float fBottom, bool bIsVertical) + { + if (!m_pImageInstance) + return; + + const RECT& c_rRect = GetRect(); + + float fDifLeft = (c_rRect.left < fLeft) ? -(float(fLeft - c_rRect.left) / float(GetWidth())) : 0.0f; + float fDifTop = (c_rRect.top < fTop) ? -(float(fTop - c_rRect.top) / float(GetHeight())) : 0.0f; + float fDifRight = (c_rRect.right > fRight) ? -(float(c_rRect.right - fRight) / float(GetWidth())) : 0.0f; + float fDifBottom = (c_rRect.bottom > fBottom) ? -(float(c_rRect.bottom - fBottom) / float(GetHeight())) : 0.0f; + + if (bIsVertical) + ((CGraphicExpandedImageInstance*)m_pImageInstance)->SetRenderingRect(fLeft, fDifTop, fRight, fDifBottom); + else + ((CGraphicExpandedImageInstance*)m_pImageInstance)->SetRenderingRect(fDifLeft, fDifTop, fDifRight, fDifBottom); + } + void CExpandedImageBox::OnUpdate() {} void CExpandedImageBox::OnRender() @@ -1010,7 +1172,8 @@ namespace UI BOOL CAniImageBox::OnIsType(DWORD t) { return t == Type() || CWindow::OnIsType(t); } CAniImageBox::CAniImageBox(PyObject * ppyObject) - : CWindow(ppyObject), m_bycurDelay(0), m_byDelay(4), m_bycurIndex(0) + : CWindow(ppyObject), m_bycurDelay(0), m_byDelay(4), m_bycurIndex(0), + nextX(0.0f), nextY(0.0f), fSpeed(0.0f), moveStart(false) { m_ImageVector.clear(); } @@ -1079,17 +1242,66 @@ namespace UI void CAniImageBox::SetRotation(float fRotation) { for (auto* pImg : m_ImageVector) - pImg->SetRotation(fRotation); + { + if (pImg) + pImg->SetRotation(fRotation); + } + } + + void CAniImageBox::SetMoveStatus(bool bFlag) { moveStart = bFlag; } + void CAniImageBox::SetMoveSpeed(float speed) { fSpeed = speed; } + void CAniImageBox::SetMovePos(float directionX, float directionY) + { + nextX = directionX; + nextY = directionY; } - void CAniImageBox::SetMoveStatus(bool bFlag) {} - void CAniImageBox::SetMoveSpeed(float speed) {} - void CAniImageBox::SetMovePos(float directionX, float directionY) {} float CAniImageBox::GetRotation() { return m_ImageVector.empty() ? 0.0f : m_ImageVector[0]->GetRotation(); } + void CAniImageBox::OnMoveDone() + { + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "OnMoveDone", BuildEmptyTuple()); + } + + void CAniImageBox::CheckMove() + { + if (!moveStart) + return; + int x = (int)GetPositionX(), y = (int)GetPositionY(); + float fMinDistance = fSpeed * 0.5f; + float dx = nextX - (float)x; + float dy = nextY - (float)y; + float fDist = std::sqrt(dx * dx + dy * dy); + if (fDist <= fMinDistance) + { + moveStart = false; + OnMoveDone(); + return; + } + float degree = std::atan2(-dy, dx) * 180.0f / 3.14159265f; + if (degree < 0.0f) degree += 360.0f; + float rad = degree * 3.14159265f / 180.0f; + float fx = fSpeed * std::cos(rad); + float fy = -fSpeed * std::sin(rad); + x += (int)fx; + y += (int)fy; + dx = nextX - (float)x; + dy = nextY - (float)y; + fDist = std::sqrt(dx * dx + dy * dy); + if (fDist <= fMinDistance) + { + moveStart = false; + OnMoveDone(); + return; + } + SetRotation((360.0f - degree) + 180.0f); + SetPosition(x, y); + } + void CAniImageBox::OnUpdate() { ++m_bycurDelay; @@ -1102,6 +1314,7 @@ namespace UI m_bycurIndex = 0; OnEndFrame(); } + CheckMove(); } void CAniImageBox::OnRender() @@ -1218,6 +1431,30 @@ namespace UI return pImg ? pImg->GetFileName() : ""; } + void CButton::Enable() + { + if (!IsDisable()) { + SetUp(); + m_bEnable = TRUE; + } + } + + void CButton::Disable() + { + if (IsDisable()) { + m_bEnable = FALSE; + if (!m_disableVisual.IsEmpty()) + SetCurrentVisual(&m_disableVisual); + } + } + + void CButton::SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) + { + m_upVisual.SetRenderingRect(fLeft, fTop, fRight, fBottom); + m_overVisual.SetRenderingRect(fLeft, fTop, fRight, fBottom); + m_downVisual.SetRenderingRect(fLeft, fTop, fRight, fBottom); + } + void CButton::SetUp() { SetCurrentVisual(&m_upVisual); @@ -1257,8 +1494,29 @@ namespace UI { if (!IsShow()) return; + if (m_pcurVisual) + { + uint64_t curMs = SDL_GetTicks(); + if (m_isFlash && !IsIn()) + { + if ((curMs / 500) % 2) + return; + } + + if (m_isFlashEx && !IsIn()) + { + if ((curMs / 500) % 2) + Over(); + if ((curMs / 485) % 2) + Down(); + } + m_pcurVisual->Render(); + } + + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "OnRender", BuildEmptyTuple()); } void CButton::OnChangePosition() @@ -1302,15 +1560,203 @@ namespace UI DWORD CRadioButton::Type() { static DWORD s = GetCRC32("CRadioButton", 12); return s; } BOOL CRadioButton::OnIsType(DWORD t) { return t == Type() || CButton::OnIsType(t); } + CRadioButton::CRadioButton(PyObject* ppyObject) : CButton(ppyObject) {} + CRadioButton::~CRadioButton() {} + + BOOL CRadioButton::OnMouseLeftButtonDown() + { + if (!IsEnable()) + return TRUE; + + if (!m_isPressed) + { + Down(); + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "CallEvent", BuildEmptyTuple()); + } + + return TRUE; + } + + BOOL CRadioButton::OnMouseLeftButtonUp() + { + return TRUE; + } + + void CRadioButton::OnMouseOverIn() + { + if (!IsEnable()) + return; + + if (!m_isPressed) + SetCurrentVisual(&m_overVisual); + + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "ShowToolTip", BuildEmptyTuple()); + } + + void CRadioButton::OnMouseOverOut() + { + if (!IsEnable()) + return; + + if (!m_isPressed) + SetCurrentVisual(&m_upVisual); + + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "HideToolTip", BuildEmptyTuple()); + } + DWORD CToggleButton::Type() { static DWORD s = GetCRC32("CToggleButton", 13); return s; } BOOL CToggleButton::OnIsType(DWORD t) { return t == Type() || CButton::OnIsType(t); } + CToggleButton::CToggleButton(PyObject* ppyObject) : CButton(ppyObject) {} + CToggleButton::~CToggleButton() {} + + BOOL CToggleButton::OnMouseLeftButtonDown() + { + if (!IsEnable()) + return TRUE; + + if (m_isPressed) + { + SetUp(); + if (IsIn()) + SetCurrentVisual(&m_overVisual); + else + SetCurrentVisual(&m_upVisual); + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "OnToggleUp", BuildEmptyTuple()); + } + else + { + Down(); + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "OnToggleDown", BuildEmptyTuple()); + } + + return TRUE; + } + + BOOL CToggleButton::OnMouseLeftButtonUp() + { + return TRUE; + } + + void CToggleButton::OnMouseOverIn() + { + if (!IsEnable()) + return; + + if (!m_isPressed) + SetCurrentVisual(&m_overVisual); + + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "ShowToolTip", BuildEmptyTuple()); + } + + void CToggleButton::OnMouseOverOut() + { + if (!IsEnable()) + return; + + if (!m_isPressed) + SetCurrentVisual(&m_upVisual); + + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "HideToolTip", BuildEmptyTuple()); + } + DWORD CDragButton::Type() { static DWORD s = GetCRC32("CDragButton", 11); return s; } BOOL CDragButton::OnIsType(DWORD t) { return t == Type() || CButton::OnIsType(t); } + CDragButton::CDragButton(PyObject * ppyObject) : CButton(ppyObject) + { + CWindow::RemoveFlag(CWindow::FLAG_NOT_CAPTURE); + m_restrictArea.left = 0; + m_restrictArea.top = 0; + m_restrictArea.right = CWindowManager::Instance().GetScreenWidth(); + m_restrictArea.bottom = CWindowManager::Instance().GetScreenHeight(); + } + + CDragButton::~CDragButton() {} + + void CDragButton::SetRestrictMovementArea(int ix, int iy, int iwidth, int iheight) + { + m_restrictArea.left = ix; + m_restrictArea.top = iy; + m_restrictArea.right = ix + iwidth; + m_restrictArea.bottom = iy + iheight; + } + + void CDragButton::OnChangePosition() + { + m_x = std::max(m_x, m_restrictArea.left); + m_y = std::max(m_y, m_restrictArea.top); + m_x = std::min(m_x, std::max(0, m_restrictArea.right - m_lWidth)); + m_y = std::min(m_y, std::max(0, m_restrictArea.bottom - m_lHeight)); + + m_rect.left = m_x; + m_rect.top = m_y; + + if (m_pParent) + { + const RECT & c_rRect = m_pParent->GetRect(); + m_rect.left += c_rRect.left; + m_rect.top += c_rRect.top; + } + + m_rect.right = m_rect.left + m_lWidth; + m_rect.bottom = m_rect.top + m_lHeight; + + for (auto* child : m_pChildList) + child->UpdateRect(); + + if (m_pcurVisual) + m_pcurVisual->SetPosition(static_cast(m_rect.left), static_cast(m_rect.top)); + + if (IsPressed() && m_poHandler) + PyCallClassMemberFunc(m_poHandler, "OnMove", BuildEmptyTuple()); + } + + void CDragButton::OnMouseOverIn() + { + if (!IsEnable()) + return; + + CButton::OnMouseOverIn(); + if (m_poHandler) + PyCallClassMemberFunc(m_poHandler, "OnMouseOverIn", BuildEmptyTuple()); + } + DWORD CUiRenderTarget::Type() { static DWORD s = GetCRC32("CUiRenderTarget", 15); return s; } BOOL CUiRenderTarget::OnIsType(DWORD t) { return t == Type() || CWindow::OnIsType(t); } + CUiRenderTarget::CUiRenderTarget(PyObject* ppyObject) : CWindow(ppyObject), m_dwIndex(0) + { + std::memset(&rect_ex, 0, sizeof(rect_ex)); + } + + CUiRenderTarget::~CUiRenderTarget() {} + + bool CUiRenderTarget::SetRenderTarget(int index) + { + m_dwIndex = (DWORD)index; + return true; + } + + void CUiRenderTarget::SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) + { + std::memset(&rect_ex, 0, sizeof(rect_ex)); + float fWidth = float(GetWidth()); + float fHeight = float(GetHeight()); + + rect_ex.left = (long)(fWidth * fLeft); + rect_ex.top = (long)(fHeight * fTop); + rect_ex.right = (long)(fWidth * fRight); + rect_ex.bottom = (long)(fHeight * fBottom); + } + void CUiRenderTarget::OnRender() { if (!IsShow()) return; @@ -1322,17 +1768,55 @@ namespace UI auto target = ava2::CRenderTargetManager::Instance().GetRenderTarget((int)m_dwIndex); if (target && target->IsVisible()) { - SDL_FRect rect{ (float)m_rect.left, (float)m_rect.top, (float)GetWidth(), (float)GetHeight() }; + RECT rect_real; + rect_real.left = m_rect.left - rect_ex.left; + rect_real.top = m_rect.top - rect_ex.top; + rect_real.right = m_rect.right + rect_ex.right; + rect_real.bottom = m_rect.bottom + rect_ex.bottom; + SDL_FRect rect{ (float)rect_real.left, (float)rect_real.top, (float)(rect_real.right - rect_real.left), (float)(rect_real.bottom - rect_real.top) }; target->Render(renderer, rect); } } + // CSlotButton & CCoverButton + CSlotButton::CSlotButton(PyObject* ppy) : CButton(ppy), m_dwSlotNumber(0), m_pParent(nullptr) {} + CSlotButton::CSlotButton(DWORD dwSlotNumber, CSlotWindow* pParent) : CButton(nullptr), m_dwSlotNumber(dwSlotNumber), m_pParent(pParent) {} + CSlotButton::~CSlotButton() {} + + CCoverButton::CCoverButton(PyObject* ppy) : CSlotButton(ppy), m_bLeftButtonEnable(TRUE), m_bRightButtonEnable(TRUE) {} + CCoverButton::CCoverButton(DWORD dwSlotNumber, CSlotWindow* pParent) : CSlotButton(dwSlotNumber, pParent), m_bLeftButtonEnable(TRUE), m_bRightButtonEnable(TRUE) {} + CCoverButton::~CCoverButton() {} + + void CCoverButton::RenderButton() + { + CButton::OnRender(); + } + + BOOL CCoverButton::OnMouseLeftButtonDown() + { + if (!IsEnable()) + return TRUE; + if (m_bLeftButtonEnable) + CButton::OnMouseLeftButtonDown(); + else if (m_pParent) + m_pParent->OnMouseLeftButtonDown(); + return TRUE; + } + DWORD CSlotWindow::Type() { static DWORD s = GetCRC32("CSlotWindow", 11); return s; } BOOL CSlotWindow::OnIsType(DWORD t) { return t == Type() || CWindow::OnIsType(t); } CSlotWindow::CSlotWindow(PyObject * ppyObject) - : CWindow(ppyObject), m_dwSlotType(0), m_dwSlotStyle(0), m_pBaseImageInstance(nullptr) + : CWindow(ppyObject), m_dwSlotType(0), m_dwSlotStyle(SLOT_STYLE_NONE), + m_isUseMode(FALSE), m_isUsableItem(FALSE), m_pBaseImageInstance(nullptr) { + m_slots.clear(); + m_dwSelectedSlotIndexList.clear(); + m_slotMap.clear(); + m_CoolDownStore.clear(); + m_apSlotActiveEffect[0] = nullptr; + m_apSlotActiveEffect[1] = nullptr; + m_apSlotActiveEffect[2] = nullptr; } CSlotWindow::~CSlotWindow() @@ -1347,21 +1831,59 @@ namespace UI CGraphicImageInstance::Delete(m_pBaseImageInstance); m_pBaseImageInstance = nullptr; } + for (int i = 0; i < 3; ++i) { + if (m_apSlotActiveEffect[i]) { + delete m_apSlotActiveEffect[i]; + m_apSlotActiveEffect[i] = nullptr; + } + } + m_slots.clear(); + m_dwSelectedSlotIndexList.clear(); + m_slotMap.clear(); + m_CoolDownStore.clear(); + } + + void CSlotWindow::SetSlotID(DWORD dwIndex, DWORD dwID) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) + pSlot->dwItemID = dwID; } void CSlotWindow::AppendSlot(DWORD dwIndex, int ix, int iy, int iw, int ih) { SSlot slot; slot.dwIndex = dwIndex; + slot.dwSlotNumber = dwIndex; + slot.dwCenterSlotNumber = dwIndex; slot.ixPosition = ix; slot.iyPosition = iy; slot.ixCellSize = iw; slot.iyCellSize = ih; + slot.byWidth = 1; + slot.byHeight = 1; + slot.byxPlacedItemSize = 1; + slot.byyPlacedItemSize = 1; slot.bRenderBaseSlotImage = true; slot.isItem = false; slot.dwItemIndex = 0; + slot.dwItemID = 0; slot.pInstance = nullptr; slot.pCoverInstance = nullptr; + slot.pNumberLine = nullptr; + slot.pCoverButton = nullptr; + slot.pSlotButton = nullptr; + slot.pSignImage = nullptr; + slot.pFinishCoolTimeEffect = nullptr; + for (int i = 0; i < 3; ++i) slot.pActiveSlotEffect[i] = nullptr; + slot.dwItemCount = 0; + slot.dwGrade = 0; + slot.bActive = false; + slot.bLocked = false; + slot.dwState = 0; + slot.fCoolTime = 0.0f; + slot.fStartCoolTime = 0.0f; + m_slotMap[dwIndex] = slot; if (!HasSlot(dwIndex)) m_slots.push_back(dwIndex); } @@ -1379,27 +1901,136 @@ namespace UI m_pBaseImageInstance->SetDiffuseColor(fr, fg, fb, fa); } - void CSlotWindow::SetCoverButton(DWORD dwIndex, const char* c_szUpImageName, const char*, const char*, const char*, BOOL, BOOL) + void CSlotWindow::SetSlotBaseImageScale(const char* szFileName, float fr, float fg, float fb, float fa, float sx, float sy) { - auto it = m_slotMap.find(dwIndex); - if (it == m_slotMap.end()) return; - CResource* pRes = CResourceManager::Instance().GetResourcePointer(c_szUpImageName); - if (!pRes || !pRes->IsType(CGraphicImage::Type())) return; - if (!it->second.pCoverInstance) - it->second.pCoverInstance = CGraphicImageInstance::New(); - it->second.pCoverInstance->SetImagePointer((CGraphicImage*)pRes); + SetSlotBaseImage(szFileName, fr, fg, fb, fa); + if (m_pBaseImageInstance) + m_pBaseImageInstance->SetScale(sx, sy); + } + + void CSlotWindow::AppendSlotButton(const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName) + { + for (auto& pair : m_slotMap) { + SSlot& rSlot = pair.second; + if (!rSlot.pSlotButton) { + rSlot.pSlotButton = new CSlotButton(rSlot.dwSlotNumber, this); + rSlot.pSlotButton->AddFlag(FLAG_FLOAT); + AddChild(rSlot.pSlotButton); + } + rSlot.pSlotButton->SetUpVisual(c_szUpImageName); + rSlot.pSlotButton->SetOverVisual(c_szOverImageName); + rSlot.pSlotButton->SetDownVisual(c_szDownImageName); + rSlot.pSlotButton->SetPosition(rSlot.ixPosition + 1, rSlot.iyPosition + 19); + rSlot.pSlotButton->Hide(); + } + } + + void CSlotWindow::AppendRequirementSignImage(const char* c_szImageName) + { + for (auto& pair : m_slotMap) { + SSlot& rSlot = pair.second; + if (!rSlot.pSignImage) { + rSlot.pSignImage = new CImageBox(nullptr); + rSlot.pSignImage->AddFlag(FLAG_NOT_PICK); + AddChild(rSlot.pSignImage); + } + rSlot.pSignImage->LoadImage(c_szImageName); + rSlot.pSignImage->Hide(); + } + } + + void CSlotWindow::ShowSlotButton(DWORD dwSlotNumber) + { + SSlot* pSlot; + if (GetSlotPointer(dwSlotNumber, &pSlot) && pSlot->pSlotButton) + pSlot->pSlotButton->Show(); + } + + void CSlotWindow::HideAllSlotButton() + { + for (auto& pair : m_slotMap) { + if (pair.second.pSlotButton) + pair.second.pSlotButton->Hide(); + } + } + + void CSlotWindow::ShowRequirementSign(DWORD dwSlotNumber) + { + SSlot* pSlot; + if (GetSlotPointer(dwSlotNumber, &pSlot) && pSlot->pSignImage) + pSlot->pSignImage->Show(); + } + + void CSlotWindow::HideRequirementSign(DWORD dwSlotNumber) + { + SSlot* pSlot; + if (GetSlotPointer(dwSlotNumber, &pSlot) && pSlot->pSignImage) + pSlot->pSignImage->Hide(); + } + + void CSlotWindow::SetCoverButton(DWORD dwIndex, const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName, const char* c_szDisableImageName, BOOL bLeftButtonEnable, BOOL bRightButtonEnable) + { + SSlot* pSlot; + if (!GetSlotPointer(dwIndex, &pSlot)) return; + + if (!pSlot->pCoverButton) + { + pSlot->pCoverButton = new CCoverButton(pSlot->dwSlotNumber, this); + pSlot->pCoverButton->AddFlag(FLAG_FLOAT); + AddChild(pSlot->pCoverButton); + } + + pSlot->pCoverButton->SetUpVisual(c_szUpImageName); + pSlot->pCoverButton->SetOverVisual(c_szOverImageName); + pSlot->pCoverButton->SetDownVisual(c_szDownImageName); + pSlot->pCoverButton->SetDisableVisual(c_szDisableImageName); + pSlot->pCoverButton->SetLeftButtonEnable(bLeftButtonEnable); + pSlot->pCoverButton->SetRightButtonEnable(bRightButtonEnable); + pSlot->pCoverButton->SetPosition(pSlot->ixPosition, pSlot->iyPosition); + pSlot->pCoverButton->Show(); + } + + void CSlotWindow::EnableCoverButton(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot) && pSlot->pCoverButton) + pSlot->pCoverButton->Enable(); + } + + void CSlotWindow::DisableCoverButton(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot) && pSlot->pCoverButton) + pSlot->pCoverButton->Disable(); + } + + BOOL CSlotWindow::IsDisableCoverButton(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot) && pSlot->pCoverButton) + return pSlot->pCoverButton->IsDisable(); + return FALSE; + } + + void CSlotWindow::SetAlwaysRenderCoverButton(DWORD dwIndex, bool bAlways) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) { + if (bAlways) pSlot->dwState |= SLOT_STATE_ALWAYS_RENDER_COVER; + else pSlot->dwState &= ~SLOT_STATE_ALWAYS_RENDER_COVER; + } } void CSlotWindow::ShowSlotBaseImage(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) it->second.bRenderBaseSlotImage = true; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->bRenderBaseSlotImage = true; } void CSlotWindow::HideSlotBaseImage(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) it->second.bRenderBaseSlotImage = false; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->bRenderBaseSlotImage = false; } BOOL CSlotWindow::HasSlot(DWORD dwIndex) @@ -1411,16 +2042,34 @@ namespace UI { auto it = m_slotMap.find(dwIndex); if (it != m_slotMap.end()) { - it->second.dwItemIndex = 0; - it->second.isItem = false; - it->second.dwItemCount = 0; - if (it->second.pInstance) { - CGraphicImageInstance::Delete(it->second.pInstance); - it->second.pInstance = nullptr; + SSlot& slot = it->second; + slot.dwItemIndex = 0; + slot.isItem = false; + slot.dwItemCount = 0; + slot.dwGrade = 0; + slot.fCoolTime = 0.0f; + slot.fStartCoolTime = 0.0f; + if (slot.pInstance) { + CGraphicImageInstance::Delete(slot.pInstance); + slot.pInstance = nullptr; } - if (it->second.pCoverInstance) { - CGraphicImageInstance::Delete(it->second.pCoverInstance); - it->second.pCoverInstance = nullptr; + if (slot.pCoverInstance) { + CGraphicImageInstance::Delete(slot.pCoverInstance); + slot.pCoverInstance = nullptr; + } + if (slot.pNumberLine) { + delete slot.pNumberLine; + slot.pNumberLine = nullptr; + } + if (slot.pFinishCoolTimeEffect) { + delete slot.pFinishCoolTimeEffect; + slot.pFinishCoolTimeEffect = nullptr; + } + for (int i = 0; i < 3; ++i) { + if (slot.pActiveSlotEffect[i]) { + delete slot.pActiveSlotEffect[i]; + slot.pActiveSlotEffect[i] = nullptr; + } } } } @@ -1428,17 +2077,45 @@ namespace UI void CSlotWindow::ClearAllSlot() { for (auto& pair : m_slotMap) { - if (pair.second.pInstance) { - CGraphicImageInstance::Delete(pair.second.pInstance); - pair.second.pInstance = nullptr; + SSlot& slot = pair.second; + if (slot.pInstance) { + CGraphicImageInstance::Delete(slot.pInstance); + slot.pInstance = nullptr; } - if (pair.second.pCoverInstance) { - CGraphicImageInstance::Delete(pair.second.pCoverInstance); - pair.second.pCoverInstance = nullptr; + if (slot.pCoverInstance) { + CGraphicImageInstance::Delete(slot.pCoverInstance); + slot.pCoverInstance = nullptr; + } + if (slot.pNumberLine) { + delete slot.pNumberLine; + slot.pNumberLine = nullptr; + } + if (slot.pCoverButton) { + delete slot.pCoverButton; + slot.pCoverButton = nullptr; + } + if (slot.pSlotButton) { + delete slot.pSlotButton; + slot.pSlotButton = nullptr; + } + if (slot.pSignImage) { + delete slot.pSignImage; + slot.pSignImage = nullptr; + } + if (slot.pFinishCoolTimeEffect) { + delete slot.pFinishCoolTimeEffect; + slot.pFinishCoolTimeEffect = nullptr; + } + for (int i = 0; i < 3; ++i) { + if (slot.pActiveSlotEffect[i]) { + delete slot.pActiveSlotEffect[i]; + slot.pActiveSlotEffect[i] = nullptr; + } } } m_slotMap.clear(); m_slots.clear(); + m_dwSelectedSlotIndexList.clear(); } void CSlotWindow::SetSlot(DWORD dwIndex, DWORD dwItemIndex, BYTE byWidth, BYTE byHeight, CGraphicImage* pImage, const D3DXCOLOR& diffuseColor) @@ -1452,6 +2129,8 @@ namespace UI slot.dwItemIndex = dwItemIndex; slot.byWidth = byWidth; slot.byHeight = byHeight; + slot.byxPlacedItemSize = byWidth ? byWidth : 1; + slot.byyPlacedItemSize = byHeight ? byHeight : 1; slot.isItem = (pImage != nullptr); if (pImage) { if (!slot.pInstance) @@ -1469,127 +2148,458 @@ namespace UI void CSlotWindow::SetSlotScale(DWORD dwIndex, DWORD dwItemIndex, BYTE byWidth, BYTE byHeight, CGraphicImage* pImage, float sx, float sy, const D3DXCOLOR& diffuseColor) { SetSlot(dwIndex, dwItemIndex, byWidth, byHeight, pImage, diffuseColor); - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end() && it->second.pInstance) { - it->second.pInstance->SetScale(sx, sy); + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot) && pSlot->pInstance) { + pSlot->pInstance->SetScale(sx, sy); } } void CSlotWindow::SetSlotCount(DWORD dwIndex, DWORD dwCount) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) { - it->second.dwItemCount = dwCount; + SSlot* pSlot; + if (!GetSlotPointer(dwIndex, &pSlot)) return; + + pSlot->dwItemCount = dwCount; + + if (dwCount <= 1 && pSlot->dwGrade == 0) { + if (pSlot->pNumberLine) { + delete pSlot->pNumberLine; + pSlot->pNumberLine = nullptr; + } + } else { + char szCount[32]; + std::snprintf(szCount, sizeof(szCount), "%u", (unsigned)dwCount); + if (!pSlot->pNumberLine) { + pSlot->pNumberLine = new CNumberLine(this); + pSlot->pNumberLine->SetHorizontalAlign(CGraphicTextInstance::HORIZONTAL_ALIGN_RIGHT); + pSlot->pNumberLine->Show(); + } + pSlot->pNumberLine->SetNumber(szCount); + } + } + + void CSlotWindow::SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount) + { + SSlot* pSlot; + if (!GetSlotPointer(dwIndex, &pSlot)) return; + + pSlot->dwGrade = dwGrade; + pSlot->dwItemCount = dwCount; + + if (dwGrade == 0) { + SetSlotCount(dwIndex, dwCount); + } else { + char szCount[32]; + switch (dwGrade) { + case 1: std::snprintf(szCount, sizeof(szCount), "m%u", (unsigned)dwCount); break; + case 2: std::snprintf(szCount, sizeof(szCount), "g%u", (unsigned)dwCount); break; + case 3: std::snprintf(szCount, sizeof(szCount), "p"); break; + default: std::snprintf(szCount, sizeof(szCount), "%u", (unsigned)dwCount); break; + } + if (!pSlot->pNumberLine) { + pSlot->pNumberLine = new CNumberLine(this); + pSlot->pNumberLine->SetHorizontalAlign(CGraphicTextInstance::HORIZONTAL_ALIGN_RIGHT); + pSlot->pNumberLine->Show(); + } + pSlot->pNumberLine->SetNumber(szCount); } } void CSlotWindow::SetSlotCoolTime(DWORD dwIndex, float fCoolTime, float fElapsedTime) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) { - it->second.fCoolTime = fCoolTime; - it->second.fStartCoolTime = (SDL_GetTicks() / 1000.0f) - fElapsedTime; - SDL_Log("CSlotWindow::SetSlotCoolTime slot=%u cd=%.1f elapsed=%.1f", (unsigned)dwIndex, fCoolTime, fElapsedTime); + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) { + pSlot->fCoolTime = fCoolTime; + pSlot->fStartCoolTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime; } } bool CSlotWindow::IsSlotCoolTime(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end() && it->second.fCoolTime > 0.0f) { - float elapsed = (SDL_GetTicks() / 1000.0f) - it->second.fStartCoolTime; - return elapsed < it->second.fCoolTime; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot) && pSlot->fCoolTime > 0.0f) { + float elapsed = CTimer::Instance().GetCurrentSecond() - pSlot->fStartCoolTime; + return elapsed < pSlot->fCoolTime; } return false; } float CSlotWindow::GetSlotCoolTime(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) return it->second.fCoolTime; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) return pSlot->fCoolTime; return 0.0f; } float CSlotWindow::GetSlotRemainingCoolTime(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end() && it->second.fCoolTime > 0.0f) { - float elapsed = (SDL_GetTicks() / 1000.0f) - it->second.fStartCoolTime; - return std::max(0.0f, it->second.fCoolTime - elapsed); + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot) && pSlot->fCoolTime > 0.0f) { + float elapsed = CTimer::Instance().GetCurrentSecond() - pSlot->fStartCoolTime; + return std::max(0.0f, pSlot->fCoolTime - elapsed); } return 0.0f; } - void CSlotWindow::SetSlotCountNew(DWORD dwIndex, DWORD dwGrade, DWORD dwCount) + void CSlotWindow::StoreSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex, float fCoolTime, float fElapsedTime) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) { - it->second.dwGrade = dwGrade; - it->second.dwItemCount = dwCount; + auto& entry = m_CoolDownStore[dwKey][dwSlotIndex]; + entry.fCoolTime = fCoolTime; + entry.fElapsedTime = CTimer::Instance().GetCurrentSecond() - fElapsedTime; + entry.bActive = false; + } + + void CSlotWindow::RestoreSlotCoolTime(DWORD dwKey) + { + auto it = m_CoolDownStore.find(dwKey); + if (it != m_CoolDownStore.end()) { + for (const auto& pair : it->second) { + SSlot* pSlot; + if (GetSlotPointer(pair.first, &pSlot)) { + pSlot->fCoolTime = pair.second.fCoolTime; + pSlot->fStartCoolTime = pair.second.fElapsedTime; + if (pair.second.bActive) + ActivateSlot(pair.first); + else + DeactivateSlot(pair.first); + } + } } } void CSlotWindow::ActivateSlot(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) it->second.bActive = true; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->bActive = true; } void CSlotWindow::DeactivateSlot(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) it->second.bActive = false; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->bActive = false; } void CSlotWindow::LockSlot(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) it->second.bLocked = true; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) { + pSlot->bLocked = true; + pSlot->dwState |= SLOT_STATE_LOCK; + } } void CSlotWindow::UnlockSlot(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) it->second.bLocked = false; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) { + pSlot->bLocked = false; + pSlot->dwState &= ~SLOT_STATE_LOCK; + } } BOOL CSlotWindow::IsLockSlot(DWORD dwIndex) { - auto it = m_slotMap.find(dwIndex); - if (it != m_slotMap.end()) return it->second.bLocked ? TRUE : FALSE; + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) + return (pSlot->dwState & SLOT_STATE_LOCK) || pSlot->bLocked ? TRUE : FALSE; return FALSE; } + void CSlotWindow::EnableSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState &= ~SLOT_STATE_DISABLE; + } + + void CSlotWindow::DisableSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState |= SLOT_STATE_DISABLE; + } + + BOOL CSlotWindow::IsEnableSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) return !(pSlot->dwState & SLOT_STATE_DISABLE); + return TRUE; + } + + void CSlotWindow::SetCantUseSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState |= SLOT_STATE_CANT_USE; + } + + void CSlotWindow::SetUseSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState &= ~SLOT_STATE_CANT_USE; + } + + BOOL CSlotWindow::IsCantUseSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) return (pSlot->dwState & SLOT_STATE_CANT_USE) ? TRUE : FALSE; + return FALSE; + } + + void CSlotWindow::SetCanMouseEventSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState &= ~SLOT_STATE_CANT_MOUSE_EVENT; + } + + void CSlotWindow::SetCantMouseEventSlot(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState |= SLOT_STATE_CANT_MOUSE_EVENT; + } + + void CSlotWindow::SetUsableSlotOnTopWnd(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState &= ~SLOT_STATE_UNUSABLE; + } + + void CSlotWindow::SetUnusableSlotOnTopWnd(DWORD dwIndex) + { + SSlot* pSlot; + if (GetSlotPointer(dwIndex, &pSlot)) pSlot->dwState |= SLOT_STATE_UNUSABLE; + } + + void CSlotWindow::SelectSlot(DWORD dwIndex) + { + if (!isSelectedSlot(dwIndex)) + m_dwSelectedSlotIndexList.push_back(dwIndex); + } + + BOOL CSlotWindow::isSelectedSlot(DWORD dwIndex) + { + return std::find(m_dwSelectedSlotIndexList.begin(), m_dwSelectedSlotIndexList.end(), dwIndex) != m_dwSelectedSlotIndexList.end(); + } + + DWORD CSlotWindow::GetSelectedSlotNumber(DWORD dwIndex) + { + if (dwIndex < m_dwSelectedSlotIndexList.size()) + return m_dwSelectedSlotIndexList[dwIndex]; + return 0; + } + + void CSlotWindow::ActivateEffect(DWORD dwIndex, float r, float g, float b, float a) + { + SSlot* pSlot; + if (!GetSlotPointer(dwIndex, &pSlot)) return; + + for (int i = 0; i < 3; ++i) { + if (pSlot->pActiveSlotEffect[i]) { + delete pSlot->pActiveSlotEffect[i]; + pSlot->pActiveSlotEffect[i] = nullptr; + } + auto* pEff = new CAniImageBox(nullptr); + for (int j = 0; j <= 12; ++j) { + char buf[128]; + std::snprintf(buf, sizeof(buf), "d:/ymir work/ui/public/slotactiveeffect/slot%d/%02d.sub", (i + 1), j); + pEff->AppendImage(buf, r, g, b, a); + } + pEff->SetRenderingMode(CGraphicExpandedImageInstance::RENDERING_MODE_SCREEN); + pSlot->pActiveSlotEffect[i] = pEff; + } + } + + void CSlotWindow::DeactivateEffect(DWORD dwIndex) + { + SSlot* pSlot; + if (!GetSlotPointer(dwIndex, &pSlot)) return; + + for (int i = 0; i < 3; ++i) { + if (pSlot->pActiveSlotEffect[i]) { + delete pSlot->pActiveSlotEffect[i]; + pSlot->pActiveSlotEffect[i] = nullptr; + } + } + } + + BOOL CSlotWindow::GetSlotPointer(DWORD dwIndex, SSlot** ppSlot) + { + auto it = m_slotMap.find(dwIndex); + if (it != m_slotMap.end()) { + if (ppSlot) *ppSlot = &it->second; + return TRUE; + } + return FALSE; + } + + BOOL CSlotWindow::GetSelectedSlotPointer(SSlot** ppSlot) + { + if (!m_dwSelectedSlotIndexList.empty()) { + return GetSlotPointer(m_dwSelectedSlotIndexList.front(), ppSlot); + } + return FALSE; + } + + void CSlotWindow::RenderSlotBaseImage() + { + if (!m_pBaseImageInstance) return; + for (const auto& pair : m_slotMap) { + const SSlot& slot = pair.second; + if (!slot.bRenderBaseSlotImage) continue; + m_pBaseImageInstance->SetPosition(static_cast(m_rect.left + slot.ixPosition), static_cast(m_rect.top + slot.iyPosition)); + m_pBaseImageInstance->Render(); + } + } + + void CSlotWindow::OnRenderPickingSlot() + { + if (!UI::CWindowManager::Instance().IsAttaching()) return; + SSlot* pSlot; + if (!GetSelectedSlotPointer(&pSlot)) return; + + CGraphicDevice* pDevice = CGraphicDevice::InstancePtr(); + SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr; + if (!ren) return; + + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(ren, 255, 255, 255, 128); + SDL_FRect r{ + static_cast(m_rect.left + pSlot->ixPosition), + static_cast(m_rect.top + pSlot->iyPosition), + static_cast(pSlot->ixCellSize), + static_cast(pSlot->iyCellSize) + }; + SDL_RenderFillRect(ren, &r); + } + + void CSlotWindow::OnRenderSelectedSlot() + { + CGraphicDevice* pDevice = CGraphicDevice::InstancePtr(); + SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr; + if (!ren) return; + + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(ren, 255, 255, 255, 128); + for (DWORD idx : m_dwSelectedSlotIndexList) { + SSlot* pSlot; + if (!GetSlotPointer(idx, &pSlot)) continue; + SDL_FRect r{ + static_cast(m_rect.left + pSlot->ixPosition), + static_cast(m_rect.top + pSlot->iyPosition), + static_cast(pSlot->ixCellSize), + static_cast(pSlot->iyCellSize) + }; + SDL_RenderFillRect(ren, &r); + } + } + + void CSlotWindow::RenderLockedSlot() + { + CGraphicDevice* pDevice = CGraphicDevice::InstancePtr(); + SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr; + if (!ren) return; + + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(ren, 0, 0, 0, 128); + for (const auto& pair : m_slotMap) { + const SSlot& slot = pair.second; + if (!slot.isItem) continue; + if ((slot.dwState & SLOT_STATE_LOCK) || slot.bLocked) { + BYTE w = slot.byxPlacedItemSize ? slot.byxPlacedItemSize : (slot.byWidth ? slot.byWidth : 1); + BYTE h = slot.byyPlacedItemSize ? slot.byyPlacedItemSize : (slot.byHeight ? slot.byHeight : 1); + SDL_FRect r{ + static_cast(m_rect.left + slot.ixPosition), + static_cast(m_rect.top + slot.iyPosition), + static_cast(slot.ixCellSize * w), + static_cast(slot.iyCellSize * h) + }; + SDL_RenderFillRect(ren, &r); + } + } + } + void CSlotWindow::OnRender() { - if (m_pBaseImageInstance) { - for (const auto& pair : m_slotMap) { - const SSlot& slot = pair.second; - if (!slot.bRenderBaseSlotImage) continue; - m_pBaseImageInstance->SetPosition(m_rect.left + slot.ixPosition, m_rect.top + slot.iyPosition); - m_pBaseImageInstance->Render(); - } + RenderSlotBaseImage(); + + switch (m_dwSlotStyle) + { + case SLOT_STYLE_PICK_UP: + OnRenderPickingSlot(); + break; + case SLOT_STYLE_SELECT: + OnRenderSelectedSlot(); + break; } - for (const auto& pair : m_slotMap) { - const SSlot& slot = pair.second; - if (slot.isItem && slot.pInstance) { - slot.pInstance->SetPosition(m_rect.left + slot.ixPosition, m_rect.top + slot.iyPosition); - slot.pInstance->Render(); - } - if (slot.pCoverInstance) { - slot.pCoverInstance->SetPosition(m_rect.left + slot.ixPosition, m_rect.top + slot.iyPosition); - slot.pCoverInstance->Render(); - } - } - - // Render cooltime overlay & countdown text CGraphicDevice* pDevice = CGraphicDevice::InstancePtr(); SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr; float curTime = CTimer::Instance().GetCurrentSecond(); for (auto& pair : m_slotMap) { SSlot& slot = pair.second; + + if (slot.pSlotButton) + slot.pSlotButton->SetPosition(slot.ixPosition + 1, slot.iyPosition + 19); + + if (slot.pSignImage) + slot.pSignImage->SetPosition(slot.ixPosition - 2, slot.iyPosition + 2); + + if (slot.pInstance) { + slot.pInstance->SetPosition(static_cast(m_rect.left + slot.ixPosition), static_cast(m_rect.top + slot.iyPosition)); + slot.pInstance->Render(); + } + + if (!slot.isItem) { + if (slot.dwState & SLOT_STATE_ALWAYS_RENDER_COVER) { + if (slot.pCoverButton) { + slot.pCoverButton->Show(); + slot.pCoverButton->SetPosition(slot.ixPosition, slot.iyPosition); + slot.pCoverButton->RenderButton(); + } + } + continue; + } + + BYTE itemW = slot.byxPlacedItemSize ? slot.byxPlacedItemSize : 1; + BYTE itemH = slot.byyPlacedItemSize ? slot.byyPlacedItemSize : 1; + + if (ren) { + if (slot.dwState & SLOT_STATE_CANT_MOUSE_EVENT) { + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(ren, 255, 0, 0, 76); + SDL_FRect r{ + static_cast(m_rect.left + slot.ixPosition), + static_cast(m_rect.top + slot.iyPosition), + static_cast(itemW * 32), + static_cast(itemH * 32) + }; + SDL_RenderFillRect(ren, &r); + } + + if (slot.dwState & SLOT_STATE_UNUSABLE) { + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(ren, 255, 255, 255, 76); + SDL_FRect r{ + static_cast(m_rect.left + slot.ixPosition), + static_cast(m_rect.top + slot.iyPosition), + static_cast(itemW * 32), + static_cast(itemH * 32) + }; + SDL_RenderFillRect(ren, &r); + } + + if (slot.dwState & SLOT_STATE_DISABLE) { + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(ren, 255, 0, 0, 76); + SDL_FRect r{ + static_cast(m_rect.left + slot.ixPosition), + static_cast(m_rect.top + slot.iyPosition), + static_cast(itemW * 32), + static_cast(itemH * 32) + }; + SDL_RenderFillRect(ren, &r); + } + } + + // CoolTime box animation if (slot.fCoolTime > 0.0f) { float elapsed = curTime - slot.fStartCoolTime; if (elapsed < slot.fCoolTime) { @@ -1670,100 +2680,71 @@ namespace UI slot.fStartCoolTime = 0.0f; } } - } - // Render locked slot overlay - if (ren) { - for (const auto& pair : m_slotMap) { - const SSlot& slot = pair.second; - if (slot.bLocked) { - SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); - SDL_SetRenderDrawColor(ren, 10, 10, 10, 185); - BYTE wCells = slot.byWidth ? slot.byWidth : 1; - BYTE hCells = slot.byHeight ? slot.byHeight : 1; - SDL_FRect lockRect{ - static_cast(m_rect.left + slot.ixPosition), - static_cast(m_rect.top + slot.iyPosition), - static_cast(slot.ixCellSize * wCells), - static_cast(slot.iyCellSize * hCells) - }; - SDL_RenderFillRect(ren, &lockRect); + if (slot.pCoverButton) { + slot.pCoverButton->SetPosition(slot.ixPosition, slot.iyPosition); + slot.pCoverButton->RenderButton(); + } + + if (slot.pNumberLine) { + int ix = slot.ixPosition + itemW * 32 - 4; + int iy = slot.iyPosition + itemH * 32 - 12 + 2; + slot.pNumberLine->SetPosition(ix, iy); + slot.pNumberLine->Update(); + slot.pNumberLine->Render(); + } + + if (slot.pFinishCoolTimeEffect) { + slot.pFinishCoolTimeEffect->SetPosition(slot.ixPosition, slot.iyPosition); + slot.pFinishCoolTimeEffect->Update(); + slot.pFinishCoolTimeEffect->Render(); + } + + // Sash / custom active effect + int iX = m_rect.left + slot.ixPosition, iY = m_rect.top + slot.iyPosition; + for (int i = 0; i < 3; ++i) { + if (slot.pActiveSlotEffect[i] && itemH == i + 1) { + slot.pActiveSlotEffect[i]->Show(); + slot.pActiveSlotEffect[i]->SetPosition(static_cast(iX), static_cast(iY)); + slot.pActiveSlotEffect[i]->Update(); + slot.pActiveSlotEffect[i]->Render(); } } + + // Slot active toggle highlight border + if (slot.bActive && ren) { + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + Uint8 alpha = static_cast(180 + 75 * std::sin(curTime * 6.0f)); + SDL_SetRenderDrawColor(ren, 255, 215, 0, alpha); + SDL_FRect borderRect{ + static_cast(m_rect.left + slot.ixPosition - 1), + static_cast(m_rect.top + slot.iyPosition - 1), + static_cast(slot.ixCellSize * itemW + 2), + static_cast(slot.iyCellSize * itemH + 2) + }; + SDL_RenderRect(ren, &borderRect); + SDL_FRect innerRect{ + static_cast(m_rect.left + slot.ixPosition), + static_cast(m_rect.top + slot.iyPosition), + static_cast(slot.ixCellSize * itemW), + static_cast(slot.iyCellSize * itemH) + }; + SDL_RenderRect(ren, &innerRect); + } } - // Render active slot highlight border - if (ren) { - for (const auto& pair : m_slotMap) { - const SSlot& slot = pair.second; - if (slot.bActive) { - SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); - Uint8 alpha = static_cast(180 + 75 * std::sin(curTime * 6.0f)); - SDL_SetRenderDrawColor(ren, 255, 215, 0, alpha); - BYTE wCells = slot.byWidth ? slot.byWidth : 1; - BYTE hCells = slot.byHeight ? slot.byHeight : 1; - SDL_FRect borderRect{ - static_cast(m_rect.left + slot.ixPosition - 1), - static_cast(m_rect.top + slot.iyPosition - 1), - static_cast(slot.ixCellSize * wCells + 2), - static_cast(slot.iyCellSize * hCells + 2) - }; - SDL_RenderRect(ren, &borderRect); - SDL_FRect innerRect{ - static_cast(m_rect.left + slot.ixPosition), - static_cast(m_rect.top + slot.iyPosition), - static_cast(slot.ixCellSize * wCells), - static_cast(slot.iyCellSize * hCells) - }; - SDL_RenderRect(ren, &innerRect); - } - } - } - - // Render item stack count / skill grade - if (ren) { - for (const auto& pair : m_slotMap) { - const SSlot& slot = pair.second; - char buf[32]{}; - if (slot.dwGrade > 0) { - switch (slot.dwGrade) { - case 1: std::snprintf(buf, sizeof(buf), "m%u", (unsigned)slot.dwItemCount); break; - case 2: std::snprintf(buf, sizeof(buf), "g%u", (unsigned)slot.dwItemCount); break; - case 3: std::snprintf(buf, sizeof(buf), "p"); break; - default: std::snprintf(buf, sizeof(buf), "%u", (unsigned)slot.dwItemCount); break; - } - } else if (slot.isItem && slot.dwItemCount > 1) { - std::snprintf(buf, sizeof(buf), "%u", (unsigned)slot.dwItemCount); - } - - if (buf[0] != '\0') { - int len = static_cast(std::strlen(buf)); - BYTE hCells = slot.byHeight ? slot.byHeight : 1; - float tx = static_cast(m_rect.left + slot.ixPosition + slot.ixCellSize - (len * 8) - 1); - float ty = static_cast(m_rect.top + slot.iyPosition + (slot.iyCellSize * hCells) - 10); - SDL_SetRenderScale(ren, 1.0f, 1.0f); - // Drop shadow - SDL_SetRenderDrawColor(ren, 0, 0, 0, 220); - SDL_RenderDebugText(ren, tx + 1.0f, ty + 1.0f, buf); - // Text color - if (slot.dwGrade == 3) { - SDL_SetRenderDrawColor(ren, 120, 200, 255, 255); - } else if (slot.dwGrade > 0) { - SDL_SetRenderDrawColor(ren, 255, 215, 60, 255); - } else { - SDL_SetRenderDrawColor(ren, 255, 255, 255, 255); - } - SDL_RenderDebugText(ren, tx, ty, buf); - } - } - } + RenderLockedSlot(); CWindow::OnRender(); } + // CGridSlotWindow DWORD CGridSlotWindow::Type() { static DWORD s = GetCRC32("CGridSlotWindow", 15); return s; } BOOL CGridSlotWindow::OnIsType(DWORD t) { return t == Type() || CSlotWindow::OnIsType(t); } + CGridSlotWindow::CGridSlotWindow(PyObject * ppyObject) : CSlotWindow(ppyObject) {} + CGridSlotWindow::~CGridSlotWindow() {} + void CGridSlotWindow::ArrangeGridSlot(DWORD dwStartIndex, DWORD dwxCount, DWORD dwyCount, int ixSlotSize, int iySlotSize, int ixTemporarySize, int iyTemporarySize) { ClearAllSlot(); @@ -1777,4 +2758,166 @@ namespace UI } SetSize(dwxCount * (ixSlotSize + ixTemporarySize), dwyCount * (iySlotSize + iyTemporarySize)); } + + BOOL CGridSlotWindow::GetPickedSlotList(BYTE byWidth, BYTE byHeight, std::vector* pSlotList) + { + if (!pSlotList) return FALSE; + pSlotList->clear(); + + long lx = 0, ly = 0; + GetMouseLocalPosition(lx, ly); + + if (lx < 0 || ly < 0) return FALSE; + + for (auto& pair : m_slotMap) + { + SSlot& s = pair.second; + if (lx >= s.ixPosition && lx < s.ixPosition + s.ixCellSize && + ly >= s.iyPosition && ly < s.iyPosition + s.iyCellSize) + { + for (BYTE y = 0; y < byHeight; ++y) + { + for (BYTE x = 0; x < byWidth; ++x) + { + int targetX = s.ixPosition + x * s.ixCellSize; + int targetY = s.iyPosition + y * s.iyCellSize; + bool found = false; + for (auto& p2 : m_slotMap) + { + if (std::abs(p2.second.ixPosition - targetX) < 4 && + std::abs(p2.second.iyPosition - targetY) < 4) + { + pSlotList->push_back(&p2.second); + found = true; + break; + } + } + if (!found) return FALSE; + } + } + return TRUE; + } + } + return FALSE; + } + + BOOL CGridSlotWindow::CheckMoving(DWORD dwSlotNumber, DWORD dwItemIndex, const std::vector& slotList) + { + for (auto* pSlot : slotList) + { + if (pSlot->isItem && pSlot->dwSlotNumber != dwSlotNumber && pSlot->dwCenterSlotNumber != dwSlotNumber) + return FALSE; + } + return TRUE; + } + + BOOL CGridSlotWindow::GetPickedSlotPointer(SSlot** ppSlot) + { + if (!UI::CWindowManager::Instance().IsAttaching()) + { + long lx = 0, ly = 0; + GetMouseLocalPosition(lx, ly); + for (auto& pair : m_slotMap) + { + SSlot& s = pair.second; + if (lx >= s.ixPosition && lx < s.ixPosition + s.ixCellSize && + ly >= s.iyPosition && ly < s.iyPosition + s.iyCellSize) + { + if (ppSlot) *ppSlot = &s; + return TRUE; + } + } + return FALSE; + } + + BYTE byWidth = 1, byHeight = 1; + UI::CWindowManager::Instance().GetAttachingIconSize(&byWidth, &byHeight); + + std::vector slotList; + if (!GetPickedSlotList(byWidth, byHeight, &slotList) || slotList.empty()) + return FALSE; + + SSlot* pMin = slotList.front(); + for (auto* s : slotList) + { + if (s->dwSlotNumber < pMin->dwSlotNumber) + pMin = s; + } + if (ppSlot) *ppSlot = pMin; + return TRUE; + } + + void CGridSlotWindow::OnRenderPickingSlot() + { + if (!UI::CWindowManager::Instance().IsAttaching()) + return; + + BYTE byWidth = 1, byHeight = 1; + UI::CWindowManager::Instance().GetAttachingIconSize(&byWidth, &byHeight); + + std::vector slotList; + if (GetPickedSlotList(byWidth, byHeight, &slotList) && !slotList.empty()) + { + DWORD dwSlotNumber = UI::CWindowManager::Instance().GetAttachingSlotNumber(); + DWORD dwItemIndex = UI::CWindowManager::Instance().GetAttachingIndex(); + + CGraphicDevice* pDevice = CGraphicDevice::InstancePtr(); + SDL_Renderer* ren = pDevice ? pDevice->GetRenderer() : nullptr; + if (!ren) return; + + RECT rect; + rect.left = m_rect.right; + rect.top = m_rect.bottom; + rect.right = 0; + rect.bottom = 0; + + for (auto* pSlot : slotList) + { + rect.left = std::min(rect.left, m_rect.left + pSlot->ixPosition); + rect.top = std::min(rect.top, m_rect.top + pSlot->iyPosition); + rect.right = std::max(rect.right, m_rect.left + pSlot->ixPosition + pSlot->byxPlacedItemSize * 32); + rect.bottom = std::max(rect.bottom, m_rect.top + pSlot->iyPosition + pSlot->byyPlacedItemSize * 32); + } + + SDL_SetRenderDrawBlendMode(ren, SDL_BLENDMODE_BLEND); + + if (m_isUseMode) + { + SSlot* pSlot = slotList.front(); + SSlot* pCenterSlot = nullptr; + auto it = m_slotMap.find(pSlot->dwCenterSlotNumber); + if (it != m_slotMap.end()) pCenterSlot = &it->second; + if (pCenterSlot && pCenterSlot->isItem) + { + if (m_isUsableItem) + SDL_SetRenderDrawColor(ren, 255, 255, 0, 128); // Yellow + else + SDL_SetRenderDrawColor(ren, 255, 0, 0, 128); // Red + + SDL_FRect r{ + static_cast(m_rect.left + pCenterSlot->ixPosition), + static_cast(m_rect.top + pCenterSlot->iyPosition), + static_cast(pCenterSlot->byxPlacedItemSize * 32), + static_cast(pCenterSlot->byyPlacedItemSize * 32) + }; + SDL_RenderFillRect(ren, &r); + return; + } + } + + bool canMove = CheckMoving(dwSlotNumber, dwItemIndex, slotList); + if (canMove) + SDL_SetRenderDrawColor(ren, 255, 255, 255, 128); // White + else + SDL_SetRenderDrawColor(ren, 255, 0, 0, 128); // Red + + SDL_FRect r{ + static_cast(rect.left), + static_cast(rect.top), + static_cast(rect.right - rect.left), + static_cast(rect.bottom - rect.top) + }; + SDL_RenderFillRect(ren, &r); + } + } } diff --git a/src/eter_ui/PythonWindow.h b/src/eter_ui/PythonWindow.h index d6987d84..6e028339 100644 --- a/src/eter_ui/PythonWindow.h +++ b/src/eter_ui/PythonWindow.h @@ -16,6 +16,7 @@ namespace UI { + class CSlotWindow; class CGraphicTextInstance { public: @@ -316,7 +317,7 @@ namespace UI { public: static DWORD Type(); - CBar3D(PyObject * ppyObject) : CWindow(ppyObject), m_dwLeftColor(0), m_dwRightColor(0), m_dwCenterColor(0) {} + CBar3D(PyObject * ppyObject) : CWindow(ppyObject), m_dwLeftColor(0xFF333333), m_dwRightColor(0xFFB2B2B2), m_dwCenterColor(0xFF000000) {} virtual ~CBar3D() {} void SetColor(DWORD l, DWORD r, DWORD c) { m_dwLeftColor = l; m_dwRightColor = r; m_dwCenterColor = c; } protected: @@ -362,15 +363,21 @@ namespace UI { public: static DWORD Type(); - CNumberLine(PyObject * ppyObject) : CWindow(ppyObject), m_iHorizontalAlign(0), m_dwWidthSummary(0) {} - CNumberLine(CWindow * pParent) : CWindow(nullptr), m_iHorizontalAlign(0), m_dwWidthSummary(0) { m_pParent = pParent; } - virtual ~CNumberLine() {} - void SetPath(const char * c_szPath) { if (c_szPath) m_strPath = c_szPath; } - void SetHorizontalAlign(int iType) { m_iHorizontalAlign = iType; } - void SetNumber(const char * c_szNumber) { if (c_szNumber) m_strNumber = c_szNumber; } + CNumberLine(PyObject * ppyObject); + CNumberLine(CWindow * pParent); + virtual ~CNumberLine(); + void SetPath(const char * c_szPath); + void SetHorizontalAlign(int iType); + void SetNumber(const char * c_szNumber); protected: + void ClearNumber(); + void OnRender() override; + void OnChangePosition() override; BOOL OnIsType(DWORD dwType) override; - std::string m_strPath, m_strNumber; + + std::string m_strPath; + std::string m_strNumber; + std::vector m_ImageInstanceVector; int m_iHorizontalAlign; DWORD m_dwWidthSummary; }; @@ -448,7 +455,7 @@ namespace UI void SetRotation(float fRotation); void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom); void SetRenderingMode(int iMode); - void SetImageClipRect(float fLeft, float fTop, float fRight, float fBottom, bool bIsVertical = false) {} + void SetImageClipRect(float fLeft, float fTop, float fRight, float fBottom, bool bIsVertical = false); protected: void OnCreateInstance() override; @@ -478,6 +485,8 @@ namespace UI void SetMoveSpeed(float speed); void SetMovePos(float directionX, float directionY); float GetRotation(); + void CheckMove(); + void OnMoveDone(); protected: void OnUpdate() override; @@ -491,6 +500,10 @@ namespace UI BYTE m_bycurDelay; BYTE m_byDelay; BYTE m_bycurIndex; + float nextX; + float nextY; + float fSpeed; + bool moveStart; std::vector m_ImageVector; }; @@ -507,7 +520,7 @@ namespace UI BOOL SetOverVisual(const char * c_szFileName); BOOL SetDownVisual(const char * c_szFileName); BOOL SetDisableVisual(const char * c_szFileName); - void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) {} + void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom); const char * GetUpVisualFileName(); const char * GetOverVisualFileName(); @@ -515,16 +528,17 @@ namespace UI void FlashEx() { m_isFlashEx = TRUE; } void Flash(bool bFlash = true) { m_isFlash = bFlash; } - void Enable() { m_bEnable = TRUE; } - void Disable() { m_bEnable = FALSE; } + void Enable(); + void Disable(); void SetUp(); void Up(); void Over(); void Down(); - BOOL IsDisable() { return !m_bEnable; } + BOOL IsDisable() { return m_bEnable; } BOOL IsPressed() { return m_isPressed; } + BOOL IsEnable() { return m_bEnable; } protected: void OnUpdate() override; @@ -536,7 +550,6 @@ namespace UI void OnMouseOverIn() override; void OnMouseOverOut() override; - BOOL IsEnable() { return m_bEnable; } void SetCurrentVisual(CGraphicImageInstance* pVisual); BOOL OnIsType(DWORD dwType) override; @@ -557,34 +570,41 @@ namespace UI { public: static DWORD Type(); - CRadioButton(PyObject* ppyObject) : CButton(ppyObject) {} - virtual ~CRadioButton() {} + CRadioButton(PyObject* ppyObject); + virtual ~CRadioButton(); protected: BOOL OnIsType(DWORD dwType) override; + BOOL OnMouseLeftButtonDown() override; + BOOL OnMouseLeftButtonUp() override; + void OnMouseOverIn() override; + void OnMouseOverOut() override; }; class CToggleButton : public CButton { public: static DWORD Type(); - CToggleButton(PyObject* ppyObject) : CButton(ppyObject) {} - virtual ~CToggleButton() {} + CToggleButton(PyObject* ppyObject); + virtual ~CToggleButton(); protected: BOOL OnIsType(DWORD dwType) override; + BOOL OnMouseLeftButtonDown() override; + BOOL OnMouseLeftButtonUp() override; + void OnMouseOverIn() override; + void OnMouseOverOut() override; }; class CDragButton : public CButton { public: static DWORD Type(); - CDragButton(PyObject * ppyObject) : CButton(ppyObject) { memset(&m_restrictArea, 0, sizeof(m_restrictArea)); } - virtual ~CDragButton() {} - void SetRestrictMovementArea(int ix, int iy, int iwidth, int iheight) { - m_restrictArea.left = ix; m_restrictArea.top = iy; - m_restrictArea.right = ix + iwidth; m_restrictArea.bottom = iy + iheight; - } + CDragButton(PyObject * ppyObject); + virtual ~CDragButton(); + void SetRestrictMovementArea(int ix, int iy, int iwidth, int iheight); protected: BOOL OnIsType(DWORD dwType) override; + void OnChangePosition() override; + void OnMouseOverIn() override; RECT m_restrictArea; }; @@ -592,33 +612,100 @@ namespace UI { public: static DWORD Type(); - CUiRenderTarget(PyObject* ppyObject) : CWindow(ppyObject), m_dwIndex(0) {} - virtual ~CUiRenderTarget() {} - bool SetRenderTarget(int index) { m_dwIndex = (DWORD)index; return true; } - void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom) {} + CUiRenderTarget(PyObject* ppyObject); + virtual ~CUiRenderTarget(); + bool SetRenderTarget(int index); + void SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom); protected: void OnRender() override; BOOL OnIsType(DWORD dwType) override; DWORD m_dwIndex; + RECT rect_ex; + }; + + class CSlotButton : public CButton + { + public: + CSlotButton(PyObject* ppy = nullptr); + CSlotButton(DWORD dwSlotNumber, CSlotWindow* pParent); + virtual ~CSlotButton(); + void SetSlotNumber(DWORD dwSlotNumber) { m_dwSlotNumber = dwSlotNumber; } + DWORD GetSlotNumber() const { return m_dwSlotNumber; } + void SetParentSlotWindow(CSlotWindow* pParent) { m_pParent = pParent; } + protected: + DWORD m_dwSlotNumber; + CSlotWindow* m_pParent; + }; + + class CCoverButton : public CSlotButton + { + public: + CCoverButton(PyObject* ppy = nullptr); + CCoverButton(DWORD dwSlotNumber, CSlotWindow* pParent); + virtual ~CCoverButton(); + void SetLeftButtonEnable(BOOL b) { m_bLeftButtonEnable = b; } + void SetRightButtonEnable(BOOL b) { m_bRightButtonEnable = b; } + void RenderButton(); + void OnRender() override {} + BOOL OnMouseLeftButtonDown() override; + protected: + BOOL m_bLeftButtonEnable; + BOOL m_bRightButtonEnable; }; class CSlotWindow : public CWindow { public: + enum ESlotState + { + SLOT_STATE_LOCK = (1 << 0), + SLOT_STATE_CANT_USE = (1 << 1), + SLOT_STATE_DISABLE = (1 << 2), + SLOT_STATE_ALWAYS_RENDER_COVER = (1 << 3), + SLOT_STATE_CANT_MOUSE_EVENT = (1 << 4), + SLOT_STATE_UNUSABLE = (1 << 5), + }; + + enum ESlotStyle + { + SLOT_STYLE_NONE = 0, + SLOT_STYLE_PICK_UP = 1, + SLOT_STYLE_SELECT = 2, + }; + + struct SStoreCoolDown + { + float fCoolTime; + float fElapsedTime; + bool bActive; + }; + struct SSlot { DWORD dwIndex = 0; + DWORD dwState = 0; + DWORD dwSlotNumber = 0; + DWORD dwCenterSlotNumber = 0; int ixPosition = 0; int iyPosition = 0; int ixCellSize = 32; int iyCellSize = 32; BYTE byWidth = 1; BYTE byHeight = 1; + BYTE byxPlacedItemSize = 1; + BYTE byyPlacedItemSize = 1; bool bRenderBaseSlotImage = true; bool isItem = false; DWORD dwItemIndex = 0; + DWORD dwItemID = 0; CGraphicImageInstance* pInstance = nullptr; CGraphicImageInstance* pCoverInstance = nullptr; + CNumberLine* pNumberLine = nullptr; + CCoverButton* pCoverButton = nullptr; + CSlotButton* pSlotButton = nullptr; + CImageBox* pSignImage = nullptr; + CAniImageBox* pFinishCoolTimeEffect = nullptr; + CAniImageBox* pActiveSlotEffect[3]{}; DWORD dwItemCount = 0; DWORD dwGrade = 0; bool bActive = false; @@ -631,22 +718,22 @@ namespace UI CSlotWindow(PyObject * ppyObject); virtual ~CSlotWindow(); void Destroy(); - void SetSlotID(DWORD dwIndex, DWORD dwID) {} + void SetSlotID(DWORD dwIndex, DWORD dwID); void SetSlotType(DWORD dwType) { m_dwSlotType = dwType; } void SetSlotStyle(DWORD dwStyle) { m_dwSlotStyle = dwStyle; } void AppendSlot(DWORD dwIndex, int ix, int iy, int iw, int ih); void SetCoverButton(DWORD dwIndex, const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName, const char* c_szDisableImageName, BOOL bLeftButtonEnable, BOOL bRightButtonEnable); void SetSlotBaseImage(const char* szFileName, float fr = 1.0f, float fg = 1.0f, float fb = 1.0f, float fa = 1.0f); - void AppendSlotButton(const char*, const char*, const char*) {} - void AppendRequirementSignImage(const char*) {} - void SetSlotBaseImageScale(const char*, float, float, float, float, float, float) {} + void AppendSlotButton(const char* c_szUpImageName, const char* c_szOverImageName, const char* c_szDownImageName); + void AppendRequirementSignImage(const char* c_szImageName); + void SetSlotBaseImageScale(const char* szFileName, float fr, float fg, float fb, float fa, float sx, float sy); void SetSlotScale(DWORD dwIndex, DWORD dwItemIndex, BYTE byWidth, BYTE byHeight, CGraphicImage* pImage, float sx, float sy, const D3DXCOLOR& diffuseColor); - void EnableCoverButton(DWORD) {} - void DisableCoverButton(DWORD) {} - void SetAlwaysRenderCoverButton(DWORD, bool = false) {} + void EnableCoverButton(DWORD dwIndex); + void DisableCoverButton(DWORD dwIndex); + void SetAlwaysRenderCoverButton(DWORD dwIndex, bool bAlways = false); void ShowSlotBaseImage(DWORD dwIndex); void HideSlotBaseImage(DWORD dwIndex); - BOOL IsDisableCoverButton(DWORD) { return FALSE; } + BOOL IsDisableCoverButton(DWORD dwIndex); BOOL HasSlot(DWORD dwIndex); void ClearAllSlot(); void ClearSlot(DWORD dwIndex); @@ -658,8 +745,8 @@ namespace UI bool IsSlotCoolTime(DWORD dwIndex); float GetSlotCoolTime(DWORD dwIndex); float GetSlotRemainingCoolTime(DWORD dwIndex); - void StoreSlotCoolTime(DWORD, DWORD, float, float = 0.0f) {} - void RestoreSlotCoolTime(DWORD) {} + void StoreSlotCoolTime(DWORD dwKey, DWORD dwSlotIndex, float fCoolTime, float fElapsedTime = 0.0f); + void RestoreSlotCoolTime(DWORD dwKey); void ActivateSlot(DWORD dwIndex); void DeactivateSlot(DWORD dwIndex); void RefreshSlot() {} @@ -667,52 +754,66 @@ namespace UI void LockSlot(DWORD dwIndex); void UnlockSlot(DWORD dwIndex); BOOL IsLockSlot(DWORD dwIndex); - void SetCantUseSlot(DWORD) {} - void SetUseSlot(DWORD) {} - BOOL IsCantUseSlot(DWORD) { return FALSE; } - void EnableSlot(DWORD) {} - void DisableSlot(DWORD) {} - BOOL IsEnableSlot(DWORD) { return TRUE; } - void SetCanMouseEventSlot(DWORD) {} - void SetCantMouseEventSlot(DWORD) {} - void SetUsableSlotOnTopWnd(DWORD) {} - void SetUnusableSlotOnTopWnd(DWORD) {} - void ClearSelected() { m_selected.clear(); } - void SelectSlot(DWORD dwIndex) { m_selected.push_back(dwIndex); } - BOOL isSelectedSlot(DWORD dwIndex) { - return std::find(m_selected.begin(), m_selected.end(), dwIndex) != m_selected.end(); - } - DWORD GetSelectedSlotCount() { return (DWORD)m_selected.size(); } - DWORD GetSelectedSlotNumber(DWORD dwIndex) { - return (dwIndex < m_selected.size()) ? m_selected[dwIndex] : 0; - } - void ShowSlotButton(DWORD) {} - void HideAllSlotButton() {} - void ShowRequirementSign(DWORD) {} - void HideRequirementSign(DWORD) {} - void SetUseMode(BOOL) {} - void SetUsableItem(BOOL) {} - void ActivateEffect(DWORD, float, float, float, float) {} - void DeactivateEffect(DWORD) {} + void SetCantUseSlot(DWORD dwIndex); + void SetUseSlot(DWORD dwIndex); + BOOL IsCantUseSlot(DWORD dwIndex); + void EnableSlot(DWORD dwIndex); + void DisableSlot(DWORD dwIndex); + BOOL IsEnableSlot(DWORD dwIndex); + void SetCanMouseEventSlot(DWORD dwIndex); + void SetCantMouseEventSlot(DWORD dwIndex); + void SetUsableSlotOnTopWnd(DWORD dwIndex); + void SetUnusableSlotOnTopWnd(DWORD dwIndex); + void ClearSelected() { m_dwSelectedSlotIndexList.clear(); } + void SelectSlot(DWORD dwIndex); + BOOL isSelectedSlot(DWORD dwIndex); + DWORD GetSelectedSlotCount() { return (DWORD)m_dwSelectedSlotIndexList.size(); } + DWORD GetSelectedSlotNumber(DWORD dwIndex); + void ShowSlotButton(DWORD dwIndex); + void HideAllSlotButton(); + void ShowRequirementSign(DWORD dwIndex); + void HideRequirementSign(DWORD dwIndex); + void SetUseMode(BOOL bFlag) { m_isUseMode = bFlag; } + void SetUsableItem(BOOL bFlag) { m_isUsableItem = bFlag; } + void ActivateEffect(DWORD dwIndex, float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f); + void DeactivateEffect(DWORD dwIndex); + + BOOL GetSlotPointer(DWORD dwIndex, SSlot** ppSlot); + BOOL GetSelectedSlotPointer(SSlot** ppSlot); + protected: void OnRender() override; BOOL OnIsType(DWORD dwType) override; + virtual void OnRenderPickingSlot(); + virtual void OnRenderSelectedSlot(); + void RenderSlotBaseImage(); + void RenderLockedSlot(); + + protected: DWORD m_dwSlotType; DWORD m_dwSlotStyle; + BOOL m_isUseMode; + BOOL m_isUsableItem; std::vector m_slots; - std::vector m_selected; + std::vector m_dwSelectedSlotIndexList; std::map m_slotMap; + std::map> m_CoolDownStore; CGraphicImageInstance* m_pBaseImageInstance; + CAniImageBox* m_apSlotActiveEffect[3]{}; }; class CGridSlotWindow : public CSlotWindow { public: static DWORD Type(); - CGridSlotWindow(PyObject * ppyObject) : CSlotWindow(ppyObject) {} - virtual ~CGridSlotWindow() {} + CGridSlotWindow(PyObject * ppyObject); + virtual ~CGridSlotWindow(); void ArrangeGridSlot(DWORD dwStartIndex, DWORD dwxCount, DWORD dwyCount, int ixSlotSize, int iySlotSize, int ixTemporarySize, int iyTemporarySize); + BOOL GetPickedSlotList(BYTE byWidth, BYTE byHeight, std::vector* pSlotList); + BOOL GetPickedSlotPointer(SSlot** ppSlot); + BOOL CheckMoving(DWORD dwSlotNumber, DWORD dwItemIndex, const std::vector& slotList); protected: + void OnRenderPickingSlot() override; BOOL OnIsType(DWORD dwType) override; }; } diff --git a/src/python_grp.cpp b/src/python_grp.cpp index 86e18813..297e2ca5 100644 --- a/src/python_grp.cpp +++ b/src/python_grp.cpp @@ -418,6 +418,18 @@ static PyObject* grpRenderBox3d(PyObject*, PyObject* poArgs) { if (!PyTuple_GetFloat(poArgs, 0, &sx) || !PyTuple_GetFloat(poArgs, 1, &sy) || !PyTuple_GetFloat(poArgs, 2, &sz) || !PyTuple_GetFloat(poArgs, 3, &ex) || !PyTuple_GetFloat(poArgs, 4, &ey) || !PyTuple_GetFloat(poArgs, 5, &ez)) return Py_BuildException(); + + auto* renderer = CGraphicDevice::Instance().GetRenderer(); + if (renderer) { + uint8_t a = (s_currentColor >> 24) & 0xFF; + uint8_t r = (s_currentColor >> 16) & 0xFF; + uint8_t g = (s_currentColor >> 8) & 0xFF; + uint8_t b = s_currentColor & 0xFF; + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, r, g, b, a); + SDL_FRect rect{ sx, sy, ex - sx, ey - sy }; + SDL_RenderRect(renderer, &rect); + } return Py_BuildNone(); } @@ -426,6 +438,18 @@ static PyObject* grpRenderBar3d(PyObject*, PyObject* poArgs) { if (!PyTuple_GetInteger(poArgs, 0, &sx) || !PyTuple_GetInteger(poArgs, 1, &sy) || !PyTuple_GetInteger(poArgs, 2, &sz) || !PyTuple_GetInteger(poArgs, 3, &ex) || !PyTuple_GetInteger(poArgs, 4, &ey) || !PyTuple_GetInteger(poArgs, 5, &ez)) return Py_BuildException(); + + auto* renderer = CGraphicDevice::Instance().GetRenderer(); + if (renderer) { + uint8_t a = (s_currentColor >> 24) & 0xFF; + uint8_t r = (s_currentColor >> 16) & 0xFF; + uint8_t g = (s_currentColor >> 8) & 0xFF; + uint8_t b = s_currentColor & 0xFF; + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, r, g, b, a); + SDL_FRect rect{ (float)sx, (float)sy, (float)(ex - sx), (float)(ey - sy) }; + SDL_RenderFillRect(renderer, &rect); + } return Py_BuildNone(); } @@ -434,6 +458,18 @@ static PyObject* grpRenderCube(PyObject*, PyObject* poArgs) { if (!PyTuple_GetFloat(poArgs, 0, &sx) || !PyTuple_GetFloat(poArgs, 1, &sy) || !PyTuple_GetFloat(poArgs, 2, &sz) || !PyTuple_GetFloat(poArgs, 3, &ex) || !PyTuple_GetFloat(poArgs, 4, &ey) || !PyTuple_GetFloat(poArgs, 5, &ez)) return Py_BuildException(); + + auto* renderer = CGraphicDevice::Instance().GetRenderer(); + if (renderer) { + uint8_t a = (s_currentColor >> 24) & 0xFF; + uint8_t r = (s_currentColor >> 16) & 0xFF; + uint8_t g = (s_currentColor >> 8) & 0xFF; + uint8_t b = s_currentColor & 0xFF; + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + SDL_SetRenderDrawColor(renderer, r, g, b, a); + SDL_FRect rect{ sx, sy, ex - sx, ey - sy }; + SDL_RenderRect(renderer, &rect); + } return Py_BuildNone(); } @@ -441,6 +477,35 @@ static PyObject* grpRenderDownButton(PyObject*, PyObject* poArgs) { int x = 0, y = 0, width = 0, height = 0; if (!PyTuple_GetInteger(poArgs, 0, &x) || !PyTuple_GetInteger(poArgs, 1, &y) || !PyTuple_GetInteger(poArgs, 2, &width) || !PyTuple_GetInteger(poArgs, 3, &height)) return Py_BuildException(); + + auto* renderer = CGraphicDevice::Instance().GetRenderer(); + if (renderer && width > 0 && height > 0) { + float sx = (float)x; + float sy = (float)y; + float ex = (float)(x + width); + float ey = (float)(y + height); + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + + // Box + uint8_t a = (s_currentColor >> 24) & 0xFF; + uint8_t r = (s_currentColor >> 16) & 0xFF; + uint8_t g = (s_currentColor >> 8) & 0xFF; + uint8_t b = s_currentColor & 0xFF; + SDL_SetRenderDrawColor(renderer, r, g, b, a); + SDL_FRect rect{ sx, sy, (float)width, (float)height }; + SDL_RenderRect(renderer, &rect); + + // Dark color (top and left) + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderLine(renderer, sx, sy, ex, sy); + SDL_RenderLine(renderer, sx, sy, sx, ey); + + // Light color (bottom and right) + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderLine(renderer, sx, ey, ex, ey); + SDL_RenderLine(renderer, ex, sy, ex, ey); + } return Py_BuildNone(); } @@ -448,6 +513,35 @@ static PyObject* grpRenderUpButton(PyObject*, PyObject* poArgs) { int x = 0, y = 0, width = 0, height = 0; if (!PyTuple_GetInteger(poArgs, 0, &x) || !PyTuple_GetInteger(poArgs, 1, &y) || !PyTuple_GetInteger(poArgs, 2, &width) || !PyTuple_GetInteger(poArgs, 3, &height)) return Py_BuildException(); + + auto* renderer = CGraphicDevice::Instance().GetRenderer(); + if (renderer && width > 0 && height > 0) { + float sx = (float)x; + float sy = (float)y; + float ex = (float)(x + width); + float ey = (float)(y + height); + + SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); + + // Box + uint8_t a = (s_currentColor >> 24) & 0xFF; + uint8_t r = (s_currentColor >> 16) & 0xFF; + uint8_t g = (s_currentColor >> 8) & 0xFF; + uint8_t b = s_currentColor & 0xFF; + SDL_SetRenderDrawColor(renderer, r, g, b, a); + SDL_FRect rect{ sx, sy, (float)width, (float)height }; + SDL_RenderRect(renderer, &rect); + + // Light color (top and left) + SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255); + SDL_RenderLine(renderer, sx, sy, ex, sy); + SDL_RenderLine(renderer, sx, sy, sx, ey); + + // Dark color (bottom and right) + SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); + SDL_RenderLine(renderer, sx, ey, ex, ey); + SDL_RenderLine(renderer, ex, sy, ex, ey); + } return Py_BuildNone(); } diff --git a/src/python_minimap.cpp b/src/python_minimap.cpp index 372126ab..1fa68633 100644 --- a/src/python_minimap.cpp +++ b/src/python_minimap.cpp @@ -304,7 +304,49 @@ void CPythonMiniMap::Render(float fScreenX, float fScreenY) m_fScreenY = fScreenY; __SetPosition(); } - // The minimap texture quads, cover filter, marks and waypoint icons are not drawn. + + for (const auto& rPosition : m_OtherPCPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + for (const auto& rPosition : m_PartyPCPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + for (const auto& rPosition : m_NPCPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + for (const auto& rPosition : m_MonsterPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + for (const auto& rPosition : m_WarpPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + for (const auto& rPosition : m_OfflineShopPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + for (const auto& rPosition : m_BossPositionVector) + { + m_BossMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_BossMark.Render(); + } + for (const auto& rPosition : m_MetinPositionVector) + { + m_WhiteMark.SetPosition(rPosition.m_fX, rPosition.m_fY); + m_WhiteMark.Render(); + } + + m_PlayerMark.Render(); } void CPythonMiniMap::SetScale(float fScale) @@ -634,7 +676,34 @@ void CPythonMiniMap::RenderAtlas(float fScreenX, float fScreenY) m_fAtlasScreenX = fScreenX; m_fAtlasScreenY = fScreenY; } - // The atlas image, marks, waypoints, guild areas and player mark are not drawn. + + m_AtlasImageInstance.SetPosition(m_fAtlasScreenX, m_fAtlasScreenY); + m_AtlasImageInstance.Render(); + + for (const auto& rAtlasMarkInfo : m_AtlasNPCInfoVector) + { + m_WhiteMark.SetPosition(rAtlasMarkInfo.m_fScreenX, rAtlasMarkInfo.m_fScreenY); + m_WhiteMark.Render(); + } + for (const auto& rAtlasMarkInfo : m_AtlasWarpInfoVector) + { + m_WhiteMark.SetPosition(rAtlasMarkInfo.m_fScreenX, rAtlasMarkInfo.m_fScreenY); + m_WhiteMark.Render(); + } + for (const auto& rAtlasMarkInfo : m_AtlasBossInfoVector) + { + m_BossMark.SetPosition(rAtlasMarkInfo.m_fScreenX, rAtlasMarkInfo.m_fScreenY); + m_BossMark.Render(); + } + for (const auto& rAtlasMarkInfo : m_AtlasWayPointInfoVector) + { + if (rAtlasMarkInfo.m_fScreenX <= 0.0f || rAtlasMarkInfo.m_fScreenY <= 0.0f) + continue; + m_WhiteMark.SetPosition(rAtlasMarkInfo.m_fScreenX, rAtlasMarkInfo.m_fScreenY); + m_WhiteMark.Render(); + } + + m_AtlasPlayerMark.Render(); } bool CPythonMiniMap::GetPickedInstanceInfo(float fScreenX, float fScreenY, std::string& rReturnName, float* pReturnPosX, float* pReturnPosY, uint32_t* pdwTextColor)