[C++] Yeni UI Class'ları (İşinize Çok Yarayacak)

  • Konbuyu başlatan Konbuyu başlatan Admin
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 0
  • Görüntüleme Görüntüleme 74

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Merhaba arkadaşlar


BU KODLARLA YAPABİLECEĞİNİZ 1. SİSTEM




  1. <li data-xf-list-type="ol">CMoveTextLine - Yutnori'de Kullanılan <li data-xf-list-type="ol">CMoveImageBox - MonsterCard, Rumi ve CatchKing'te <li data-xf-list-type="ol">CMoveScaleImageBox - Yutnori'de Kullanılır.

Şimdi Gelelim Kodlar'a Örnek Video'da Göstereceğim O Video'da Göreceğiniz Simgelerin Gidişlerini Bu Vereceğim Kodlarla Yapabileceksiniz.


1.) EterPythonLib \ PythonWindow.h dosyasını açın ve UI ad alanında istediğiniz yere aşağıdaki sınıf tanımlarını ekleyin:


Kod:
class CMoveTextLine : public CTextLine     {     public:         CMoveTextLine(PyObject * ppyObject);         virtual ~CMoveTextLine();     public:         static DWORD Type();         void SetMoveSpeed(float fSpeed);         void SetMovePosition(float fDstX, float fDstY);         bool GetMove();         void MoveStart();         void MoveStop();     protected:         void OnUpdate();         void OnRender();         void OnEndMove();         void OnChangePosition();         BOOL OnIsType(DWORD dwType);         D3DXVECTOR2 m_v2SrcPos, m_v2DstPos, m_v2NextPos, m_v2Direction, m_v2NextDistance;         float m_fDistance, m_fMoveSpeed;         bool m_bIsMove;     };     class CMoveImageBox : public CImageBox     {         public:             CMoveImageBox(PyObject * ppyObject);             virtual ~CMoveImageBox();             static DWORD Type();             void SetMoveSpeed(float fSpeed);             void SetMovePosition(float fDstX, float fDstY);             bool GetMove();             void MoveStart();             void MoveStop();         protected:             virtual void OnCreateInstance();             virtual void OnDestroyInstance();             virtual void OnUpdate();             virtual void OnRender();             virtual void OnEndMove();             BOOL OnIsType(DWORD dwType);             D3DXVECTOR2 m_v2SrcPos, m_v2DstPos, m_v2NextPos, m_v2Direction, m_v2NextDistance;             float m_fDistance, m_fMoveSpeed;             bool m_bIsMove;     };     class CMoveScaleImageBox : public CMoveImageBox     {         public:             CMoveScaleImageBox(PyObject * ppyObject);             virtual ~CMoveScaleImageBox();             static DWORD Type();             void SetMaxScale(float fMaxScale);             void SetMaxScaleRate(float fMaxScaleRate);             void SetScalePivotCenter(bool bScalePivotCenter);         protected:             virtual void OnCreateInstance();             virtual void OnDestroyInstance();             virtual void OnUpdate();             BOOL OnIsType(DWORD dwType);             float m_fMaxScale, m_fMaxScaleRate, m_fScaleDistance, m_fAdditionalScale;             D3DXVECTOR2 m_v2CurScale;     };


2.) EterPythonLib \ PythonWindow.cpp dosyasını açın ve yeni sınıfların işlevlerini istediğiniz yere yapıştırın:


Kod:
/// CMoveTextLine     CMoveTextLine::CMoveTextLine(PyObject * ppyObject) :         CTextLine(ppyObject),         m_v2SrcPos(0.0f, 0.0f),         m_v2DstPos(0.0f, 0.0f),         m_v2NextPos(0.0f, 0.0f),         m_v2Direction(0.0f, 0.0f),         m_v2NextDistance(0.0f, 0.0f),         m_fDistance(0.0f),         m_fMoveSpeed(10.0f),         m_bIsMove(false)     {     }     CMoveTextLine::~CMoveTextLine()     {         m_TextInstance.Destroy();     }     DWORD CMoveTextLine::Type()     {         static DWORD s_dwType = GetCRC32("CMoveTextLine", strlen("CMoveTextLine"));         return (s_dwType);     }     BOOL CMoveTextLine::OnIsType(DWORD dwType)     {         if (CMoveTextLine::Type() == dwType)             return TRUE;         return FALSE;     }     void CMoveTextLine::SetMoveSpeed(float fSpeed)     {         m_fMoveSpeed = fSpeed;     }     bool CMoveTextLine::GetMove()     {         return m_bIsMove;     }     void CMoveTextLine::MoveStart()     {         m_bIsMove = true;         m_v2NextPos = m_v2SrcPos;     }     void CMoveTextLine::MoveStop()     {         m_bIsMove = false;     }     void CMoveTextLine::OnEndMove()     {         PyCallClassMemberFunc(m_poHandler, "OnEndMove", BuildEmptyTuple());     }     void CMoveTextLine::OnChangePosition()     {         m_TextInstance.SetPosition((GetDefaultCodePage() == CP_1256) ? m_rect.right : m_rect.left, m_rect.top);     }     void CMoveTextLine::SetMovePosition(float fDstX, float fDstY)     {         if (fDstX != m_v2DstPos.x || fDstY != m_v2DstPos.y || m_rect.left != m_v2SrcPos.x || m_rect.top != m_v2SrcPos.y)         {             m_v2SrcPos.x = m_rect.left;             m_v2SrcPos.y = m_rect.top;             m_v2DstPos.x = fDstX;             m_v2DstPos.y = fDstY;             D3DXVec2Subtract(&amp;m_v2Direction, &amp;m_v2DstPos, &amp;m_v2SrcPos);             m_fDistance = (m_v2Direction.y*m_v2Direction.y + m_v2Direction.x*m_v2Direction.x);             D3DXVec2Normalize(&amp;m_v2Direction, &amp;m_v2Direction);             if (m_v2SrcPos != m_v2NextPos)             {                 float fDist = sqrtf(m_v2NextDistance.x*m_v2NextDistance.x + m_v2NextDistance.y*m_v2NextDistance.y);                 m_v2NextPos = m_v2Direction * fDist;                 m_TextInstance.SetPosition(m_v2NextPos.x, m_v2NextPos.y);             }         }     }     void CMoveTextLine::OnUpdate()     {         if (IsShow() &amp;&amp; GetMove())         {             D3DXVec2Add(&amp;m_v2NextPos, &amp;m_v2NextPos, &amp;(m_v2Direction * m_fMoveSpeed));             D3DXVec2Subtract(&amp;m_v2NextDistance, &amp;m_v2NextPos, &amp;m_v2SrcPos);             float fNextDistance = m_v2NextDistance.y * m_v2NextDistance.y + m_v2NextDistance.x * m_v2NextDistance.x;             if (fNextDistance &gt;= m_fDistance)             {                 m_v2NextPos = m_v2DstPos;                 MoveStop();                 OnEndMove();             }             m_TextInstance.SetPosition(m_v2NextPos.x, m_v2NextPos.y);             m_TextInstance.Update();         }     }     void CMoveTextLine::OnRender()     {         if (IsShow())             m_TextInstance.Render();     }     /// CMoveImageBox     CMoveImageBox::CMoveImageBox(PyObject * ppyObject) :         CImageBox(ppyObject),         m_v2SrcPos(0.0f, 0.0f),         m_v2DstPos(0.0f, 0.0f),         m_v2NextPos(0.0f, 0.0f),         m_v2Direction(0.0f, 0.0f),         m_v2NextDistance(0.0f, 0.0f),         m_fDistance(0.0f),         m_fMoveSpeed(10.0f),         m_bIsMove(false)     {     }     CMoveImageBox::~CMoveImageBox()     {         OnDestroyInstance();     }     void CMoveImageBox::OnCreateInstance()     {         OnDestroyInstance();         m_pImageInstance = CGraphicImageInstance::New();     }     void CMoveImageBox::OnDestroyInstance()     {         if (m_pImageInstance)         {             CGraphicImageInstance::Delete(m_pImageInstance);             m_pImageInstance = NULL;         }     }     DWORD CMoveImageBox::Type()     {         static DWORD s_dwType = GetCRC32("CMoveImageBox", strlen("CMoveImageBox"));         return (s_dwType);     }     BOOL CMoveImageBox::OnIsType(DWORD dwType)     {         if (CMoveImageBox::Type() == dwType)             return TRUE;         return FALSE;     }     void CMoveImageBox::OnEndMove()     {         PyCallClassMemberFunc(m_poHandler, "OnEndMove", BuildEmptyTuple());     }     void CMoveImageBox::SetMovePosition(float fDstX, float fDstY)     {         if (fDstX != m_v2DstPos.x || fDstY != m_v2DstPos.y || m_rect.left != m_v2SrcPos.x || m_rect.top != m_v2SrcPos.y)         {             m_v2SrcPos.x = m_rect.left;             m_v2SrcPos.y = m_rect.top;             m_v2DstPos.x = fDstX;             m_v2DstPos.y = fDstY;             D3DXVec2Subtract(&amp;m_v2Direction, &amp;m_v2DstPos, &amp;m_v2SrcPos);             m_fDistance = (m_v2Direction.x*m_v2Direction.x + m_v2Direction.y*m_v2Direction.y);             D3DXVec2Normalize(&amp;m_v2Direction, &amp;m_v2Direction);             if (m_pImageInstance &amp;&amp; m_v2SrcPos != m_v2NextPos)             {                 float fDist = sqrtf(m_v2NextDistance.x*m_v2NextDistance.x + m_v2NextDistance.y*m_v2NextDistance.y);                 m_v2NextPos = m_v2Direction * fDist;                 m_pImageInstance-&gt;SetPosition(m_v2NextPos.x, m_v2NextPos.y);             }         }     }     void CMoveImageBox::SetMoveSpeed(float fSpeed)     {         m_fMoveSpeed = fSpeed;     }     void CMoveImageBox::MoveStart()     {         m_bIsMove = true;         m_v2NextPos = m_v2SrcPos;     }     void CMoveImageBox::MoveStop()     {         m_bIsMove = false;     }     bool CMoveImageBox::GetMove()     {         return m_bIsMove;     }     void CMoveImageBox::OnUpdate()     {         if (!m_pImageInstance)             return;         if (IsShow() &amp;&amp; GetMove())         {             D3DXVec2Add(&amp;m_v2NextPos, &amp;m_v2NextPos, &amp;(m_v2Direction * m_fMoveSpeed));             D3DXVec2Subtract(&amp;m_v2NextDistance, &amp;m_v2NextPos, &amp;m_v2SrcPos);             float fNextDistance = (m_v2NextDistance.x*m_v2NextDistance.x + m_v2NextDistance.y*m_v2NextDistance.y);             if (fNextDistance &gt;= m_fDistance)             {                 m_v2NextPos = m_v2DstPos;                 MoveStop();                 OnEndMove();             }             m_pImageInstance-&gt;SetPosition(m_v2NextPos.x, m_v2NextPos.y);         }     }     void CMoveImageBox::OnRender()     {         if (!m_pImageInstance)             return;         if (IsShow())             m_pImageInstance-&gt;Render();     }     /// CMoveScaleImageBox     CMoveScaleImageBox::CMoveScaleImageBox(PyObject * ppyObject) :         CMoveImageBox(ppyObject),         m_fMaxScale(1.0f),         m_fMaxScaleRate(1.0f),         m_fScaleDistance(0.0f),         m_fAdditionalScale(0.0f),         m_v2CurScale(1.0f, 1.0f)     {     }     CMoveScaleImageBox::~CMoveScaleImageBox()     {         OnDestroyInstance();     }     void CMoveScaleImageBox::OnCreateInstance()     {         OnDestroyInstance();         m_pImageInstance = CGraphicImageInstance::New();     }     void CMoveScaleImageBox::OnDestroyInstance()     {         if (m_pImageInstance)         {             CGraphicImageInstance::Delete(m_pImageInstance);             m_pImageInstance = NULL;         }     }     DWORD CMoveScaleImageBox::Type()     {         static DWORD s_dwType = GetCRC32("CMoveScaleImageBox", strlen("CMoveScaleImageBox"));         return (s_dwType);     }     BOOL CMoveScaleImageBox::OnIsType(DWORD dwType)     {         if (CMoveScaleImageBox::Type() == dwType)             return TRUE;         return FALSE;     }     void CMoveScaleImageBox::SetMaxScale(float fMaxScale)     {         m_fMaxScale = fMaxScale;     }     void CMoveScaleImageBox::SetMaxScaleRate(float fMaxScaleRate)     {         m_fMaxScaleRate = fMaxScaleRate;         float fDistanceRate = m_fDistance * fMaxScaleRate;         m_fScaleDistance = fDistanceRate;         m_v2CurScale = m_pImageInstance-&gt;GetScale();         float fDiffScale = m_fMaxScale - m_v2CurScale.x;         m_fAdditionalScale = fDiffScale / (sqrtf(fDistanceRate) / m_fMoveSpeed);     }     void CMoveScaleImageBox::SetScalePivotCenter(bool bScalePivotCenter)     {         if (m_pImageInstance)             m_pImageInstance-&gt;SetScalePivotCenter(bScalePivotCenter);     }     void CMoveScaleImageBox::OnUpdate()     {         if (!m_pImageInstance)             return;         if (IsShow() &amp;&amp; GetMove())         {             D3DXVec2Add(&amp;m_v2NextPos, &amp;m_v2NextPos, &amp;(m_v2Direction * m_fMoveSpeed));             D3DXVec2Subtract(&amp;m_v2NextDistance, &amp;m_v2NextPos, &amp;m_v2SrcPos);             float fNextDistance = (m_v2NextDistance.x*m_v2NextDistance.x + m_v2NextDistance.y*m_v2NextDistance.y);             if (m_fScaleDistance &lt; fNextDistance)                 m_fAdditionalScale *= -1.0f;                       D3DXVECTOR2 v2NewScale;             D3DXVec2Add(&amp;v2NewScale, &amp;m_pImageInstance-&gt;GetScale(), &amp;D3DXVECTOR2(m_fAdditionalScale, m_fAdditionalScale));             if (m_fMaxScale &lt; v2NewScale.x)                 v2NewScale = D3DXVECTOR2(m_fMaxScale, m_fMaxScale);             if (m_v2CurScale.x &gt; v2NewScale.x)                 v2NewScale = m_v2CurScale;             m_pImageInstance-&gt;SetScale(v2NewScale);             if (fNextDistance &gt;= m_fDistance)             {                 m_pImageInstance-&gt;SetScale(m_v2CurScale);                 m_v2NextPos = m_v2DstPos;                 MoveStop();                 OnEndMove();             }             m_pImageInstance-&gt;SetPosition(m_v2NextPos.x, m_v2NextPos.y);         }     }


3.1.) EterPythonLib \ PythonWindowManager.h dosyasını açın ve enum'un altına ekleyin:

Kod:
WT_MOVE_TEXTLINE,                 WT_MOVE_IMAGEBOX,                 WT_MOVE_SCALEIMAGEBOX,

Şunuda Enum'un bitişinin alt kısmına ekleyin :

Kod:
CWindow *    RegisterMoveTextLine(PyObject * po, const char * c_szLayer);             CWindow *    RegisterMoveImageBox(PyObject * po, const char * c_szLayer);             CWindow *    RegisterMoveScaleImageBox(PyObject * po, const char * c_szLayer);


4.1.) EterPythonLib \ Py thonWindowManager.cpp dosyasını aç ve ARAT :

Kod:
CWindow *    CWindowManager::__NewWindow(PyObject * po, DWORD dwWndType)


alt kısımlarına ekleyin :

Kod:
case WT_MOVE_TEXTLINE:                 return new CMoveTextLine(po);                 break;             case WT_MOVE_IMAGEBOX:                 return new CMoveImageBox(po);                 break;             case WT_MOVE_SCALEIMAGEBOX:                 return new CMoveScaleImageBox(po);                 break;


Aynı Şekilde Bunlarıda En Alt'a Yada Ortalara Ekleyin İstediğiniz Yere:

Kod:
CWindow * CWindowManager::RegisterMoveTextLine(PyObject * po, const char * c_szLayer)     {         assert(m_LayerWindowMap.end() != m_LayerWindowMap.find(c_szLayer));         CWindow * pWin = new CMoveTextLine(po);         m_LayerWindowMap[c_szLayer]-&gt;AddChild(pWin); #ifdef __WINDOW_LEAK_CHECK__         gs_kSet_pkWnd.insert(pWin); #endif         return pWin;     }     CWindow * CWindowManager::RegisterMoveImageBox(PyObject * po, const char * c_szLayer)     {         assert(m_LayerWindowMap.end() != m_LayerWindowMap.find(c_szLayer));         CWindow * pWin = new CMoveImageBox(po);         m_LayerWindowMap[c_szLayer]-&gt;AddChild(pWin); #ifdef __WINDOW_LEAK_CHECK__         gs_kSet_pkWnd.insert(pWin); #endif         return pWin;     }     CWindow * CWindowManager::RegisterMoveScaleImageBox(PyObject * po, const char * c_szLayer)     {         assert(m_LayerWindowMap.end() != m_LayerWindowMap.find(c_szLayer));         CWindow * pWin = new CMoveScaleImageBox(po);         m_LayerWindowMap[c_szLayer]-&gt;AddChild(pWin); #ifdef __WINDOW_LEAK_CHECK__         gs_kSet_pkWnd.insert(pWin); #endif         return pWin;     }


5.1.) ETerPythonLib \ PythonWindowManagerModule.cpp'yi açın ve aşağıdaki işlevleri istediğiniz yere ekleyin:

Kod:
// MoveTextLine PyObject * wndMgrRegisterMoveTextLine(PyObject * poSelf, PyObject * poArgs) {     PyObject * po;     if (!PyTuple_GetObject(poArgs, 0, &amp;po))         return Py_BuildException();     char * szLayer;     if (!PyTuple_GetString(poArgs, 1, &amp;szLayer))         return Py_BuildException();     UI::CWindow * pWindow = UI::CWindowManager::Instance().RegisterMoveTextLine(po, szLayer);     return Py_BuildValue("i", pWindow); } // MoveImageBox PyObject * wndMgrRegisterMoveImageBox(PyObject * poSelf, PyObject * poArgs) {     PyObject * po;     if (!PyTuple_GetObject(poArgs, 0, &amp;po))         return Py_BuildException();     char * szLayer;     if (!PyTuple_GetString(poArgs, 1, &amp;szLayer))         return Py_BuildException();     UI::CWindow * pWindow = UI::CWindowManager::Instance().RegisterMoveImageBox(po, szLayer);     return Py_BuildValue("i", pWindow); } // MoveScaleImageBox PyObject * wndMgrRegisterMoveScaleImageBox(PyObject * poSelf, PyObject * poArgs) {     PyObject * po;     if (!PyTuple_GetObject(poArgs, 0, &amp;po))         return Py_BuildException();     char * szLayer;     if (!PyTuple_GetString(poArgs, 1, &amp;szLayer))         return Py_BuildException();     UI::CWindow * pWindow = UI::CWindowManager::Instance().RegisterMoveScaleImageBox(po, szLayer);     return Py_BuildValue("i", pWindow); } PyObject * wndSetMoveSpeed(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     float fSpeed;     if (!PyTuple_GetFloat(poArgs, 1, &amp;fSpeed))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveImageBox::Type()) || pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveImageBox*)pWindow)-&gt;SetMoveSpeed(fSpeed);     else if (pWindow-&gt;IsType(UI::CMoveTextLine::Type()))         ((UI::CMoveTextLine*)pWindow)-&gt;SetMoveSpeed(fSpeed);     return Py_BuildNone(); } PyObject * wndSetMovePosition(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     float fDstX(0.0f), fDstY(0.0f);     if (!PyTuple_GetFloat(poArgs, 1, &amp;fDstX))         return Py_BuildException();     if (!PyTuple_GetFloat(poArgs, 2, &amp;fDstY))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveImageBox::Type()) || pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveImageBox*)pWindow)-&gt;SetMovePosition(fDstX, fDstY);     else if (pWindow-&gt;IsType(UI::CMoveTextLine::Type()))         ((UI::CMoveTextLine*)pWindow)-&gt;SetMovePosition(fDstX, fDstY);     return Py_BuildNone(); } PyObject * wndMoveStart(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveImageBox::Type()) || pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveImageBox*)pWindow)-&gt;MoveStart();     else if (pWindow-&gt;IsType(UI::CMoveTextLine::Type()))         ((UI::CMoveTextLine*)pWindow)-&gt;MoveStart();     return Py_BuildNone(); } PyObject * wndMoveStop(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveImageBox::Type()) || pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveImageBox*)pWindow)-&gt;MoveStop();     else if (pWindow-&gt;IsType(UI::CMoveTextLine::Type()))         ((UI::CMoveTextLine*)pWindow)-&gt;MoveStop();     return Py_BuildNone(); } PyObject * wndGetMove(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveImageBox::Type()) || pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         return Py_BuildValue("i", ((UI::CMoveImageBox*)pWindow)-&gt;GetMove());     else if (pWindow-&gt;IsType(UI::CMoveTextLine::Type()))         return Py_BuildValue("i", ((UI::CMoveTextLine*)pWindow)-&gt;GetMove());     else         return Py_BuildValue("i", 0); } PyObject * wndSetMaxScale(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     float fMaxScale = 1.0f;     if (!PyTuple_GetFloat(poArgs, 1, &amp;fMaxScale))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveScaleImageBox*)pWindow)-&gt;SetMaxScale(fMaxScale);     return Py_BuildNone(); } PyObject * wndSetMaxScaleRate(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     float fMaxScaleRate = 1.0f;     if (!PyTuple_GetFloat(poArgs, 1, &amp;fMaxScaleRate))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveScaleImageBox*)pWindow)-&gt;SetMaxScaleRate(fMaxScaleRate);     return Py_BuildNone(); } PyObject * wndSetScalePivotCenter(PyObject * poSelf, PyObject * poArgs) {     UI::CWindow * pWindow;     if (!PyTuple_GetWindow(poArgs, 0, &amp;pWindow))         return Py_BuildException();     bool bScalePivotCenter = false;     if (!PyTuple_GetBoolean(poArgs, 1, &amp;bScalePivotCenter))         return Py_BuildException();     if (pWindow-&gt;IsType(UI::CMoveScaleImageBox::Type()))         ((UI::CMoveScaleImageBox*)pWindow)-&gt;SetScalePivotCenter(bScalePivotCenter);     return Py_BuildNone(); }


Aynı Şekilde Bunlarıda "void initwndMgr()" Altına Ekleyiniz :




Kod:
{ "RegisterMoveTextLine",        wndMgrRegisterMoveTextLine,            METH_VARARGS },         { "RegisterMoveImageBox",        wndMgrRegisterMoveImageBox,            METH_VARARGS },         { "RegisterMoveScaleImageBox",    wndMgrRegisterMoveScaleImageBox,    METH_VARARGS },         { "SetMoveSpeed",                wndSetMoveSpeed,                    METH_VARARGS },         { "SetMovePosition",            wndSetMovePosition,                    METH_VARARGS },         { "MoveStart",                    wndMoveStart,                        METH_VARARGS },         { "MoveStop",                    wndMoveStop,                        METH_VARARGS },         { "GetMove",                    wndGetMove,                            METH_VARARGS },         { "SetMaxScale",                wndSetMaxScale,                        METH_VARARGS },         { "SetMaxScaleRate",            wndSetMaxScaleRate,                    METH_VARARGS },         { "SetScalePivotCenter",        wndSetScalePivotCenter,                METH_VARARGS },

6.1.)EterLib \ GrpImageInstance.h ye aşağıdaki işlevleri CGraphicImageInstance sınıfına genel olarak ekleyin:

Kod:
void SetScale(float fx, float fy);         void SetScale(D3DXVECTOR2 v2Scale);         const D3DXVECTOR2 &amp; GetScale() const;         void SetScalePercent(BYTE byPercent);         void SetScalePivotCenter(bool bScalePivotCenter);


6.2.) Bunlarıda protected Altına Ekleyin Aynı CGraphicImageInstance Sınıfı İçinde:

Kod:
D3DXVECTOR2 m_v2Scale;         bool m_bScalePivotCenter;


7.1.) EterLib \ GrpImageInstance.cpp dosyasını açın ve yeni değişkenleri CGraphicImageInstance::Initialize içine dahil edin :


Kod:
m_v2Scale.x = m_v2Scale.y = 1.0f;     m_bScalePivotCenter = false;



7.2.) Yeni fonksiyonları istediğiniz yere ekleyin:

Kod:
void CGraphicImageInstance::SetScale(float fx, float fy) {     m_v2Scale.x = fx;     m_v2Scale.y = fy; } void CGraphicImageInstance::SetScale(D3DXVECTOR2 v2Scale) {     m_v2Scale = v2Scale; } void CGraphicImageInstance::SetScalePercent(BYTE byPercent) {     m_v2Scale.x *= byPercent;     m_v2Scale.y *= byPercent; } const D3DXVECTOR2 &amp; CGraphicImageInstance::GetScale() const {     return m_v2Scale; } void CGraphicImageInstance::SetScalePivotCenter(bool bScalePivotCenter) {     m_bScalePivotCenter = bScalePivotCenter; }


7.3.) OnRender ve OnRenderCoolTime İçindeki Bunları :

Kod:
float fimgWidth = pImage-&gt;GetWidth();     float fimgHeight = pImage-&gt;GetHeight();

Bununla Değiştir :

Kod:
float fimgWidth = pImage-&gt;GetWidth() * m_v2Scale.x;     float fimgHeight = pImage-&gt;GetHeight() * m_v2Scale.y;


7.4.) Aşağıdaki İşlevleri OnRender Fonksiyonunun içine ekleyeceksiniz (CGraphicBase::SetPDTStream önce ekleyeceksiniz):

Kod:
if (m_bScalePivotCenter)     {         vertices[0].texCoord = TTextureCoordinate(eu, sv);         vertices[1].texCoord = TTextureCoordinate(su, sv);         vertices[2].texCoord = TTextureCoordinate(eu, ev);         vertices[3].texCoord = TTextureCoordinate(su, ev);     }

8.1.) Root\ui.py Açın ve Yeni Sınıfları Ekleyin:

Kod:
class MoveTextLine(TextLine):     def __init__(self):         TextLine.__init__(self)         self.end_move_event_func = None         self.end_move_event_args = None     def __del__(self):         TextLine.__del__(self)         self.end_move_event_func = None         self.end_move_event_args = None     def RegisterWindow(self, layer):         self.hWnd = wndMgr.RegisterMoveTextLine(self, layer)     def SetMovePosition(self, dst_x, dst_y):         wndMgr.SetMovePosition(self.hWnd, dst_x, dst_y)     def SetMoveSpeed(self, speed):         wndMgr.SetMoveSpeed(self.hWnd, speed)     def MoveStart(self):         wndMgr.MoveStart(self.hWnd)     def MoveStop(self):         wndMgr.MoveStop(self.hWnd)     def GetMove(self):         return wndMgr.GetMove(self.hWnd)     def OnEndMove(self):         if self.end_move_event_func:             apply(self.end_move_event_func, self.end_move_event_args)     def SetEndMoveEvent(self, event, *args):         self.end_move_event_func = event         self.end_move_event_args = args class MoveImageBox(ImageBox):     def __init__(self, layer = "UI"):         ImageBox.__init__(self, layer)         self.end_move_event = None     def __del__(self):         ImageBox.__del__(self)         self.end_move_event = None     def RegisterWindow(self, layer):         self.hWnd = wndMgr.RegisterMoveImageBox(self, layer)     def MoveStart(self):         wndMgr.MoveStart(self.hWnd)     def MoveStop(self):         wndMgr.MoveStop(self.hWnd)     def GetMove(self):         return wndMgr.GetMove(self.hWnd)     def SetMovePosition(self, dst_x, dst_y):         wndMgr.SetMovePosition(self.hWnd, dst_x, dst_y)     def SetMoveSpeed(self, speed):         wndMgr.SetMoveSpeed(self.hWnd, speed)     def OnEndMove(self):         if self.end_move_event:             self.end_move_event()     def SetEndMoveEvent(self, event):         self.end_move_event = event class MoveScaleImageBox(MoveImageBox):     def __init__(self, layer = "UI"):         MoveImageBox.__init__(self, layer)     def __del__(self):         MoveImageBox.__del__(self)     def RegisterWindow(self, layer):         self.hWnd = wndMgr.RegisterMoveScaleImageBox(self, layer)     def SetMaxScale(self, scale):         wndMgr.SetMaxScale(self.hWnd, scale)     def SetMaxScaleRate(self, pivot):         wndMgr.SetMaxScaleRate(self.hWnd, pivot)     def SetScalePivotCenter(self, flag):         wndMgr.SetScalePivotCenter(self.hWnd, flag)


İşte Size Örnek PY :

Kod:
class MoveTextLineTest(ui.BoardWithTitleBar):     def __init__(self):         ui.BoardWithTitleBar.__init__(self)         self.__LoadWindow()         self.__LoadGUI()     def __del__(self):         ui.BoardWithTitleBar.__del__(self)     def __LoadWindow(self):         self.SetSize(200, 100)         self.SetPosition(0, 0)         self.AddFlag('movable')         self.AddFlag('float')         self.SetTitleName("       ~ MoveTextLineTest")         self.SetCloseEvent(self.BeginBoi)     def __LoadGUI(self):         self.Biatch = ui.MoveTextLine()         self.Biatch.SetParent(self)         self.Biatch.SetText("TEST")         self.Biatch.Show()     def BeginBoi(self):         self.Biatch.SetPosition(0, 0)         self.Biatch.SetMoveSpeed(2.)         (pgx, pgy) = self.GetGlobalPosition()         self.Biatch.SetMovePosition(pgx + 175, pgy + 80)         self.Biatch.SetEndMoveEvent(ui.__mem_func__(self.GetCancer))         self.Biatch.MoveStart()     def GetCancer(self):         self.Hide()         return 1     def OnPressEscapeKey(self):         self.GetCancer()         return 1 class MoveImageBoxTest(ui.BoardWithTitleBar):     def __init__(self):         ui.BoardWithTitleBar.__init__(self)         self.__LoadWindow()         self.__LoadGUI()     def __del__(self):         ui.BoardWithTitleBar.__del__(self)     def __LoadWindow(self):         self.SetSize(200, 100)         self.SetPosition(0, 0)         self.SetCloseEvent(self.BeginBoi)         self.SetTitleName("       ~ MoveImageBoxTest")         self.AddFlag('movable')         self.AddFlag('float')         # self.SetCenterPosition()     def __LoadGUI(self):         self.Biatch = ui.MoveImageBox()         self.Biatch.SetParent(proxy(self))         self.Biatch.LoadImage("icon/item/trade.tga")         self.Biatch.SetPosition(0,0)         self.Biatch.AddFlag("float")         self.Biatch.Show()     def BeginBoi(self):         self.Biatch.SetMoveSpeed(1.)         (pgx, pgy) = self.GetGlobalPosition()         self.Biatch.SetMovePosition(pgx + 175, pgy + 80)         self.Biatch.SetEndMoveEvent(ui.__mem_func__(self.GetCancer))         self.Biatch.MoveStart()     def GetCancer(self):         self.Hide()         return 1     def OnPressEscapeKey(self):         self.GetCancer()         return 1 class MoveScaleImageBoxTest(ui.BoardWithTitleBar):     def __init__(self):         ui.BoardWithTitleBar.__init__(self)         self.Pivot = False         self.__LoadWindow()         self.__LoadGUI()     def __del__(self):         ui.BoardWithTitleBar.__del__(self)     def __LoadWindow(self):         self.SetSize(200, 100)         self.SetPosition(0, 0)         self.SetCloseEvent(self.BeginBoi)         self.SetTitleName("       ~ MoveScaleImageBoxTest")         self.AddFlag('movable')         self.AddFlag('float')     def __LoadGUI(self):         self.Biatch = ui.MoveScaleImageBox()         self.Biatch.SetParent(self)         self.Biatch.LoadImage("icon/item/trade.tga")         self.Biatch.SetScalePivotCenter(self.Pivot)         self.Biatch.AddFlag("float")         self.Biatch.Show()     def BeginBoi(self):         (pgx, pgy) = self.GetGlobalPosition()         self.Biatch.SetPosition(0,0)         self.Biatch.SetMovePosition(pgx+0, pgy+35)         self.Biatch.SetMoveSpeed(1.5)         self.Biatch.SetMaxScale(2.0)         self.Biatch.SetMaxScaleRate(1.5)         self.Biatch.MoveStart()         self.Biatch.SetEndMoveEvent(ui.__mem_func__(self.Step0))     def Step0(self):         (pgx, pgy) = self.GetGlobalPosition()         self.Biatch.SetPosition(0,35)         self.Biatch.SetMovePosition(pgx+30, pgy+35)         self.Biatch.SetMoveSpeed(1.5)         self.Biatch.SetMaxScale(3.0)         self.Biatch.SetMaxScaleRate(1.5)         self.Biatch.MoveStart()         self.Biatch.SetEndMoveEvent(ui.__mem_func__(self.Step1))     def Step1(self):         (pgx, pgy) = self.GetGlobalPosition()         self.Biatch.SetPosition(30,35)         self.Biatch.SetMovePosition(pgx+30, pgy+65)         self.Biatch.SetMoveSpeed(1.5)         self.Biatch.SetMaxScale(3.0)         self.Biatch.SetMaxScaleRate(1.5)         self.Biatch.MoveStart()         self.Biatch.SetEndMoveEvent(ui.__mem_func__(self.Step2))     def Step2(self):         (pgx, pgy) = self.GetGlobalPosition()         self.Biatch.SetPosition(30,65)         self.Biatch.SetMovePosition(pgx+125, pgy+65)         self.Biatch.SetMoveSpeed(1.5)         self.Biatch.SetMaxScale(2.0)         self.Biatch.SetMaxScaleRate(1.5)         self.Biatch.MoveStart()         self.Biatch.SetEndMoveEvent(ui.__mem_func__(self.Step3))     def Step3(self):         self.Biatch.SetPosition(125,65)     def GetCancer(self):         self.Hide()         return 1     def OnPressEscapeKey(self):         self.GetCancer()         return 1

Örnek Video :


[C++] Yeni UI Class'ları (İşinize Çok Yarayacak)

[C++] ile geliştirilen Metin2 özel sunucularında kullanıcı arayüzü (UI) sınıflarının doğru ve verimli bir şekilde yapılandırılması, hem oyun deneyimini artırır hem de geliştirme sürecini kolaylaştırır. Özellikle Metin2 gibi eski yapılı oyunlarda, UI sistemleri genellikle Python tabanlıdır ve bu sınıfların C++ ile entegrasyonu oldukça kritiktir. Bu yazıda, Metin2 özel sunucu geliştiricileri için işinize yarayacak yeni UI class'ları üzerinde duracağız.

UI Sınıfı Nedir?

Metin2'de UI sınıfları, oyun içi arayüz elemanlarını yönetmek için kullanılır. Bunlar; envanter, beceri paneli, sohbet ekranı, eşya bilgi kutusu gibi bileşenleri içerir. Bu sınıflar genellikle Python ile yazılır ve C++ oyun motoruyla iletişim halindedir. Ancak bazı durumlarda C++ seviyesinde UI sınıfları geliştirmek, performans artışı ve daha fazla kontrol sağlayabilir.

Neden Yeni UI Class'ları Gereklidir?

Gelişmiş PvP sistemleri, özel ekipman ekranları, guild savaşları arayüzleri, özel menü sistemleri gibi birçok alanda mevcut UI sınıflarının yetersiz kaldığı görülür. Bu durumda geliştiricilerin, yeni UI sınıfları tasarlaması gerekir. Bu sınıflar, hem client/src hem de uiscript dosyalarında tanımlanmalıdır. Python GUI sistemleri ile entegre çalışabilen bu yapılar, Py Root ve Py GUI sınıfları üzerinden genişletilebilir.

Yeni UI Sınıfı Oluşturmak

Yeni bir UI sınıfı oluşturmak için aşağıdaki adımları izlemek önemlidir:

- Client/src altında yeni bir header (.h) ve cpp (.cpp) dosyası oluşturulur.
- Header dosyasında sınıf tanımı yapılır. Örneğin: class CNewUIWindow : public CUIWindow.
- CUIWindow sınıfından türeyen bu yeni sınıf, OnUpdate, OnRender, OnKeyDown gibi metodları override edebilir.
- UI Script dosyası (.py) içinde bu sınıf çağrılır ve arayüz elemanları tanımlanır.

UI Script ile Entegrasyon

UIScript dosyaları, oyun arayüzünü tanımlamak için kullanılır. Bu dosyalarda Python nesneleri kullanılır ve genellikle py root dizini altında yer alır. Yeni UI sınıfınız burada çağrıldığında, C++ tarafında tanımlanan fonksiyonlarla etkileşim kurabilir. Bu sayede hem grafiksel hem de mantıksal işlemler daha verimli hale gelir.

Avantajları

Yeni UI sınıfları sayesinde:

- Performans artar.
- Daha fazla görsel efekt eklenebilir.
- PvP sistemleri için özel arayüzler geliştirilebilir.
- Ekipman takibi, guild sistemleri gibi dinamik içerikler daha iyi yönetilir.

Örnek Uygulama

Basit bir örnek olarak, özel bir PvP puanı gösteren UI sınıfı oluşturabiliriz. Bu sınıf, oyun sırasında gerçek zamanlı olarak puanı günceller ve özel bir animasyonla gösterir. Bu tür özel sınıflar, Metin2 PvP sistemleri için oldukça faydalıdır ve oyuncu deneyimini artırır.

Sonuç

Metin2 özel sunucu geliştiricileri için yeni UI sınıfları, hem teknik hem de estetik açıdan büyük avantajlar sağlar. Doğru yapılandırılmış bir UI sınıfı, sunucunuzun diğerlerinden ayrılmasını sağlayabilir. Geliştirme sürecinde C++ sistem, Python GUI, uiscript ve pack sistemleri arasında uyumlu bir yapı kurmak, uzun vadede daha verimli bir geliştirme ortamı sunar.


New UI Classes in [C++] (Very Useful for You)

In Metin2 private servers developed with [C++], structuring user interface (UI) classes correctly and efficiently enhances both the gaming experience and simplifies the development process. In older games like Metin2, UI systems are often Python-based, and integrating these classes with [C++] is critical. In this article, we will focus on new UI classes that will be very useful for Metin2 private server developers.

What Is a UI Class?

In Metin2, UI classes manage in-game interface elements such as inventory, skill panels, chat screens, item information boxes, etc. These classes are typically written in Python and communicate with the [C++] game engine. However, sometimes developing UI classes at the [C++] level can offer performance improvements and greater control.

Why Are New UI Classes Needed?

In areas like advanced PvP systems, custom equipment screens, guild battle interfaces, and special menu systems, existing UI classes may prove insufficient. In such cases, developers need to design new UI classes. These classes must be defined in both client/src and uiscript files. These structures, which integrate with Python GUI systems, can be extended through Py Root and Py GUI classes.

Creating a New UI Class

To create a new UI class, follow these steps:

- Create a new header (.h) and cpp (.cpp) file under Client/src.
- Define the class in the header file. Example: class CNewUIWindow : public CUIWindow.
- This new class, inheriting from CUIWindow, can override methods like OnUpdate, OnRender, OnKeyDown.
- Call this class in the UI Script file (.py) and define interface elements.

Integration with UI Script

UIScript files define the game interface. These files use Python objects and are generally located under the py root directory. When your new UI class is called here, it can interact with functions defined on the [C++] side. Thus, both graphical and logical operations become more efficient.

Benefits

With new UI classes:

- Performance increases.
- More visual effects can be added.
- Custom interfaces can be developed for PvP systems.
- Dynamic content like equipment tracking and guild systems can be better managed.

Sample Application

As a simple example, we could create a custom UI class that displays a special PvP score. This class updates the score in real-time during the game and shows it with a custom animation. Such custom classes are highly beneficial for Metin2 PvP systems and enhance player experience.

Conclusion

For Metin2 private server developers, new UI classes provide significant advantages both technically and aesthetically. A well-configured UI class can set your server apart from others. Establishing a harmonious structure between C++ systems, Python GUI, uiscript, and pack systems during development creates a more efficient development environment in the long run.
 

Şuan Bu Konuyu Görüntüleyen Kullanıcılar (Toplam : 0, Üye : 0, Misafir : 0)

Benzer konular

Geri
Üst Alt