godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.54k stars 20.27k forks source link

Windows: installing Asset Library Project or Demo whose name contain a colon will setup invalid folder name #77127

Open hsandt opened 1 year ago

hsandt commented 1 year ago

Godot version

v4.0.2.stable.official [7a0977ce2]

System information

Windows 10

Issue description

If you try to install a project or demo from the Asset Library Projects tab in the Godot launcher popup, and the name contains a colon such as:

Movement 2: A sequel to 2D Platformer demos https://godotengine.org/asset-library/asset/1830

Godot 4 0 2 - Cannot create folder with colon on Windows and some samples have one

The Project Name will keep the colon, and clicking Create Folder will fail with error:

Couldn't create folder.

While this is technically correct, a user not familiar with Windows limitations will be confused. I also expect the default name to work out of the box. There I report this in bug rather than proposals.

I see a few solutions: a. Upstream conversion: immediately convert project name invalid characters to valid ones (e.g. : -> -) when filling Project Name. Advantage: fixes all further steps. Disadvantage: that also affects the Project Name string, which doesn't have such limitations itself. b. Explanation: if the folder name is invalid for the current platform, explain why in the error message (should not contain invalid character ":', "/", etc.). Advantage: user learns something. Disadvantage: they must still fix the issue themselves, either changing the Project Name (which leads to disadvantage of a.) or clicking Browse > Manually create folder with name containing valid characters and select it, which takes more steps and defeats the convenience of the Create Folder button) c. Downstream conversion: when creating a folder, convert invalid characters to valid ones as needed for the current platform, but only for the created folder. Project Name remains untouched. Advantage: preserves Project Name. Disadvantage: things done under the hood, user may not understand why colon suddenly became hyphen... But I don't think that's a big deal, since many apps do this already, such as github turning your project name spaces into hyphen so you get a standardized repo name/URL.

We also need to decide how to convert things. Should : become empty (just remove it), hyphen - (that will create an ugly Title- Subtitle with no space before the hyphen, space with hyphen -, etc. ?

Steps to reproduce

  1. Open Godot launcher
  2. Select Asset Library Projects
  3. Search "Movement 2"
  4. Download Movement 2: A sequel to 2D Platformer demos
  5. Create Folder

Minimal reproduction project

N/A

hsandt commented 1 year ago

Related to https://github.com/godotengine/godot/issues/4928 which was solved by replacing invalid characters with hyphen, but still allow developers to customize their user paths per project (done in another PR https://github.com/godotengine/godot/pull/13317/files).

Here, user can already customize install path with the Browse button if they want. I suppose we could also allow sample project/demo developers to customize the default folder name on their side, but not sure if it's worth the hassle (unlike user path which was also made customizable for another reason to allow unique paths like Company/Game to avoid conflicts with other games with the same name.

Calinou commented 1 year ago

We also need to decide how to convert things. Should : become empty (just remove it), hyphen - (that will create an ugly Title- Subtitle with no space before the hyphen, space with hyphen -, etc. ?

We have a String.validate_filename() method to return a normalized file/folder names (i.e. valid on all operating systems). We should use it when setting the folder name.

This should also be done when automatically setting a folder name based on project name in the project creation dialog, although I think we use a custom solution currently (rather than String.validate_filename()). We should probably use both for the project creation dialog, as we want to use snake_case for the project folder name by default.