noisiv 1
noisiv
Manwe Work 1
Manwe Work
Scarlet 1
Scarlet
xranzei 1
xranzei
mavzermete 1
mavzermete
Hikaye Ekle

Debug UI Window Scripts

  • Konuyu başlatan Konuyu başlatan Reached
  • Başlangıç tarihi Başlangıç tarihi
  • Cevaplar Cevaplar 16
  • Görüntüleme Görüntüleme 5K
5.00 yıldız(lar) 1 Değerlendirme Değerlendirenler

HERAKLES Otomatik Avlı kalıcı sunucu. 19 Haziran'da açılıyor. Atius & Wizard güvencesiyle hemen kayıt ol, ön kayıt ödülleri aktif. HEMEN TIKLA!

Paylaşım sahibi : @martysama0134


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
Python:
##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)
constInfo.py
Python:
##boş bir yere ekleyin
ENABLE_UI_DEBUG_WINDOW = True # load DebugWindow.py from client folder instead of login window

networkModule.py
Python:
##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.
Python:
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 @martysama0134
 

En Çok Reaksiyon Alan Mesajlar

Şu an konuyu görüntüleyenler (Toplam : 0, Üye: 0, Misafir: 0)

Geri
Üst