Paylaşım sahibi :
Q: Ne işe yarar?
A: Arayüzde yaptığınız düzenlemeler için oyunu kapatıp açmadan anlık olarak görmenize olanak sağlar.
ui.py
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Q: Ne işe yarar?
A: Arayüzde yaptığınız düzenlemeler için oyunu kapatıp açmadan anlık olarak görmenize olanak sağlar.
Kod:
##ara def LoadScriptFile(self, window, FileName) ##üstüne ekle def LoadScriptData(self, window, code): self.Clear() exec code in self.ScriptDictionary Body = self.ScriptDictionary["window"] self.CheckKeyList("window", Body, self.BODY_KEY_LIST) window.ClearDictionary() self.InsertFunction = window.InsertChild window.SetPosition(int(Body["x"]), int(Body["y"])) if localeInfo.IsARABIC(): w = wndMgr.GetScreenWidth() h = wndMgr.GetScreenHeight() if "width" in Body: w = int(Body["width"]) if "height" in Body: h = int(Body["height"]) window.SetSize(w, h) else: window.SetSize(int(Body["width"]), int(Body["height"])) if True == ("style" in Body): for StyleList in Body["style"]: window.AddFlag(StyleList) self.LoadChildren(window, Body)
Kod:
##boş bir yere ekleyin ENABLE_UI_DEBUG_WINDOW = True # load DebugWindow.py from client folder instead of login window
networkModule.py
Kod:
##ara import introLogin self.SetPhaseWindow(introLogin.LoginWindow(self)) ##değiştir import constInfo if constInfo.ENABLE_UI_DEBUG_WINDOW: self.SetPhaseWindow(DebugWindow(self)) else: import introLogin self.SetPhaseWindow(introLogin.LoginWindow(self)) ##sayfanın en sonuna ekle import app, dbg, ime, net, time, ui, constInfo, wndMgr class DebugWindow(ui.ScriptWindow): def __init__(self, stream): ui.ScriptWindow.__init__(self) net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self) net.SetAccountConnectorHandler(self) self.stream=stream # extra self.autoUpdate = True self.lastUpdate = 0 self.debugUpdate = 0 self.hideTipUI = False self.squares = [[0,0],[0,0]] self.mousePress = False def __del__(self): net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self) net.SetAccountConnectorHandler(0) ui.ScriptWindow.__del__(self) def LoadDefaultWindow(self): self.blackboard = ui.Bar("GAME")#bottom ui self.blackboard.AddFlag("attach") self.blackboard.SetPosition(0, 0) self.blackboard.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight()) self.blackboard.SetColor(0xFF7f7f7f)#0xFF000000) self.blackboard.Show() self.infotips = ui.TextLine() self.infotips.SetParent(self.blackboard) self.infotips.SetPackedFontColor(0xFFffaaaa) self.infotips.SetOutline() self.infotips.SetFontName("Arial:24") self.infotips.SetText("F5 MANUAL-REFRESH - F6 AUTOMATIC-REFRESH - F7 HIDE TIPS") self.infotips.SetPosition(wndMgr.GetScreenWidth() / 2 - self.infotips.GetTextSize()[0] / 2, 20) self.infotips.Show() self.updatetips = ui.TextLine() self.updatetips.SetParent(self.blackboard) self.updatetips.SetPackedFontColor(0xFFff6666) self.updatetips.SetOutline() self.updatetips.SetFontName("Arial:20") self.updatetips.SetText("AUTOREFRESH STATUS: {}".format("ON" if self.autoUpdate else "OFF")) self.updatetips.SetPosition(wndMgr.GetScreenWidth() / 2 - self.updatetips.GetTextSize()[0] / 2, 40) self.updatetips.Show() self.debugtips = ui.TextLine() self.debugtips.SetParent(self.blackboard) self.debugtips.SetPackedFontColor(0xFF66ff66) self.debugtips.SetOutline() self.debugtips.SetFontName("Arial:20") self.debugtips.SetText("ScreenWidth {}, ScreenHeight {}, MouseX {}, MouseY {}") self.debugtips.SetPosition(wndMgr.GetScreenWidth() / 2 - self.debugtips.GetTextSize()[0] / 2, 60) self.debugtips.Show() self.squaretips = ui.TextLine() self.squaretips.SetParent(self.blackboard) self.squaretips.SetPackedFontColor(0xFF6666ff) self.squaretips.SetOutline() self.squaretips.SetFontName("Arial:20") self.squaretips.SetText("Selected Box: Pos [xxx,xxx],[xxx,xxx] Size [xxx,xxx]") self.squaretips.SetPosition(wndMgr.GetScreenWidth() / 2 - self.squaretips.GetTextSize()[0] / 2, 80) self.squaretips.Hide() self.squarebox = ui.Box("CURTAIN")#top ui self.squarebox.AddFlag("attach") self.squarebox.SetPosition(0, 0) self.squarebox.SetSize(10, 10) self.squarebox.SetColor(0xFF6666ff) self.squarebox.Hide() self.blackboard.OnMouseLeftButtonDown = self.OnMouseLeftButtonDown self.blackboard.OnMouseLeftButtonUp = self.OnMouseLeftButtonUp def OnMouseLeftButtonDown(self): xMouse, yMouse = wndMgr.GetMousePosition() xBoard, yBoard = self.blackboard.GetGlobalPosition() realX = xMouse-xBoard realY = yMouse-yBoard if realX < 0 or realX > wndMgr.GetScreenWidth(): return False if realY < 0 or realY > wndMgr.GetScreenHeight(): return False self.squares[0] = [realX, realY] self.squares[1] = [0, 0] self.mousePress = True def OnMouseLeftButtonUp(self): def run(): xMouse, yMouse = wndMgr.GetMousePosition() xBoard, yBoard = self.blackboard.GetGlobalPosition() realX = xMouse-xBoard realY = yMouse-yBoard if realX < 0 or realX > wndMgr.GetScreenWidth(): self.squares[1] = [0,0] return False if realY < 0 or realY > wndMgr.GetScreenHeight(): self.squares[1] = [0,0] return False self.squares[1] = [realX, realY] if self.squares[0] == self.squares[1]: self.squares[1] = [0,0] run() self.mousePress = False self.RefreshSquareBox() def RefreshDebugInfo(self): xMouse, yMouse = wndMgr.GetMousePosition() xBoard, yBoard = self.blackboard.GetGlobalPosition() self.debugtips.SetText("ScreenWidth {}, ScreenHeight {}, X {}, Y {}".format( wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight(), xMouse-xBoard, yMouse-yBoard )) def RefreshSquareBox(self): squares = list(self.squares) if squares[0] != [0,0] and squares[1] != [0,0]: if squares[0] > squares[1]: squares[0], squares[1] = squares[1], squares[0] sizes = [squares[1][i] - squares[0][i] for i in range(len(squares[0]))] self.squarebox.SetPosition(*squares[0]) self.squarebox.SetSize(*sizes) self.squarebox.Show() self.squaretips.SetText("Selected Box: Pos {} Des {} Size {}".format(str(squares[0]), str(squares[1]), str(sizes))) self.squaretips.Show() else: self.squarebox.Hide() self.squaretips.Hide() def LoadWindow(self): try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptData(self, open("DebugWindow.py", "rb").read()) except Exception as e: dbg.TraceError("MakeWindow::LoadWindow Error: {}".format(e)) def Open(self): self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight()) self.SetWindowName("MakeWindow") # load default ui self.LoadDefaultWindow() self.LoadWindow() self.Show() app.ShowCursor() def Close(self): ime.ClearExceptKey() app.HideCursor() def OnPressExitKey(self): if self.stream.popupWindow: self.stream.popupWindow.Close() self.stream.SetPhaseWindow(0) return True def Refresh(self): self.ClearDictionary() del self.Children self.LoadWindow() def SetOnMouseChildren(child): child.OnMouseLeftButtonDown = self.OnMouseLeftButtonDown child.OnMouseLeftButtonUp = self.OnMouseLeftButtonUp if hasattr(child, "Children") and isinstance(child.Children, list): for child2 in child.Children: SetOnMouseChildren(child2) SetOnMouseChildren(self) def OnKeyDown(self, key): if app.DIK_F5 == key: self.Refresh() elif app.DIK_F6 == key: self.autoUpdate = not self.autoUpdate self.updatetips.SetText("AUTOREFRESH STATUS: {}".format("ON" if self.autoUpdate else "OFF")) dbg.LogBox("AutoUpdate {}".format("activated" if self.autoUpdate else "disabled")) elif app.DIK_F7 == key: self.hideTipUI = not self.hideTipUI if self.hideTipUI: self.infotips.Hide() self.updatetips.Hide() self.debugtips.Hide() self.squaretips.Hide() self.squaretips.Hide() else: self.infotips.Show() self.updatetips.Show() self.debugtips.Show() self.squaretips.Show() return True def OnUpdate(self): if self.autoUpdate: if self.lastUpdate < time.clock(): self.Refresh() self.lastUpdate = time.clock()+1 if self.debugUpdate < time.clock(): self.debugUpdate = time.clock()+0.05 self.RefreshDebugInfo() if self.mousePress: xMouse, yMouse = wndMgr.GetMousePosition() xBoard, yBoard = self.blackboard.GetGlobalPosition() realX = xMouse-xBoard realY = yMouse-yBoard self.squares[1] = [realX, realY] self.RefreshSquareBox() return True
Aşağıdaki kodu DebugWindow.py olarak kaydedip client'in olduğu dizine atın.
Kod:
import uiScriptLocale BOARD_WIDTH = 280 BOARD_HEIGHT = 105 window = { "name" : "PopupDialog", "style" : ("movable", "float",),#movable ui "x" : SCREEN_WIDTH/2 - BOARD_WIDTH/2,#centered "y" : SCREEN_HEIGHT/2 - BOARD_HEIGHT/2,#centered "width" : BOARD_WIDTH, "height" : BOARD_HEIGHT, "children" : ( { "name" : "board", "type" : "board", #"style" : ("attach",),#required for movable "x" : 0, "y" : 0, "width" : BOARD_WIDTH, "height" : BOARD_HEIGHT, "children" : ( { "name" : "message", "type" : "text", "x" : 0, "y" : 38, "text" : uiScriptLocale.MESSAGE, "horizontal_align" : "center", "text_horizontal_align" : "center", "text_vertical_align" : "center", }, { "name" : "accept", "type" : "button", "x" : 0, "y" : 63, "width" : 61, "height" : 21, "horizontal_align" : "center", "text" : uiScriptLocale.OK, "default_image" : "d:/ymir work/ui/public/middle_button_01.sub", "over_image" : "d:/ymir work/ui/public/middle_button_02.sub", "down_image" : "d:/ymir work/ui/public/middle_button_03.sub", }, ), }, ), }
Kanıt:
Thank you for this
Ziyaretçiler için gizlenmiş link,görmek için üye olmalısınız!
Giriş yap veya üye ol.
Metin2 Debug UI Penceresi Scriptleri
Metin2 özel sunucularında geliştirme yaparken, kullanıcı arayüzü (UI) üzerinde çalışan scriptlerin test edilmesi ve hata ayıklanması oldukça kritiktir. Özellikle PvP sistemlerinde veya oyun içi GUI elementlerinde kullanılan Debug UI Window Scripts adı verilen bu scriptler, geliştiricilerin hataları daha hızlı ve etkili bir şekilde tespit etmelerini sağlar.
Debug UI Window Nedir?
Debug UI Window, geliştiricilerin oyun içi arayüz elemanlarını test etmek, değişkenleri takip etmek, olayları loglamak ve genel olarak UI'nın davranışlarını anlamak için kullandığı bir pencere türüdür. Bu pencere genellikle Python GUI (PyGUI) ya da UIScript kullanılarak geliştirilir ve oyun içine entegre edilir. Py Root dosyalarında tanımlanan bu yapılarla, oyun içindeki scriptlerin kontrolü kolaylaşır.
Python ve C++ Kombinasyonunda UI Hata Ayıklama
Metin2 sunucularında, UI sistemleri genellikle Python tarafında tanımlanırken, bazı fonksiyonlar C++ backend tarafından sağlanır. Bu nedenle, debug UI window scriptleri hem Python hem de C++ seviyesinde çalışabilir. Geliştiriciler, Python tarafında bir pencere oluştururken aynı zamanda C++ backend'ten gelen verileri de takip edebilmek için bu iki dili entegre etmelidir.
UIScript ile Debug Arayüzü Oluşturma
UIScript, Metin2 UI sistemlerinin temel yapı taşlarından biridir. Bu scriptler, XML benzeri yapılarla yazılmaz; aksine, Python tabanlı bir yapıya sahiptir. Debug UI Window scriptleri genellikle bu yapıya göre tasarlanır. Örneğin, bir debug penceresi açıldığında, oyun içindeki olaylar, değişkenler ve veriler bu pencereye yazdırılır. Bu sayede geliştirici, scriptlerin nasıl davrandığını ve nerede hata oluştuğunu görebilir.
PyGUI ile Hata Ayıklama
PyGUI, Python tabanlı grafiksel arayüz oluşturmaya yarar. Metin2 geliştiricileri, PyGUI kullanarak debug pencereleri oluşturabilir ve bu pencereler üzerinden oyun içi verileri izleyebilirler. PyGUI, Py Root dosyalarıyla entegre çalıştığı için, scriptlerin doğrudan oyun içi verilerle etkileşim kurmasını sağlar. Bu da debug süreçlerini daha verimli kılar.
PVP Sistemlerinde Debug UI Kullanımı
PvP sistemlerinde debug UI window scriptleri özellikle önemlidir. Oyuncuların eylemleri, skorlar, savaş verileri gibi bilgiler debug pencereleri üzerinden takip edilebilir. Bu sayede, PvP sistemlerindeki mantık hataları, performans sorunları veya veri akışı problemleri daha hızlı çözülebilir.
Martysama ve Metin2 Development Araçları
Metin2 geliştirme ortamında Martysama gibi isimler, birçok geliştirici için referans teşkil eder. Debug UI scriptleri de bu altyapıların bir parçasıdır. Bu tür araçlar sayesinde, hem yeni başlayan geliştiriciler hem de deneyimli oyuncular, sistemlerini daha verimli test edebilir ve geliştirebilirler.
Sonuç
Debug UI Window Scripts, Metin2 özel sunucu geliştirme sürecinde önemli bir rol oynar. Geliştiricilerin UI sistemlerini test etmesini ve hata ayıklamasını kolaylaştırır. Python GUI, UIScript ve Py Root gibi teknolojilerle birleştirildiğinde, bu scriptler güçlü bir geliştirme aracı haline gelir. PvP sistemleri, DB işlemleri ve oyun içi scriptler için bu yapılar vazgeçilmezdir.
Metin2 Debug UI Window Scripts
When developing on Metin2 private servers, testing and debugging scripts that run on the user interface (UI) are critical. Especially in PvP systems or in-game GUI elements, these scripts called Debug UI Window Scripts help developers detect errors faster and more effectively.
What is Debug UI Window?
Debug UI Window is a type of window used by developers to test in-game UI elements, track variables, log events, and understand the behavior of the UI. This window is generally developed using Python GUI (PyGUI) or UIScript and integrated into the game. Through Py Root files, these structures allow easier control of the game scripts.
UI Debugging with Python and C++ Combination
In Metin2 servers, UI systems are usually defined on the Python side, while certain functions are provided by the C++ backend. Therefore, debug UI window scripts can operate at both Python and C++ levels. Developers must integrate both languages in order to create a window on the Python side while tracking data coming from the C++ backend.
Creating Debug Interface with UIScript
UIScript is one of the fundamental building blocks of Metin2 UI systems. These scripts are not written in an XML-like structure but rather follow a Python-based syntax. Debug UI Window scripts are often designed according to this structure. For instance, when a debug window opens, in-game events, variables, and data are printed to this window. This allows the developer to see how the scripts behave and where errors occur.
Debugging with PyGUI
PyGUI enables the creation of Python-based graphical interfaces. Metin2 developers can create debug windows using PyGUI and monitor in-game data through these windows. Since PyGUI works in integration with Py Root files, it allows scripts to directly interact with in-game data. This makes debugging processes more efficient.
Using Debug UI in PVP Systems
Debug UI window scripts are particularly important in PvP systems. Player actions, scores, combat data, etc., can be tracked via debug windows. This allows logic errors, performance issues, or data flow problems within PvP systems to be resolved more quickly.
Martysama and Metin2 Development Tools
Within the Metin2 development environment, names like Martysama serve as references for many developers. Debug UI scripts are part of these infrastructures. Thanks to such tools, both beginner and experienced developers can test and enhance their systems more efficiently.
Conclusion
Debug UI Window Scripts play a crucial role in the Metin2 private server development process. They make it easier for developers to test and debug UI systems. Combined with technologies like Python GUI, UIScript, and Py Root, these scripts become powerful development tools. They are indispensable for PvP systems, database operations, and in-game scripting.
