Проблема с imgui.InputInt

caing

Участник
Автор темы
35
4
Версия MoonLoader
.026-beta
В общем, в скрипте есть InputInt, я могу его редактировать как при помощи +/-, так и поставив курсор в окошко и введя от руки значение. Проблема в том, что если я закрываю imgui окно при помощи крестика или на клавишу активации\деактивации, то все ок, но если закрываю на клавишу ESC, то при последующем открытии окна я не могу поставить курсор в Input.
Чтобы было понятнее, что я написал, гляньте видос

Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8


local main_window_state = imgui.ImBool(false)
inputWindow = imgui.ImInt(100)
function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
    imgui.Begin('My window', main_window_state)
    imgui.Text('Hello world')
    if imgui.InputInt(u8"##4", inputWindow, 10) then
        --
    end
    imgui.End()
  end
end

function main()
    addEventHandler("onWindowMessage", function (msg, wparam, lparam) -- закрытие окна на ESC
        if wparam == key.VK_ESCAPE then
            if not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() then
                if main_window_state.v then main_window_state.v = false consumeWindowMessage(true, true) end
            end
        end
    end)
  while true do
    wait(0)
    if wasKeyPressed(key.VK_X) then
        main_window_state.v = not main_window_state.v
    end
    imgui.Process = main_window_state.v
  end
end
 
Решение
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
local inputWindow = imgui.ImInt(100)

function main()
    addEventHandler("onWindowMessage", function (msg, wparam, lparam) -- закрытие окна на ESC
        if wparam == key.VK_ESCAPE and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and imgui.Process then
            main_window_state.v = not main_window_state.v consumeWindowMessage(true, false)
        end
    end)
    while true do
        wait(0)
        if wasKeyPressed(key.VK_X) then
            main_window_state.v = not main_window_state.v
        end...

caing

Участник
Автор темы
35
4
  • Нравится
Реакции: qdIbp

Next..

Известный
343
135
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
local inputWindow = imgui.ImInt(100)

function main()
    addEventHandler("onWindowMessage", function (msg, wparam, lparam) -- закрытие окна на ESC
        if wparam == key.VK_ESCAPE and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and imgui.Process then
            main_window_state.v = not main_window_state.v consumeWindowMessage(true, false)
        end
    end)
    while true do
        wait(0)
        if wasKeyPressed(key.VK_X) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
    imgui.Begin('My window', main_window_state)
    imgui.Text('Hello world')
    if imgui.InputInt(u8"##4", inputWindow, 10) then
        --
    end
    imgui.End()
  end
end
из-за if main_window_state.v then это проверки так происходить, если проверять imgui.Process все окей
 
  • Вау
  • Нравится
Реакции: Double Tap Inside и caing

kizn

О КУ)))
Всефорумный модератор
2,405
2,057
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
local inputWindow = imgui.ImInt(100)

function main()
    addEventHandler("onWindowMessage", function (msg, wparam, lparam) -- закрытие окна на ESC
        if wparam == key.VK_ESCAPE and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and imgui.Process then
            main_window_state.v = not main_window_state.v consumeWindowMessage(true, false)
        end
    end)
    while true do
        wait(0)
        if wasKeyPressed(key.VK_X) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
    imgui.Begin('My window', main_window_state)
    imgui.Text('Hello world')
    if imgui.InputInt(u8"##4", inputWindow, 10) then
        --
    end
    imgui.End()
  end
end
из-за if main_window_state.v then это проверки так происходить, если проверять imgui.Process все окей
> нажатие эскейп
>проверка имгуи.процесс == тру
>пока окно не открыто имгуи.процесс == фолс
как же скрипт будет открываться на эскейп?
 

caing

Участник
Автор темы
35
4
Lua:
local imgui = require 'imgui'
local key = require 'vkeys'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8

local main_window_state = imgui.ImBool(false)
local inputWindow = imgui.ImInt(100)

function main()
    addEventHandler("onWindowMessage", function (msg, wparam, lparam) -- закрытие окна на ESC
        if wparam == key.VK_ESCAPE and not sampIsChatInputActive() and not sampIsDialogActive() and not sampIsScoreboardOpen() and imgui.Process then
            main_window_state.v = not main_window_state.v consumeWindowMessage(true, false)
        end
    end)
    while true do
        wait(0)
        if wasKeyPressed(key.VK_X) then
            main_window_state.v = not main_window_state.v
        end
        imgui.Process = main_window_state.v
    end
end

function imgui.OnDrawFrame()
  if main_window_state.v then
    imgui.SetNextWindowSize(imgui.ImVec2(150, 200), imgui.Cond.FirstUseEver)
    imgui.Begin('My window', main_window_state)
    imgui.Text('Hello world')
    if imgui.InputInt(u8"##4", inputWindow, 10) then
        --
    end
    imgui.End()
  end
end
из-за if main_window_state.v then это проверки так происходить, если проверять imgui.Process все окей
Как это правильно заюзать, если у меня не 1 окно imgui, а несколько? При этом 1 окно активно, а другое нет.

Если юзать так:
main_window_state.v = not main_window_state.v consumeWindowMessage(true, false)
second_window.v = not second_window.v consumeWindowMessage(true, false)
То открытое окно закроется, а закрытое откроется. Как это правильно сделать?
 

Next..

Известный
343
135
Как это правильно заюзать, если у меня не 1 окно imgui, а несколько? При этом 1 окно активно, а другое нет.

Если юзать так:
main_window_state.v = not main_window_state.v consumeWindowMessage(true, false)
second_window.v = not second_window.v consumeWindowMessage(true, false)
То открытое окно закроется, а закрытое откроется. Как это правильно сделать?
Посмотри у меня в скрипте https://www.blast.hk/threads/69462/