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

Allow to set custom feature tags for testing #63529

Merged
merged 1 commit into from
Feb 13, 2024

Conversation

KoBeWi
Copy link
Member

@KoBeWi KoBeWi commented Jul 27, 2022

Closes godotengine/godot-proposals#373

Added a dialog under "Project -> Tools -> Custom Feature Tags..." that allows to specify custom feature tags when running the project. The are read during Project Settings initialization (passed via __GODOT_EDITOR_CUSTOM_FEATURES__ environment variable), so they also affect project setting feature overrides.

godot.windows.tools.64_cInpHtDNT0.mp4

EDIT:
New look:
image

Production edit: closes godotengine/godot-roadmap#18

@KoBeWi KoBeWi added feature proposal topic:editor cherrypick:3.x Considered for cherry-picking into a future 3.x release labels Jul 27, 2022
@KoBeWi KoBeWi added this to the 4.0 milestone Jul 27, 2022
@KoBeWi KoBeWi requested a review from a team as a code owner July 27, 2022 11:35
@KoBeWi KoBeWi force-pushed the fake_features_v2 branch from 7b2827a to eab9bc1 Compare July 27, 2022 11:44
@akien-mga
Copy link
Member

I think this kind of feature would be nice to have exposed together with the dialog I propose here to configure run options and number of instances: godotengine/godot-proposals#522 (comment)

There could be an additional text field for each instance to configure custom feature tags (so you can also test e.g. how demo and full clients could play together in a multiplayer game, or test steam and eos variants at once, etc.).

@rsubtil
Copy link
Contributor

rsubtil commented Mar 25, 2023

Would this also work when exporting projects through the command line for CI environments? Something like this?
__EDITOR_CUSTOM_FEATURES__=feature1,feature2 godot --export ...

@Calinou
Copy link
Member

Calinou commented Mar 25, 2023

Would this also work when exporting projects through the command line for CI environments? Something like this? __EDITOR_CUSTOM_FEATURES__=feature1,feature2 godot --export ...

It should work, but that reminds me…

The environment variable's naming should be changed to match Godot conventions. Specifically, all environment variables should be prefixed with GODOT_ to avoid conflicts with other programs: GODOT_EDITOR_CUSTOM_FEATURES

@KoBeWi KoBeWi force-pushed the fake_features_v2 branch from eab9bc1 to f78c32e Compare March 25, 2023 17:16
@KoBeWi
Copy link
Member Author

KoBeWi commented Mar 25, 2023

Would this also work when exporting projects through the command line for CI environments?

No, it only works when running the project. It does not affect the export.

EDIT:

I think this kind of feature would be nice to have exposed together with the dialog I propose here to configure run options and number of instances

I can change this after #65753 is merged

@KoBeWi KoBeWi force-pushed the fake_features_v2 branch 2 times, most recently from f165f5b to 62b3687 Compare March 26, 2023 20:31
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased against master da81ca6), it works as expected.

I suggest moving this to the Debug menu indeed, as this functionality is not persisted to project.godot.

#ifdef TOOLS_ENABLED
// Available only at runtime in editor builds. Needs to be processed before anything else to work properly.
if (!Engine::get_singleton()->is_editor_hint()) {
String editor_features = OS::get_singleton()->get_environment("__GODOT_EDITOR_CUSTOM_FEATURES__");
Copy link
Member

@Calinou Calinou Jul 28, 2023

Choose a reason for hiding this comment

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

Is there a reason the environment variable is surrounded by 2 underscores? I think the EDITOR makes it clear that it'll only work in editor builds. This feature should be able to work when running a project from the command line when using an editor build after all.

For comparison, other environment variables used by Godot aren't surrounded by underscores.

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 is to signify that this variable is internal. Another example:

OS::get_singleton()->set_environment("__GODOT_EDITOR_STOP_SHORTCUT__", shortcut);

Although maybe using it from command line makes sense.

@adamscott
Copy link
Member

adamscott commented Feb 5, 2024

I would put this dialog inside the editor settings, as a simple entry. I don't feel it needs to have a new menu entry.

@Calinou
Copy link
Member

Calinou commented Feb 5, 2024

I would put this dialog inside the editor settings, as a simple entry. I don't feel it needs to have a new menu entry.

Setting feature tags for testing is specific to a project, rather than something you enable for all projects in your editor instance.

Maybe we should merge this dialog together with the one that lets you customize command line arguments for each instance?

@akien-mga
Copy link
Member

I think this kind of feature would be nice to have exposed together with the dialog I propose here to configure run options and number of instances

I can change this after #65753 is merged

This can be worked on now. Feel free to involve other folks in the UI concept if you're unsure about how to feature everything in that dialog.

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 8, 2024

I'm reworking it right now. Here's my idea for the unified instance list:
image

@akien-mga
Copy link
Member

akien-mga commented Feb 8, 2024

I'm wondering if this wouldn't work better with a table like we have for Autoloads, etc.

Instance Launch Arguments Override Main Run Args Feature Tags Override Main Tags
1 --yolo [x] blue, red, green [ ]
2 [ ] demo [x]
3 "res://my_test_scene.tscn" --verbose [x] [ ]

The main challenge may be for the "Override ..." columns not to take too much space so there's still enough for the actually args and feature tags. Maybe the column names can be wrapped on two lines.

Edit: Seems possible to wrap long column names for columns meant to be small, we do it for Autoloads "Global Variable":

image

Edit 2: And possibly it could use the same kind of widget we have in the inspector to add/remove elements to arrays/dictionaries... but I guess those are completely different types of controls so it might requirement significant rework which is maybe not worth it.

image

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 8, 2024

Ok pushed the design I showed above, I'll try to change it to table.

EDIT:
Still not changed, I was just fixing CI.

@KoBeWi KoBeWi force-pushed the fake_features_v2 branch 2 times, most recently from cb449b2 to 5dd6941 Compare February 8, 2024 22:54
@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 9, 2024

Here's the dialog with table:
image
It's more compact (at least vertically), but it lost tooltips for overrides.

Should I push this version?

@Calinou
Copy link
Member

Calinou commented Feb 9, 2024

It's more compact (at least vertically), but it lost tooltips for overrides.

It looks pretty good 🙂

I'm wondering if this table could have alternating row colors, by the way. This would help improve readability of long rows, but I don't remember if we have support for that in Tree.

Should I push this version?

Yes – if in doubt, push it as a separate commit and squash it later.

@akien-mga
Copy link
Member

That looks pretty good to me!

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Feb 9, 2024
@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 9, 2024

Pushed the new design. Old code is in 5dd6941

@KoBeWi KoBeWi force-pushed the fake_features_v2 branch 2 times, most recently from 7061567 to a720c28 Compare February 9, 2024 17:19
@akien-mga
Copy link
Member

Tested briefly, it seems to work well!

image
image

The original minsize seems to be too small to fit the table initially, it would need some more space:

image


Bunch of ideas for future improvements, but let's maybe wait and see what users request:

  • Some users might want to preserve their config for multiple instances while reducing the amount of instances they're testing now. Currently reducing the count will lose the config for the last instances in the list. There could be a checkbox to enable/disable a specific instance while keeping its config saved.
  • We still don't have a simple way to query all enabled custom feature tags aside from checking each manually with OS.has_feature()?
  • Multiple instances could use a way to be identified visually. We could change the window title (as suggested in Identify debug instances with window title #68054, but this should be redone based on this new dialog, and ideally not affect the single-instance use case), or add another kind of identifier that could be queried from code. We could also envision an editor hotkey (or checkbox in this dialog) that toggles displaying the instance number on each instance. Or many other options, some which may best be explored via plugins until we figure out what makes most sense.

#ifdef TOOLS_ENABLED
// Available only at runtime in editor builds. Needs to be processed before anything else to work properly.
if (!Engine::get_singleton()->is_editor_hint()) {
String editor_features = OS::get_singleton()->get_environment("GODOT_EDITOR_CUSTOM_FEATURES");
Copy link
Member

Choose a reason for hiding this comment

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

For discussion's sake - any particular reason to pass these as an environment variable instead of a new command line argument?

Copy link
Member Author

@KoBeWi KoBeWi Feb 13, 2024

Choose a reason for hiding this comment

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

Not really. Environment variable is easier to access and parse, but it could be a command line argument I guess. I used the same approach as #47744 (though in that PR a variable made more sense, because it was passing event data).

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 13, 2024

We still don't have a simple way to query all enabled custom feature tags aside from checking each manually with OS.has_feature()?

Some features are defined using #ifdef, so they can be only queried.

Multiple instances could use a way to be identified visually.

#34528 would be one idea, but not sure how it would work.

The original minsize seems to be too small to fit the table initially, it would need some more space:

Should I change it now?

@akien-mga
Copy link
Member

The original minsize seems to be too small to fit the table initially, it would need some more space:

Should I change it now?

Yeah that would be good if you know what to change. For the record I'm on a 2K screen with 150% system scaling (and the same configured for Godot scaling).

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 13, 2024

It's this line:

set_min_size(Size2i(1200, 500) * EDSCALE);

Though not sure what value I should use. I didn't observe this problem on my side.

@KoBeWi
Copy link
Member Author

KoBeWi commented Feb 13, 2024

Increased height to 600.
I also changed how dialog size is determined (it's set during popup instead of minimum size, so you can shrink it now).

@akien-mga akien-mga merged commit ab54569 into godotengine:master Feb 13, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

@KoBeWi KoBeWi deleted the fake_features_v2 branch February 13, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherrypick:3.x Considered for cherry-picking into a future 3.x release enhancement topic:editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add function to emulate features when playing the game from Editor
6 participants