imgui

Seaside_

Участник
Автор темы
64
2
Версия MoonLoader
.026-beta
Привет, взял имгуи, добавил туда имгуи текст и при выборе нужного окна, гташка крашится, что делать
Lua:
imgui                            = require 'imgui'
samp                            = require 'samp.events'
encoding                        = require 'encoding'
encoding.default                    = 'CP1251'
u8                            = encoding.UTF8
active_menu                        = imgui.ImBool(false)

function apply_custom_style()
    imgui.SwitchContext()
    local style = imgui.GetStyle()
    local colors = style.Colors
    local clr = imgui.Col
    local ImVec4 = imgui.ImVec4

    style.WindowRounding = 2.0
    style.WindowTitleAlign = imgui.ImVec2(0.5, 0.84)
    style.ChildWindowRounding = 2.0
    style.FrameRounding = 2.0
    style.ItemSpacing = imgui.ImVec2(5.0, 4.0)
    style.ScrollbarSize = 13.0
    style.ScrollbarRounding = 0
    style.GrabMinSize = 8.0
    style.GrabRounding = 1.0
    colors[clr.Text]            = ImVec4(1.00, 1.00, 1.00, 1.00)
    colors[clr.TextDisabled]        = ImVec4(0.50, 0.50, 0.50, 1.00)
    colors[clr.WindowBg]            = ImVec4(0.06, 0.06, 0.06, 0.94)
    colors[clr.ChildWindowBg]        = ImVec4(1.00, 1.00, 1.00, 0.00)
    colors[clr.PopupBg]            = ImVec4(0.08, 0.08, 0.08, 0.94)
    colors[clr.ComboBg]            = colors[clr.PopupBg]
    colors[clr.Border]            = ImVec4(0.43, 0.43, 0.50, 0.50)
    colors[clr.BorderShadow]        = ImVec4(0.00, 0.00, 0.00, 0.00)
    colors[clr.FrameBg]            = ImVec4(0.16, 0.29, 0.48, 0.54)
    colors[clr.FrameBgHovered]        = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.FrameBgActive]        = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.TitleBg]            = ImVec4(0.04, 0.04, 0.04, 1.00)
    colors[clr.TitleBgActive]        = ImVec4(0.16, 0.29, 0.48, 1.00)
    colors[clr.TitleBgCollapsed]        = ImVec4(0.00, 0.00, 0.00, 0.51)
    colors[clr.MenuBarBg]            = ImVec4(0.14, 0.14, 0.14, 1.00)
    colors[clr.ScrollbarBg]        = ImVec4(0.02, 0.02, 0.02, 0.53)
    colors[clr.ScrollbarGrab]        = ImVec4(0.31, 0.31, 0.31, 1.00)
    colors[clr.ScrollbarGrabHovered]    = ImVec4(0.41, 0.41, 0.41, 1.00)
    colors[clr.ScrollbarGrabActive]    = ImVec4(0.51, 0.51, 0.51, 1.00)
    colors[clr.CheckMark]            = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.SliderGrab]            = ImVec4(0.24, 0.52, 0.88, 1.00)
    colors[clr.SliderGrabActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Button]            = ImVec4(0.26, 0.59, 0.98, 0.40)
    colors[clr.ButtonHovered]        = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ButtonActive]        = ImVec4(0.06, 0.53, 0.98, 1.00)
    colors[clr.Header]            = ImVec4(0.26, 0.59, 0.98, 0.31)
    colors[clr.HeaderHovered]        = ImVec4(0.26, 0.59, 0.98, 0.80)
    colors[clr.HeaderActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.Separator]            = colors[clr.Border]
    colors[clr.SeparatorHovered]        = ImVec4(0.26, 0.59, 0.98, 0.78)
    colors[clr.SeparatorActive]        = ImVec4(0.26, 0.59, 0.98, 1.00)
    colors[clr.ResizeGrip]            = ImVec4(0.26, 0.59, 0.98, 0.25)
    colors[clr.ResizeGripHovered]    = ImVec4(0.26, 0.59, 0.98, 0.67)
    colors[clr.ResizeGripActive]        = ImVec4(0.26, 0.59, 0.98, 0.95)
    colors[clr.CloseButton]        = ImVec4(0.41, 0.41, 0.41, 0.50)
    colors[clr.CloseButtonHovered]    = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.CloseButtonActive]        = ImVec4(0.98, 0.39, 0.36, 1.00)
    colors[clr.PlotLines]            = ImVec4(0.61, 0.61, 0.61, 1.00)
    colors[clr.PlotLinesHovered]        = ImVec4(1.00, 0.43, 0.35, 1.00)
    colors[clr.PlotHistogram]        = ImVec4(0.90, 0.70, 0.00, 1.00)
    colors[clr.PlotHistogramHovered]    = ImVec4(1.00, 0.60, 0.00, 1.00)
    colors[clr.TextSelectedBg]        = ImVec4(0.26, 0.59, 0.98, 0.35)
    colors[clr.ModalWindowDarkening]    = ImVec4(0.80, 0.80, 0.80, 0.35)

end

apply_custom_style()

function imgui.OnDrawFrame()
    local x, y = getScreenResolution()
    if active_menu.v then
        imgui.LockPlayer = true
        imgui.SetNextWindowPos(imgui.ImVec2(x/2, y/2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
        imgui.SetNextWindowSize(imgui.ImVec2(900, 500), imgui.Cond.FirstUseEver)
        imgui.Begin(u8('Admin Tools'), active_menu)
        imgui.BeginChild('left pane', imgui.ImVec2(150, 0), true)
        if not selected then selected = 1 end
        if imgui.Selectable(u8('Админ правила'), false) then selected = 1 end
        if imgui.Selectable(u8('Гос.цена т/с'), false) then selected = 2 end
        if imgui.Selectable(u8('Нормы наказания'), false) then selected = 3 end
        if imgui.Selectable(u8('Правила проекта'), false) then selected = 4 end
        if imgui.Selectable(u8('Нормы наказания'), false) then selected = 5 end
                if imgui.Selectable(u8('Мини-справка'), false) then selected = 6 end
        imgui.EndChild()
        imgui.SameLine()
        imgui.BeginGroup()
        if selected == 2 then
                    imgui.Text(u8'Последнее обновление статистики было 30 марта, 2020 года')
                    imgui.Separator()
                    imgui.Text(u8'СЕДАНЫ:\nBravura(401) - 56.000\nSentinel(405) - 70.000\nManana(410) - 58.000\nAdmiral(445) - 75.000\nWashington(421) - 72.000\nBobcat(422) - 55.000\nPremier(426) - 60.000\nPrevion(436) - 57.000\nSolair(458) - 59.000\nRegina(479) - 57.000\nElegant(507) - 67.000\nNebula(516) - 59.000\nFortune(526) - 62.000\nSunrise(550) - 69.000\nCadrona(527) - 60.000\nWillard(529) - 57.000\nIntruder(546) - 62.000\nPrimo(547) - 60.000\nUranus(558) - 75.000\nMerit(551) - 73.000')
                    imgui.Separator()
                    imgui.Text(u8'КАБРИОЛЕТЫ:\nWindsor(555) - 110.000\nStallion(439) - 90.000\nComet(480) - 180.000\nFeltzer(533) - 130.000')
                    imgui.Separator()
                    imgui.Text(u8'ЛОУРАЙДЕРЫ:\nVoodoo(412) - 110.000\nSlamvan(535) - 85.000\nBlade(536) - 79.000\nSavanna(567) - 91.000\nBroadway(575) - 82.000\nRemington(534) - 100.000\nTahoma(566) - 80.000\nTornado(576) - 83.000')
                    imgui.Separator()
                    imgui.Text(u8'МОТОЦИКЛЫ:\nBF-400(581) - 220.000\nPCJ-600(461) - 120.000\nFreeway(463) - 340.000\nFCR-900(521) - 180.000\nNRG-500(522) - 900.000\nSanchez(468) - 120.000\nWayfarer(586) - 80.000\nFaggio(462) - 3.800')
                    imgui.Separator()
                    imgui.Text(u8'ВНЕДОРОЖНИКИ:\nLandstalker(400) - 80.000\nRancher(489) - 140.000\nRancher(505) - 170.000\nHuntley(579) - 200.000\nMesa(500) - 90.000\nYosemite(554) - 180.000')
                    imgui.Separator()
                    imgui.Text(u8'СПОРТИВНЫЕ АВТОМОБИЛИ:\nInfernus(411) - 900.000\nTurismo(451) - 750.000\nBullet(541) - 800.000\nBuffalo(402) - 380.000\nClub(589) - 285.000\nBanshee(429) - 420.000\nSultan(560) - 330.000\nElegy(562) - 220.000\nSabre(475) - 170.000\nZR-350(477) - 300.000\nSuper GT(506) - 330.000\nFlash(565) - 280.000\nJester(559) - 240.000\nPhoenix(603) - 370.000')
                    imgui.Separator()
                    imgui.Text(u8'УНИКАЛЬНЫЙ АВТОМОБИЛЬ:\nSandking(495) - 1.400.000')
                    imgui.Separator()
                    imgui.Text(u8'АВТОМОБИЛИ С РУЛЕТКИ:\nStratum(561) - 100.000\nEmperor(585) - 150.000\nBravura(401) - 56.000\nAlpha(602) - 200.000\nSlamvan(535) - 85.000\nPerenniel(404) - 100.000\nStafford(580) - 150.000\nTurismo(451) - 750.000\nEuros(587) - 350.000\nSanchez(468) - 120.000\nPhoenix(603) - 370.000\nBuccaneer(518) - 300.000\nClover(542) - 400.000\nHotring Racer(503) - 800.000\nBF-400(581) - 220.000\nStallion(434) - 90.000\nHotKnife(434) - 600.000')
                    imgui.Separator()
                    imgui.Text(u8'ВОЗДУШНЫЙ ТРАНСПОРТ:\nSparrow(469) - 900.000\nMaverick(487) - 1.200.000')
                    imgui.End()
                end
                end
        -- ...
        imgui.EndGroup()
        imgui.End()
    end

function main()
    while not isSampAvailable() do wait(0) end
    sampRegisterChatCommand('infotest', function() active_menu.v = not active_menu.v end)
    while true do wait(0) imgui.Process = active_menu.v end
end