- 1
- 0
- Версия MoonLoader
- Другое
Обьясняю, я просто баловался с imgui сидел узновал новые функции, сделал карче код(ниже прекреплю) и суть проблема мне надо заблокировать курсор мыши чтоб он не появлялся при открытии окна, но как я уже понял он появляется изза другова lua с окном статистики(тоесть там постоянно весит окно статистики с помощью imgui) и она походу канфликтуют и не робят ): мышка как бы появляется но она зажата в центре экрана, но ее видно.
Помогите пожалуйста это поченить
Не большое уточнение player.HideCursor = false Не помогает
Помогите пожалуйста это поченить
testimgui:
local imgui = require 'imgui'
local encoding = require 'encoding'
encoding.default = 'CP1251'
local u8 = encoding.UTF8
local open = imgui.ImBool(false)
local closeTime = 0
local playerNickname = ""
imgui.ShowCursor = false
-- шрифты
local font = nil
local fontPath = getWorkingDirectory() .. '\\config\\imguitest\\GNF.ttf'
-- анимации
local animation = {
fadeInDuration = 0.3,
stayDuration = 2.0,
fadeOutDuration = 0.15,
offset = 10,
startTime = 0,
totalDuration = 1.3
}
-- основа
function main()
while not isSampAvailable() do wait(100) end
-- шрифты
if doesFileExist(fontPath) then
font = imgui.GetIO().Fonts:AddFontFromFileTTF(
fontPath,
48.0,
nil,
imgui.GetIO().Fonts:GetGlyphRangesCyrillic()
)
print(u8"шрифт загружен")
else
print(u8"файл шрифта не найден")
font = imgui.GetIO().Fonts:AddFontDefault()
end
-- ник
local result, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
if result then
playerNickname = sampGetPlayerNickname(id)
end
-- тест
sampRegisterChatCommand('test', function()
open.v = true
imgui.Process = true
animation.startTime = os.clock()
animation.totalDuration = animation.fadeInDuration + animation.stayDuration + animation.fadeOutDuration
closeTime = animation.startTime + animation.totalDuration
end)
-- ГЦ
while true do
wait(0)
imgui.ShowCursor = false
if open.v and os.clock() >= closeTime then
open.v = false
if not open.v then
imgui.Process = false
end
end
if open.v and wasKeyPressed(0x1B) then
open.v = false
if not open.v then
imgui.Process = false
end
end
end
end
-- анимка
function calculateAnimation()
local elapsed = os.clock() - animation.startTime
local screenHeight = getScreenResolution()
local windowHeight = 120
local centerY = (screenHeight - windowHeight) / 2
local alpha = 0
local posY = centerY + animation.offset
if elapsed < animation.fadeInDuration then
local progress = elapsed / animation.fadeInDuration
alpha = progress
posY = centerY + animation.offset - (animation.offset * progress)
elseif elapsed < animation.fadeInDuration + animation.stayDuration then
alpha = 1.0
posY = centerY
elseif elapsed < animation.totalDuration then
local progress = (elapsed - animation.fadeInDuration - animation.stayDuration) / animation.fadeOutDuration
alpha = 1.0 - progress
posY = centerY - (animation.offset * progress)
end
return alpha, posY
end
-- окно
function imgui.OnDrawFrame()
if not open.v or not font then return end
local flags = bit.bor(
imgui.WindowFlags.NoTitleBar,
imgui.WindowFlags.NoResize,
imgui.WindowFlags.NoMove,
imgui.WindowFlags.NoInputs
)
local screenWidth = getScreenResolution()
local windowSize = imgui.ImVec2(screenWidth, 120)
imgui.SetNextWindowSize(windowSize, imgui.Cond.Always)
local alpha, posY = calculateAnimation()
imgui.SetNextWindowPos(imgui.ImVec2(0, posY), imgui.Cond.Always)
imgui.PushStyleColor(imgui.Col.WindowBg, imgui.ImVec4(0, 0, 0, 0))
-- Текст
if imgui.Begin("##HelloWindow", nil, flags) then
imgui.PushFont(font)
imgui.PushStyleColor(imgui.Col.Text, imgui.ImVec4(1, 1, 1, alpha))
local helloText = u8"привет: "
local helloTextSize = imgui.CalcTextSize(helloText)
imgui.SetCursorPosX((screenWidth - helloTextSize.x) / 2 - helloTextSize.x / 2)
imgui.Text(helloText)
imgui.PopStyleColor()
imgui.PushStyleColor(imgui.Col.Text, imgui.ImVec4(0.5, 0.8, 1.0, alpha))
imgui.SameLine(0, 0)
imgui.Text(playerNickname)
imgui.PopStyleColor()
imgui.PopFont()
imgui.End()
end
imgui.PopStyleColor()
end
Не большое уточнение player.HideCursor = false Не помогает
Последнее редактирование: