Jump to content

I need help to solve this error


Go to solution Solved by nazox,

Recommended Posts

Quote

syserr.txt

0403 21:59:11614 :: 
uiPatchnotes.py(line:42) LoadWindow
ui.py(line:2707) GetChild

PatchNoteWindow.LoadWindow.BindObject - <type 'exceptions.KeyError'>:'patch_notes_area'

0403 21:59:11615 :: ============================================================================================================
0403 21:59:11615 :: Abort!!!!

Quote


uiPatchnotes.py

import app, net, ui, dbg, os, localeInfo, constInfo, uiScriptLocale, uiCommon
from _weakref import proxy

IMAGE_PATH = "d:/ymir work/ui/public/patchnote/"

MAX_VIEW_PATCHNOTES = 10

class PatchNoteWindow(ui.ScriptWindow):
    def __init__(self):
        ui.ScriptWindow.__init__(self)
        self.isMouseWheel = False
        self.ScrollBarStep = 0.2
        self.curScrollbarPos = 0.0

        self.LoadWindow()

    def __del__(self):
        ui.ScriptWindow.__del__(self)
        self.isMouseWheel = False
        self.ScrollBarStep = 0.2
        self.curScrollbarPos = 0.0
        self.destScrollbarPos = 0.0

    def Show(self):
        ui.ScriptWindow.Show(self)

    def Close(self):
        self.Hide()
        
    def LoadWindow(self):
        try:
            pyScrLoader = ui.PythonScriptLoader()
            pyScrLoader.LoadScriptFile(self, "patchnotes.py")
        except:
            import exception
            exception.Abort("PatchNoteWindow.LoadWindow.LoadObject")
            
        try:
            self.GetChild("board").SetCloseEvent(self.Close)

            self.boxPatchnotes = ListBoxItems()
            self.boxPatchnotes.SetParent(self.GetChild("patch_notes_area"))
            self.boxPatchnotes.SetGlobalParent(self)
            self.boxPatchnotes.SetPosition(0, 0)
            self.boxPatchnotes.SetSize(627, 489)
            self.boxPatchnotes.Show()
                
            self.scrollBar = ScrollBar()
            self.scrollBar.SetParent(self.GetChild("patch_scrollbar_area"))
            self.scrollBar.SetScrollEvent(ui.__mem_func__(self.OnScroll))
            self.scrollBar.SetTexture(IMAGE_PATH + "patchnote_scrollbar.png")
            self.scrollBar.SetMovementArea(0, 0, 4, 493)
            self.scrollBar.SetPosition(0, 0)
            self.scrollBar.Show()
            
            self.BuildPatchnotes()

        except:
            import exception
            exception.Abort("PatchNoteWindow.LoadWindow.BindObject")
    
    def OnRunMouseWheel(self, nLen):
        if self.scrollBar.IsShow():
            if nLen > 0:
                pos = self.destScrollbarPos - self.ScrollBarStep
            else:
                pos = self.destScrollbarPos + self.ScrollBarStep
            pos = max(0.0, pos)
            pos = min(1.0, pos)

            self.isMouseWheel = True
            self.destScrollbarPos = pos

    def OnScroll(self):
        self.listbox.OnScroll(self.scrollBar.GetPos())

    def OnUpdate(self):
        if self.isMouseWheel:
            self.curScrollbarPos += (self.destScrollbarPos - self.curScrollbarPos) / 10.0
            if abs(self.curScrollbarPos - self.destScrollbarPos) < 0.0005:
                self.curScrollbarPos = self.destScrollbarPos
                self.isMouseWheel = False
            self.scrollBar.SetPos(self.curScrollbarPos)
        else:
            self.curScrollbarPos = self.scrollBar.GetPos()
            self.destScrollbarPos = self.scrollBar.GetPos()
    
    def BuildPatchnotes(self):
        try:
            patchnotes = pack_open("%s/patchnotes.txt" % app.GetLocalePath(), "r")
        except:
            patchnotes = pack_open("locale/pt/patchnotes.txt", "r")
        
        count_patchnotes = 0
        isUpdate = False
        title = ["", ""]
        lines = []
        
        for line in patchnotes:
            if "Version: " in line:
                title[0] = line.split()[1]
            if "Date: " in line:
                title[1] = line.split()[1]
            if "## UPDATE ##" in line:
                isUpdate = True
                continue
            if "## END ##" in line:
                self.ListBox.AppendObject(title, lines)
                isUpdate = False
                title = ["", ""]
                lines = []
                count_patchnotes += 1
                if MAX_VIEW_PATCHNOTES != 0 and MAX_VIEW_PATCHNOTES == count_patchnotes:
                    break

            if isUpdate:
                lines.append(self.SplitDescription(line, 120))
        
        if count_patchnotes > 8:
            self.ScrollBarStep = 0.1
        if count_patchnotes > 12:
            self.ScrollBarStep = 0.07
        if count_patchnotes > 15:
            self.ScrollBarStep = 0.04

    def SplitDescription(self, desc, limit):
        total_tokens = desc.split()
        line_tokens = []
        line_len = 0
        lines = []
        for token in total_tokens:
            if "|" in token:
                sep_pos = token.find("|")
                line_tokens.append(token[:sep_pos])

                lines.append(" ".join(line_tokens))
                line_len = len(token) - (sep_pos + 1)
                line_tokens = [token[sep_pos+1:]]
            else:
                line_len += len(token)
                if len(line_tokens) + line_len > limit:
                    lines.append(" ".join(line_tokens))
                    line_len = len(token)
                    line_tokens = [token]
                else:
                    line_tokens.append(token)
        
        if line_tokens:
            lines.append(" ".join(line_tokens))

        return lines

class ListBoxItems(ui.Window):
    class Item(ui.Window):
        def __init__(self, parent, index, title, lines):
            ui.Window.__init__(self)
            ui.Window.SetParent(self, parent)
            
            # self.tooltipItem = uiToolTip.ItemToolTip()
            # self.tooltipItem.Hide()
            
            self.parent = proxy(parent)
            self.SetWindowName("ListBox_Patchnotes")
            self.xBase, self.yBase = 0, 0
            
            self.index = index

            self.image_title = ui.MakeExpandedImageBox(self, IMAGE_PATH + "patchnote_top.png", 0, 0, "not_pick")
            self.image_title.SetParent(self)
            self.image_title.Show()
            
            self.textVersion = ui.TextLine()
            self.textVersion.SetParent(self.image_title)
            self.textVersion.SetHorizontalAlignCenter()
            self.textVersion.SetPosition(50, 4)
            self.textVersion.SetPackedFontColor(0xffffffff)
            self.textVersion.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
            self.textVersion.SetOutline()
            self.textVersion.SetText(str(title[0]))
            self.textVersion.Show()
            
            self.textDate = ui.TextLine()
            self.textDate.SetParent(self.image_title)
            self.textDate.SetHorizontalAlignCenter()
            self.textDate.SetPosition(580, 4)
            self.textDate.SetPackedFontColor(0xffffffff)
            self.textDate.SetFontName(localeInfo.UI_DEF_FONT_LARGE)
            self.textDate.SetOutline()
            self.textDate.SetText(str(title[1]))
            self.textDate.Show()
            
            self.text_backgrounds = []
            self.text_rows = []
            
            line_count = 0
            for row_lines in xrange(len(lines)):
                for sub_lines in xrange(len(lines[row_lines])):
                    row_image = ui.MakeExpandedImageBox(self, IMAGE_PATH + "patchnote_middle.png", 0, 22 + 15 * line_count, "not_pick")
                    row_image.SetParent(self)
                    row_image.Show()
                    self.text_backgrounds.append(row_image)
                    
                    textLine = ui.TextLine()
                    textLine.SetParent(row_image)
                    textLine.SetPosition(5, 0)
                    textLine.SetFontName(localeInfo.UI_DEF_FONT_SLARGE)
                    textLine.SetText(str(lines[row_lines][sub_lines]))
                    textLine.Show()
                    self.text_rows.append(textLine)
                    line_count += 1
            row_image = ui.MakeExpandedImageBox(self, IMAGE_PATH + "patchnote_bottom.png", 0, 22 + 15 * line_count, "not_pick")
            row_image.SetParent(self)
            row_image.Show()
            self.text_backgrounds.append(row_image)

        def __del__(self):
            ui.Window.__del__(self)
            self.xBase, self.yBase = 0, 0
            self.index = 0

        def SetBasePosition(self, x, y):
            self.xBase = x
            self.yBase = y

        def GetBasePosition(self):
            return (self.xBase, self.yBase)

        def GetIndex(self):
            return self.index

        def Show(self):
            ui.Window.Show(self)
        
        def OnRender(self):
            xList, yList = self.parent.GetGlobalPosition()

            self.image_title.SetClipRect(xList, yList, xList + self.parent.GetWidth(), yList + self.parent.GetHeight())

            xText, yText = self.textVersion.GetGlobalPosition()
            wText, hText = self.textVersion.GetWidth(), 13

            if yText < yList or (yText + hText > yList + self.parent.GetHeight()):
                self.textVersion.Hide()
                self.textDate.Hide()
            else:
                self.textVersion.Show()
                self.textDate.Show()
                
            for i in xrange(len(self.text_backgrounds)):
                self.text_backgrounds[i].SetClipRect(xList, yList, xList + self.parent.GetWidth(), yList + self.parent.GetHeight())

            for i in xrange(len(self.text_rows)):
                xText, yText = self.text_rows[i].GetGlobalPosition()
                wText, hText = self.text_rows[i].GetWidth(), 13

                if yText < yList or (yText + hText > yList + self.parent.GetHeight()):
                    self.text_rows[i].Hide()
                else:
                    self.text_rows[i].Show()
                    

    def __init__(self):
        ui.Window.__init__(self)
        self.SetWindowName("ListBox")
        self.globalParent = None
        self.size_y = 0
        self.index_list = 0
        self.object_list = []

    def __del__(self):
        ui.Window.__del__(self)
        self.globalParent = None
        self.size_y = 0
        self.index_list = 0
        self.object_list = []

    def GetObjectCount(self):
        count = 0
        for i in xrange(len(self.object_list)):
            count += 1
        return count

    def GetSize(self):
        return self.size_y
        
    def SetGlobalParent(self, parent):
        self.globalParent = proxy(parent)

    def OnScroll(self, scrollPos):
        totalHeight = 0
        for item in self.object_list:
            totalHeight += item.GetHeight() 

        totalHeight -= self.GetHeight()

        for i in xrange(len(self.object_list)):
            x, y = self.object_list[i].GetLocalPosition()
            xB, yB = self.object_list[i].GetBasePosition()
            setPos = yB - int(scrollPos * totalHeight)
            self.object_list[i].SetPosition(xB, setPos)

    def AppendObject(self, title, lines):
        self.index_list += 1
        item = self.Item(self, self.index_list, title, lines)

        line_count = 0
        for row_lines in xrange(len(lines)):
            for sub_lines in xrange(len(lines[row_lines])):
                line_count += 15
    
        item.SetSize(639, 30 + line_count + 4 + 4)
        self.size_y += 22 + line_count + 4 + 4
        # item.SetSize(32, 32 + space_y)
        
        if len(self.object_list) == 0:
            item.SetPosition(0, 0)
            item.SetBasePosition(0, 0)
        else:
            x, y = self.object_list[-1].GetLocalPosition()
            item.SetPosition(0, y + self.object_list[-1].GetHeight())
            item.SetBasePosition(0, y + self.object_list[-1].GetHeight())
        
        item.Show()
        self.object_list.append(item)
        
    def ClearList(self):
        self.index_list = 0
        self.object_list = []

class ScrollBar(ui.DragButton):
    def __init__(self):
        ui.DragButton.__init__(self)
        self.AddFlag("float")
        self.AddFlag("movable")
        self.AddFlag("restrict_x")

        self.eventScroll = lambda *arg: None
        self.movearea = 0
        self.currentPos = 0.0

    def __del__(self):
        ui.DragButton.__del__(self)
        self.movearea = 0
        self.currentPos = 0.0
        self.eventScroll = lambda *arg: None

    def SetMovementArea(self, x, y, width, height):
        self.movearea = height - y - self.GetHeight()
        self.SetRestrictMovementArea(x, y, width, height)
    
    def SetTexture(self, image):
        self.SetUpVisual(image)
        self.SetOverVisual(image)
        self.SetDownVisual(image)

    def SetScrollEvent(self, event):
        self.eventScroll = event

    def SetPos(self, pos):
        pos = max(0.0, pos)
        pos = min(1.0, pos)

        yPos = float(pos * self.movearea)

        self.SetPosition(12, yPos)
        self.OnMove()

    def GetPos(self):
        return self.currentPos
        
    def OnMove(self):
        (xLocal, yLocal) = self.GetLocalPosition()
        self.currentPos = float(yLocal) / float(self.movearea) 

        self.eventScroll()

Quote

patchnotes.py

import uiScriptLocale
import localeInfo
import constInfo

WINDOW_WIDTH = 680
WINDOW_HEIGHT = 550

window = {
    "name" : "PatchNotesWindow",

    "x" : (SCREEN_WIDTH / 2) - (WINDOW_WIDTH / 2),
    "y" : (SCREEN_HEIGHT / 2) - (WINDOW_HEIGHT / 2) ,

    "style" : ("movable", "float",),

    "width" : WINDOW_WIDTH,
    "height" : WINDOW_HEIGHT,

    "children" :
    (
        {
            "name" : "board",
            "type" : "board_with_titlebar",

            "x" : 0,
            "y" : 0,

            "width" : WINDOW_WIDTH,
            "height" : WINDOW_HEIGHT,
            "title" : "Patchnotes",
            "children" :
            (
                { 
                    "name" : "container",
                    "type" : "border_b",
                    "x" : 15,
                    "y" : 35,
                    "width" : WINDOW_WIDTH - 30,
                    "height" : WINDOW_HEIGHT - 35 - 15,
                    "children" :
                    (
                        { "name" : "line",
                        "type" : "line",
                        "x" : 636,
                        "y" : 0,
                        "color" : 0xff232323,
                        "width" : 0, "height" : 498, 
                        },
                        
                        { "name" : "patch_scrollbar_area",
                        "type" : "window",
                        "x" : 639,
                        "y" : 4,
                        "width" : 7,
                        "height" : 493, 
                        },
                        
                        { "name" : "patch_notes_area",
                        "type" : "window", 
                        "x" : 6,
                        "y" : 6,
                        "width" : 627,
                        "height" : 489, 
                        },
                    ),
                },
            ),
        },
    ),
}

 

Link to comment
Share on other sites

  • 3 weeks later...
  • Active Member
  • Solution

1. Go to uiscript/patchnotes.py and replace for this:

Quote

                { 
                    "name" : "container",  "type" : "thinboard", "x" : 15, "y" : 35, "width" : WINDOW_WIDTH - 30, "height" : WINDOW_HEIGHT - 35 - 15,
                    "children" :
                    (
                        {  "name" : "line",  "type" : "line", "x" : 636, "y" : 0, "color" : 0xff232323,"width" : 0, "height" : 498, },
                        { "name" : "patch_scrollbar_area", "type" : "window", "x" : 639, "y" : 4, "width" : 7, "height" : 493, },
                        { "name" : "patch_notes_area", "type" : "window", "x" : 6, "y" : 6, "width" : 627, "height" : 489, },
                    ),
                },

1.1 New change is "border_b" to "thinboard"

2.Go to "ui.py" and now search : "def MakeImageBox(parent, name, x, y): " and after function add:

Quote

def MakeExpandedImageBox(parent, name, x, y, flag = ""):
    image = ExpandedImageBox()
    image.SetParent(parent)
    image.LoadImage(name)
    image.SetPosition(x, y)
    if flag != "":
        image.AddFlag(flag)
        image.Show()
    return image

2.1 Like this:

Quote

 

def MakeImageBox(parent, name, x, y):
    image = ImageBox()
    image.SetParent(parent)
    image.LoadImage(name)
    image.SetPosition(x, y)
    image.Show()
    return image

def MakeExpandedImageBox(parent, name, x, y, flag = ""): #This is the new function
    image = ExpandedImageBox()
    image.SetParent(parent)
    image.LoadImage(name)
    image.SetPosition(x, y)
    if flag != "":
        image.AddFlag(flag)
        image.Show()
    return image

 

3. If  you have problem with "Y_Start" in "systemdialog.py" only change for Y : xx (add new cordenates)

3.1 For example this:

Quote

 

                    "name" : "patchnotes_button",
                    "type" : "button",

                    "x" : 10,
                    "y" : 247+90, #New 

                    "text_color" : 0xffF8BF24,
                    "text" : "Parches",
                    
                    "default_image" : ROOT + "XLarge_Button_01.sub",
                    "over_image" : ROOT + "XLarge_Button_02.sub",
                    "down_image" : ROOT + "XLarge_Button_03.sub",
                },

 

3.2 Note: remember add in systemwindow.py locale or uiscript (this depence your files.)

4.For the problem " UI_DEF_FONT_SLARGE " go to locale/xx/locale_game" and add on top:

Quote

UI_DEF_FONT_SLARGE    Patchnotes

Have fun! 🙂

  • Love 4

KH.jpg

Nicks: Nazox Krone Nagato Yahiko Yakiro
Proyecto: Trabajando en el.
Compañeros & firma: DreamHQ  - 2009-2015 [Nostalgia]

Link to comment
Share on other sites

  • 10 months later...

if somebody has problem with: 

def BuildPatchnotes(self):
        try:
            patchnotes = pack_open("%s/patchnotes.txt" % app.GetLocalePath(), "r")
        except:
            patchnotes = pack_open("locale/pt/patchnotes.txt", "r")


Change pack_open with open: 

def BuildPatchnotes(self):
        try:
            patchnotes = open("%s/patchnotes.txt" % app.GetLocalePath(), "r")
        except:
            patchnotes = open("locale/it/patchnotes.txt", "r")

Link to comment
Share on other sites

  • 11 months later...
  • Premium

Hello,
I had the same error which I managed to solve. However, now I am struggling with the error:

 

SYSERR: Traceback (most recent call last):

SYSERR:   File "networkModule.py", line 270, in SetGamePhase

SYSERR:   File "game.py", line 118, in __init__

SYSERR:   File "interfaceModule.py", line 559, in MakeInterface

SYSERR:   File "interfaceModule.py", line 461, in __MakeDialogs

SYSERR:   File "uiSystem.py", line 57, in LoadDialog

SYSERR:   File "uiSystem.py", line 76, in __LoadSystemMenu_Default

SYSERR:   File "ui.py", line 4448, in GetChild

SYSERR: KeyError
SYSERR: :
SYSERR: 'patchnotes_button'
SYSERR:

 

Key is in:

systemdialog.py:

if app.ENABLE_PATCHNOTE_WINDOW:
    ADD_Y += 30
    window["height"] = window["height"] + 30
    window["children"][0]["height"] = window["children"][0]["height"] + 30
    window["children"][0]["children"] = window["children"][0]["children"] + [
        {
            "name" : "patchnotes_button",
            "type" : "button",

            "x" : 10,
            "y" : ADD_Y + VERSION_ADD_Y,

            "text" : "Patchnotes",

            "default_image" : ROOT + "XLarge_Button_01.sub",
            "over_image" : ROOT + "XLarge_Button_02.sub",
            "down_image" : ROOT + "XLarge_Button_03.sub",
        },
    ]



uisystem.py:
 

        if app.ENABLE_PATCHNOTE_WINDOW:
            self.wndPatchnotes = uiPatchnotes.PatchNoteWindow()
            self.GetChild("patchnotes_button").SAFE_SetEvent(self.__ClickPatchnotesButton)


Does anyone know how to get past this error?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.