Jump to content

Fix left menu in inventory


Recommended Posts

  • Premium

Hi,
I managed to place an expansion menu next to the inventory, but I have a problem with the menu being "above" the inventory. I need to put it under the inventory when overlapping. How can I do this?

class SidebarWindow(ui.Board):
    BUTTON_WIDTH = 0
    BUTTON_HEIGHT = 32
    BUTTON_GAP_X = 20 #Position of button
    BUTTON_GAP_Y = 20 #Position of button

    def __init__(self, wndInventory):
        ui.Board.__init__(self)
        self.AddFlag("float")
        self.children = []
        self.wndInventory = wndInventory

        # NOTE: Add your buttons
        self.SIDEBAR_BUTTON = [
            {
                'text' : 'Teleport',
                'default_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'down_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'over_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'function' : self.wndInventory.ClickDSSButton
            },
            {
                'text' : 'Tržnice',
                'default_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'down_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'over_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'function' : self.wndInventory.ClickMallButton
            },
            {
                'text' : 'Switchbot',
                'default_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'down_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'over_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'function' : self.wndInventory.ClickMallButton
            },
            {
                'text' : 'Sklad',
                'default_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'down_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'over_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'function' : self.wndInventory.ClickMallButton
            },
            {
                'text' : 'Alchymie Dračích kamenů',
                'default_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'down_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'over_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'function' : self.wndInventory.ClickMallButton
            },
            {
                'text' : 'Button6',
                'default_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'down_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'over_image' : 'd:/ymir work/ui/public/slot_base.sub',
                'function' : self.wndInventory.ClickMallButton
            }
        ]
        self.CreateButtons()

    def Destroy(self):
        self.children = []
        self.wndInventory = None

    def __del__(self):
        ui.Board.__del__(self)

    def CreateButtons(self):
        y_pos = self.BUTTON_GAP_Y

        for item in self.SIDEBAR_BUTTON:
            button = ui.Button()
            button.SetParent(self)
            button.SetUpVisual(item['default_image'])
            button.SetDownVisual(item['down_image'])
            button.SetOverVisual(item['over_image'])
            button.SetToolTipText(item['text'])
            button.SetEvent(lambda : item['function']())
            button.SetPosition(self.BUTTON_GAP_X, y_pos)
            button.Show()

            self.children.append(button)
            y_pos += (self.BUTTON_GAP_Y + button.GetHeight())

        self.SetSize(
            self.BUTTON_GAP_X + self.BUTTON_WIDTH + self.BUTTON_GAP_X,
            len(self.SIDEBAR_BUTTON) * (self.BUTTON_HEIGHT + self.BUTTON_GAP_Y) + self.BUTTON_GAP_Y
        )
        self.AdjustPosition()

    def AdjustPosition(self):
        x, y = self.wndInventory.GetGlobalPosition()

        # NOTE: Adjust pos here
        self.SetPosition(x - 60, y)

 

Thank you

 

Image:

xMnKVGE.png

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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.