DCS EFM ImGui (FmGui)  v1.2
Source only library for using ImGui with the DCS: World EFM API.
FmGui.hpp
1 /* =============================================================================
2  * DCS-EFM-ImGui, file: FmGui.hpp Created: 18-JUN-2022
3  *
4  * Copyright 2022-2023 Brian Hoffpauir, USA
5  * All rights reserved.
6  *
7  * Redistribution and use of this source file, with or without modification, is
8  * permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of this source file must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * =============================================================================
28  */
29 #ifndef FMGUI_FMGUI_HPP
30 #define FMGUI_FMGUI_HPP
31 
32 #define WIN32_LEAN_AND_MEAN
33 #include <Windows.h>
34 
35 #include <cstdio>
36 #include <cstdlib>
37 #include <type_traits>
38 #include <string>
39 #include <vector>
43 #include <imgui.h>
47 #if defined FMGUI_ENABLE_IMPLOT
48 #include <implot.h>
49 #endif
50 
51 #if !defined(FMGUI_FASTCALL)
52 #define FMGUI_FASTCALL __fastcall
53 #endif
54 
55 // Disable ImGui XINPUT
56 #define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD
57 
58 // Forward declare IDXGISwapChain structure.
59 struct IDXGISwapChain;
60 
61 // Forward declare typedef for ImGuiConfigFlags.
62 using ImGuiConfigFlags = int;
63 
65 namespace FmGui
66 {
68  enum struct Style
69  {
70  kCLASSIC,
71  kDARK,
72  kLIGHT
73  };
75  struct Config
76  {
82  Style style = Style::kDARK;
88  ImGuiConfigFlags configFlags = ImGuiConfigFlags_NavNoCaptureKeyboard;
95  std::string iniFileName = "imgui.ini";
101  float iniSavingRate = 5.0f;
102  };
104  enum struct MessageSeverity
105  {
106  kNOTIFICATION,
107  kLOW,
108  kMEDIUM,
109  kHIGH
110  };
112  struct Message
113  {
114  MessageSeverity severity;
115  std::string content;
116  std::string file;
117  std::string function;
118  std::size_t line;
119  };
120 
121  using MessageVector = std::vector<Message>;
123  using MessageCallback = std::add_pointer<void(const Message &message)>::type;
125  using RoutinePtr = std::add_pointer<void(void)>::type;
127  using InputRoutinePtr = std::add_pointer<void(UINT uMsg, WPARAM wParam, LPARAM lParam)>::type;
141  void SetRoutinePtr(RoutinePtr pRoutine);
167  void SetInputRoutinePtr(InputRoutinePtr pInputRoutine);
174  bool SetWidgetVisibility(bool bEnabled);
191  bool StartupHook(const Config &config = Config());
196  std::string AddressDump(void);
201  const Message &GetLastError(void);
205  std::vector<Message> GetEveryMessage(void);
211  void SetMessageCallback(MessageCallback pMessageCallback);
220  std::string DebugLayerMessageDump(void);
225  bool ShutdownHook(void);
226 } // End namespace (FmGui)
227 
228 #endif /* !FMGUI_FMGUI_HPP */
FmGui types & functions.
Definition: FmGui.cpp:53
void SetMessageCallback(MessageCallback pMessageCallback)
Definition: FmGui.cpp:137
bool StartupHook(const Config &config=Config())
Definition: FmGui.cpp:376
std::string AddressDump(void)
Definition: FmGui.cpp:142
std::vector< Message > GetEveryMessage(void)
Definition: FmGui.cpp:658
void SetRoutinePtr(RoutinePtr pRoutine)
Definition: FmGui.cpp:127
std::add_pointer< void(void)>::type RoutinePtr
Alias for FmGui routine function.
Definition: FmGui.hpp:125
void SetInputRoutinePtr(InputRoutinePtr pInputRoutine)
Definition: FmGui.cpp:132
std::add_pointer< void(UINT uMsg, WPARAM wParam, LPARAM lParam)>::type InputRoutinePtr
Alias for FmGui input routine function.
Definition: FmGui.hpp:127
std::add_pointer< void(const Message &message)>::type MessageCallback
Alias for message callback.
Definition: FmGui.hpp:123
Style
ImGui display style.
Definition: FmGui.hpp:69
bool SetWidgetVisibility(bool bEnabled)
Definition: FmGui.cpp:360
const Message & GetLastError(void)
Definition: FmGui.cpp:653
std::string DebugLayerMessageDump(void)
Definition: FmGui.cpp:158
MessageSeverity
FmGui message severity levels.
Definition: FmGui.hpp:105
bool ShutdownHook(void)
Definition: FmGui.cpp:595
FmGui configuration data.
Definition: FmGui.hpp:76
ImGuiConfigFlags configFlags
Definition: FmGui.hpp:88
Style style
Definition: FmGui.hpp:82
std::string iniFileName
Definition: FmGui.hpp:95
float iniSavingRate
Definition: FmGui.hpp:101
FmGui message data.
Definition: FmGui.hpp:113