GUIDE] Metin2 Client'in Ekranın Ortasında Açılmasını Sağlamak

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

Admin

Metin2Lobby
Yönetici
Founder
Katılım
6 Mayıs 2022
Mesajlar
52,647
Ticaret : 1 / 0 / 0
Bu konuda sizlerle Metin2 istemcisinin (client) artık masaüstünün sol üst köşesinde değil, ekranın tam ortasında açılmasını nasıl sağlayacağınızı paylaşacağım. Özellikle çoklu monitör veya büyük ekran kullananlar için bu küçük ama etkili düzenleme oldukça faydalı olacaktır.

🛠️ Yapılacak İşlem:​


PythonApplication.cpp dosyasındaki pencere konumlandırma kodunu değiştiriyoruz.

Aşağıdaki if (Windowed) bloğunu bulun:
Kod:
if (Windowed) {     // ...     SetPosition(-dropshadowSize, (m_pySystem.GetHeight() >= 1000) ? -titlebarSize : 0); }

Yeni Kod:​

Eski bloğu silin ve yerine aşağıdaki kodu ekleyin:

Kod:
if (Windowed) {     m_isWindowed = true;     RECT rcClient{}, rcWindow{};     GetClientRect(&rcClient);     GetWindowRect(&rcWindow);     int windowWidth = rcClient.right - rcClient.left;     int windowHeight = rcClient.bottom - rcClient.top;     int borderX = (rcWindow.right - rcWindow.left) - windowWidth;     int borderY = (rcWindow.bottom - rcWindow.top) - windowHeight;     int screenWidth = GetSystemMetrics(SM_CXSCREEN);     int screenHeight = GetSystemMetrics(SM_CYSCREEN);     int posX = (screenWidth - windowWidth - borderX) / 2;     int posY = (screenHeight - windowHeight - borderY) / 2;     SetPosition(posX, posY); }

Sonuç:​


Artık Metin2 client'iniz her başlatıldığında ekranın tam ortasında açılacaktır. Küçük ama güzel bir kullanıcı deneyimi iyileştirmesi!

NOT: BAŞKA YERDEN ALINMIŞ ALINTIDIR.
Metin2 Client'in Ekranın Ortasında Açılmasını Sağlamak

Metin2 özel sunucularında kullanıcı deneyimini artırmak isteyen geliştiriciler için küçük ama etkili değişiklikler yapmak önemlidir. Bunlardan birisi de Metin2 client'in başlatıldığında ekranın ortasında açılmasını sağlamaktır. Bu işlem, özellikle kullanıcı dostu bir arayüz tasarımı için gereklidir ve profesyonel bir izlenim bırakabilir. Bu rehberde, Metin2 client'ı ekranın ortasında açacak şekilde nasıl yapılandıracağınızı detaylı olarak ele alacağız.

Neden Metin2 Client Ekranın Ortasında Açılmalı?

Bir oyuncu Metin2 özel sunucusuna bağlanmak için client'i başlattığında, pencerenin rastgele bir konumda açılması kullanıcıyı rahatsız edebilir. Özellikle birden fazla monitör kullanan oyuncularda bu durum daha da dikkat çekici olabilir. Pencerenin merkezi konumda açılması, kullanıcıya profesyonellik ve dikkat verilmiş bir arayüz imajı verir. Ayrıca, oyuncuların dikkatini doğrudan oyun içeriğine yönlendirmek açısından faydalıdır.

Client Kaynak Kodlarında Yapılacak Değişiklikler[/COORD]

Metin2 client'in ekranın ortasında açılabilmesi için client src dosyalarında bazı düzenlemeler yapılmalıdır. Genellikle bu işlem, uiscript veya Python GUI tabanlı arayüz dosyalarında yapılmaktadır. Eğer client tarafında py root veya PyGUI kullanıyorsanız, pencere pozisyonunu belirleyen kod parçasını değiştirmeniz gerekir.

Örneğin, Python tabanlı bir yapıda pencere boyutu ve pozisyonu aşağıdaki gibi tanımlanabilir:

Kod:
window.SetSize(1024, 768)[BR][/BR]window.SetPosition(SCREEN_WIDTH / 2 - 512, SCREEN_HEIGHT / 2 - 384)


Bu örnekte, SCREEN_WIDTH ve SCREEN_HEIGHT değerleri ekran çözünürlüğünü temsil eder. Pencere boyutu 1024x768 ise, pencereyi ekranın tam ortasında konumlandırmak için X ve Y koordinatları bu şekilde hesaplanmalıdır.

UIScript Dosyasında Merkezi Konumlandırma

Eğer client tarafında uiscript dosyaları kullanıyorsanız, ilgili pencere tanımında konum ayarı yapmanız gerekir. Örneğin, bir giriş ekranı (login screen) için konum şu şekilde ayarlanabilir:

Kod:
<window>[BR][/BR] <size>1024, 768</size>[BR][/BR] <position>(SCREEN_WIDTH / 2 - 512), (SCREEN_HEIGHT / 2 - 384)</position>[BR][/BR]</window>


Bu yapılandırma sayesinde, client başlatıldığında pencere ekranın tam ortasında açılacaktır.

Olası Sorunlar ve Çözümler

Bazı durumlarda, farklı çözünürlüklerde ekran boyutu ve pencere konumu uyumsuz olabilir. Bu sebeple, çözünürlükten bağımsız dinamik hesaplamalar yapmanız önerilir. Ayrıca, bazı client yapılarında C++ tabanlı sistemlerde WinAPI üzerinden pencere pozisyonu ayarlamak gerekebilir. Bu gibi durumlarda, SetWindowPos() fonksiyonu kullanılabilir:

Kod:
SetWindowPos(hWnd, HWND_TOP, (GetSystemMetrics(SM_CXSCREEN) - width) / 2, (GetSystemMetrics(SM_CYSCREEN) - height) / 2, width, height, SWP_SHOWWINDOW);


Sonuç

Metin2 client'in ekranın ortasında açılması, kullanıcı deneyimini ciddi anlamda artırabilir. Bu küçük değişiklik, hem profesyonellik hem de kullanıcı dostu bir yapı sunar. Client kaynak kodları üzerinde yapılan bu tür geliştirmeler, sunucunuzun diğerlerinden ayrılmasına yardımcı olur. Metin2Lobby olarak, bu tür gelişmiş sistemler ve kaynak kodlar hakkında daha fazla bilgiye ulaşabilirsiniz.


How to Make the Metin2 Client Open in the Center of the Screen

Enhancing the user experience on Metin2 private servers requires attention to small but effective details. One such detail is ensuring that the Metin2 client opens in the center of the screen when launched. This adjustment can significantly improve the interface’s look and feel, giving off a more professional vibe. In this guide, we will walk you through how to configure the Metin2 client to open at the center of your screen.

Why Should the Metin2 Client Open in the Center?

When a player launches the Metin2 client to connect to a private server, having the window appear at a random location on the screen can be unsettling. This issue becomes even more prominent for players using multiple monitors. Opening the window in the center provides a clean and professional look while directing the player's focus straight into the game content.

Modifications Required in Client Source Files

To make the Metin2 client open in the center of the screen, certain adjustments must be made in the client src files. Usually, this involves modifying uiscript or Python GUI-based interface files. If you are using py root or PyGUI on the client side, you need to alter the code responsible for setting the window position.

For instance, in a Python-based structure, the window size and position might be defined like this:

Kod:
window.SetSize(1024, 768)[BR][/BR]window.SetPosition(SCREEN_WIDTH / 2 - 512, SCREEN_HEIGHT / 2 - 384)


In this example, SCREEN_WIDTH and SCREEN_HEIGHT represent the screen resolution. If the window size is 1024x768, calculating the X and Y coordinates in this manner ensures the window appears centered on the screen.

Centering the Window via UIScript File

If you are using uiscript files on the client side, you should adjust the position settings within the relevant window definition. For example, for a login screen, the position can be set as follows:

Kod:
<window>[BR][/BR] <size>1024, 768</size>[BR][/BR] <position>(SCREEN_WIDTH / 2 - 512), (SCREEN_HEIGHT / 2 - 384)</position>[BR][/BR]</window>


With this configuration, the client window will appear exactly in the center of the screen upon launch.

Potential Issues and Solutions

In some cases, different screen resolutions may cause mismatched window sizes and positions. Therefore, it is recommended to implement dynamic calculations that work independently of screen resolution. Additionally, in some client structures based on C++, you may need to use WinAPI to set the window position. In such scenarios, the SetWindowPos() function can be used:

Kod:
SetWindowPos(hWnd, HWND_TOP, (GetSystemMetrics(SM_CXSCREEN) - width) / 2, (GetSystemMetrics(SM_CYSCREEN) - height) / 2, width, height, SWP_SHOWWINDOW);


Conclusion

Centering the Metin2 client window significantly improves the user experience. Such a minor change brings both professionalism and user-friendliness to your interface. Adjustments like these in client source codes help distinguish your server from others. Visit Metin2Lobby to find more advanced systems and source code information.
 

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

Geri
Üst Alt