Не показывается текст в imgui.InputText

3211Marlon1123

Участник
Автор темы
130
12
Версия MoonLoader
.026-beta
Lua:
sw, sh = getScreenResolution()

local sizeformainbuttonX, sizeformainbuttonY = 400, 40
local sizePokazButtonX, sizePokazButtonY = 100, 20

pokazCHATID = true
pokazTOKENBOT = true

local main_window_state = imgui.ImBool(false)

local chatidbuff = imgui.ImBuffer(u8(ini.main.chatid), 256)
local tokenbuff = imgui.ImBuffer(u8(ini.main.bottoken), 256)

function imgui.OnDrawFrame()
    imgui.SetNextWindowSize(imgui.ImVec2(820, 600), imgui.Cond.FirstUseEver)
    imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))

    imgui.Begin('Market Helper', main_window_state)
            TelegramSettingsImgui('chat_id')

            imgui.SameLine()

            if imgui.Button(u8'Проверить', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
                sendTelegramNotification('Это проверочное сообщение.')
            end

            imgui.Spacing()

            TelegramSettingsImgui('token')
    imgui.End()
end

function InputTextPopItemWidth(pop, title, buff, flag)
  imgui.PushItemWidth(tonumber(pop))
  imgui.InputText(title, buff, flag)
  imgui.PopItemWidth()
end

function TelegramSettingsImgui(arg)
    if arg == 'chat_id' then
        if imgui.Button(u8'Сохранить', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
            ini.main.chatid = u8:decode(chatidbuff.v)
            inicfg.save(ini, directIni)
        end

        imgui.SameLine()
       
        if imgui.Button(u8'Показать', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
            pokazCHATID = not pokazCHATID
        end
   
        imgui.SameLine()
   
        InputTextPopItemWidth(130, u8'- ID аккаунта ' .. fa.ICON_ADDRESS_CARD, chatidbuff, pokazCHATID and imgui.InputTextFlags.Password or 0)
    elseif arg == 'token' then
        if imgui.Button(u8'Сохранить', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
            ini.main.bottoken = u8:decode(tokenbuff.v)
            inicfg.save(ini, directIni)
        end

        imgui.SameLine()

        if imgui.Button(u8'Показать', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
            pokazTOKENBOT = not pokazTOKENBOT
        end

        imgui.SameLine()

        InputTextPopItemWidth(130, u8'- token бота ' .. fa.ICON_ADDRESS_BOOK, tokenbuff, pokazTOKENBOT and imgui.InputTextFlags.Password or 0)
    end
end
152246

Чутка говнокода. Вся нижняя строка с кнопками не работает. Не сохраняет ничё и не показывает символы внутри. Записывать можно. Причём если поменять местами строки эти, то всё равно нижняя не будет работать. В чём трабл?
 

Вложения

  • sa-mp-019.png
    sa-mp-019.png
    11 KB · Просмотры: 128
Последнее редактирование:
Решение
Сделай уникальные названия кнопок (можно к ним добавить текст, который не будет виден с помощью ##)
К примеру для айди аккаунта сделай
Lua:
if imgui.Button(u8'Сохранить##chatid', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
    ini.main.chatid = u8:decode(chatidbuff.v)
    inicfg.save(ini, directIni)
end

imgui.SameLine()

if imgui.Button(u8'Показать##chatid', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
    pokazCHATID = not pokazCHATID
end

imgui.SameLine()

InputTextPopItemWidth(130, u8'- ID аккаунта ' .. fa.ICON_ADDRESS_CARD, chatidbuff, pokazCHATID and imgui.InputTextFlags.Password or 0)
А для токена

Lua:
if imgui.Button(u8'Сохранить##token'...

Letovo

Участник
95
12
Сделай уникальные названия кнопок (можно к ним добавить текст, который не будет виден с помощью ##)
К примеру для айди аккаунта сделай
Lua:
if imgui.Button(u8'Сохранить##chatid', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
    ini.main.chatid = u8:decode(chatidbuff.v)
    inicfg.save(ini, directIni)
end

imgui.SameLine()

if imgui.Button(u8'Показать##chatid', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
    pokazCHATID = not pokazCHATID
end

imgui.SameLine()

InputTextPopItemWidth(130, u8'- ID аккаунта ' .. fa.ICON_ADDRESS_CARD, chatidbuff, pokazCHATID and imgui.InputTextFlags.Password or 0)
А для токена

Lua:
if imgui.Button(u8'Сохранить##token', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
    ini.main.bottoken = u8:decode(tokenbuff.v)
    inicfg.save(ini, directIni)
end

imgui.SameLine()

if imgui.Button(u8'Показать##token', imgui.ImVec2(SetSizeForObject(sizePokazButtonX, sizePokazButtonY))) then
    pokazTOKENBOT = not pokazTOKENBOT
end

imgui.SameLine()

InputTextPopItemWidth(130, u8'- token бота ' .. fa.ICON_ADDRESS_BOOK, tokenbuff, pokazTOKENBOT and imgui.InputTextFlags.Password or 0)