2024-03-27 00:02:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef NEO_SYS_SYS_IMGUI_H_
|
|
|
|
#define NEO_SYS_SYS_IMGUI_H_
|
|
|
|
|
|
|
|
#include "../libs/imgui/imgui.h"
|
|
|
|
|
|
|
|
namespace D3 {
|
|
|
|
namespace ImGuiHooks {
|
|
|
|
|
2024-04-05 04:33:33 +00:00
|
|
|
enum D3ImGuiWindow {
|
|
|
|
D3_ImGuiWin_None = 0,
|
|
|
|
D3_ImGuiWin_Settings = 1, // advanced dhewm3 settings menu
|
|
|
|
D3_ImGuiWin_Demo = 2, // ImGui demo window
|
|
|
|
// next should be 4, then 8, etc so a bitmask can be used
|
|
|
|
};
|
|
|
|
|
2024-03-27 00:02:03 +00:00
|
|
|
#ifndef IMGUI_DISABLE
|
|
|
|
|
|
|
|
extern ImGuiContext* imguiCtx; // this is only here so IsImguiEnabled() can use it inline
|
|
|
|
|
|
|
|
inline bool IsImguiEnabled()
|
|
|
|
{
|
|
|
|
return imguiCtx != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// using void* instead of SDL_Window and SDL_GLContext to avoid dragging SDL headers into sys_imgui.h
|
|
|
|
extern bool Init(void* sdlWindow, void* sdlGlContext);
|
|
|
|
|
|
|
|
extern void Shutdown();
|
|
|
|
|
2024-04-05 04:33:33 +00:00
|
|
|
extern void OpenWindow( D3ImGuiWindow win );
|
|
|
|
|
|
|
|
extern void CloseWindow( D3ImGuiWindow win );
|
2024-03-27 00:02:03 +00:00
|
|
|
|
2024-04-19 10:30:37 +00:00
|
|
|
// enum D3ImGuiWindow values of all currently open imgui windows or-ed together
|
|
|
|
// (0 if none are open)
|
|
|
|
extern int GetOpenWindowsMask();
|
|
|
|
|
2024-04-05 04:33:33 +00:00
|
|
|
// called with every SDL event by Sys_GetEvent()
|
|
|
|
// returns true if ImGui has handled the event (so it shouldn't be handled by D3)
|
2024-03-27 00:02:03 +00:00
|
|
|
extern bool ProcessEvent(const void* sdlEvent);
|
|
|
|
|
2024-05-22 14:39:37 +00:00
|
|
|
// for binding keys from an ImGui-based menu: send input events to dhewm3
|
|
|
|
// even if ImGui window has focus
|
|
|
|
extern void SetKeyBindMode( bool enable );
|
|
|
|
|
2024-05-28 02:41:21 +00:00
|
|
|
// returns true if the system cursor should be shown because an ImGui menu is active
|
|
|
|
extern bool ShouldShowCursor();
|
|
|
|
|
2024-04-05 04:33:33 +00:00
|
|
|
// NewFrame() is called once per D3 frame, after all events have been gotten
|
|
|
|
// => ProcessEvent() has already been called (probably multiple times)
|
|
|
|
extern void NewFrame();
|
|
|
|
|
|
|
|
// called at the end of the D3 frame, when all other D3 rendering is done
|
|
|
|
// renders ImGui menus then
|
2024-03-27 00:02:03 +00:00
|
|
|
extern void EndFrame();
|
|
|
|
|
2024-04-19 10:30:37 +00:00
|
|
|
extern float GetScale();
|
|
|
|
extern void SetScale( float scale );
|
2024-04-06 02:03:22 +00:00
|
|
|
|
2024-05-22 14:39:37 +00:00
|
|
|
// show a red overlay-window at the center of the screen that contains
|
|
|
|
// a warning symbol (triangle with !) and the given text
|
|
|
|
// disappears after a few seconds or when a key is pressed or the mouse is moved
|
|
|
|
extern void ShowWarningOverlay( const char* text );
|
|
|
|
|
2024-05-24 02:00:19 +00:00
|
|
|
enum Style {
|
|
|
|
Dhewm3,
|
|
|
|
ImGui_Default,
|
|
|
|
User
|
|
|
|
};
|
|
|
|
|
|
|
|
// set the overall style for ImGui: Both shape (sizes, roundings, etc) and colors
|
|
|
|
extern void SetImGuiStyle( Style style );
|
|
|
|
|
|
|
|
// set the default dhewm3 imgui style colors
|
2024-05-26 01:56:28 +00:00
|
|
|
extern void SetDhewm3StyleColors( ImGuiStyle* dst = nullptr );
|
2024-05-24 02:00:19 +00:00
|
|
|
extern void SetUserStyleColors();
|
|
|
|
|
|
|
|
// write current style settings (incl. colors) as userStyle
|
|
|
|
extern bool WriteUserStyle();
|
|
|
|
|
2024-05-25 16:16:00 +00:00
|
|
|
// copy current style to clipboard
|
2024-05-26 01:56:28 +00:00
|
|
|
extern void CopyCurrentStyle( bool onlyChanges );
|
2024-05-25 16:16:00 +00:00
|
|
|
|
2024-03-27 00:02:03 +00:00
|
|
|
#else // IMGUI_DISABLE - just stub out everything
|
|
|
|
|
|
|
|
inline bool IsImguiEnabled()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// using void* instead of SDL_Window and SDL_GLContext to avoid dragging SDL headers into sys_imgui.h
|
|
|
|
inline bool Init(void* sdlWindow, void* sdlGlContext)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void Shutdown() {}
|
|
|
|
|
|
|
|
inline bool ProcessEvent(const void* sdlEvent) { return false; }
|
|
|
|
|
2024-05-22 14:39:37 +00:00
|
|
|
inline void SetKeyBindMode( bool enable ) {}
|
|
|
|
|
2024-05-28 02:41:21 +00:00
|
|
|
inline bool ShouldShowCursor() { return false; }
|
|
|
|
|
2024-04-05 04:33:33 +00:00
|
|
|
inline void NewFrame() {}
|
|
|
|
|
2024-03-27 00:02:03 +00:00
|
|
|
inline void EndFrame() {}
|
|
|
|
|
2024-04-05 04:33:33 +00:00
|
|
|
inline void OpenWindow( D3ImGuiWindow win ) {}
|
|
|
|
|
|
|
|
inline void CloseWindow( D3ImGuiWindow win ) {}
|
|
|
|
|
2024-04-19 10:30:37 +00:00
|
|
|
inline int GetOpenWindowsMask() { return 0; }
|
|
|
|
|
|
|
|
inline float GetScale() { return 1.0f; }
|
|
|
|
inline void SetScale( float scale ) {}
|
2024-04-06 02:03:22 +00:00
|
|
|
|
2024-05-22 14:39:37 +00:00
|
|
|
inline void ShowWarningOverlay( const char* text ) {}
|
|
|
|
|
2024-05-24 02:00:19 +00:00
|
|
|
inline bool WriteUserStyle() { return false; }
|
|
|
|
|
2024-03-27 00:02:03 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}} //namespace D3::ImGuiHooks
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* NEO_SYS_SYS_IMGUI_H_ */
|