CAniImageBox Yüklemesini Optimize Etmek

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
picture-gif.81985


Selam beyler,

Bildiğimiz gibi, bir ani-image içinde çok fazla resim varsa, yüklenmesi gerçekten yavaş olabilir ve oyunun bir an için donmasına neden olabilir. Bu bizi gerçekten sınırlıyor çünkü kullanıcı deneyimi üzerinde kötü bir etkisi olacağından daha uzun bir görüntü dizisi kullanamıyoruz.

Bazı öğreticilerimizi birleştirerek 126 görüntüden oluşan bir dizi oluşturdum, işte eski (sol) ve yeni (sağ) sürümü gösteren bir karşılaştırma GIF'i.
Kod:
arat std::vector<CGraphicExpandedImageInstance*> m_ImageVector; altına ekle std::queue<std::string> m_ImageFileNames; std::function<void(CGraphicExpandedImageInstance*)> m_SetRenderingRect, m_SetRenderingMode, m_SetDiffuseColor;

Kod:
arat ve bu kod ile değiştir     void CAniImageBox::AppendImage(const char * c_szFileName)     {         m_ImageFileNames.push(c_szFileName);     } tekrar arat CAniImageBox::OnUpdate kodun içine ekle         if (!m_ImageFileNames.empty())         {             const std::string& stFileName = m_ImageFileNames.front();             CResource* pResource = CResourceManager::Instance().GetResourcePointer(stFileName.c_str());             if (pResource->IsType(CGraphicImage::Type()))             {                 CGraphicExpandedImageInstance* pImageInstance = CGraphicExpandedImageInstance::New();                 pImageInstance->SetImagePointer(static_cast<CGraphicImage*>(pResource));                 if (pImageInstance->IsEmpty())                 {                     CGraphicExpandedImageInstance::Delete(pImageInstance);                 }                 else                 {                     pImageInstance->SetPosition(m_rect.left, m_rect.top);                     if (m_SetRenderingRect)                         m_SetRenderingRect(pImageInstance);                     if (m_SetRenderingMode)                         m_SetRenderingMode(pImageInstance);                     if (m_SetDiffuseColor)                         m_SetDiffuseColor(pImageInstance);                     m_ImageVector.push_back(pImageInstance);                 }             }             m_ImageFileNames.pop();         } arat ve değiştir     void CAniImageBox::SetRenderingRect(float fLeft, float fTop, float fRight, float fBottom)     {         m_SetRenderingRect = std::bind(&CGraphicExpandedImageInstance::SetRenderingRect, std::placeholders::_1, fLeft, fTop, fRight, fBottom);         std::for_each(m_ImageVector.begin(), m_ImageVector.end(), m_SetRenderingRect);     } arat ve değiştir     void CAniImageBox::SetRenderingMode(int iMode)     {         m_SetRenderingMode = std::bind(&CGraphicExpandedImageInstance::SetRenderingMode, std::placeholders::_1, iMode);         std::for_each(m_ImageVector.begin(), m_ImageVector.end(), m_SetRenderingMode);     } arat ve değiştir     void CAniImageBox::SetDiffuseColor(float fR, float fG, float fB, float fA)     {         m_SetDiffuseColor = std::bind(&CGraphicExpandedImageInstance::SetDiffuseColor, std::placeholders::_1, fR, fG, fB, fA);         std::for_each(m_ImageVector.begin(), m_ImageVector.end(), m_SetDiffuseColor);     } arat ve değiştir     void CAniImageBox::OnChangePosition()     {         std::for_each(m_ImageVector.begin(), m_ImageVector.end(),             std::bind(&CGraphicExpandedImageInstance::SetPosition, std::placeholders::_1, m_rect.left, m_rect.top));     }

ve bu kadar. İyi forumlar.

Distraught'a Teşekkürler.
CAniImageBox Yüklemesini Optimize Etmek

Metin2 özel sunucularında kullanıcı arayüzü performansı ve görsel kalite, oyuncu deneyimini doğrudan etkileyen kritik bileşenlerden biridir. Özellikle Martysama ve diğer gelişmiş C++ tabanlı sistemler üzerinde çalışan sunucularda, UI elementlerinin verimli çalışması büyük önem taşır. Bu bağlamda, CAniImageBox gibi animasyonlu görsel nesnelerin doğru ve optimize bir şekilde yüklenmesi, hem FPS düşüşlerini önlemek hem de arayüzün daha akıcı çalışmasını sağlamak adına gereklidir.

CAniImageBox Nedir?
CAniImageBox, Metin2 UI Script yapısında kullanılan, bir dizi görselden oluşan animasyonları destekleyen bir UI sınıfıdır. Genellikle buton efektleri, loading animasyonları veya menü geçişlerinde kullanılır. Ancak bu sınıfın yanlış kullanımı ya da eksik optimizasyonu, özellikle düşük donanımlı istemcilerde ciddi performans sorunlarına yol açabilir.

Yüklemeyi Etkileyen Faktörler
Bir CAniImageBox nesnesinin hızlı ve sorunsuz yüklenmesi, birkaç temel bileşene bağlıdır:
- Görsel dosyaların sıkıştırma formatı (PNG, TGA)
- Animasyon kare sayısının fazla olması
- Aynı anda birden fazla animasyonun yüklenmeye çalışılması
- Görsellerin çözünürlüğü
- Arka planda çalışan diğer UI sınıfları ile çakışmalar

Performans Sorunlarını Önlemek
CAniImageBox nesnesi için ilk adım, görsel dosyaların doğru sıkıştırılmasıdır. Yüksek boyutlu görseller, bellek kullanımını artırır ve yükleme süresini uzatır. PNG formatı tercih edilmeli, ancak boyut çok büyükse lossless sıkıştırma kullanılmalıdır. Ayrıca, animasyon kareleri mümkünse tek bir sprite olarak birleştirilmeli; bu yöntem, UIScript tarafında daha verimli render sağlar.

Örnek Kod Yapısı
Aşağıda örnek bir CAniImageBox tanımı görülmektedir:
ani_image = ui.AnimatedImageBox()
ani_image.Load('gfx/ui/loading.tga')
ani_image.SetPosition(100, 100)
ani_image.Hide()

Ancak bu yapıda, animasyon başlatılmadan önce yüklenmelidir. Aksi takdirde oyun donabilir. Bunun için uiScript içinde bir preload fonksiyonu tanımlamak iyi bir uygulamadır.

Lazy Loading ve Preloading Teknikleri
Lazy loading, animasyonların yalnızca ihtiyaç duyulduğunda yüklenmesini sağlar. Bu, bellek yönetimini optimize eder. Preloading ise, oyun başlatılırken ya da sahne değişikliklerinde gerekli animasyonların önceden belleğe alınmasını sağlar. Her iki teknik de Py Root ve UIScript arasında koordineli bir yapıyla uygulanmalıdır.

Sunucu Tarafında Entegrasyon
Metin2 özel sunucularında, CAniImageBox ile ilgili veriler genellikle Game Server tarafından tetiklenir. Örneğin, bir PvP etkinliği başladığında bir loading animasyonu göstermek istenebilir. Bu durumda, Python GUI ile sunucudan gelen sinyaller senkronize edilmelidir. Bu, DB Core[/COORD] üzerinden de izlenebilir.

Sonuç
CAniImageBox’ın doğru şekilde optimize edilmesi, hem kullanıcı deneyimini artırır hem de sunucu tarafında oluşabilecek ek yükü azaltır. Özellikle Metin2 Lobby gibi topluluk odaklı platformlarda, geliştiricilerin bu tür UI detaylarına dikkat etmesi, daha kaliteli sistemlerin ortaya çıkmasına yardımcı olur.


Optimizing CAniImageBox Loading

In Metin2 private servers, user interface performance and visual quality are critical components that directly affect player experience. Particularly on advanced C++ based systems like Martysama, efficient operation of UI elements is essential. In this context, properly and efficiently loading animated visual objects such as CAniImageBox prevents FPS drops and ensures smoother interface operations.

What is CAniImageBox?
CAniImageBox is a UI class used in Metin2 UI Script structure that supports animations composed of multiple images. It is commonly used for button effects, loading animations, or menu transitions. However, incorrect usage or insufficient optimization can cause significant performance issues, especially on lower-end clients.

Factors Affecting Load Times
The fast and smooth loading of a CAniImageBox object depends on several key factors:
- Image file compression format (PNG, TGA)
- High number of animation frames
- Multiple animations loading simultaneously
- Resolution of images
- Conflicts with other UI classes running in the background

Preventing Performance Issues
The first step for CAniImageBox is correct compression of image files. Large-sized images increase memory usage and extend loading times. PNG format should be preferred, but if the size is too large, lossless compression can be used. Additionally, animation frames should be combined into a single sprite if possible; this method allows more efficient rendering in UIScript.

Sample Code Structure
Below is an example definition of a CAniImageBox:
ani_image = ui.AnimatedImageBox()
ani_image.Load('gfx/ui/loading.tga')
ani_image.SetPosition(100, 100)
ani_image.Hide()

However, in this structure, the animation must be loaded before starting. Otherwise, the game may freeze. Therefore, defining a preload function in uiScript is a good practice.

Lazy Loading and Preloading Techniques
Lazy loading loads animations only when needed. This optimizes memory management. Preloading means loading necessary animations into memory during startup or scene changes. Both techniques should be implemented with coordinated structures between Py Root and UIScript.

Server-Side Integration
In Metin2 private servers, data related to CAniImageBox is usually triggered by the Game Server. For instance, a loading animation might be shown upon starting a PvP event. In such cases, signals from the server must be synchronized with the Python GUI. This can also be tracked via DB Core.

Conclusion
Properly optimizing CAniImageBox loading enhances user experience while reducing potential load on the server side. Especially on community-focused platforms like Metin2 Lobby, attention to such UI details helps developers create higher-quality systems.
 

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

Geri
Üst Alt