imgui окно

no3jour

Участник
Автор темы
55
0
Версия MoonLoader
.026-beta
Вопросик по imgui, хочу сделать кнопки сбоку, вроде нашел функцию, но отображается бар под этими кнопками, а мне нужно сбоку,

PHP:
function imgui.OnDrawFrame()
  if imgui_1.v then
      local btnSize = imgui.ImVec2(150, 0)
      imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
      imgui.Begin(u8'Второе окно', s_openn, imgui.WindowFlags.MenuBar)
      imgui.BeginChild('Тест', imgui.ImVec2(150, 500), true)
      if imgui.Button(u8'test 1', btnSize) then selected = 1 end;
      if imgui.Button(u8'test 2', btnSize) then selected = 2 end;
      if selected == 1 then
        if imgui.RadioButton(u8"Команды Arizona RP.", imgui_2.v) then
          imgui_2.v = not imgui_2.v
        end
      elseif selected == 2 then
        if imgui.RadioButton(u8"Команды Samp RP.", imgui_2.v) then
          imgui_2.v = not imgui_2.v
        end
      end
      imgui.EndChild()
      imgui.End()
  end
Пример:
 
Решение
Lua:
require "lib.moonloader"
require "lib.sampfuncs"

local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8

local imgui_1 = imgui.ImBool(false)
local imgui_2 = imgui.ImBool(false)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end

  sampRegisterChatCommand("asd", function() imgui_1.v = not imgui_1.v end)

  while true do
    wait(0)
    imgui.Process = imgui_1.v or imgui_2.v
    if not imgui_1.v and not imgui_2.v then
      imgui.ShowCursor = false
    end
  end
end

function imgui.OnDrawFrame()
  if imgui_1.v then
    imgui.ShowCursor = true
    local btnSize = imgui.ImVec2(150, 0)...

no3jour

Участник
Автор темы
55
0
Сорри, ху*ню сделал, пробуй это
Lua:
function imgui.OnDrawFrame()
  if imgui_1.v then
    local btnSize = imgui.ImVec2(150, 0)
    imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Второе окно', s_openn, imgui.WindowFlags.MenuBar)
    imgui.BeginChild('Тест', imgui.ImVec2(150, 500), true)
    if imgui.Button(u8'test 1', btnSize) then selected = 1 end
    if imgui.Button(u8'test 2', btnSize) then selected = 2 end
        imgui.SameLine()
    if selected == 1 then
      if imgui.RadioButton(u8"Команды Arizona RP.", imgui_2.v) then
        imgui_2.v = not imgui_2.v
      end
    elseif selected == 2 then
      if imgui.RadioButton(u8"Команды Samp RP.", imgui_2.v) then
        imgui_2.v = not imgui_2.v
      end
    end
    imgui.EndChild()
    imgui.End()
  end
end
при нажатии на кнопки test 1 и test2 ничего не происходит
PHP:
  function imgui.OnDrawFrame()
    if imgui_1.v then
      local btnSize = imgui.ImVec2(150, 0)
      imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
      imgui.Begin(u8'Второе окно', s_openn, imgui.WindowFlags.MenuBar)
      imgui.BeginChild('Тест', imgui.ImVec2(150, 500), true)
      if imgui.Button(u8'test 1', btnSize) then selected = 1 end
      if imgui.Button(u8'test 2', btnSize) then selected = 2 end
          imgui.SameLine()
      if selected == 1 then
        if imgui.RadioButton(u8"Команды Arizona RP.", imgui_2.v) then
          imgui_2.v = not imgui_2.v
        end
      elseif selected == 2 then
        if imgui.RadioButton(u8"Команды Samp RP.", imgui_2.v) then
          imgui_2.v = not imgui_2.v
        end
      end
      imgui.EndChild()
      imgui.End()
    end
  if imgui_2.v then
    imgui.SetNextWindowSize(imgui.ImVec2(250, 100), imgui.Cond.FirstUseEver) -- меняем размер
    imgui.Begin(u8'Авторизация') -- обратите внимание на u8 перед текстом, это и есть преобразование кодировки
    imgui.Text(u8'Введите свой пароль для авторизации')
    imgui.Text(u8'Пароль:')
    imgui.SameLine();
    if imgui.InputText(u8'', apass, imgui.ImVec2(25, 0)) then end
    if imgui.Button(u8'Авторизоваться') then
      checkpassd(arg)
    end
    imgui.End()
  end
end
 

Albertio

Attention! Thanks for your attention.
877
702
Lua:
require "lib.moonloader"
require "lib.sampfuncs"

local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8

local imgui_1 = imgui.ImBool(false)
local imgui_2 = imgui.ImBool(false)

function main()
  if not isSampLoaded() or not isSampfuncsLoaded() then return end
  while not isSampAvailable() do wait(100) end

  sampRegisterChatCommand("asd", function() imgui_1.v = not imgui_1.v end)

  while true do
    wait(0)
    imgui.Process = imgui_1.v or imgui_2.v
    if not imgui_1.v and not imgui_2.v then
      imgui.ShowCursor = false
    end
  end
end

function imgui.OnDrawFrame()
  if imgui_1.v then
    imgui.ShowCursor = true
    local btnSize = imgui.ImVec2(150, 0)
    imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x / 2, imgui.GetIO().DisplaySize.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(500, 500), imgui.Cond.FirstUseEver)
    imgui.Begin(u8'Второе окно', imgui_1, imgui.WindowFlags.MenuBar)
    imgui.BeginChild('Тест', imgui.ImVec2(150, 500), true)
    if imgui.Button(u8'test 1', btnSize) then selected = 1 end
    if imgui.Button(u8'test 2', btnSize) then selected = 2 end
    imgui.EndChild()
    imgui.SameLine()
    if selected == 1 then
      if imgui.RadioButton(u8"Команды Arizona RP.", imgui_2.v) then
        imgui_2.v = not imgui_2.v
      end
    elseif selected == 2 then
      if imgui.RadioButton(u8"Команды Samp RP.", imgui_2.v) then
        imgui_2.v = not imgui_2.v
      end
    end
    imgui.End()
  end
  if imgui_2.v then
    imgui.ShowCursor = true
    imgui.SetNextWindowPos(imgui.ImVec2(imgui.GetIO().DisplaySize.x / 2, imgui.GetIO().DisplaySize.y / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
    imgui.SetNextWindowSize(imgui.ImVec2(250, 100), imgui.Cond.FirstUseEver) -- меняем размер
    imgui.Begin(u8'Авторизация', imgui_2) -- обратите внимание на u8 перед текстом, это и есть преобразование кодировки
    imgui.Text(u8'Введите свой пароль для авторизации')
    imgui.Text(u8'Пароль:')
    imgui.SameLine()
    if imgui.InputText(u8'', apass, imgui.ImVec2(25, 0)) then end
    if imgui.Button(u8'Авторизоваться') then
      checkpassd(arg)
    end
    imgui.End()
  end
end