- 1,471
- 435
- Версия MoonLoader
- .026-beta
Как это можно перевести на imgui?
Lua:
local function imgui_text_wrapped(clr, text)
if clr then imgui.PushStyleColor(imgui.Col.Text, clr) end
text = ffi.new('char[?]', #text + 1, text)
local text_end = text + ffi.sizeof(text) - 1
local pFont = imgui.GetFont()
local scale = 1.0
local endPrevLine = pFont:CalcWordWrapPositionA(scale, text, text_end, imgui.GetContentRegionAvail().x)
imgui.TextUnformatted(text, endPrevLine)
while endPrevLine < text_end do
text = endPrevLine
if text[0] == 32 then text = text + 1 end
endPrevLine = pFont:CalcWordWrapPositionA(scale, text, text_end, imgui.GetContentRegionAvail().x)
if text == endPrevLine then
endPrevLine = endPrevLine + 1
end
imgui.TextUnformatted(text, endPrevLine)
end
if clr then imgui.PopStyleColor() end
end
Код:
[ML] (error) LiteHelper.lua: C:\Games\GTA San Andreas\moonloader\LiteHelper.lua:2142: stack index 3, expected string, received cdata: (bad argument into 'const char*(ImFont&, float, std::basic_string<char,std::char_traits<char>,std::allocator<char> >, float)')
stack traceback:
[C]: in function 'CalcWordWrapPositionA'
C:\Games\GTA San Andreas\moonloader\LiteHelper.lua:2142: in function 'imgui_text_wrapped'
C:\Games\GTA San Andreas\moonloader\LiteHelper.lua:4907: in function 'OnDrawFrame'
C:\Games\GTA San Andreas\moonloader\lib\imgui.lua:1378: in function <C:\Games\GTA San Andreas\moonloader\lib\imgui.lua:1367>
[ML] (error) LiteHelper.lua: Script died due to an error. (09829514)