mirror of
https://github.com/edubart/otclient.git
synced 2025-11-30 15:26:49 +01:00
Buttons for client options
This commit is contained in:
@@ -284,3 +284,7 @@ end
|
||||
function addTab(name, panel, icon)
|
||||
optionsTabBar:addTab(name, panel, icon)
|
||||
end
|
||||
|
||||
function addButton(name, func, icon)
|
||||
optionsTabBar:addButton(name, func, icon)
|
||||
end
|
||||
|
||||
@@ -60,6 +60,18 @@ function UITabBar:addTab(text, panel, icon)
|
||||
return tab
|
||||
end
|
||||
|
||||
function UITabBar:addButton(text, func, icon)
|
||||
local button = g_ui.createWidget(self:getStyleName() .. 'Button', self.buttonsPanel)
|
||||
button:setText(text)
|
||||
|
||||
local style = {}
|
||||
style['icon-source'] = icon
|
||||
button:mergeStyle(style)
|
||||
|
||||
button.onClick = func
|
||||
return button
|
||||
end
|
||||
|
||||
function UITabBar:removeTab(tab)
|
||||
local index = table.find(self.tabs, tab)
|
||||
if index == nil then return end
|
||||
|
||||
@@ -40,7 +40,7 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||
textEdit:setText(text)
|
||||
textEdit:setEditable(writeable)
|
||||
textEdit:setCursorVisible(writeable)
|
||||
|
||||
|
||||
local desc = ''
|
||||
if #writter > 0 then
|
||||
desc = tr('You read the following, written by \n%s\n', writter)
|
||||
@@ -71,6 +71,10 @@ function onGameEditText(id, itemId, maxLength, text, writter, time)
|
||||
textWindow:setText(tr('Edit Text'))
|
||||
end
|
||||
|
||||
if description:getHeight() < 64 then
|
||||
description:setHeight(64)
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
textWindow:destroy()
|
||||
table.removevalue(windows, textWindow)
|
||||
@@ -109,20 +113,22 @@ function onGameEditList(id, doorId, text)
|
||||
description:setText(tr('Enter one name per line.'))
|
||||
textWindow:setText(tr('Edit List'))
|
||||
|
||||
if description:getHeight() < 64 then
|
||||
description:setHeight(64)
|
||||
end
|
||||
|
||||
local function destroy()
|
||||
textWindow:destroy()
|
||||
table.removevalue(windows, textWindow)
|
||||
end
|
||||
|
||||
doneFunc = function()
|
||||
local doneFunc = function()
|
||||
g_game.editList(id, doorId, textEdit:getText())
|
||||
destroy()
|
||||
end
|
||||
|
||||
okButton.onClick = doneFunc
|
||||
cancelButton.onClick = destroy
|
||||
|
||||
textWindow.onEnter = doneFunc
|
||||
textWindow.onEscape = destroy
|
||||
|
||||
table.insert(windows, textWindow)
|
||||
|
||||
Reference in New Issue
Block a user