Skip to content

Commit 8792699

Browse files
The-EFabian Woltermann
andauthored
Feature/dear imgui (#4987)
* Add imgui * migrate render options * remove wmcgui * Add subsystem selection and highlighting * Add a syntactic sugar extension for imgui * don't rebuild the mission list every frame * Add imgui_sugar extension * Move helper functions out of lab_ui, add function to display consolidated table text for object * add button to export cubemap * fix entering and exiting the lab * refactor some of this for greater cleanness * use techroom lighting when no mission background is set * minor things * add imguizmo * add imguizmo * Add imgui * migrate render options * remove wmcgui * Add subsystem selection and highlighting * Add a syntactic sugar extension for imgui * don't rebuild the mission list every frame * Move helper functions out of lab_ui, add function to display consolidated table text for object * add button to export cubemap * fix entering and exiting the lab * refactor some of this for greater cleanness * minor things * add imguizmo * add imguizmo * Add button to reset changes made in the render dialog * refactoring * unfuck rebase * fix issue with loose mission files * use with_CollapsingHeader for greater uniformity * add weapon selection functionality * make primaries and secondaries fire again * implement animation triggers * avoid crash when switching back and forth between ships with and without team colors * add control to set team color setting to renderer texture dialog * make sure the table text updates when the ship class changes * let rotating subsystems rotate * do not add imgui.h to pstypes * code cleanup * add subsys highlighter from fred * Highlight non-modelled subsystems as well * add cmdline flag to show the imgui demo dialogue * fix compiler warnings reported by CI * fix error when building the subsystem list * refactor variable/method naming * code cleanup * remove vestigial code * update to imgui 1.89.1 * add credits entry for imgui * use the imgui namespace * Separate the background dialog out into its own window * make sure the subsystem highlights are placed correctly Co-authored-by: Fabian Woltermann <fabian.woltermann@peakwork.com>
1 parent 66becc9 commit 8792699

File tree

234 files changed

+94657
-5721
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+94657
-5721
lines changed

.gitmodules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
[submodule "lib/libRocket"]
55
path = lib/libRocket
66
url = https://github.com/asarium/libRocket.git
7+

code/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ target_link_libraries(code PUBLIC any)
7070

7171
target_link_libraries(code PUBLIC optional)
7272

73+
target_link_libraries(code PUBLIC imgui)
74+
7375
# Headers for standalone "gui" on UNIX
7476
IF(UNIX)
7577
TARGET_LINK_LIBRARIES(code PUBLIC ${MONGOOSE_LIBS})

code/cmdline/cmdline.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ Flag exe_params[] =
260260
{ "-gr_debug", "Output graphics debug information", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gr_debug", },
261261
{ "-stdout_log", "Output log file to stdout", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-stdout_log", },
262262
{ "-slow_frames_ok", "Don't adjust timestamps for slow frames", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-slow_frames_ok", },
263+
{ "-imgui_debug", "Show imgui debug/demo window in the lab", true, 0, EASY_DEFAULT, "Dev Tool", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-imgui_debug", },
263264
};
264265
// clang-format on
265266

@@ -511,6 +512,7 @@ cmdline_parm slow_frames_ok_arg("-slow_frames_ok", nullptr, AT_NONE); // Cmdline
511512
cmdline_parm fixed_seed_rand("-seed", nullptr, AT_INT); // Cmdline_rng_seed,Cmdline_reuse_rng_seed;
512513
cmdline_parm luadev_arg("-luadev", nullptr, AT_NONE); // Cmdline_lua_devmode
513514
cmdline_parm override_arg("-override_data", nullptr, AT_NONE); // Cmdline_override_data
515+
cmdline_parm imgui_debug_arg("-imgui_debug", nullptr, AT_NONE);
514516

515517
char *Cmdline_start_mission = NULL;
516518
int Cmdline_dis_collisions = 0;
@@ -545,6 +547,7 @@ bool Cmdline_log_to_stdout = false;
545547
bool Cmdline_slow_frames_ok = false;
546548
bool Cmdline_lua_devmode = false;
547549
bool Cmdline_override_data = false;
550+
bool Cmdline_show_imgui_debug = false;
548551

549552
// Other
550553
cmdline_parm get_flags_arg(GET_FLAGS_STRING, "Output the launcher flags file", AT_STRING);
@@ -2176,6 +2179,10 @@ bool SetCmdlineParams()
21762179
Cmdline_override_data = true;
21772180
}
21782181

2182+
if (imgui_debug_arg.found()) {
2183+
Cmdline_show_imgui_debug = true;
2184+
}
2185+
21792186
if (show_video_info.found())
21802187
{
21812188
Cmdline_show_video_info = true;

code/cmdline/cmdline.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ extern bool Cmdline_log_to_stdout;
155155
extern bool Cmdline_slow_frames_ok;
156156
extern bool Cmdline_lua_devmode;
157157
extern bool Cmdline_override_data;
158+
extern bool Cmdline_show_imgui_debug;
158159

159160
enum class WeaponSpewType { NONE = 0, STANDARD, ALL };
160161
extern WeaponSpewType Cmdline_spew_weapon_stats;

code/globalincs/pstypes.h

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -482,25 +482,37 @@ SCP_string dump_stacktrace();
482482
const auto ptr_memset = std::memset;
483483
#define memset memset_if_trivial_else_error
484484

485+
// Forward declarations from libraries
486+
struct ImDrawListSplitter;
487+
485488
// Put into std to be compatible with code that uses std::mem*
486489
namespace std
487490
{
488-
template<typename T>
489-
using trivial_check = std::is_trivially_copyable<T>;
491+
template <typename T>
492+
using trivial_check = std::is_trivially_copyable<T>;
493+
494+
template <typename T>
495+
void* memset_if_trivial_else_error(
496+
typename std::enable_if<!std::is_same<T, ImDrawListSplitter>::value, T>::type* memset_data,
497+
int ch,
498+
size_t count)
499+
{
500+
static_assert(trivial_check<T>::value, "memset on non-trivial object");
501+
return ptr_memset(memset_data, ch, count);
502+
}
490503

491-
template<typename T>
492-
void *memset_if_trivial_else_error(T *memset_data, int ch, size_t count)
493-
{
494-
static_assert(trivial_check<T>::value, "memset on non-trivial object");
495-
return ptr_memset(memset_data, ch, count);
496-
}
504+
// assume memset on a void* is "safe"
505+
// only used in cutscene/mveplayer.cpp:mve_video_createbuf()
506+
inline void* memset_if_trivial_else_error(void* memset_data, int ch, size_t count)
507+
{
508+
return ptr_memset(memset_data, ch, count);
509+
}
497510

498-
// assume memset on a void* is "safe"
499-
// only used in cutscene/mveplayer.cpp:mve_video_createbuf()
500-
inline void *memset_if_trivial_else_error(void *memset_data, int ch, size_t count)
501-
{
502-
return ptr_memset(memset_data, ch, count);
503-
}
511+
// Dear ImGui triggers these as well, so we need to let them pass
512+
inline void* memset_if_trivial_else_error(ImDrawListSplitter* memset_data, int ch, size_t count)
513+
{
514+
return ptr_memset(memset_data, ch, count);
515+
}
504516

505517
// MEMCPY!
506518
const auto ptr_memcpy = std::memcpy;

0 commit comments

Comments
 (0)