Bu konuda orijinal oyuna yeni eklenen sistemlerle gelen wndMgr.IsDisable fonksiyonunu eklemeyi anlatacağım. Eğer böyle bir fonksiyon yoksa şuna benzer bir syserr alırsınız.
Mesela şu kodda mevcut bir tuşun kullanılabilirliğini kontrol edip aktif etmek istiyoruz.
Ama bu şekilde syserr veriyor;
Peki nasıl çözebiliriz?
Aslında çözmesi çok kolay.
Zaten kaynak kodlarında bir butonun aktif olup olmadığını deneyleyen şu fonksiyon mevcut;
Client/EterPythonLib/PythonWindow.cpp
Bize kalan tek şey ise root dosyalarında ki python dosyalarımızda bu fonksiyonu kullanmak yeni kaynak koduna python fonksiyonu tanımlayacağız.
İlk önce Client/EterPythonLib/PythonWindowManagerModule.cpp dosyasını aratıyoruz ve şu kodu aratıyoruz;
Altına şunu ekleyin;
Şu kodu aratın;
Altına ekleyin;
İşlemleri yaptıktan sonra clienti build edin.
root/ui.py dosyasını açın ve class Button(Window): içinde ki şu fonksiyonu aratın;
Altına ekleyin;
Artık gui tasarlarken kullanıma kapattığınız tuşları bu fonksiyon sayesinde kontrol edebilirsiniz.
Çalıştığına Dair Kanıt;
MaviAyGames | wndMgr.IsDisable Fonksiyonu Ekleme Rehberi
Metin2 özel sunucularında kullanıcı arayüzü geliştirmek, özellikle Python GUI tabanlı menü sistemlerinde esneklik kazandırmak açısından oldukça önemlidir. Bu rehberde, wndMgr.IsDisable fonksiyonunun nasıl ekleneceği ve kullanılacağı detaylı olarak ele alınacaktır. Bu işlem, Martysama tarzı sistemlerde UI script geliştirme sürecini kolaylaştıracaktır.
Önemli Not: Bu rehber, Py Root ve UIScript tabanlı sistemlerde çalışan geliştiriciler içindir. Metin2 özel sunucularında C++ ve Python dilleri arasında köprü kurmak, arayüz kontrolünü daha verimli hale getirir.
wndMgr Nedir?
wndMgr, Metin2 client tarafında pencere yönetimi sağlayan temel Python sınıfıdır. UI bileşenlerinin oluşturulması, görünüm durumu ayarlanması ve etkileşim kurulması gibi işlemleri sağlar. Ancak bazı durumlarda, bir pencerenin veya butonun devre dışı bırakılması gerekebilir. Bu noktada IsDisable fonksiyonu büyük kolaylık sağlar.
Fonksiyon Ekleme Adımları
1. Client Tarafında PyObject Tanımı:
WndMgrModule.cpp dosyasında wndMgr modülüne yeni bir fonksiyon tanımı eklenmelidir. Örnek olarak:
2. Fonksiyon Tanımı ve Geri Dönüş Değeri:
Fonksiyon, bir pencere nesnesinin devre dışı olup olmadığını kontrol eder. Eğer nesne devre dışıysa True, değilse False döner. Bu bilgi, UI scriptlerde koşullu işlemler için idealdir.
3. Python Tarafında Kullanımı:
uiscript içinde örnek kullanım şu şekildedir:
4. Derleme ve Test:
Metin2 Compile işlemi sonrasında, fonksiyonun doğru çalışıp çalışmadığı test edilmelidir. Özellikle pack[/BR]
Avantajları
- UI elementlerinin durum kontrolünü merkezi şekilde sağlar.
- Oyuncu etkileşimlerinde daha akıcı deneyim sunar.
- Script tarafında fazladan kontrol kodları yazmaya gerek kalmaz.
Sonuç
wndMgr.IsDisable fonksiyonu, Metin2 özel sunucularında UI geliştirme sürecini hızlandıran küçük ama güçlü bir özelliktir. Metin2Dev topluluğu bu tür gelişmelerle birlikte daha verimli sistemler inşa edebilir. Bu rehber sayesinde, MaviAyGames tarzı projelerde UI sistemlerini daha stabil hale getirebilirsiniz.
MaviAyGames | Adding wndMgr.IsDisable Function Guide
Enhancing user interfaces in Metin2 private servers, especially in Python GUI based menu systems, requires flexibility. In this guide, we will detail how to add and use the wndMgr.IsDisable function. This process will ease the UI scripting workflow in systems similar to Martysama.
Important Note: This guide targets developers working with Py Root and UIScript based setups. Integrating C++ and Python helps achieve more efficient UI control in Metin2 private servers.
What is wndMgr?
wndMgr is the primary Python class responsible for window management on the Metin2 client side. It handles the creation of UI components, managing their visibility states, and interactions. However, sometimes it's necessary to disable a window or button temporarily. That's where the IsDisable function comes into play.
Steps to Add the Function
1. PyObject Definition on Client Side:
In the WndMgrModule.cpp file, add a new function definition to the wndMgr module. Example:
2. Function Definition and Return Value:
The function checks whether a window object is disabled. If so, it returns True; otherwise, it returns False. This information is ideal for conditional operations in UI scripts.
3. Usage in Python:
An example usage inside uiscript is as follows:
4. Compilation and Testing:
After Metin2 Compile, verify that the function works properly. Ensure all pack files are updated accordingly.
Benefits
- Provides centralized status checking for UI elements.
- Offers smoother player interactions.
- Eliminates the need for additional control codes in scripts.
Conclusion
The wndMgr.IsDisable function is a small yet powerful feature that speeds up UI development in Metin2 private servers. With such improvements, the Metin2Dev community can build more efficient systems. Thanks to this guide, you can make UI systems more stable in projects like MaviAyGames.
Kod:
0216 00:58:29495 :: File "ui.py", line 1009, in IsDisable 0216 00:58:29496 :: 0216 00:58:29496 :: return wndMgr.IsDisable(self.hWnd) 0216 00:58:29496 :: AttributeError 0216 00:58:29496 :: : 0216 00:58:29496 :: 'module' object has no attribute 'IsDisable' 0216 00:58:29496 ::
Mesela şu kodda mevcut bir tuşun kullanılabilirliğini kontrol edip aktif etmek istiyoruz.
Kod:
if self.xxButton.IsDisable() == 0: self.xxButton.Enable()
Ama bu şekilde syserr veriyor;
Kod:
0216 00:00:33209 :: AttributeError 0216 00:00:33209 :: : 0216 00:00:33210 :: 'Button' object has no attribute 'IsDisable' 0216 00:00:33210 ::
Peki nasıl çözebiliriz?
Aslında çözmesi çok kolay.
Zaten kaynak kodlarında bir butonun aktif olup olmadığını deneyleyen şu fonksiyon mevcut;
Client/EterPythonLib/PythonWindow.cpp
Kod:
BOOL CButton::IsDisable() { return m_bEnable; }
Bize kalan tek şey ise root dosyalarında ki python dosyalarımızda bu fonksiyonu kullanmak yeni kaynak koduna python fonksiyonu tanımlayacağız.
İlk önce Client/EterPythonLib/PythonWindowManagerModule.cpp dosyasını aratıyoruz ve şu kodu aratıyoruz;
Kod:
PyObject * wndButtonIsDown(PyObject * poSelf, PyObject * poArgs) { UI::CWindow * pWindow; if (!PyTuple_GetWindow(poArgs, 0, &pWindow)) return Py_BuildException(); return Py_BuildValue("i", ((UI::CButton*)pWindow)->IsPressed()); }
Altına şunu ekleyin;
Kod:
PyObject * wndButtonIsDisable(PyObject * poSelf, PyObject * poArgs) { UI::CWindow* pWindow; if (!PyTuple_GetWindow(poArgs, 0, &pWindow)) return Py_BuildException(); return Py_BuildValue("i", ((UI::CButton*)pWindow)->IsDisable()); }
Şu kodu aratın;
Kod:
{ "IsDown", wndButtonIsDown, METH_VARARGS },
Altına ekleyin;
Kod:
{ "IsDisable", wndButtonIsDisable, METH_VARARGS },
İşlemleri yaptıktan sonra clienti build edin.
root/ui.py dosyasını açın ve class Button(Window): içinde ki şu fonksiyonu aratın;
Kod:
def Disable(self): wndMgr.Disable(self.hWnd)
Altına ekleyin;
Kod:
def IsDisable(self): return wndMgr.IsDisable(self.hWnd)
Artık gui tasarlarken kullanıma kapattığınız tuşları bu fonksiyon sayesinde kontrol edebilirsiniz.
Çalıştığına Dair Kanıt;
MaviAyGames | wndMgr.IsDisable Fonksiyonu Ekleme Rehberi
Metin2 özel sunucularında kullanıcı arayüzü geliştirmek, özellikle Python GUI tabanlı menü sistemlerinde esneklik kazandırmak açısından oldukça önemlidir. Bu rehberde, wndMgr.IsDisable fonksiyonunun nasıl ekleneceği ve kullanılacağı detaylı olarak ele alınacaktır. Bu işlem, Martysama tarzı sistemlerde UI script geliştirme sürecini kolaylaştıracaktır.
Önemli Not: Bu rehber, Py Root ve UIScript tabanlı sistemlerde çalışan geliştiriciler içindir. Metin2 özel sunucularında C++ ve Python dilleri arasında köprü kurmak, arayüz kontrolünü daha verimli hale getirir.
wndMgr Nedir?
wndMgr, Metin2 client tarafında pencere yönetimi sağlayan temel Python sınıfıdır. UI bileşenlerinin oluşturulması, görünüm durumu ayarlanması ve etkileşim kurulması gibi işlemleri sağlar. Ancak bazı durumlarda, bir pencerenin veya butonun devre dışı bırakılması gerekebilir. Bu noktada IsDisable fonksiyonu büyük kolaylık sağlar.
Fonksiyon Ekleme Adımları
1. Client Tarafında PyObject Tanımı:
WndMgrModule.cpp dosyasında wndMgr modülüne yeni bir fonksiyon tanımı eklenmelidir. Örnek olarak:
Kod:
[COLOR=green]PyObject* wndMgrIsDisable(PyObject* poSelf, PyObject* poArgs)[/COLOR]
2. Fonksiyon Tanımı ve Geri Dönüş Değeri:
Fonksiyon, bir pencere nesnesinin devre dışı olup olmadığını kontrol eder. Eğer nesne devre dışıysa True, değilse False döner. Bu bilgi, UI scriptlerde koşullu işlemler için idealdir.
3. Python Tarafında Kullanımı:
uiscript içinde örnek kullanım şu şekildedir:
Kod:
[COLOR=green]if wndMgr.IsDisable('button_name')[/COLOR]
4. Derleme ve Test:
Metin2 Compile işlemi sonrasında, fonksiyonun doğru çalışıp çalışmadığı test edilmelidir. Özellikle pack[/BR]
Avantajları
- UI elementlerinin durum kontrolünü merkezi şekilde sağlar.
- Oyuncu etkileşimlerinde daha akıcı deneyim sunar.
- Script tarafında fazladan kontrol kodları yazmaya gerek kalmaz.
Sonuç
wndMgr.IsDisable fonksiyonu, Metin2 özel sunucularında UI geliştirme sürecini hızlandıran küçük ama güçlü bir özelliktir. Metin2Dev topluluğu bu tür gelişmelerle birlikte daha verimli sistemler inşa edebilir. Bu rehber sayesinde, MaviAyGames tarzı projelerde UI sistemlerini daha stabil hale getirebilirsiniz.
MaviAyGames | Adding wndMgr.IsDisable Function Guide
Enhancing user interfaces in Metin2 private servers, especially in Python GUI based menu systems, requires flexibility. In this guide, we will detail how to add and use the wndMgr.IsDisable function. This process will ease the UI scripting workflow in systems similar to Martysama.
Important Note: This guide targets developers working with Py Root and UIScript based setups. Integrating C++ and Python helps achieve more efficient UI control in Metin2 private servers.
What is wndMgr?
wndMgr is the primary Python class responsible for window management on the Metin2 client side. It handles the creation of UI components, managing their visibility states, and interactions. However, sometimes it's necessary to disable a window or button temporarily. That's where the IsDisable function comes into play.
Steps to Add the Function
1. PyObject Definition on Client Side:
In the WndMgrModule.cpp file, add a new function definition to the wndMgr module. Example:
Kod:
[COLOR=green]PyObject* wndMgrIsDisable(PyObject* poSelf, PyObject* poArgs)[/COLOR]
2. Function Definition and Return Value:
The function checks whether a window object is disabled. If so, it returns True; otherwise, it returns False. This information is ideal for conditional operations in UI scripts.
3. Usage in Python:
An example usage inside uiscript is as follows:
Kod:
[COLOR=green]if wndMgr.IsDisable('button_name')[/COLOR]
4. Compilation and Testing:
After Metin2 Compile, verify that the function works properly. Ensure all pack files are updated accordingly.
Benefits
- Provides centralized status checking for UI elements.
- Offers smoother player interactions.
- Eliminates the need for additional control codes in scripts.
Conclusion
The wndMgr.IsDisable function is a small yet powerful feature that speeds up UI development in Metin2 private servers. With such improvements, the Metin2Dev community can build more efficient systems. Thanks to this guide, you can make UI systems more stable in projects like MaviAyGames.
