local sf = require 'sampfuncs' function submenusshow(menu, caption, selectbutton,…
- User
local sf = require 'sampfuncs'
function submenus_show(menu, caption, select_button, close_button, back_button) select_button, close_button, back_button = select_button or 'Select', close_button or 'Close', back_button or 'Back' prev_menus = {} function display(menu, id, caption) local string_list = {} for i, v in ipairs(menu) do table.insert(string_list, type(v.submenu) == 'table' and v.title .. ' >>' or v.title) end sampShowDialog(id, caption, table.concat(string_list, '\n'), select_button, (#prev_menus > 0) and back_button or close_button, sf.DIALOG_STYLE_LIST) repeat wait(0) local result, button, list = sampHasDialogRespond(id) if result then if button == 1 and list ~= -1 then local item = menu[list + 1] if type(item.submenu) == 'table' then -- submenu table.insert(prev_menus, {menu = menu, caption = caption}) if type(item.onclick) == 'function' then item.onclick(menu, list + 1, item.submenu) end return display(item.submenu, id + 1, item.submenu.title and item.submenu.title or item.title) elseif type(item.onclick) == 'function' then local result = item.onclick(menu, list + 1) if not result then return result end return display(menu, id, caption) end else -- if button == 0 if #prev_menus > 0 then local prev_menu = prev_menus[#prev_menus] prev_menus[#prev_menus] = nil return display(prev_menu.menu, id - 1, prev_menu.caption) end return false end end until result end return display(menu, 31337, caption or menu.title) end
-- Цвета local WHITE = "{FFFFFF}" local GREEN = "{5cb85c}" local RED = "{d9534f}"
-- Типы размещения local typeNames = { [0] = "Линия", [1] = "Сетка", [2] = "Фигура", [3] = "Рандом", }
-- Фейковые обработчики для демонстрации local function temporary_placeholder() return true end
-- Опции по типам с уникальными onclick local typeOptions = { [0] = { { title = " - Line specific option 1", onclick = temporary_placeholder }, { title = " - Line specific option 4", onclick = temporary_placeholder }, { title = " - Line specific option 3", onclick = temporary_placeholder }, { title = " - Line specific option 2", onclick = temporary_placeholder }, }, [1] = { { title = " - Grid specific option 1", onclick = temporary_placeholder }, { title = " - Grid specific option 3", onclick = temporary_placeholder }, { title = " - Grid specific option 2", onclick = temporary_placeholder }, }, [2] = { { title = " - Shape specific option 1", onclick = temporary_placeholder }, { title = " - Shape specific option 2", onclick = temporary_placeholder }, }, [3] = { { title = " - Область рандома \t\t\t [ Радиус ]", onclick = temporary_placeholder }, { title = " - Random specific option 5", onclick = temporary_placeholder }, { title = " - Random specific option 4", onclick = temporary_placeholder }, { title = " - Random specific option 3", onclick = temporary_placeholder }, { title = " - Random specific option 2", onclick = temporary_placeholder }, }, }
-- Переменные состояния local typeId = 3 local allign = false
-- Меню local menu = {}
-- Построить динамические элементы local function insertDynamicOptions(menu) local opts = typeOptions[typeId] for i = #opts, 1, -1 do local item = opts[i] item.dynamic = true table.insert(menu, 2, item) end end
- Assistant
- User
нет, не чтобы стиль ВСЕГДА был другим.. просто чтобы некоторые КОНКРЕТНЫЕ сабменю могли иметь другой стиль
- Assistant