Jump to content

Help Gui


Parker

Recommended Posts

Hello, I want to create a custom button under the menu on the left, but I have an error on line 10, I can't figure out how much

 

function init()
    -- Определяем размер панельки
    local panelWidth = 200
    local panelHeight = 100
    -- Создаем кнопку и добавляем ее на панель
    local button = ISButton:new(0, 0, 100, 30, "Открыть", nil, onButtonClick)
    local panel = ISPanel:new(getCore():getScreenWidth() - panelWidth, getCore():getScreenHeight() - panelHeight, panelWidth, panelHeight)
    panel:addChild(button)
    -- Добавляем панель на существующее окно "NewCraftingUI"
    local craftingUI = UIManager:getWindow("NewCraftingUI") -- ERROR!!!
    craftingUI:addView("MyPanel", panel)
  end
  
  -- Вызывается при нажатии на кнопку
  function onButtonClick(button)
    -- Создаем и отображаем окно со списком кнопок
    local menu = ISContextMenu:new(0, 0, 0, 0)
    menu:addOption("Статистика", nil) -- TODO: Добавить обработчик нажатия
    menu:addOption("Опции", nil) -- TODO: Добавить обработчик нажатия
    menu:addOption("Выход", nil) -- TODO: Добавить обработчик нажатия
    menu:setX(getCore():getScreenWidth() - menu:getWidth())
    menu:setY(getCore():getScreenHeight() - menu:getHeight())
    menu:addToUIManager()
  end
  
  -- Вызываем функцию при подключении к игре
  Events.OnGameBoot.Add(init)

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...