Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Porting MFC tools #649

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions neo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,26 @@ set(src_imgui ${src_imgui}
sys/sys_imgui.h
sys/sys_imgui.cpp
sys/imgui_savestyle.cpp

tools/imgui/ImGuiTools.cpp
tools/imgui/util/ImGui_IdWidgets.h
tools/imgui/util/ImGui_IdWidgets.cpp

tools/imgui/afeditor/AfEditor.h
tools/imgui/afeditor/AfEditor.cpp
tools/imgui/afeditor/AfBodyEditor.h
tools/imgui/afeditor/AfBodyEditor.cpp
tools/imgui/afeditor/AfConstraintEditor.h
tools/imgui/afeditor/AfConstraintEditor.cpp
tools/imgui/afeditor/AfPropertyEditor.h
tools/imgui/afeditor/AfPropertyEditor.cpp

tools/imgui/lighteditor/LightEditor.h
tools/imgui/lighteditor/LightEditor.cpp
tools/imgui/pdaeditor/PDAEditor.h
tools/imgui/pdaeditor/PDAEditor.cpp
tools/imgui/particleeditor/ParticleEditor.h
tools/imgui/particleeditor/ParticleEditor.cpp
)
else()
set(src_imgui sys/sys_imgui.h)
Expand Down
93 changes: 69 additions & 24 deletions neo/framework/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,22 @@ idCommonLocal::InitTool
=================
*/
void idCommonLocal::InitTool( const toolFlag_t tool, const idDict *dict ) {
#ifndef IMGUI_DISABLE
if ( tool & EDITOR_SOUND ) {
//SoundEditorInit( dict );
} else if ( tool & EDITOR_LIGHT ) {
ImGuiTools::LightEditorInit( dict );
} else if ( tool & EDITOR_PARTICLE ) {
//ParticleEditorInit( dict );
} else if ( tool & EDITOR_AF ) {
ImGuiTools::AfEditorInit(); // TODO: dict ?
} else if ( tool & EDITOR_PDA ) {
ImGuiTools::PDAEditorInit( dict );
} else if ( tool & EDITOR_PARTICLE ) {
ImGuiTools::ParticleEditorInit( dict );
}
#endif

#ifdef ID_ALLOW_TOOLS
if ( tool & EDITOR_SOUND ) {
SoundEditorInit( dict );
Expand Down Expand Up @@ -1228,71 +1244,100 @@ static void PrintMemInfo_f( const idCmdArgs &args ) {
fileSystem->CloseFile( f );
}

#ifdef ID_ALLOW_TOOLS

/*
==================
Com_EditLights_f
==================
*/
static void Com_EditLights_f( const idCmdArgs &args ) {
#ifndef IMGUI_DISABLE
D3::ImGuiHooks::ShowInfoOverlay( "Shoot a light to open it in the Light Editor" );
cvarSystem->SetCVarInteger( "g_editEntityMode", 1 );
#elif defined(ID_ALLOW_TOOLS)
LightEditorInit( NULL );
cvarSystem->SetCVarInteger( "g_editEntityMode", 1 );
#else
common->Warning( "Editors not available because dhewm3 was built without ImGui or MFC Tools" );
#endif
}

/*
==================
Com_EditSounds_f
Com_EditPDAs_f
==================
*/
static void Com_EditSounds_f( const idCmdArgs &args ) {
SoundEditorInit( NULL );
cvarSystem->SetCVarInteger( "g_editEntityMode", 2 );
static void Com_EditPDAs_f( const idCmdArgs &args ) {
#ifndef IMGUI_DISABLE
ImGuiTools::PDAEditorInit( NULL );
#elif defined(ID_ALLOW_TOOLS)
PDAEditorInit( NULL );
#else
common->Warning( "Editors not available because dhewm3 was built without ImGui or MFC Tools" );
#endif
}

/*
==================
Com_EditDecls_f
Com_EditAFs_f
==================
*/
static void Com_EditDecls_f( const idCmdArgs &args ) {
DeclBrowserInit( NULL );
static void Com_EditAFs_f( const idCmdArgs &args ) {
// TODO: cvarSystem->SetCVarInteger( "g_editEntityMode", 3 ); ?
#ifndef IMGUI_DISABLE
ImGuiTools::AfEditorInit();
#elif defined(ID_ALLOW_TOOLS)
AFEditorInit( NULL );
#else
common->Warning( "Editors not available because dhewm3 was built without ImGui or MFC Tools" );
#endif
}

/*
==================
Com_EditAFs_f
Com_EditParticles_f
==================
*/
static void Com_EditAFs_f( const idCmdArgs &args ) {
AFEditorInit( NULL );
static void Com_EditParticles_f(const idCmdArgs& args) {
#ifndef IMGUI_DISABLE
ImGuiTools::ParticleEditorInit( NULL );
#elif defined(ID_ALLOW_TOOLS)
ParticleEditorInit(NULL);
#else
common->Warning( "Editors not available because dhewm3 was built without ImGui or MFC Tools" );
#endif
}


#ifdef ID_ALLOW_TOOLS
/*
==================
Com_EditParticles_f
Com_EditSounds_f
==================
*/
static void Com_EditParticles_f( const idCmdArgs &args ) {
ParticleEditorInit( NULL );
static void Com_EditSounds_f( const idCmdArgs &args ) {
SoundEditorInit( NULL );
cvarSystem->SetCVarInteger( "g_editEntityMode", 2 );
}

/*
==================
Com_EditScripts_f
Com_EditDecls_f
==================
*/
static void Com_EditScripts_f( const idCmdArgs &args ) {
ScriptEditorInit( NULL );
static void Com_EditDecls_f( const idCmdArgs &args ) {
DeclBrowserInit( NULL );
}

/*
==================
Com_EditPDAs_f
Com_EditScripts_f
==================
*/
static void Com_EditPDAs_f( const idCmdArgs &args ) {
PDAEditorInit( NULL );
static void Com_EditScripts_f( const idCmdArgs &args ) {
ScriptEditorInit( NULL );
}

#endif // ID_ALLOW_TOOLS

/*
Expand Down Expand Up @@ -2331,17 +2376,17 @@ void idCommonLocal::InitCommands( void ) {
cmdSystem->AddCommand( "roq", RoQFileEncode_f, CMD_FL_TOOL, "encodes a roq file" );
#endif

#ifdef ID_ALLOW_TOOLS
// editors
cmdSystem->AddCommand( "editor", Com_Editor_f, CMD_FL_TOOL, "launches the level editor Radiant" );
cmdSystem->AddCommand( "editLights", Com_EditLights_f, CMD_FL_TOOL, "launches the in-game Light Editor" );
cmdSystem->AddCommand( "editPDAs", Com_EditPDAs_f, CMD_FL_TOOL, "launches the in-game PDA Editor" );
cmdSystem->AddCommand( "editAFs", Com_EditAFs_f, CMD_FL_TOOL, "launches the in-game Articulated Figure Editor" );
#ifdef ID_ALLOW_TOOLS
cmdSystem->AddCommand( "editor", Com_Editor_f, CMD_FL_TOOL, "launches the level editor Radiant" );
cmdSystem->AddCommand( "editSounds", Com_EditSounds_f, CMD_FL_TOOL, "launches the in-game Sound Editor" );
cmdSystem->AddCommand( "editDecls", Com_EditDecls_f, CMD_FL_TOOL, "launches the in-game Declaration Editor" );
cmdSystem->AddCommand( "editAFs", Com_EditAFs_f, CMD_FL_TOOL, "launches the in-game Articulated Figure Editor" );
cmdSystem->AddCommand( "editParticles", Com_EditParticles_f, CMD_FL_TOOL, "launches the in-game Particle Editor" );
cmdSystem->AddCommand( "editScripts", Com_EditScripts_f, CMD_FL_TOOL, "launches the in-game Script Editor" );
cmdSystem->AddCommand( "editGUIs", Com_EditGUIs_f, CMD_FL_TOOL, "launches the GUI Editor" );
cmdSystem->AddCommand( "editPDAs", Com_EditPDAs_f, CMD_FL_TOOL, "launches the in-game PDA Editor" );
cmdSystem->AddCommand( "debugger", Com_ScriptDebugger_f, CMD_FL_TOOL, "launches the Script Debugger" );

//BSM Nerve: Add support for the material editor
Expand Down
6 changes: 6 additions & 0 deletions neo/framework/Dhewm3SettingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2337,6 +2337,12 @@ static void DrawOtherOptionsMenu()
if ( ImGui::Button("Reset") ) {
D3::ImGuiHooks::SetScale( -1.0f );
}
ImGuiIO& io = ImGui::GetIO();
ImGui::CheckboxFlags( "Enable multiple ImGui Viewports", &io.ConfigFlags, ImGuiConfigFlags_ViewportsEnable );
AddDescrTooltip( "Allows dragging ImGui windows out of the main dhewm3 window. Might not work (well) on all platforms or window managers" );

ImGui::CheckboxFlags( "Enable ImGui Docking support", &io.ConfigFlags, ImGuiConfigFlags_DockingEnable );
AddDescrTooltip( "Allows docking ImGui windows to each other (or the edge of real windows, if dhewm3 enables it, which it currently does not, but might for tools..)" );

int style_idx = imgui_style.GetInteger();
if ( ImGui::Combo( "ImGui Style", &style_idx, "dhewm3\0ImGui Default\0Userstyle\0") )
Expand Down
1 change: 1 addition & 0 deletions neo/idlib/Str.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ If you have questions concerning this license or the applicable additional terms
#ifndef __STR_H__
#define __STR_H__

#include "sys/platform.h" // ID_INLINE
#include "idlib/CmdArgs.h"

/*
Expand Down
3 changes: 3 additions & 0 deletions neo/libs/imgui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ examples/example_sdl2_opengl3/web/*
.idea
cmake-build-*

## VS code artifacts
.vscode

## Unix executables from our example Makefiles
examples/example_glfw_metal/example_glfw_metal
examples/example_glfw_opengl2/example_glfw_opengl2
Expand Down
3 changes: 2 additions & 1 deletion neo/libs/imgui/backends/imgui_impl_allegro5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
// [X] Platform: Clipboard support (from Allegro 5.1.12).
// [X] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'.
// Missing features or Issues:
// [ ] Renderer: The renderer is suboptimal as we need to convert vertices manually.
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
// [ ] Platform: Missing gamepad support.
// [ ] Renderer: Multi-viewport support (multiple windows).

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand Down
1 change: 1 addition & 0 deletions neo/libs/imgui/backends/imgui_impl_allegro5.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// Missing features or Issues:
// [ ] Renderer: The renderer is suboptimal as we need to unindex our buffers and convert vertices manually.
// [ ] Platform: Missing gamepad support.
// [ ] Renderer: Multi-viewport support (multiple windows).

// You can use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this.
// Prefer including the entire imgui/ repository into your project (either as a copy or as a submodule), and only build the backends you need.
Expand Down
1 change: 1 addition & 0 deletions neo/libs/imgui/backends/imgui_impl_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// [ ] Platform: Clipboard support.
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [ ] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
// Important:
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
Expand Down
1 change: 1 addition & 0 deletions neo/libs/imgui/backends/imgui_impl_android.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// [ ] Platform: Clipboard support.
// [ ] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'.
// [ ] Platform: Mouse cursor shape and visibility (ImGuiBackendFlags_HasMouseCursors). Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: Check if this is even possible with Android.
// [ ] Platform: Multi-viewport support (multiple windows). Not meaningful on Android.
// Important:
// - Consider using SDL or GLFW backend on Android, which will be more full-featured than this.
// - FIXME: On-screen keyboard currently needs to be enabled by the application (see examples/ and issue #3446)
Expand Down
Loading
Loading