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

Build internal level editor #397

Merged
merged 7 commits into from
Jun 14, 2024
Merged

Build internal level editor #397

merged 7 commits into from
Jun 14, 2024

Conversation

Lgt2x
Copy link
Member

@Lgt2x Lgt2x commented May 27, 2024

Pull Request Type

  • GitHub Workflow changes
  • Documentation or Wiki changes
  • Build and Dependency changes
  • Runtime changes
    • Render changes
    • Audio changes
    • Input changes
    • Network changes
    • Other changes

Description

Minimal modifications to get the internal D3 editor to build (Windows only), based on @jmarshall23 's work.

@Lgt2x Lgt2x force-pushed the d3-editor branch 2 times, most recently from 31cd789 to b2f5694 Compare May 27, 2024 20:41
@GravisZro
Copy link
Contributor

It looks like you need to add #include "pserror.h" in editor\d3edit.h

@GravisZro
Copy link
Contributor

Also, if you could review my various small PRs, that would be great.

const char *Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"};
const char *Anim_state_names[] = {"Alert",
extern char *Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"};
extern char *Anim_state_names[] = {"Alert",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The proper type is const char* const but this could totally be made into a std::array of std::string_views. Use of the extern keyword here is invalid as extern indicates the symbol is declared elsewhere.

Copy link
Member Author

@Lgt2x Lgt2x Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified the qualifier. For the sake of pushing minimal changes for the editor in this PR I did not convert to std::array, but it's a good future improvement

@GravisZro
Copy link
Contributor

A bunch of missing files that you will need are located over in: https://github.com/DescentDevelopers/D3Edit

@GravisZro
Copy link
Contributor

I'm not sure why people are bent on having an in-game editor but when going this route it would be best to use https://github.com/ocornut/imgui/ to make the actual tool windows. Frankly, I think it would be far better and easier to simply port the existing editor to Qt which works on all platforms.

@Lgt2x
Copy link
Member Author

Lgt2x commented May 29, 2024

It looks like you need to add #include "pserror.h" in editor\d3edit.h

Yeah I have some small fixes locally that I have yet to push to fix the remaining builds. This should be still marked as "draft".

Also, if you could review my various small PRs, that would be great.

Sure, that's in my task queue, I'm struggling to get much free time (with an online connection) this week, sorry about that. I'll make sure that you don't get a ton of merge conflicts this time.

A bunch of missing files that you will need are located over in: https://github.com/DescentDevelopers/D3Edit

Thanks, for now it is just a matter of getting the editor to build to unlock modifications of the Dallas-related files (#346, #347), I'll see afterwards for getting it to run properly

I'm not sure why people are bent on having an in-game editor but when going this route it would be best to use https://github.com/ocornut/imgui/ to make the actual tool windows. Frankly, I think it would be far better and easier to simply port the existing editor to Qt which works on all platforms.

I agree that Qt is the way to go to get cross-platform support of D3Edit, I have familiarity with the framework so it should not be too hard if we ever want to do that. Meanwhile I think we should still try reviving the internal editor and provide an option to compile it, at least for historical purposes. It's not a problem if we ever need to drop it.

Thanks for your feedback!

@Lgt2x Lgt2x marked this pull request as draft May 29, 2024 07:01
@GravisZro
Copy link
Contributor

After a bit of checking, the non-"new editor" appears to have functions missing that were undoubtedly discarded when moving to make the "new editor".

@bryanperris
Copy link
Contributor

I think the in-game editor would be useful for allowing you mess with D3 like its a sandbox. Yes, I am too on board for the modern dear imgui to be used for the in-game editor UI.

For example, a highly sophisticated one: https://www.cryengine.com/features/view/sandbox

@winterheart
Copy link
Collaborator

There DXX-Rebirth Editor exists (very impressive applications based on imgui framework), which can generate D2 compatible levels that can be loaded by D3Editor (our legacy editor, I believe) for additional polishing. Perhaps we can contribute to DXX-R with D3 map support or fork DXX-R editor and adapt it for our needs.

Still, we need working legacy editor to figure out what is miss or what we need to implement.

@bryanperris
Copy link
Contributor

There DXX-Rebirth Editor exists (very impressive applications based on imgui framework), which can generate D2 compatible levels that can be loaded by D3Editor (our legacy editor, I believe) for additional polishing. Perhaps we can contribute to DXX-R with D3 map support or fork DXX-R editor and adapt it for our needs.

Still, we need working legacy editor to figure out what is miss or what we need to implement.

D3 maps are radically different from D1/D2 maps.

@Lgt2x Lgt2x force-pushed the d3-editor branch 2 times, most recently from 418e9d3 to 03e5663 Compare June 5, 2024 20:01
@GravisZro
Copy link
Contributor

@Lgt2x the ; at the end of #define In_editor_mode 0; isn't doing the build any favors. :)

@Lgt2x
Copy link
Member Author

Lgt2x commented Jun 7, 2024

The code is a mess but CI builds are all green, will revisit to clean up

Copy link
Member Author

@Lgt2x Lgt2x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now ready for review for anyone interested. To sum up the changes made to get the editor to compile:

  • un-const some functions that edit strings
  • fix struct definitions
  • added a 64bit compatibility layer for incompatible MFC defines
  • disabled code paths that are missing some functions defined in missing files (may be enabled later if we can match with D3Edit)
  • StdAfx.h fixes inspired by jmarshall's
  • backport of some fixes made in the rest of D3 code
  • make the editor use some Debug code paths, because in many places it supposes that it has been compiled in Debug mode. Maybe Release mode was never intended for the editor

const char *Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"};
const char *Anim_state_names[] = {"Alert",
extern char *Movement_class_names[] = {"Standing", "Flying", "Rolling", "Walking", "Jumping"};
extern char *Anim_state_names[] = {"Alert",
Copy link
Member Author

@Lgt2x Lgt2x Jun 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified the qualifier. For the sake of pushing minimal changes for the editor in this PR I did not convert to std::array, but it's a good future improvement

)

set(SOURCE
../descent3/aiambient.cpp
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a very ideal or optimized solution because many source files need to be build twice. In many cases, the EDITOR define changes compilation units. I have not found a better solution so far that does not involve heavy changes to the D3 module system, I'd say we can keep it this way until the editor is in a less "experimental" state

@Lgt2x Lgt2x marked this pull request as ready for review June 9, 2024 18:15
@JeodC
Copy link
Collaborator

JeodC commented Jun 9, 2024

As expected, x64 throws an error for dinput.
Screenshot 2024-06-09 160235

The x86 build runs, but the mouse cursor becomes invisible and it becomes almost impossible to exit the application. There is a mouse mode selection in init.cpp which seems to be the problem--the debug build's editor works fine.

Previously, in release builds, mouse exclusive mode was the default since -windowed was disabled for release. With the advent of the editor, this block needs tweaking again. Simply removing the preprocessor definitions should suffice, but that will reintroduce the issue that caused them to be placed: hardware cursor visibility in fullscreen mode in release builds.

@Lgt2x
Copy link
Member Author

Lgt2x commented Jun 9, 2024

Thanks for testing! This PR only aims to fix the build, I did not even expect the editor to start without crashing. Don't hesitate to file an issue about the cursor problem, it looks like an easy enough fix. The editor was supposed to never be built in release mode when you look at the code, I'm not surprised it has runtime problems

@JeodC
Copy link
Collaborator

JeodC commented Jun 9, 2024

It would just reopen #363.

@GravisZro
Copy link
Contributor

@Lgt2x I'm working on a parser for the "Resource-Definition File" format which is the editor.rc file that defines the GUI layout. Would you be interested in hooking up generated "Dear ImGui" code if I make it? This would make the editor usable on all platforms. The only other robust/well supported alternative I can think of is Qt and that has a lot of dependencies.

Copy link
Collaborator

@Arcnor Arcnor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done a first pass, but there is a ton of code removed, and I'm not sure if it's needed or not.

Descent3/Briefing.cpp Outdated Show resolved Hide resolved
Descent3/room.h Outdated Show resolved Hide resolved
editor/D3XStringEditor.cpp Show resolved Hide resolved
editor/MainFrm.cpp Show resolved Hide resolved
editor/ScriptLevelInterface.cpp Show resolved Hide resolved
editor/WorldTexturesDialog.cpp Show resolved Hide resolved
editor/WorldObjectsRobotDialog.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like a few other files, this whole file is full of removed code, is the editor still working with all of this removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this first PR is about building it, runtime correctness will come later. These deactivated parts don't seem necessary, Justin's fork disabled them as well

editor/StdAfx.h Show resolved Hide resolved
editor/ScriptWizard.cpp Outdated Show resolved Hide resolved
@bryanperris
Copy link
Contributor

@Lgt2x I'm working on a parser for the "Resource-Definition File" format which is the editor.rc file that defines the GUI layout. Would you be interested in hooking up generated "Dear ImGui" code if I make it? This would make the editor usable on all platforms. The only other robust/well supported alternative I can think of is Qt and that has a lot of dependencies.

It is not worth the time to be trying to parse .rc files (https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files?redirectedfrom=MSDN) and trying generate imgui from it, that is a whole long-term project itself.

I recommend writing a simple imgui C++ app, and begin to mimic the d3 editor UI by hand, mostly its just buttons and list views, besides the 3D viewer of the map, look at the inferno project (https://github.com/nbayazes/Inferno).

RC scripts are compiled into something else, and they can involve preprocessing directives. You aren't going to understand the exact layout without emulating the entire GDI+ system. Who even knows what hacky things has been put into the RC compiler from Microsoft over a decade. I have no doubt it took the wine team to reach a stable GDI emulated system after like 17 years. I know that the RC files are generated by Visual Studio's drag and drop based GUI designer.

Copy link
Member Author

@Lgt2x Lgt2x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arcnor thanks for the review, I fixed or commented back on your comments, feel free to merge if it looks good enough

Descent3/Briefing.cpp Outdated Show resolved Hide resolved
Descent3/room.h Outdated Show resolved Hide resolved
editor/D3XStringEditor.cpp Show resolved Hide resolved
editor/ScriptLevelInterface.cpp Show resolved Hide resolved
editor/ScriptWizard.cpp Outdated Show resolved Hide resolved
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this first PR is about building it, runtime correctness will come later. These deactivated parts don't seem necessary, Justin's fork disabled them as well

editor/WorldTexturesDialog.cpp Show resolved Hide resolved
netgames/dmfc/dmfccfg.cpp Outdated Show resolved Hide resolved
@Lgt2x
Copy link
Member Author

Lgt2x commented Jun 10, 2024

@Lgt2x I'm working on a parser for the "Resource-Definition File" format which is the editor.rc file that defines the GUI layout. Would you be interested in hooking up generated "Dear ImGui" code if I make it? This would make the editor usable on all platforms. The only other robust/well supported alternative I can think of is Qt and that has a lot of dependencies.

It is not worth the time to be trying to parse .rc files (https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files?redirectedfrom=MSDN) and trying generate imgui from it, that is a whole long-term project itself.

I recommend writing a simple imgui C++ app, and begin to mimic the d3 editor UI by hand, mostly its just buttons and list views, besides the 3D viewer of the map, look at the inferno project (https://github.com/nbayazes/Inferno).

RC scripts are compiled into something else, and they can involve preprocessing directives. You aren't going to understand the exact layout without emulating the entire GDI+ system. Who even knows what hacky things has been put into the RC compiler from Microsoft over a decade. I have no doubt it took the wine team to reach a stable GDI emulated system after like 17 years. I know that the RC files are generated by Visual Studio's drag and drop based GUI designer.

It also looks like a big effort to me as well that may or may not be worth it in the end. You can make a proof of concept if you want to gauge the task and get community feedback first, to see if we want to pursue this further

@GravisZro
Copy link
Contributor

GravisZro commented Jun 11, 2024

It is not worth the time to be trying to parse .rc files (https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files?redirectedfrom=MSDN) and trying generate imgui from it, that is a whole long-term project itself.

Not really because I've done XSL parsing before and .rc files are simplistic by comparison.

It also looks like a big effort to me as well that may or may not be worth it in the end. You can make a proof of concept if you want to gauge the task and get community feedback first, to see if we want to pursue this further

Well since it's generated, it's really an all or nothing proposition but I suppose I'll post something. The hard part in this is learning the imgui API since it's so poorly documented. Qt would be a super easy port, so I might do that first.

@Arcnor Arcnor merged commit 9e93fc3 into DescentDevelopers:main Jun 14, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants