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

QtFRED campaign editor #3392

Merged
merged 87 commits into from
Mar 15, 2023
Merged

Conversation

the-maddin
Copy link
Contributor

@the-maddin the-maddin commented Apr 19, 2021

First steps to implement #1693
Currently implemented as viewer-only of campaign files.

Lacks ability to add and properly modify branches, a campaign tree view, and saving of edits.
It also says so in a warning dialog on launch. I'd like to get it merged in this stage to get some feedback,
because I've done some things differently than they were done in FRED.

I'm making some changes to other parts of the code: Campaign names get stored with full paths,
so I can open campaign files with the qt filechooser everywhere, qtfred loads subsystems mainhalls,
cutscenes, and ranks to populate default campaign options, clang fixes in main.cpp and some changes
to my checked data list model.

@the-maddin the-maddin force-pushed the qt-campaign-editor branch from 3814f35 to 53e30ba Compare May 5, 2021 22:01
@the-maddin the-maddin marked this pull request as ready for review May 6, 2021 00:12
@JohnAFernandez JohnAFernandez added the qtfred A feature or issue related to qtFred. label May 24, 2021
so qtfred can load them fro outside the cfile tree.
(cherry picked from commit 0ed5a18)
Make necessary changes and improvements
in model usage.
Unlike FRED, I'm using a checked list of all
missions, not a simple list of the unused ones.
I'm showing uneditable / packaged missions
in yellow, missing / unloadable missions in red.
Also keeping missions loaded.
Since the campaign type determines the compatible
missions, changing it would require invalidating
the mission list. So I'm restricting it to being
set on campaign creation.
(cherry picked from commit 9959cda)
because it won't be shown for re-selection after
next load of campaign
according to first mission.
editable cmission data

Also make CheckedDataList construction translator
callbacks explicitly const.
@Goober5000
Copy link
Contributor

@the-maddin Can you incorporate the bugfix in #4341 into this PR?

@the-maddin
Copy link
Contributor Author

I didn't implement an error checker, so this fix does not apply. I'm using the in-game parsing functions as far as possible, so the bug did not appear. My UI is hopefully somewhat stricter than FRED in preventing invalid data.

@Goober5000
Copy link
Contributor

The dialog should still have an error checker. There are actions the FREDder could take, such as setting the middle campaign branch to true, that are perfectly valid from a UI sense but still errors from a design sense. And others, like the internal_error lines in the original FRED dialog, are good defensive checks.

@the-maddin
Copy link
Contributor Author

I'm doing this particular check when saving the campaign. I'll take another look at FRED's implementation of the error checker, but I do believe that error checking should not be different from saving a copy.
True branch in the middle is indeed hard to check for during editing, but I consider it undesirable for the UI to accept this kind of semantic error, so I will prefer making the checks when editing.

@the-maddin
Copy link
Contributor Author

@Goober5000 I've itemized the error checks in comments. Now tagged with the same numbers, I've expanded my "live" input validation to prevent the user from giving these kinds of bad input. It should be rather easy now to verify this simply by searching for a check number.
Only in a few cases I'm running checks on saving, which result in warning/message dialogs. As I've added an option to save a copy, I believe this is sufficient. A "dry run" saving code path would also be possible, but, I believe, less useful than a copy for testing or manual proofreading.

@the-maddin
Copy link
Contributor Author

Having resolved resolved previous change requests as far as I'm currently able to, I'd like to re-request reviews.

@the-maddin the-maddin requested review from z64555 and jg18 June 24, 2022 22:34
@jg18
Copy link
Member

jg18 commented Jun 27, 2022

@the-maddin thanks for the updates!

Assuming that you've tested the functionality your PR adds, then I'm good with the PR whenever @z64555 is.

Note that, per the 22.2 RC cycle's feature freeze, even once the PR is approved, merging will need to wait until after 22.2 becomes Final.

Thanks again for taking the time to make this.

qtfred/src/CheckedDataListModel.h Show resolved Hide resolved
void connect(const SCP_unordered_set<const CampaignMissionData*>& missions);

// constants
enum BranchType { INVALID, REPEAT, NEXT, NEXT_NOT_FOUND, END, };
Copy link
Member

Choose a reason for hiding this comment

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

What namespaces do the enumerations show up with? (INVALID, REPEAT, NEXT, etc.)

@Goober5000
Copy link
Contributor

@the-maddin It looks like there are a few unaddressed comments from jg18 and z64555. Could you take another look at this?

@the-maddin
Copy link
Contributor Author

AFAIK, jg18 is ok with the current state of the PR.
As for @z64555 's last unresolved comment, which I seem to have overlooked, the enum variants are used only within the CampaignEditorModel, as CampaignBranchData::VARIANT. I'm adding some comments to clarify their use.

@z64555
Copy link
Member

z64555 commented Feb 22, 2023

Since its been a few months I forget what exactly I was trying to hint at with the namespace question, maybe I was trying to push you towards using enum class since plain enum's are interpreted as a const int

@the-maddin
Copy link
Contributor Author

This enum is nested two classes deep, and private to the outer class, so I never felt it was worth the effort to add another namespace for type safety. It only ever gets used in the most straightforward way of indicating an object's state.

@z64555
Copy link
Member

z64555 commented Mar 3, 2023

Yeah uhm, The enum's don't actually get scoped regardless of what class they may be buried in. Each of the enum's defined values are effectively the same as const ints in the namespace that the enum was declared in.

You must either use a namespace bracket to scope them, or use enum class for the enum's values to ensure they will not collide with another enumeration, constant, or #define. Another old scheme to "scope" the enumeration is to add the name of the enum as a prefix to each value, such as "BRANCHTYPE_INVALID," but that gets old fast.

Possibly the least-effort fix here is to just put in enum class instead of just enum.

@the-maddin
Copy link
Contributor Author

Declaring the enum inside a class has exactly the same effect as declaring it inside a namespace. Outside the inner class BranchData, the variants are used with that namespace, BranchData::VARIANT. Outside the outer class CampaignMissionData, they are not visible, as the namespace BranchData is private to that outer class.

When used inside BranchData, they shadow any global constant or enum variant, making a qualifier in that specific place unnecessary.

@z64555
Copy link
Member

z64555 commented Mar 11, 2023

All right, either I'm remembering an ancient bug that's been addressed last century or misremembering how enum's scope.

@Goober5000
Copy link
Contributor

If @jg18 is ok with the current state of the PR, as mentioned in a comment above, then we can merge this.

@Goober5000 Goober5000 dismissed jg18’s stale review March 14, 2023 15:25

Per comment above, jg18 is ok with the PR

@Goober5000 Goober5000 merged commit 75a1462 into scp-fs2open:master Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
qtfred A feature or issue related to qtFred. required feature A PR that provides required functionality for an app in development. (not fix or enhancement)
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants