Исходник [ImGui] Pie

#SameLine

Активный
415
36
появляется курсор меню не видно но кликаю по воздуху отправляется Пока. Привет. и так далее

Lua:
local pie = require 'imgui_piemenu'
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
imgui.BufferingBar = require('imgui_addons').BufferingBar
encoding.default = 'CP1251'
u8 = encoding.UTF8

local pie_mode = imgui.ImBool(false) -- режим PieMenu
local pie_keyid = 0 -- 0 ЛКМ, 1 ПКМ, 2 СКМ
local pie_elements =
{
  {name = 'Сказать привет', action = function() sampSendChat('Привет.') end, next = nil},
  {name = 'Сказать пока', action = function() sampSendChat('Пока.') end, next = nil},
  {name = 'Сказать что-то', action = function() end, next = {
    {name = 'Сказать как дела', action = function() sampSendChat('Как дела.') end, next = nil},
    {name = 'Сказать ку-ку', action = function() sampSendChat('Ку-ку.') end, next = nil},
    {name = 'Сказать дароу', action = function() sampSendChat('Дароу.') end, next = nil}
  }}
}

function main()
    imgui.Process = true
    while true do
        wait(0)
        pie_mode.v = isKeyDown(key.VK_Z) and true or false
        imgui.ShowCursor = pie_mode.v
    end
end

function imgui.OnDrawFrame()
    if pie_mode.v then
        imgui.OpenPopup('PieMenu')
        if pie.BeginPiePopup('PieMenu', pie_keyid) then
          for k, v in ipairs(pie_elements) do
            if v.next == nil then if pie.PieMenuItem(u8(v.name)) then v.action() end
            elseif type(v.next) == 'table' then drawPieSub(v) end
          end
          pie.EndPiePopup()
        end
    end
end

function drawPieSub(v)
  if pie.BeginPieMenu(u8(v.name)) then
    for i, l in ipairs(v.next) do
      if l.next == nil then
        if pie.PieMenuItem(u8(l.name)) then l.action() end
      elseif type(l.next) == 'table' then
        drawPieSub(l)
      end
    end
    pie.EndPieMenu()
  end
end

код выше, ниже то что в lib'е
 

Вложения

  • imgui_piemenu.lua
    13.6 KB · Просмотры: 40
Последнее редактирование:

Anton Nixon

Активный
474
48
появляется курсор меню не видно но кликаю по воздуху отправляется Пока. Привет. и так далее

Lua:
local pie = require 'imgui_piemenu'
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
imgui.BufferingBar = require('imgui_addons').BufferingBar
encoding.default = 'CP1251'
u8 = encoding.UTF8

local pie_mode = imgui.ImBool(false) -- режим PieMenu
local pie_keyid = 0 -- 0 ЛКМ, 1 ПКМ, 2 СКМ
local pie_elements =
{
  {name = 'Сказать привет', action = function() sampSendChat('Привет.') end, next = nil},
  {name = 'Сказать пока', action = function() sampSendChat('Пока.') end, next = nil},
  {name = 'Сказать что-то', action = function() end, next = {
    {name = 'Сказать как дела', action = function() sampSendChat('Как дела.') end, next = nil},
    {name = 'Сказать ку-ку', action = function() sampSendChat('Ку-ку.') end, next = nil},
    {name = 'Сказать дароу', action = function() sampSendChat('Дароу.') end, next = nil}
  }}
}

function main()
    imgui.Process = true
    while true do
        wait(0)
        pie_mode.v = isKeyDown(key.VK_Z) and true or false
        imgui.ShowCursor = pie_mode.v
    end
end

function imgui.OnDrawFrame()
    if pie_mode.v then
        imgui.OpenPopup('PieMenu')
        if pie.BeginPiePopup('PieMenu', pie_keyid) then
          for k, v in ipairs(pie_elements) do
            if v.next == nil then if pie.PieMenuItem(u8(v.name)) then v.action() end
            elseif type(v.next) == 'table' then drawPieSub(v) end
          end
          pie.EndPiePopup()
        end
    end
end

function drawPieSub(v)
  if pie.BeginPieMenu(u8(v.name)) then
    for i, l in ipairs(v.next) do
      if l.next == nil then
        if pie.PieMenuItem(u8(l.name)) then l.action() end
      elseif type(l.next) == 'table' then
        drawPieSub(l)
      end
    end
    pie.EndPieMenu()
  end
end

код выше, ниже то что в lib'е
У меня такое было на встроенной графике, если у тебя такая же, то ничем не помочь.
 

b1no

Участник
69
22
скрипт:
local pie = require 'imgui_piemenu'
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
imgui.BufferingBar = require('imgui_addons').BufferingBar
encoding.default = 'CP1251'
u8 = encoding.UTF8

local pie_mode = imgui.ImBool(false) -- режим PieMenu
local pie_keyid = 0 -- 0 ЛКМ, 1 ПКМ, 2 СКМ
local pie_elements =
{
  {name = 'Начало', action = function() end, next = {
    {name = 'lock', action = function() sampSendChat('/lock') end, next = nil},
    {name = 'key', action = function() sampSendChat('/key') end, next = nil},
  }}
}

function main()
    imgui.Process = true
    while true do
        wait(0)
        pie_mode.v = isKeyDown(key.VK_MBUTTON) and true or false
        imgui.ShowCursor = pie_mode.v
    end
end

function imgui.OnDrawFrame()
    if pie_mode.v then
        imgui.OpenPopup('PieMenu')
        if pie.BeginPiePopup('PieMenu', pie_keyid) then
          for k, v in ipairs(pie_elements) do
            if v.next == nil then if pie.PieMenuItem(u8(v.name)) then v.action() end
            elseif type(v.next) == 'table' then drawPieSub(v) end
          end
          pie.EndPiePopup()
        end
    end
end

function drawPieSub(v)
  if pie.BeginPieMenu(u8(v.name)) then
    for i, l in ipairs(v.next) do
      if l.next == nil then
        if pie.PieMenuItem(u8(l.name)) then l.action() end
      elseif type(l.next) == 'table' then
        drawPieSub(l)
      end
    end
    pie.EndPieMenu()
  end
end
помогите, зажимаю скм - селектор появляется как и нужно, отпускаю - не пропадает
 

Nightcoffee Prod.

Участник
50
12
Как сделать что бы эта менюшка всегда появлялась вцентре экрана? Я просто в луа ваще -1/10