- 37
- 14
- Версия SA-MP
-
- 0.3.7 (R1)
Как сделать, чтобы при нажатии кнопки, текст показывался справа (см. скрин ниже), а не под кнопками.
Вот код
Вот код
Код:
local key = require 'vkeys'
local imgui = require ('imgui')
local encoding = require ('encoding')
encoding.default = 'CP1251'
u8 = encoding.UTF8
local state=false
local nark=false
local ev = require('lib.samp.events')
local lock = imgui.ImBool(true)
local autonarko = imgui.ImBool(true)
local imgui = require 'imgui'
local main_window_state = imgui.ImBool(false)
local text_buffer = imgui.ImBuffer(256)
local checked_radio = imgui.ImInt(1)
local checked_expl = imgui.ImBool(false)
local checked_expl_2 = imgui.ImBool(false)
local combo_select = imgui.ImInt(0)
local explosion_mass = { u8"Стиль 1", u8"Cтиль 2", u8"Стиль 3"}
local sw, sh = getScreenResolution()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
menu_state = 1
function main()
if not isSampfuncsLoaded() or not isSampLoaded() then return end
while not isSampAvailable() do wait(100) end
repeat wait(0) until isSampAvailable()
sampRegisterChatCommand("nk",narkizka)
sampRegisterChatCommand("explosion", expl_imgui)
sampRegisterChatCommand("check", cmd_check)
imgui.Process = false
while true do
wait(0)
if main_window_state.v == false then
imgui.Process = false
end
end
end
function expl_imgui(arg)
main_window_state.v = not main_window_state.v
imgui.Process = main_window_state.v
end
function cmd_check(arg)
sampAddChatMessage(checked_radio.v,-1)
if checked_expl.v then
sampAddChatMessage("Галочка стоит",-1)
end
sampAddChatMessage(u8:decode (explosion_mass[combo_select.v + 1]), -1)
end
function imgui.OnDrawFrame()
imgui.SetNextWindowSize(imgui.ImVec2(700, 600), imgui.Cond.FirstUseEver)
imgui.SetNextWindowPos(imgui.ImVec2((sw / 2), sh / 2), imgui.Cond.FirstUseEver, imgui.ImVec2(0.5, 0.5))
imgui.Begin(u8"EXPLOSION SQUAD HELPER", main_window_state, imgui.WindowFlags.NoResize + imgui.WindowFlags.NoCollapse + imgui.WindowFlags.MenuBar)
imgui.BeginChild("Expl", imgui.ImVec2(200,600), true)
if imgui.Button(u8'Основное', imgui.ImVec2(-1,70)) then
menu_state = 1
end
if imgui.Button(u8'Настройки', imgui.ImVec2(-1,80)) then
menu_state = 2
end
if imgui.Button(u8'Информация', imgui.ImVec2(-1,90)) then
menu_state = 3
end
if menu_state == 1 then
end
if menu_state == 2 then
imgui.PushItemWidth(140)
imgui.Combo("Combo 1", combo_select, explosion_mass, #explosion_mass)
end
if combo_select.v == 0 then
imgui.SwitchContext()
colors[clr.Text] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.TextDisabled] = ImVec4(0.24, 0.24, 0.24, 1.00)
colors[clr.WindowBg] = ImVec4(1.00, 1.00, 1.00, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.96, 0.96, 0.96, 1.00)
colors[clr.PopupBg] = ImVec4(0.92, 0.92, 0.92, 1.00)
colors[clr.Border] = ImVec4(0.86, 0.86, 0.86, 1.00)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.88, 0.88, 0.88, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.82, 0.82, 0.82, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.76, 0.76, 0.76, 1.00)
colors[clr.TitleBg] = ImVec4(0.00, 0.45, 1.00, 0.82)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.45, 1.00, 0.82)
colors[clr.TitleBgActive] = ImVec4(0.00, 0.45, 1.00, 0.82)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.37, 0.78, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 0.35, 1.00, 0.78)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 0.33, 1.00, 0.84)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 0.31, 1.00, 0.88)
colors[clr.ComboBg] = ImVec4(0.92, 0.92, 0.92, 1.00)
colors[clr.CheckMark] = ImVec4(0.00, 0.49, 1.00, 0.59)
colors[clr.SliderGrab] = ImVec4(0.00, 0.49, 1.00, 0.59)
colors[clr.SliderGrabActive] = ImVec4(0.00, 0.39, 1.00, 0.71)
colors[clr.Button] = ImVec4(0.00, 0.49, 1.00, 0.59)
colors[clr.ButtonHovered] = ImVec4(0.00, 0.49, 1.00, 0.71)
colors[clr.ButtonActive] = ImVec4(0.00, 0.49, 1.00, 0.78)
colors[clr.Header] = ImVec4(0.00, 0.49, 1.00, 0.78)
colors[clr.HeaderHovered] = ImVec4(0.00, 0.49, 1.00, 0.71)
colors[clr.HeaderActive] = ImVec4(0.00, 0.49, 1.00, 0.78)
colors[clr.ResizeGrip] = ImVec4(0.00, 0.39, 1.00, 0.59)
colors[clr.ResizeGripHovered] = ImVec4(0.00, 0.27, 1.00, 0.59)
colors[clr.ResizeGripActive] = ImVec4(0.00, 0.25, 1.00, 0.63)
colors[clr.CloseButton] = ImVec4(0.00, 0.35, 0.96, 0.71)
colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.31, 0.88, 0.69)
colors[clr.CloseButtonActive] = ImVec4(0.00, 0.25, 0.88, 0.67)
colors[clr.PlotLines] = ImVec4(0.00, 0.39, 1.00, 0.75)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 0.39, 1.00, 0.75)
colors[clr.PlotHistogram] = ImVec4(0.00, 0.39, 1.00, 0.75)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 0.35, 0.92, 0.78)
colors[clr.TextSelectedBg] = ImVec4(0.00, 0.47, 1.00, 0.59)
colors[clr.ModalWindowDarkening] = ImVec4(0.20, 0.20, 0.20, 0.35)
elseif combo_select.v == 1 then
imgui.SwitchContext()
style.Alpha = 1.0
style.ChildWindowRounding = 3
style.WindowRounding = 3
style.GrabRounding = 1
style.GrabMinSize = 20
style.FrameRounding = 3
colors[clr.Text] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.TextDisabled] = ImVec4(0.00, 0.40, 0.41, 1.00)
colors[clr.WindowBg] = ImVec4(0.00, 0.00, 0.00, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.Border] = ImVec4(0.00, 1.00, 1.00, 0.65)
colors[clr.BorderShadow] = ImVec4(0.00, 0.00, 0.00, 0.00)
colors[clr.FrameBg] = ImVec4(0.44, 0.80, 0.80, 0.18)
colors[clr.FrameBgHovered] = ImVec4(0.44, 0.80, 0.80, 0.27)
colors[clr.FrameBgActive] = ImVec4(0.44, 0.81, 0.86, 0.66)
colors[clr.TitleBg] = ImVec4(0.14, 0.18, 0.21, 0.73)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.54)
colors[clr.TitleBgActive] = ImVec4(0.00, 1.00, 1.00, 0.27)
colors[clr.MenuBarBg] = ImVec4(0.00, 0.00, 0.00, 0.20)
colors[clr.ScrollbarBg] = ImVec4(0.22, 0.29, 0.30, 0.71)
colors[clr.ScrollbarGrab] = ImVec4(0.00, 1.00, 1.00, 0.44)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.00, 1.00, 1.00, 0.74)
colors[clr.ScrollbarGrabActive] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.ComboBg] = ImVec4(0.16, 0.24, 0.22, 0.60)
colors[clr.CheckMark] = ImVec4(0.00, 1.00, 1.00, 0.68)
colors[clr.SliderGrab] = ImVec4(0.00, 1.00, 1.00, 0.36)
colors[clr.SliderGrabActive] = ImVec4(0.00, 1.00, 1.00, 0.76)
colors[clr.Button] = ImVec4(0.00, 0.65, 0.65, 0.46)
colors[clr.ButtonHovered] = ImVec4(0.01, 1.00, 1.00, 0.43)
colors[clr.ButtonActive] = ImVec4(0.00, 1.00, 1.00, 0.62)
colors[clr.Header] = ImVec4(0.00, 1.00, 1.00, 0.33)
colors[clr.HeaderHovered] = ImVec4(0.00, 1.00, 1.00, 0.42)
colors[clr.HeaderActive] = ImVec4(0.00, 1.00, 1.00, 0.54)
colors[clr.ResizeGrip] = ImVec4(0.00, 1.00, 1.00, 0.54)
colors[clr.ResizeGripHovered] = ImVec4(0.00, 1.00, 1.00, 0.74)
colors[clr.ResizeGripActive] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.CloseButton] = ImVec4(0.00, 0.78, 0.78, 0.35)
colors[clr.CloseButtonHovered] = ImVec4(0.00, 0.78, 0.78, 0.47)
colors[clr.CloseButtonActive] = ImVec4(0.00, 0.78, 0.78, 1.00)
colors[clr.PlotLines] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.PlotLinesHovered] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.PlotHistogram] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.PlotHistogramHovered] = ImVec4(0.00, 1.00, 1.00, 1.00)
colors[clr.TextSelectedBg] = ImVec4(0.00, 1.00, 1.00, 0.22)
colors[clr.ModalWindowDarkening] = ImVec4(0.04, 0.10, 0.09, 0.51)
elseif combo_select.v == 2 then
imgui.SwitchContext()
local style = imgui.GetStyle()
local colors = style.Colors
local clr = imgui.Col
local ImVec4 = imgui.ImVec4
local ImVec2 = imgui.ImVec2
style.WindowPadding = ImVec2(15, 15)
style.WindowRounding = 15.0
style.FramePadding = ImVec2(5, 5)
style.ItemSpacing = ImVec2(12, 8)
style.ItemInnerSpacing = ImVec2(8, 6)
style.IndentSpacing = 25.0
style.ScrollbarSize = 15.0
style.ScrollbarRounding = 15.0
style.GrabMinSize = 15.0
style.GrabRounding = 7.0
style.ChildWindowRounding = 8.0
style.FrameRounding = 6.0
colors[clr.Text] = ImVec4(0.95, 0.96, 0.98, 1.00)
colors[clr.TextDisabled] = ImVec4(0.36, 0.42, 0.47, 1.00)
colors[clr.WindowBg] = ImVec4(0.11, 0.15, 0.17, 1.00)
colors[clr.ChildWindowBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.PopupBg] = ImVec4(0.08, 0.08, 0.08, 0.94)
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.20, 0.25, 0.29, 1.00)
colors[clr.FrameBgHovered] = ImVec4(0.12, 0.20, 0.28, 1.00)
colors[clr.FrameBgActive] = ImVec4(0.09, 0.12, 0.14, 1.00)
colors[clr.TitleBg] = ImVec4(0.09, 0.12, 0.14, 0.65)
colors[clr.TitleBgCollapsed] = ImVec4(0.00, 0.00, 0.00, 0.51)
colors[clr.TitleBgActive] = ImVec4(0.08, 0.10, 0.12, 1.00)
colors[clr.MenuBarBg] = ImVec4(0.15, 0.18, 0.22, 1.00)
colors[clr.ScrollbarBg] = ImVec4(0.02, 0.02, 0.02, 0.39)
colors[clr.ScrollbarGrab] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ScrollbarGrabHovered] = ImVec4(0.18, 0.22, 0.25, 1.00)
colors[clr.ScrollbarGrabActive] = ImVec4(0.09, 0.21, 0.31, 1.00)
colors[clr.ComboBg] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.CheckMark] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrab] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.SliderGrabActive] = ImVec4(0.37, 0.61, 1.00, 1.00)
colors[clr.Button] = ImVec4(0.20, 0.25, 0.29, 1.00)
colors[clr.ButtonHovered] = ImVec4(0.28, 0.56, 1.00, 1.00)
colors[clr.ButtonActive] = ImVec4(0.06, 0.53, 0.98, 1.00)
colors[clr.Header] = ImVec4(0.20, 0.25, 0.29, 0.55)
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.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.06, 0.05, 0.07, 1.00)
colors[clr.CloseButton] = ImVec4(0.40, 0.39, 0.38, 0.16)
colors[clr.CloseButtonHovered] = ImVec4(0.40, 0.39, 0.38, 0.39)
colors[clr.CloseButtonActive] = ImVec4(0.40, 0.39, 0.38, 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.25, 1.00, 0.00, 0.43)
colors[clr.ModalWindowDarkening] = ImVec4(1.00, 0.98, 0.95, 0.73)
end
imgui.EndChild()
imgui.End()
end