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

Add a default main.tscn to a new project #2792

Closed
Tracked by #15
boukew99 opened this issue May 27, 2021 · 32 comments
Closed
Tracked by #15

Add a default main.tscn to a new project #2792

boukew99 opened this issue May 27, 2021 · 32 comments

Comments

@boukew99
Copy link

Describe the project you are working on

A block building builder for the GoGodot game jam.

Describe the problem or limitation you are having in your project

Every time a new project is started a "interrupting" popup appears that says to define a main scene. Not a big deal, but it breaks the flow a bit and I feel like there could be a more elegant solution, that also communicates better what "main" means, as I did not know this for some time.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

godotengine/godot#1134, this is a previous issue about this, which talks about this popup: "The pop up will solve the issue of a new user having to search for "Project Settings" and the main_scene setting.".

Proposal: Add a default Main.tscn to the project, which the ProjectSettings automatically sets as the main_scene, just like icon.png. Then you can add your scenes/nodes under main and run it with F5 immediately .

This does not communicate however that the option to change the main scene exist. Therefore, you could add a Node with editor description to Main.tscn explaining what main stands for and that you can change it in ProjectSettings, but I am not really sure about this.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

afbeelding

If this enhancement will not be used often, can it be worked around with a few lines of script?

no, it happens at startup.

Is there a reason why this should be core and not an add-on in the asset library?

no, it happens at startup.

@boukew99 boukew99 changed the title Add a default Main.tscn to the project Add a default Main.tscn to a new project May 27, 2021
@YuriSizov YuriSizov changed the title Add a default Main.tscn to a new project Add a default Main.tscn to a new project May 27, 2021
@YuriSizov
Copy link
Contributor

I don't think it's a good idea. Current behavior highlights a configuration problem that each developer needs to solve as they see fit. Your solution would hide that there is a problem, yet doesn't help inexperienced developers when they create their own scenes, hit "Play" and don't see them, because the empty and untouched default "main" scene was launched.

There is also a question of what that scene would be, what type of node would it have as its root and why.

@boukew99
Copy link
Author

Okay thanks, I see now. Will close this now. BTW tried the highlighting of Tree and it was really nice

@YuriSizov
Copy link
Contributor

Generally there is no need to close your proposals after one disagreeing comment. This is just my opinion 🙂 But if you don't feel like it's worth it anymore, then it's fine to close it.

@boukew99
Copy link
Author

boukew99 commented May 27, 2021

Mmm okay. Felt like I did not really know the size of what I was proposing anymore. But will leave it open a bit longer then and see what other think.

To clarify:
In my understanding main scene was just the entry point. But a tree only has one entry point and that is its root, thus that is what Main.tscn represented for me.
However the actual root is the root viewport though, so that is the actual entry point, however that can't be customized.
So that's why there is your own main scene. I did not take into account that it might be configured in different ways.

Furthermore, a possible main scene could be the root viewport. It will be more transparent about what happens when you run a scene (as can be seen with remote Scenetree).

@boukew99 boukew99 reopened this May 27, 2021
@Calinou
Copy link
Member

Calinou commented May 27, 2021

Furthermore, a possible main scene could be the root viewport. It will be more transparent about what happens when you run a scene (as can be seen with remote Scenetree).

This would require the scene to be added as an autoload for it to work as expected when you use F6 to run a custom scene.

Also, it should be main.tscn instead of Main.tscn to follow the existing naming conventions 🙂

@Xrayez
Copy link
Contributor

Xrayez commented May 27, 2021

I have a script which creates a project from a template containing main.tscn with Node2D as root (because I make 2D projects most of the time), so yeah I highly support the idea behind this proposal, see godot-extended-libraries/godot-ideas#12 which describes the hurdles of creating new projects similarly.

See also related proposals in Speeding up creation of new projects or development workflows section in godot-extended-libraries/godot-ideas#15 (quite a bunch of them so far).

@seocwen
Copy link

seocwen commented May 27, 2021

I always liked having the default main file in XNA, with all its excessive comments, but Godot, is less in need of that sort of mini-tutorial because nodes handle so much functionality. I think the equivalent would be an empty default main.tscn with an attached default main.gd with useful comments, but I struggle to think of what this would be. I wrote down my thoughts from the first time I used Godot:

When I opened Godot for the first time it asked if I wanted to explore available templates, which sounded amazing. I didn’t know I wanted my game engine to introduce itself by showing off its features and offering a foundation to work from, but apparently I did. Then again, GUI Drag and Drop Demo didn’t exactly deliver on those expectations. Was it unreasonable of me to yearn for a template that might serve as a broad tutorial for how the engine worked? Perhaps even a game where the goal was to learn how the game engine itself worked? I’ve never seen such a thing, but opening Godot made me want it.
So, I found the engine’s documentation—the website navigation hides it under the learn tag, which for all knew might have been a page marketing Godot to schools—which I liked. It’s because of the FAQ I decided to write this.

@rainlizard
Copy link

I would like this because it speeds things up. I agree a little with pycbouh, it's good for the new-user to get a grasp on the filesystem and where they're saving their scene. I think that's really user-friendly stuff for new users. The issue here is that while it's good for new users it's rather tedious for the rest of us.

I think project templates need to be better implemented. Local project templates, not these internet templates that take 10 seconds to load, I've never used someone else's template because working with someone else's code in your project is just a huge chore. But I would ALWAYS use small local templates that I made, if I could. For test projects, for new projects, etc. To bring this back to the topic - such a template would allow you to create a simple project with a Main.tscn (in a sub directory if necessary).

You can't just tell me to use templates because this topic is about relieving some tedium and the current implementation of templates is no faster.

@boukew99 boukew99 changed the title Add a default Main.tscn to a new project Add a default main.tscn to a new project May 28, 2021
@dalexeev
Copy link
Member

We can add main.tscn with one "Hello world" label. Just so that you can press Play and the project will start.

@YuriSizov
Copy link
Contributor

I think that just a better way to make personal project templates is the solution here, like @rainlizard mentioned. We can even include an example of such template that would add some default main.tscn. But I still don't think we should change the default behavior.

@Xrayez
Copy link
Contributor

Xrayez commented May 28, 2021

I have created a new repository for this purpose now: https://github.com/godot-extended-libraries/godot-main.

For now it has godot.ahk script which I've been using for quite a while with great success. With it, it just takes a few keystrokes to create, launch and edit a new project, and you're ready to code in literally 5 seconds (Windows only).

Of course, if someone wants to implement other scripts for other platforms, feel welcomed!

@Calinou
Copy link
Member

Calinou commented May 28, 2021

I also have a godot-init script for command line users: https://gist.github.com/Calinou/cd4c67e2a44377c9fb772500daa467f5

It doesn't create a main scene, icon.png and default_env.tres, but this can be done relatively easily.

@dalexeev
Copy link
Member

It seems to me that we are talking about inexperienced users who have just opened Godot. I remember how a few years ago I could not figure out what was needed for 5 minutes:

  1. add a root node (there was a problem here);
  2. save the scene;
  3. press the Play button and select the main scene.

Now point 1 is almost eliminated, thanks to the Root Selection in the Scene panel, but still, the process is not so obvious when you first see it. Yes, this is just a minute delay, but a little help to the user is important at the start.

I think that just a better way to make personal project templates

I also have a godot-init script for command line users

When we talk about newbies, command line and personal project templates won't help. This should be in the default template, and the user can replace the template with the one they want.

@YuriSizov
Copy link
Contributor

YuriSizov commented May 28, 2021

@dalexeev To simplify your step 1 further I've proposed #679 some time ago.

When we talk about newbies, command line and personal project templates won't help. This should be in the default template, and the user can replace the template with the one they want.

Also what I've suggested in my comment there is that we do provide a newbie-friendly template out of the box that they can then quickly use, but we shouldn't change the default behavior because there is no universal solution except for an empty project. If someone wants to customize their personal templates and use them instead they are free to do so. (This btw also helps with the lack of universal addons, as you'd be able to prepack some with your templates).

Otherwise we get into that silly Blender territory, where everyone just deletes the default cube.

@Xrayez
Copy link
Contributor

Xrayez commented May 28, 2021

The way I see this, it could be an option in the project manager:

godot_project_manager_2d_3d

  • Empty: will do nothing (current behavior).
  • 2D: will instantiate Node2D scene and assign it as main one.
  • 3D: will instantiate Spatial/Node3D scene and assign it as main one.

2D projects don't need to instantiate default_environment.tscn, so we can skip generating this resource, which also speeds up project initialization (due to procedural sky which needs to be generated every time).

Depending on the project type, default project settings could also be adjusted.

The rationale behind those options could also be explained just like for GLES2/GLES3 rendering options, that way we can teach new users about the fact that they can/should assign main scene and hit F5 to debug the project (or not, if they choose 2D/3D template instead).

Don't know about you, but I would see this as a major workflow improvement.

@YuriSizov
Copy link
Contributor

YuriSizov commented May 28, 2021

Make it a dropdown (like with the script templates) and a way to define your own templates in the editor data folder (likely just a folder with all the files you want the way you want them for each template), and that's it.

@Calinou
Copy link
Member

Calinou commented May 28, 2021

@pycbouh Sounds like a good idea to me (on top of being easy to implement), but we'll have to rename the "Templates" tab in the project manager to something like "Online Templates" since it will not list local templates.

The Templates tab could also have a "Open Templates Folder" button to open the folder where template folders should be placed.

@YuriSizov
Copy link
Contributor

YuriSizov commented May 28, 2021

@Calinou We do have a PR to rename tabs in the PM: godotengine/godot#47871

Speaking of PRs, this is conflicting a bit with #1813 / godotengine/godot#42447. If we are to move forward with this latest idea this proposal by @aaronfranke needs to be considered.

@aaronfranke
Copy link
Member

@Xrayez @pycbouh We could take what is in godotengine/godot#42447 and swap out the default environment checkbox for another dropdown which has options for creating default scenery for 2D, 3D, UI, or Empty. Picture for reference:

Screenshot from 2021-05-28 17-14-20

@boukew99
Copy link
Author

boukew99 commented May 28, 2021

but a little help to the user is important at the start

that we do provide a newbie-friendly template out of the box

Yes, it would be super nice to have a supportive starting foundation that sends you on the right path

@Error7Studios
Copy link

If you're going to add a default main.tscn, please give it a main.gd with:

func _input(event):
	if event.is_action_pressed("ui_cancel"):
		get_tree().quit()

I feel like I've written that function a thousand times.

@Xrayez
Copy link
Contributor

Xrayez commented May 29, 2021

Note that you can stop the Godot debug process with F8 key (which works while the game window is focused and while in the editor). Unless you'd also like to let the scene tree to trigger other deinitialization callbacks.

@Error7Studios
Copy link

Note that you can stop the Godot debug process with F8 key

Thanks, I always forget about this.
Escape is the universal close/exit window key, so it feels natural to have that also stop the main scene by default.

@Calinou
Copy link
Member

Calinou commented May 29, 2021

Escape is the universal close/exit window key, so it feels natural to have that also stop the main scene by default.

This means you wouldn't be able to use Escape to open an in-game menu anymore, since the process would kill itself when you press Escape (this is how F8 works right now).

@Error7Studios
Copy link

This means you wouldn't be able to use Escape to open an in-game menu anymore

Hm, good point. Guess I'll just get used to using F8, then.
(P.S. Thanks for the any key tag)

@rainlizard
Copy link

That's why you do:

if Input.is_action_just_pressed('ui_cancel'):
	if OS.has_feature("standalone") == true:
		oConfirmQuit.popup_centered()
	else:
		get_tree().quit()

lol, old habits die hard.

But this conversation doesn't matter because it's absolutely necessary that templates be custom and defined by user.

@MaaaxiKing
Copy link

Such a basic but wonderful idea! I wonder that no one else came up with this yet. However, wouldn't game.tscn be more sensible owing to the fact that Godot is a Game Engine, regardless of the opportunity to produce some other-kind program‽

@YuriSizov
Copy link
Contributor

Such a basic but wonderful idea! I wonder that no one else came up with this yet. However, wouldn't game.tscn be more sensible owing to the fact that Godot is a Game Engine, regardless of the opportunity to produce some other-kind program‽

It doesn't really matter what we would call it, especially since we are talking about some default template. If you want it to be anything else, you can always customize it after your vision.

@Xrayez
Copy link
Contributor

Xrayez commented May 31, 2021

The way I see it, it's more about the program's execution/entry point. Many (if not all) statically built apps are invoked via main() function as requested by operating system. Even though GDScript is interpreted language, this conveys an appropriate message that this main scene could be considered as the main entry point in the context of Godot's scene tree system. Especially when the "main scene" concept is already familiar to existing Godot users.

@me2beats
Copy link

local templates could solve the problem as well
#1481

@boukew99
Copy link
Author

Okay, however this proposal has lost its need for me, since I mostly work on 1 project now and have a pretty fixed main scene (switched sometimes for iterating). I think my proposal originally came from a confusion of how to apply structure, partially due to inexperience, and thus I ended up making more new projects. I am fine now with how it is.

@KoBeWi
Copy link
Member

KoBeWi commented Jan 22, 2022

btw in 3.5 when you try to run a project without main scene, you get an option to set the current one as main (which is also auto-selected by default, so you can just press Enter).
image

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

No branches or pull requests