- 478
- 20
че не так ? почему второе окно не появляеться ?
и еще как сделать отображение сторон света по этому https://www.blast.hk/threads/13380/post-290957 ?
и еще как сделать отображение сторон света по этому https://www.blast.hk/threads/13380/post-290957 ?
Lua:
require "lib.moonloader"
local key = require "vkeys"
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
u8 = encoding.UTF8
local fa = require 'fAwesome5'
local themes = import "resource/imgui_themes.lua"
local main_window_state = imgui.ImBool(false)
local window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256) -- Зачем тебе он тут если нету ImGui.InputText(name, buffer)
local menu = 0
local Buttonaver = imgui.ImBool(false)
local PrintNick = imgui.ImBool(false)
local PrintID = imgui.ImBool(false)
local PrintPing = imgui.ImBool(false)
local PrintHeart = imgui.ImBool(false)
function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand("plh", function() main_window_state.v = not main_window_state.v end)
_, myid = sampGetPlayerIdByCharHandle(PLAYER_PED)
mynick = sampGetPlayerNickname(myid)
imgui.Process = false -- его можно вынести до функции при желании
while true do
wait(0)
if isKeyDown(key.VK_LMENU) and isKeyJustPressed(key.VK_M) then
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
if main_window_state.v == false then
imgui.Process = false -- зачем тебе их два?
imgui.SwitchContext()
themes.SwitchColorTheme(3)
end
end
end -- добавил ещё end который закрывает функцию маин
function cmdimgui() -- не правильный аргумент cmd_imgui заменен на cmdimgui и тут не обязательно вписывать (arg) можно обойтись и ()
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function onWindowMessage(msg, wparam, lparam)
if msg == 0x100 or msg == 0x101 then
if (wparam == key.VK_ESCAPE and (main_window_state.v)) and not isPauseMenuActive() and not isSampfuncsConsoleActive() then
consumeWindowMessage(true, false)
if msg == 0x101 then
main_window_state.v = false
end
end
end
end
function imgui.CenterTextColoredRGB(text)
local width = imgui.GetWindowWidth()
local style = imgui.GetStyle()
local colors = style.Colors
local ImVec4 = imgui.ImVec4
local explode_argb = function(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
local getcolor = function(color)
if color:sub(1, 6):upper() == 'SSSSSS' then
local r, g, b = colors[1].x, colors[1].y, colors[1].z
local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
return ImVec4(r, g, b, a / 255)
end
local color = type(color) == 'string' and tonumber(color, 16) or color
if type(color) ~= 'number' then return end
local r, g, b, a = explode_argb(color)
return imgui.ImColor(r, g, b, a):GetVec4()
end
local render_text = function(text_)
for w in text_:gmatch('[^\r\n]+') do
local textsize = w:gsub('{.-}', '')
local text_width = imgui.CalcTextSize(u8(textsize))
imgui.SetCursorPosX( width / 2 - text_width .x / 2 )
local text, colors_, m = {}, {}, 1
w = w:gsub('{(......)}', '{%1FF}')
while w:find('{........}') do
local n, k = w:find('{........}')
local color = getcolor(w:sub(n + 1, k - 1))
if color then
text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
colors_[#colors_ + 1] = color
m = n
end
w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
end
if text[0] then
for i = 0, #text do
imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
imgui.SameLine(nil, 0)
end
imgui.NewLine()
else
imgui.Text(u8(w))
end
end
end
render_text(text)
end
local fa_font = nil
local fa_glyph_ranges = imgui.ImGlyphRanges({ fa.min_range, fa.max_range })
function imgui.BeforeDrawFrame()
if fa_font == nil then
local font_config = imgui.ImFontConfig()
font_config.MergeMode = true
fa_font = imgui.GetIO().Fonts:AddFontFromFileTTF('moonloader/resource/fonts/fa-solid-900.ttf', 50.0, font_config, fa_glyph_ranges)
if fontsize == nil then
fontsize = imgui.GetIO().Fonts:AddFontFromFileTTF(getFolderPath(0x14) .. '\\trebucbd.ttf', 47.0, nil, imgui.GetIO().Fonts:GetGlyphRangesCyrillic()) -- вместо 30 любой нужный размеp
end
end
end
function imgui.TextColoredRGB(text)
local style = imgui.GetStyle()
local colors = style.Colors
local ImVec4 = imgui.ImVec4
local explode_argb = function(argb)
local a = bit.band(bit.rshift(argb, 24), 0xFF)
local r = bit.band(bit.rshift(argb, 16), 0xFF)
local g = bit.band(bit.rshift(argb, 8), 0xFF)
local b = bit.band(argb, 0xFF)
return a, r, g, b
end
local getcolor = function(color)
if color:sub(1, 6):upper() == 'SSSSSS' then
local r, g, b = colors[1].x, colors[1].y, colors[1].z
local a = tonumber(color:sub(7, 8), 16) or colors[1].w * 255
return ImVec4(r, g, b, a / 255)
end
local color = type(color) == 'string' and tonumber(color, 16) or color
if type(color) ~= 'number' then return end
local r, g, b, a = explode_argb(color)
return imgui.ImColor(r, g, b, a):GetVec4()
end
local render_text = function(text_)
for w in text_:gmatch('[^\r\n]+') do
local text, colors_, m = {}, {}, 1
w = w:gsub('{(......)}', '{%1FF}')
while w:find('{........}') do
local n, k = w:find('{........}')
local color = getcolor(w:sub(n + 1, k - 1))
if color then
text[#text], text[#text + 1] = w:sub(m, n - 1), w:sub(k + 1, #w)
colors_[#colors_ + 1] = color
m = n
end
w = w:sub(1, n - 1) .. w:sub(k + 1, #w)
end
if text[0] then
for i = 0, #text do
imgui.TextColored(colors_[i] or colors[1], u8(text[i]))
imgui.SameLine(nil, 0)
end
imgui.NewLine()
else imgui.Text(u8(w)) end
end
end
render_text(text)
end
function imgui.SelectButton(name, bool, size)
if Buttonaver.v then
imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.0, 0.6, 0.0, 0.40))
imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0.0, 0.8, 0.0, 1.0))
imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(0.0, 1.0, 0.0, 1.0))
else
imgui.PushStyleColor(imgui.Col.Button, imgui.ImVec4(0.6, 0.0, 0.0, 0.40))
imgui.PushStyleColor(imgui.Col.ButtonHovered, imgui.ImVec4(0.8, 0.0, 0.0, 1.0))
imgui.PushStyleColor(imgui.Col.ButtonActive, imgui.ImVec4(1.0, 0.0, 0.0, 1.0))
end
if not size then size = imgui.ImVec2(0, 0) end
local result = imgui.Button(name, size)
imgui.PopStyleColor(3)
if result then Buttonaver.v = not Buttonaver.v end
return result
end
function imgui.OnDrawFrame() -- не Flame а Frame!!
if main_window_state.v then
local sw, sh = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(900, 535))
imgui.Begin('##localwindow', main_window_state, imgui.WindowFlags.AlwaysAutoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.NoTitleBar + imgui.WindowFlags.NoMove)
imgui.NewLine()
imgui.SetCursorPosY(0)
imgui.NewLine()
imgui.NewLine()
imgui.NewLine()
imgui.Text(fa.ICON_FA_USER_SHIELD .. "")
imgui.SameLine()
imgui.SetCursorPosY(20)
imgui.PushFont(fontsize)
imgui.TextColoredRGB("{0000CB}POLICE HELPER")
imgui.PopFont()
imgui.NewLine()
if menu == 0 then
imgui.BeginChild('##localchild', imgui.ImVec2(890, 432), true)
if imgui.Button(u8"Основное", imgui.ImVec2(291, 210)) then
menu = 2 end
imgui.SameLine()
if imgui.Button(fa.ICON_FA_COG .. u8"Настройки", imgui.ImVec2(291, 210)) then
menu = 3 end
imgui.SameLine()
if imgui.Button(u8"Донат", imgui.ImVec2(291, 210)) then
menu = 4 end
if imgui.Button(u8"Новости", imgui.ImVec2(291, 210)) then
menu = 5 end
imgui.SameLine()
if imgui.Button(u8"Биндер", imgui.ImVec2(291, 210)) then
menu = 6 end
imgui.SameLine()
if imgui.Button(u8"Мульти-настройки", imgui.ImVec2(291, 210)) then
menu = 7 end
imgui.EndChild()
end
if menu == 2 then
imgui.BeginChild("", imgui.ImVec2(890, 402), true)
imgui.Text("test")
imgui.EndChild()
if imgui.Button(u8"< Назад", imgui.ImVec2(100, 30)) then
menu = 0
end
end
if menu == 3 then
imgui.BeginChild("", imgui.ImVec2(890, 402), true)
if imgui.Button(u8'Вкл/Выкл Статистику') then window_state.v = not window_state.v end
if imgui.Checkbox('Nick', PrintNick) then end
if imgui.Checkbox('ID', PrintID) then end
if imgui.Checkbox('Ping', PrintPing) then end
if imgui.Checkbox('Heart', PrintHeart) then end
imgui.EndChild()
if imgui.Button(u8"< Назад", imgui.ImVec2(100, 30)) then
menu = 0
end
end
if menu == 4 then
imgui.BeginChild("", imgui.ImVec2(890, 402), true)
imgui.Text("test")
imgui.EndChild()
if imgui.Button(u8"< Назад", imgui.ImVec2(100, 30)) then
menu = 0
end
end
if menu == 5 then
imgui.BeginChild("", imgui.ImVec2(890, 402), true)
imgui.EndChild()
if imgui.Button(u8"< Назад", imgui.ImVec2(100, 30)) then
menu = 0
end
end
if menu == 6 then
imgui.BeginChild("", imgui.ImVec2(890, 402), true)
imgui.Text("test")
imgui.EndChild()
if imgui.Button(u8"< Назад", imgui.ImVec2(100, 30)) then
menu = 0
end
end
if menu == 7 then
imgui.BeginChild("", imgui.ImVec2(890, 402), true)
imgui.Text("test")
imgui.EndChild()
if imgui.Button(u8"< Назад", imgui.ImVec2(100, 30)) then
menu = 0
end
end
end
imgui.End()
end
if window_state.v then
local sw, sh = getScreenResolution()
imgui.SetNextWindowPos(imgui.ImVec2(sw / 2, sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.SetNextWindowSize(imgui.ImVec2(250, 230), imgui.Cond.FirstUseEver)
imgui.Begin(u8'test', two_window_state, imgui.WindowFlags.NoResize)
if imgui.Button(u8'test', imgui.ImVec2(-0.1, 20))then
-- что будет происходить если будет нажата кнопка
end
imgui.End()
end
-- end он тут не нужен
Последнее редактирование: