Показать сообщение отдельно

  #8  
Старый 02.08.2023, 20:23
Smeruxa
Познавший АНТИЧАТ
Регистрация: 27.11.2020
Сообщений: 1,431
С нами: 2874035

Репутация: 183


По умолчанию

Подключил ImGui в SF плагин, если бегать с ним минуту где-то, то при открытии все меню с ума начинает сходить, иногда на что-то нажимает, а со временем проходит, будто повторяет все мои действия сделанные раннее, просто с отключенным курсором, как можно исправить?

Подгружаю я imgui_load в mainloop main.cpp

main.cpp:





Код:
if
(
SUCCEEDED
(
SF
->
getRender
(
)
->
BeginRender
(
)
)
)
{
// RENDER
rVisual
->
Render
(
)
;
// RENDER
// IMGUI
if
(
rConfig
->
imgui_active
)
{
ImGui_ImplDX9_NewFrame
(
)
;
ImGui_ImplWin32_NewFrame
(
)
;
ImGui
::
NewFrame
(
)
;
// DRAW
SF
->
getSAMP
(
)
->
getMisc
(
)
->
ToggleCursor
(
true
)
;
ImGui
::
SetNextWindowSize
(
ImVec2
(
651.f
,
296.f
)
)
;
ImGui
::
SetNextWindowPos
(
ImVec2
(
rConfig
->
ScreenResolution
[
0
]
*
0.5f
,
rConfig
->
ScreenResolution
[
1
]
*
0.5f
)
,
ImGuiCond_Always
,
ImVec2
(
0.5f
,
0.5f
)
)
;
ImGui
::
Begin
(
""
,
&
rConfig
->
imgui_active
,
ImGuiWindowFlags_NoResize
|
ImGuiWindowFlags_NoCollapse
)
;
ImGui
::
End
(
)
;
// DRAW
ImGui
::
EndFrame
(
)
;
ImGui
::
Render
(
)
;
ImGui_ImplDX9_RenderDrawData
(
ImGui
::
GetDrawData
(
)
)
;
IDirect3DDevice9
*
device
=
SF
->
getRender
(
)
->
getD3DDevice
(
)
;
device
->
SetRenderState
(
D3DRS_ZENABLE
,
FALSE
)
;
device
->
SetRenderState
(
D3DRS_ALPHABLENDENABLE
,
FALSE
)
;
device
->
SetRenderState
(
D3DRS_SCISSORTESTENABLE
,
FALSE
)
;
}
// IMGUI
SF
->
getRender
(
)
->
EndRender
(
)
;
}


C++:





Код:
LRESULT
ImGui_ImplWin32_WndProcHandler
(
HWND hWnd
,
UINT msg
,
WPARAM wParam
,
LPARAM lParam
)
;
bool
CALLBACK
Present
(
CONST RECT
*
pSourceRect
,
CONST RECT
*
pDestRect
,
HWND hDestWindowOverride
,
CONST RGNDATA
*
pDirtyRegion
)
;
HRESULT CALLBACK
Reset
(
D3DPRESENT_PARAMETERS
*
pPresentationParameters
)
{
ImGui_ImplDX9_InvalidateDeviceObjects
(
)
;
return
true
;
}
bool
CALLBACK
WndProcHandler
(
HWND hwd
,
UINT msg
,
WPARAM wParam
,
LPARAM lParam
)
{
ImGui_ImplWin32_WndProcHandler
(
hwd
,
msg
,
wParam
,
lParam
)
;
return
true
;
}
void
CALLBACK
PluginFree
(
)
{
ImGui_ImplDX9_Shutdown
(
)
;
ImGui_ImplWin32_Shutdown
(
)
;
ImGui
::
DestroyContext
(
)
;
}
void
set_style
(
)
{
ImGuiStyle
&
style
=
ImGui
::
GetStyle
(
)
;
ImGuiIO
&
io
=
ImGui
::
GetIO
(
)
;
style
.
WindowPadding
=
ImVec2
(
2
,
2
)
;
style
.
WindowRounding
=
1
;
style
.
ChildRounding
=
2
;
style
.
FramePadding
=
ImVec2
(
3
,
3
)
;
style
.
FrameRounding
=
1
;
style
.
ItemSpacing
=
ImVec2
(
2
,
2
)
;
style
.
TouchExtraPadding
=
ImVec2
(
0
,
0
)
;
style
.
IndentSpacing
=
21
;
style
.
ScrollbarSize
=
9
;
style
.
ScrollbarRounding
=
1
;
style
.
GrabMinSize
=
10
;
style
.
GrabRounding
=
1
;
style
.
WindowTitleAlign
=
ImVec2
(
0.5
,
0.5
)
;
style
.
ButtonTextAlign
=
ImVec2
(
0.5
,
0.5
)
;
style
.
Colors
[
ImGuiCol_FrameBg
]
=
ImVec4
(
0.16
,
0.29
,
0.48
,
0.54
)
;
style
.
Colors
[
ImGuiCol_FrameBgHovered
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.40
)
;
style
.
Colors
[
ImGuiCol_FrameBgActive
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.67
)
;
style
.
Colors
[
ImGuiCol_TitleBg
]
=
ImVec4
(
0.16
,
0.29
,
0.48
,
1.00
)
;
style
.
Colors
[
ImGuiCol_TitleBgActive
]
=
ImVec4
(
0.16
,
0.29
,
0.48
,
1.00
)
;
style
.
Colors
[
ImGuiCol_TitleBgCollapsed
]
=
ImVec4
(
0.16
,
0.29
,
0.48
,
1.00
)
;
style
.
Colors
[
ImGuiCol_CheckMark
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
1.00
)
;
style
.
Colors
[
ImGuiCol_SliderGrab
]
=
ImVec4
(
0.24
,
0.52
,
0.88
,
1.00
)
;
style
.
Colors
[
ImGuiCol_SliderGrabActive
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
1.00
)
;
style
.
Colors
[
ImGuiCol_Button
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.40
)
;
style
.
Colors
[
ImGuiCol_ButtonHovered
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
1.00
)
;
style
.
Colors
[
ImGuiCol_ButtonActive
]
=
ImVec4
(
0.06
,
0.53
,
0.98
,
1.00
)
;
style
.
Colors
[
ImGuiCol_Header
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.31
)
;
style
.
Colors
[
ImGuiCol_HeaderHovered
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.80
)
;
style
.
Colors
[
ImGuiCol_HeaderActive
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
1.00
)
;
style
.
Colors
[
ImGuiCol_Separator
]
=
style
.
Colors
[
ImGuiCol_Border
]
;
style
.
Colors
[
ImGuiCol_SeparatorHovered
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.78
)
;
style
.
Colors
[
ImGuiCol_SeparatorActive
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
1.00
)
;
style
.
Colors
[
ImGuiCol_ResizeGrip
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.25
)
;
style
.
Colors
[
ImGuiCol_ResizeGripHovered
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.67
)
;
style
.
Colors
[
ImGuiCol_ResizeGripActive
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.95
)
;
style
.
Colors
[
ImGuiCol_TextSelectedBg
]
=
ImVec4
(
0.26
,
0.59
,
0.98
,
0.35
)
;
style
.
Colors
[
ImGuiCol_Text
]
=
ImVec4
(
1.00
,
1.00
,
1.00
,
1.00
)
;
style
.
Colors
[
ImGuiCol_TextDisabled
]
=
ImVec4
(
0.50
,
0.50
,
0.50
,
1.00
)
;
style
.
Colors
[
ImGuiCol_WindowBg
]
=
ImVec4
(
0.06
,
0.06
,
0.06
,
0.94
)
;
style
.
Colors
[
ImGuiCol_ChildBg
]
=
ImVec4
(
1.00
,
1.00
,
1.00
,
0.00
)
;
style
.
Colors
[
ImGuiCol_PopupBg
]
=
ImVec4
(
0.08
,
0.08
,
0.08
,
0.94
)
;
//style.Colors[ImGuiCol_ComboBg] = style.Colors[ImGuiCol_PopupBg]; ImGuiCol_Bg
style
.
Colors
[
ImGuiCol_Border
]
=
ImVec4
(
0.43
,
0.43
,
0.50
,
0.50
)
;
style
.
Colors
[
ImGuiCol_BorderShadow
]
=
ImVec4
(
0.00
,
0.00
,
0.00
,
0.00
)
;
style
.
Colors
[
ImGuiCol_MenuBarBg
]
=
ImVec4
(
0.14
,
0.14
,
0.14
,
1.00
)
;
style
.
Colors
[
ImGuiCol_ScrollbarBg
]
=
ImVec4
(
0.02
,
0.02
,
0.02
,
0.53
)
;
style
.
Colors
[
ImGuiCol_ScrollbarGrab
]
=
ImVec4
(
0.31
,
0.31
,
0.31
,
1.00
)
;
style
.
Colors
[
ImGuiCol_ScrollbarGrabHovered
]
=
ImVec4
(
0.41
,
0.41
,
0.41
,
1.00
)
;
style
.
Colors
[
ImGuiCol_ScrollbarGrabActive
]
=
ImVec4
(
0.51
,
0.51
,
0.51
,
1.00
)
;
//style.Colors[ImGuiCol_CloseButton] = ImVec4(0.41, 0.41, 0.41, 0.50);
//style.Colors[ImGuiCol_CloseButtonHovered] = ImVec4(0.98, 0.39, 0.36, 1.00);
//style.Colors[ImGuiCol_CloseButtonActive] = ImVec4(0.98, 0.39, 0.36, 1.00);
style
.
Colors
[
ImGuiCol_PlotLines
]
=
ImVec4
(
0.61
,
0.61
,
0.61
,
1.00
)
;
style
.
Colors
[
ImGuiCol_PlotLinesHovered
]
=
ImVec4
(
1.00
,
0.43
,
0.35
,
1.00
)
;
style
.
Colors
[
ImGuiCol_PlotHistogram
]
=
ImVec4
(
0.90
,
0.70
,
0.00
,
1.00
)
;
style
.
Colors
[
ImGuiCol_PlotHistogramHovered
]
=
ImVec4
(
1.00
,
0.60
,
0.00
,
1.00
)
;
style
.
Colors
[
ImGuiCol_ModalWindowDimBg
]
=
ImVec4
(
0.80
,
0.80
,
0.80
,
0.35
)
;
}
void
ImGuiInizialization
::
Load
(
)
{
ImGui
::
CreateContext
(
)
;
ImGui_ImplWin32_Init
(
GetActiveWindow
(
)
)
;
ImGui_ImplDX9_Init
(
SF
->
getRender
(
)
->
getD3DDevice
(
)
)
;
ImGui
::
GetIO
(
)
.
Fonts
->
AddFontFromFileTTF
(
"C:\\Windows\\Fonts\\Arial.ttf"
,
16.5f
,
NULL
,
ImGui
::
GetIO
(
)
.
Fonts
->
GetGlyphRangesCyrillic
(
)
)
;
child_font
=
ImGui
::
GetIO
(
)
.
Fonts
->
AddFontFromFileTTF
(
"C:\\Windows\\Fonts\\Arial.ttf"
,
17.f
,
NULL
,
ImGui
::
GetIO
(
)
.
Fonts
->
GetGlyphRangesCyrillic
(
)
)
;
set_style
(
)
;
SF
->
getRender
(
)
->
registerD3DCallback
(
eDirect3DDeviceMethods
::
D3DMETHOD_PRESENT
,
Present
)
;
SF
->
getRender
(
)
->
registerD3DCallback
(
eDirect3DDeviceMethods
::
D3DMETHOD_RESET
,
Reset
)
;
SF
->
getGame
(
)
->
registerWndProcCallback
(
SFGame
::
MEDIUM_CB_PRIORITY
,
WndProcHandler
)
;
SF
->
getGame
(
)
->
registerGameDestructorCallback
(
PluginFree
)
;
}
 
Ответить с цитированием