Merge pull request #112 from SunTrustDev/bugfix/map-markers-uniform-scaling

This commit is contained in:
rtw1x1
2026-02-18 15:50:41 +00:00
committed by GitHub
5 changed files with 105 additions and 15 deletions

View File

@@ -2,4 +2,5 @@
#define ENABLE_ENERGY_SYSTEM #define ENABLE_ENERGY_SYSTEM
#define ENABLE_DRAGON_SOUL_SYSTEM #define ENABLE_DRAGON_SOUL_SYSTEM
#define ENABLE_NEW_EQUIPMENT_SYSTEM #define ENABLE_NEW_EQUIPMENT_SYSTEM
#define ENABLE_ATLAS_SCALE
//#define ENABLE_DISCORD_RPC //#define ENABLE_DISCORD_RPC

View File

@@ -1484,4 +1484,10 @@ void initapp()
#else #else
PyModule_AddIntConstant(poModule, "ENABLE_NEW_EQUIPMENT_SYSTEM", 0); PyModule_AddIntConstant(poModule, "ENABLE_NEW_EQUIPMENT_SYSTEM", 0);
#endif #endif
#ifdef ENABLE_ATLAS_SCALE
PyModule_AddIntConstant(poModule, "ENABLE_ATLAS_SCALE", 1);
#else
PyModule_AddIntConstant(poModule, "ENABLE_ATLAS_SCALE", 0);
#endif
} }

View File

@@ -711,8 +711,9 @@ void CPythonMiniMap::RegisterAtlasMark(BYTE byType, const char * c_szName, long
aAtlasMarkInfo.m_fY = float(ly); aAtlasMarkInfo.m_fY = float(ly);
aAtlasMarkInfo.m_strText = c_szName; aAtlasMarkInfo.m_strText = c_szName;
aAtlasMarkInfo.m_fScreenX = aAtlasMarkInfo.m_fX / m_fAtlasMaxX * m_fAtlasImageSizeX - (float)m_WhiteMark.GetWidth() / 2.0f; __GlobalPositionToAtlasPosition(lx, ly, &aAtlasMarkInfo.m_fScreenX, &aAtlasMarkInfo.m_fScreenY);
aAtlasMarkInfo.m_fScreenY = aAtlasMarkInfo.m_fY / m_fAtlasMaxY * m_fAtlasImageSizeY - (float)m_WhiteMark.GetHeight() / 2.0f; aAtlasMarkInfo.m_fScreenX -= (float)m_WhiteMark.GetWidth() / 2.0f;
aAtlasMarkInfo.m_fScreenY -= (float)m_WhiteMark.GetHeight() / 2.0f;
switch(byType) switch(byType)
{ {
@@ -807,6 +808,22 @@ void CPythonMiniMap::DeleteTarget(int iID)
RemoveWayPoint(iID); RemoveWayPoint(iID);
} }
void CPythonMiniMap::SetAtlasScale(float fx, float fy)
{
m_AtlasImageInstance.SetScale(fx, fy);
m_fAtlasImageSizeX = float(m_AtlasImageInstance.GetWidth()) * fx;
m_fAtlasImageSizeY = float(m_AtlasImageInstance.GetHeight()) * fy;
ComputeAtlasCenteringOffsets();
}
void CPythonMiniMap::ClearAtlasMarks()
{
ClearAtlasMarkInfo();
ClearGuildArea();
}
bool CPythonMiniMap::LoadAtlas() bool CPythonMiniMap::LoadAtlas()
{ {
CPythonBackground& rkBG=CPythonBackground::Instance(); CPythonBackground& rkBG=CPythonBackground::Instance();
@@ -850,16 +867,42 @@ bool CPythonMiniMap::LoadAtlas()
m_fAtlasImageSizeX = (float) m_AtlasImageInstance.GetWidth(); m_fAtlasImageSizeX = (float) m_AtlasImageInstance.GetWidth();
m_fAtlasImageSizeY = (float) m_AtlasImageInstance.GetHeight(); m_fAtlasImageSizeY = (float) m_AtlasImageInstance.GetHeight();
ComputeAtlasCenteringOffsets();
ClearAtlasMarks();
if (m_bShowAtlas) if (m_bShowAtlas)
OpenAtlasWindow(); OpenAtlasWindow();
return true; return true;
} }
void CPythonMiniMap::ComputeAtlasCenteringOffsets()
{
float fScaleX = m_fAtlasImageSizeX / m_fAtlasMaxX;
float fScaleY = m_fAtlasImageSizeY / m_fAtlasMaxY;
float fUniformScale = std::min(fScaleX, fScaleY);
float fScaledMapWidth = m_fAtlasMaxX * fUniformScale;
float fScaledMapHeight = m_fAtlasMaxY * fUniformScale;
m_fAtlasOffsetX = (m_fAtlasImageSizeX - fScaledMapWidth) * 0.5f;
m_fAtlasOffsetY = (m_fAtlasImageSizeY - fScaledMapHeight) * 0.5f;
}
float CPythonMiniMap::GetAtlasUniformScale() const
{
float fScaleX = m_fAtlasImageSizeX / m_fAtlasMaxX;
float fScaleY = m_fAtlasImageSizeY / m_fAtlasMaxY;
return std::min(fScaleX, fScaleY);
}
void CPythonMiniMap::__GlobalPositionToAtlasPosition(long lx, long ly, float * pfx, float * pfy) void CPythonMiniMap::__GlobalPositionToAtlasPosition(long lx, long ly, float * pfx, float * pfy)
{ {
*pfx = lx / m_fAtlasMaxX * m_fAtlasImageSizeX; float fUniformScale = GetAtlasUniformScale();
*pfy = ly / m_fAtlasMaxY * m_fAtlasImageSizeY;
*pfx = lx * fUniformScale + m_fAtlasOffsetX;
*pfy = ly * fUniformScale + m_fAtlasOffsetY;
} }
void CPythonMiniMap::UpdateAtlas() void CPythonMiniMap::UpdateAtlas()
@@ -878,8 +921,10 @@ void CPythonMiniMap::UpdateAtlas()
while(fRotation < 0.0f) while(fRotation < 0.0f)
fRotation += 360.0f; fRotation += 360.0f;
m_AtlasPlayerMark.SetPosition(kInstPos.x / m_fAtlasMaxX * m_fAtlasImageSizeX - (float)m_AtlasPlayerMark.GetWidth() / 2.0f, float fPlayerX, fPlayerY;
kInstPos.y / m_fAtlasMaxY * m_fAtlasImageSizeY - (float)m_AtlasPlayerMark.GetHeight() / 2.0f); __GlobalPositionToAtlasPosition((long)kInstPos.x, (long)kInstPos.y, &fPlayerX, &fPlayerY);
m_AtlasPlayerMark.SetPosition(fPlayerX - (float)m_AtlasPlayerMark.GetWidth() / 2.0f,
fPlayerY - (float)m_AtlasPlayerMark.GetHeight() / 2.0f);
m_AtlasPlayerMark.SetRotation(fRotation); m_AtlasPlayerMark.SetRotation(fRotation);
} }
@@ -1057,14 +1102,25 @@ bool CPythonMiniMap::GetPickedInstanceInfo(float fScreenX, float fScreenY, std::
} }
void CPythonMiniMap::__AtlasPositionToGlobalPosition(float fAtlasX, float fAtlasY, float* pfWorldX, float* pfWorldY) const
{
float fReverseScale = 1.0f / GetAtlasUniformScale();
*pfWorldX = (fAtlasX - m_fAtlasOffsetX) * fReverseScale;
*pfWorldY = (fAtlasY - m_fAtlasOffsetY) * fReverseScale;
}
bool CPythonMiniMap::GetAtlasInfo(float fScreenX, float fScreenY, std::string & rReturnString, float * pReturnPosX, float * pReturnPosY, DWORD * pdwTextColor, DWORD * pdwGuildID) bool CPythonMiniMap::GetAtlasInfo(float fScreenX, float fScreenY, std::string & rReturnString, float * pReturnPosX, float * pReturnPosY, DWORD * pdwTextColor, DWORD * pdwGuildID)
{ {
float fRealX = (fScreenX - m_fAtlasScreenX) * (m_fAtlasMaxX / m_fAtlasImageSizeX); float fLocalX = fScreenX - m_fAtlasScreenX;
float fRealY = (fScreenY - m_fAtlasScreenY) * (m_fAtlasMaxY / m_fAtlasImageSizeY); float fLocalY = fScreenY - m_fAtlasScreenY;
//((float) CTerrainImpl::CELLSCALE) * 10.0f float fRealX, fRealY;
float fCheckWidth = (m_fAtlasMaxX / m_fAtlasImageSizeX) * 5.0f; __AtlasPositionToGlobalPosition(fLocalX, fLocalY, &fRealX, &fRealY);
float fCheckHeight = (m_fAtlasMaxY / m_fAtlasImageSizeY) * 5.0f;
float fReverseScale = 1.0f / GetAtlasUniformScale();
float fCheckWidth = fReverseScale * 5.0f;
float fCheckHeight = fReverseScale * 5.0f;
CInstanceBase * pkInst = CPythonCharacterManager::Instance().GetMainInstancePtr(); CInstanceBase * pkInst = CPythonCharacterManager::Instance().GetMainInstancePtr();
@@ -1242,8 +1298,7 @@ void CPythonMiniMap::__UpdateWayPoint(TAtlasMarkInfo * pkInfo, int ix, int iy)
{ {
pkInfo->m_fX = float(ix); pkInfo->m_fX = float(ix);
pkInfo->m_fY = float(iy); pkInfo->m_fY = float(iy);
pkInfo->m_fScreenX = pkInfo->m_fX / m_fAtlasMaxX * m_fAtlasImageSizeX; __GlobalPositionToAtlasPosition(ix, iy, &pkInfo->m_fScreenX, &pkInfo->m_fScreenY);
pkInfo->m_fScreenY = pkInfo->m_fY / m_fAtlasMaxY * m_fAtlasImageSizeY;
} }
// WayPoint // WayPoint
@@ -1382,6 +1437,9 @@ void CPythonMiniMap::__Initialize()
m_fAtlasScreenX = 0.0f; m_fAtlasScreenX = 0.0f;
m_fAtlasScreenY = 0.0f; m_fAtlasScreenY = 0.0f;
m_fAtlasOffsetX = 0.0f;
m_fAtlasOffsetY = 0.0f;
m_dwAtlasBaseX = 0; m_dwAtlasBaseX = 0;
m_dwAtlasBaseY = 0; m_dwAtlasBaseY = 0;

View File

@@ -81,6 +81,10 @@ class CPythonMiniMap : public CScreen, public CSingleton<CPythonMiniMap>
void UnregisterAtlasWindow(); void UnregisterAtlasWindow();
void OpenAtlasWindow(); void OpenAtlasWindow();
void SetAtlasCenterPosition(int x, int y); void SetAtlasCenterPosition(int x, int y);
void SetAtlasScale(float fx, float fy);
// Atlas Marks
void ClearAtlasMarks();
// NPC List // NPC List
void ClearAtlasMarkInfo(); void ClearAtlasMarkInfo();
@@ -106,6 +110,9 @@ class CPythonMiniMap : public CScreen, public CSingleton<CPythonMiniMap>
void __RenderTargetMark(int ixCenter, int iyCenter); void __RenderTargetMark(int ixCenter, int iyCenter);
void __GlobalPositionToAtlasPosition(long lx, long ly, float * pfx, float * pfy); void __GlobalPositionToAtlasPosition(long lx, long ly, float * pfx, float * pfy);
void __AtlasPositionToGlobalPosition(float fAtlasX, float fAtlasY, float* pfWorldX, float* pfWorldY) const;
void ComputeAtlasCenteringOffsets();
float GetAtlasUniformScale() const;
protected: protected:
// Atlas // Atlas
@@ -208,7 +215,7 @@ class CPythonMiniMap : public CScreen, public CSingleton<CPythonMiniMap>
D3DXMATRIX m_matMiniMapCover; D3DXMATRIX m_matMiniMapCover;
bool m_bShowAtlas; bool m_bShowAtlas;
CGraphicImageInstance m_AtlasImageInstance; CGraphicExpandedImageInstance m_AtlasImageInstance;
D3DXMATRIX m_matWorldAtlas; D3DXMATRIX m_matWorldAtlas;
CGraphicExpandedImageInstance m_AtlasPlayerMark; CGraphicExpandedImageInstance m_AtlasPlayerMark;
@@ -217,6 +224,9 @@ class CPythonMiniMap : public CScreen, public CSingleton<CPythonMiniMap>
DWORD m_dwAtlasBaseX; DWORD m_dwAtlasBaseX;
DWORD m_dwAtlasBaseY; DWORD m_dwAtlasBaseY;
float m_fAtlasOffsetX;
float m_fAtlasOffsetY;
float m_fAtlasMaxX; float m_fAtlasMaxX;
float m_fAtlasMaxY; float m_fAtlasMaxY;

View File

@@ -286,6 +286,20 @@ PyObject* miniMapUnregisterAtlasWindow(PyObject* poSelf, PyObject* poArgs)
return Py_BuildNone(); return Py_BuildNone();
} }
PyObject* miniMapSetAtlasScale(PyObject* poSelf, PyObject* poArgs)
{
float fx;
if (!PyTuple_GetFloat(poArgs, 0, &fx))
return Py_BuildException();
float fy;
if (!PyTuple_GetFloat(poArgs, 1, &fy))
return Py_BuildException();
CPythonMiniMap::Instance().SetAtlasScale(fx, fy);
return Py_BuildNone();
}
PyObject* miniMapGetGuildAreaID(PyObject* poSelf, PyObject* poArgs) PyObject* miniMapGetGuildAreaID(PyObject* poSelf, PyObject* poArgs)
{ {
float fx; float fx;
@@ -339,6 +353,7 @@ void initMiniMap()
{ "UnregisterAtlasWindow", miniMapUnregisterAtlasWindow, METH_VARARGS }, { "UnregisterAtlasWindow", miniMapUnregisterAtlasWindow, METH_VARARGS },
{ "GetGuildAreaID", miniMapGetGuildAreaID, METH_VARARGS }, { "GetGuildAreaID", miniMapGetGuildAreaID, METH_VARARGS },
{ "SetAtlasScale", miniMapSetAtlasScale, METH_VARARGS },
{ NULL, NULL }, { NULL, NULL },
}; };