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

Conversation

ashalkhakov
Copy link

@ashalkhakov ashalkhakov commented Jan 31, 2025

This adds editors ported from MFC and builds on top of imgui-docking.

Currently ported tools:

  • PDA editor

image

DanielGibson and others added 9 commits January 29, 2025 18:34
incl. dhewm3-specific adjustments to imgui_impl_opengl2.cpp
(two additional qgl #defines)
c2dcc80 Docking: fixed ImGuiWindowFlags_DockNodeHost /
  ImGuiWindowFlags_NavFlattened clash introduced by c38c18c
  just for 1.91.7 (#8357)

1.91.7-docking crashed when opening the dhewm3 settings window,
now this issue is fixed upstream so upgrade to the latest code.
using commit 719e925b2eabeef "Started to simplify the light editor"
(afterwards they started integrating ImGuizmo, let's do that later
 once things work...)

compiles (without AfEditor), but not functional yet
seems to work!
at least as long as the MFC tools are disabled
unless ImGui is disabled, then use the MFC one, unless that's also
disabled, then just print a warning
shows a little grey overlay window with given text in the upper left
corner of the window
- functionality is the same as the old dialog (video/audio editing does not work)
@DanielGibson
Copy link
Member

DanielGibson commented Jan 31, 2025

Thank you very much! The screenshot looks pretty good :)

I'll look at the code later; are the questions from #647 (comment) regarding modal dialogs and layout still open or have you figured that out already?
Modals should be pretty easy (ImGui::BeginPopupModal()), for layout I'd have to figure that out myself, depending on what you want to do. Is it about having basically three columns and have that scale when resizing the window?

@ashalkhakov
Copy link
Author

I'll look at the code later; are the questions from #647 (comment) regarding modal dialogs and layout still open or have you figured that out already? Modals should be pretty easy (ImGui::BeginPopupModal()), for layout I'd have to figure that out myself, depending on what you want to do. Is it about having basically three columns and have that scale when resizing the window?

I think I figured modals out. The code:

	CDialogPDAAdd dlg;
	if ( dlg.DoModal() == IDOK ) {
/* modal dialog accepted */
	}

translates to the opening of the dialog:

	addPDADlg.Reset();
	ImGui::OpenPopup( "PDAAdd" );

and it's drawing & output handling routine:

		if ( ImGui::BeginPopupModal( "PDAAdd", nullptr, ImGuiWindowFlags_AlwaysAutoResize ) ) {
			bool accepted = addPDADlg.Draw();

			if ( accepted ) {
/* modal dialog accepted */
			}

			ImGui::EndPopup();
		}

for layout I'd have to figure that out myself, depending on what you want to do. Is it about having basically three columns and have that scale when resizing the window?

Yes, I wanted to have a 3-column layout like in the original MFC dialog and have it scale or change according to the available space. For this dialog, I think the fixed layout will suffice, for other dialogs we may have to get creative.

There is also the issue that the window position is reset when PDA is selected.

@DanielGibson
Copy link
Member

Ok, I'll have a look!

By the way, did you check out the ImGui Demo (open Dhewm3Settings menu with F10 -> Other Options -> [Show ImGui Demo])?
Maybe it could somehow be done with groups (Layout & Scrolling -> Groups) and/or Tables (Tables & Columns -> Resizable, stretch)?

@ashalkhakov
Copy link
Author

Ok, I'll have a look!

By the way, did you check out the ImGui Demo (open Dhewm3Settings menu with F10 -> Other Options -> [Show ImGui Demo])? Maybe it could somehow be done with groups (Layout & Scrolling -> Groups) and/or Tables (Tables & Columns -> Resizable, stretch)?

Thank you, I'll check it out!

Artyom Shalkhakov added 2 commits January 31, 2025 10:46
- the name of the window passed to ImGui must be stable
@ashalkhakov
Copy link
Author

@DanielGibson Table layout works nicely! Also, fixed the reappearing window bug: the name of the window passed to ImGui must be stable.

image

@DanielGibson
Copy link
Member

DanielGibson commented Jan 31, 2025

That's awesome!

Regarding the stable title: You can use "Whatever changing text###PDA Editor" as title (or generally as name in ImGui widgets) - then only "PDA Editor" (or its hash) is used as identifier and only "Whatever changing text" is displayed.

Simlarly, you could use for example "Add...##Email" and "Add...##video" (this time 2 # instead of 3) - then the ID is calculated from the whole string, but still only "Add..." is displayed. But of course pushing IDs around them is also a solution for that.

@DanielGibson
Copy link
Member

I know this was already the case in the original PDA editor, but I wonder why the buttons in the left pane use "Add" and "Del" while the others use "Add..." and "Delete..."

Also, I just tried that "Add" (PDA) button and it asked me for a name and I entered it and clicked ok, but the modal didn't close (neither when clicking cancel or pressing escape or anything else). The .pda file was written, though.

A problem with the ImGui-based ingame editors is that when clicking
into the game window the cursor is grabbed by the game again (because
then the ImGui window doesn't have focus anymore) and it's hard to get
it back.
I feel like the ingame editor integration could overall be better, maybe
with a command to launch a menu that allows launching and editor; that
command could also free the mousecursor?
except for the ones that already were in the ImGui namespace
@DanielGibson
Copy link
Member

In https://github.com/DanielGibson/dhewm3/tree/imgui-tools I have (based on your branch) integrated the AfEditor and also modified Com_EditPDAs_f() in the way I suggested above

}

void PDAEditor::OnBtnClickedPDADel()
{
Copy link
Member

Choose a reason for hiding this comment

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

maybe this could be implemented like

idStr fileName = "newpdas/";
fileName += pdaName; // TODO
fileName += ".pda";
fileSystem->RemoveFile( fileName );

@ashalkhakov
Copy link
Author

I know this was already the case in the original PDA editor, but I wonder why the buttons in the left pane use "Add" and "Del" while the others use "Add..." and "Delete..."

I just tried to implement deletion, cannot get it to work. The Decl manager keeps a copy of PDA decl in memory, so even if the file is deleted, it will still get re-created.

Also, I just tried that "Add" (PDA) button and it asked me for a name and I entered it and clicked ok, but the modal didn't close (neither when clicking cancel or pressing escape or anything else). The .pda file was written, though.

Fixed that. I'll add the missing dialogs for audio & video and include this fix.

@DanielGibson
Copy link
Member

The Decl manager keeps a copy of PDA decl in memory, so even if the file is deleted, it will still get re-created.

Interesting. Looks like the idDeclManager doesn't support removing decls at all - that's weird.
I guess the Delete button has to remain a dummy then, for now (or maybe even comment it out, what's the point in buttons that don't do anything...)

@ashalkhakov
Copy link
Author

@DanielGibson Should I do a PR to your branch or to the main repo? (I've just updated imgui-tools on my fork.)

@DanielGibson
Copy link
Member

You could update your tools-porting branch with my changes (either merge or rebase, I don't care) and continue to work on that. I don't think we need a new PR for them, let's just keep this here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants