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

editor: Pick proper dir and filename in Save Map/Scenario As dialog #8911

Closed
soliton- opened this issue May 24, 2024 · 20 comments · Fixed by #8903
Closed

editor: Pick proper dir and filename in Save Map/Scenario As dialog #8911

soliton- opened this issue May 24, 2024 · 20 comments · Fixed by #8903
Assignees
Labels
Editor Map/scenario editor issues. Enhancement Issues that are requests for new features or changes to existing ones. UI User interface issues, including both back-end and front-end issues.

Comments

@soliton-
Copy link
Member

Describe the desired feature

  1. Enter editor
  2. New Scenario
  3. Save Scenario As
  4. Type in some name and save
  5. Save Map As
    Now you get the previous scenario filename in the dialog and if you do save you overwrite your scenario.

Similarly you get the map file name if you save as map first.

This is confusing and can lead to data loss if the user is not careful. Even if you change the filename you're saving to the wrong dir.

The save dialog should pick the proper dir to start with and even then it might be good to give an explicit warning if someone saves a map as .cfg or a scenario as .map and/or when they save them in the wrong dir (as much as the editor can tell, so just if the dir is named maps/scenarios). The wrong extension could perhaps even be completely forbidden.

@soliton- soliton- added Enhancement Issues that are requests for new features or changes to existing ones. Editor Map/scenario editor issues. labels May 24, 2024
@Wedge009 Wedge009 added the UI User interface issues, including both back-end and front-end issues. label May 24, 2024
@Wedge009
Copy link
Member

On the directory aspect, #2807 seems related.

@babaissarkar
Copy link
Contributor

@soliton- Please check if the latest commit in #8903 alleviates this somewhat?

The save dialog should pick the proper dir to start with and even then it might be good to give an explicit warning if someone saves a map as .cfg or a scenario as .map and/or when they save them in the wrong dir (as much as the editor can tell, so just if the dir is named maps/scenarios). The wrong extension could perhaps even be completely forbidden.

Working on this part. Forbidding the extension completely should be much easier. Plus I can use my validation textbox idea (a textbox which shows check/cross marks based on whether the input is valid or not).

@babaissarkar babaissarkar self-assigned this May 29, 2024
@babaissarkar
Copy link
Contributor

@soliton- Is b1d0a53 in #8903 enough to resolve this?

@soliton-
Copy link
Member Author

Is input_name the whole path? I think safer would be to just check the directory that is saved into. Not that we get confused by a user with "map" somewhere in their name or something.

Does the user see some feedback on what is wrong? Can they override it?

Using the correct starting dir to save to is also important. I forgot if you already added that in a different commit.

@babaissarkar
Copy link
Contributor

Is input_name the whole path? I think safer would be to just check the directory that is saved into. Not that we get confused by a user with "map" somewhere in their name or something.

input_name is the absolute, username-santized, cached path to the savefile.
Example : /home/USER/.local/share/wesnoth/1.19/data/add-ons/TestAddon/scenarios/test_scenario.cfg

I'll check the last directory.

Does the user see some feedback on what is wrong? Can they override it?

No. What the code does is check the (cached) path and if it is empty or has 'maps'/'scenarios', it opens the file dialog into the default directory (which is the addon's scenario/map directory) with a blank filename.

Using the correct starting dir to save to is also important. I forgot if you already added that in a different commit.

Save Map As opens into the addon's map directory (addon's scenarios directory for Save Scenario As) unless the user has already saved it somewhere else, in which case that directory is opened.

@soliton-
Copy link
Member Author

Ok, to pick the proper dir to start with I was just thinking to use <addon dir>/maps for Save Map As and <addon dir>/scenarios for Save Scenario As.

The other logic would be to warn the user when they pick something that seems to make no sense. Like when they navigate to the scenarios dir from the Save Map As dialog, type in the file name and click Save. Or when they try to save a scenario in any dir with a .map extension. At that point there could be a warning dialog where they can save anyway though if they want.

@babaissarkar
Copy link
Contributor

babaissarkar commented May 30, 2024

Ok, to pick the proper dir to start with I was just thinking to use <addon dir>/maps for Save Map As and <addon dir>/scenarios for Save Scenario As.

This already exists in my PR.

The other logic would be to warn the user when they pick something that seems to make no sense. Like when they navigate to the scenarios dir from the Save Map As dialog, type in the file name and click Save. Or when they try to save a scenario in any dir with a .map extension. At that point there could be a warning dialog where they can save anyway though if they want.

Okay, will work on this one.

@soliton-
Copy link
Member Author

Ok, to pick the proper dir to start with I was just thinking to use <addon dir>/maps for Save Map As and <addon dir>/scenarios for Save Scenario As.

This already exists.

I assume you mean in your PR.

@CelticMinstrel
Copy link
Member

Saving in the wrong directory should be allowed. Saving with the wrong extension should be forbidden.

babaissarkar added a commit to babaissarkar/wesnoth that referenced this issue May 31, 2024
@babaissarkar
Copy link
Contributor

babaissarkar commented May 31, 2024

This is what I added in 9c65d1e :
Screenshot from 2024-05-31 11-44-16

The example is from Save Map As, but it also appears for Save Scenario As with the corresponding extension.

@babaissarkar
Copy link
Contributor

692924b gives the user a warning the first they try to save a scenario in maps folder or vice versa. Pressing "Yes" saves anyway, "No" closes dialog.
Screenshot from 2024-06-19 18-05-48

@babaissarkar
Copy link
Contributor

babaissarkar commented Jun 19, 2024

How do I deal with empty filenames? I see two approaches:

  1. Disable the "Save" button until the user enters a non-empty filename.
  2. Use auto generated filename, something like "UntitledMapDDMMYY.map"

file dialog seems to use a different design pattern than other dialogs which is confusing to me. It could have used post_show(), but it does it in a way that makes it really hard to tweak things there (at least for me).

@irydacea Any thoughts on why you used a different pattern in file_dialog that is different than other dialogs AFAICS?

@soliton-
Copy link
Member Author

Disabling saving until a name is given sounds good to me. I don't see a reason to auto generate a name.

@babaissarkar
Copy link
Contributor

babaissarkar commented Jun 19, 2024

Disabling saving until a name is given sounds good to me. I don't see a reason to auto generate a name.

I'm thinking about making the filename textbox something like this: validation_textbox

Is this fine?

@babaissarkar
Copy link
Contributor

Commits 8eac378 and da83c9a :

Screenshot from 2024-06-20 18-57-03
Screenshot from 2024-06-20 18-26-01

Extension checking is now file dialog's responsibility (since it already had extension info), so I'll remove that from the editor. Editor will now only be responsible for checking map/scenario folders.

@babaissarkar
Copy link
Contributor

Anything else needs to be done as part of this issue?

@soliton-
Copy link
Member Author

The extension is enforced now or can be overridden by the user? I think besides .map also .mask should be allowed.

Otherwise I think this looks to be resolved if the code gets merged.

@babaissarkar
Copy link
Contributor

babaissarkar commented Jun 21, 2024

The extension is enforced now or can be overridden by the user?

Cannot be overridden, so file cannot be saved without correct extension. (The code calling the file_dialog can choose to turn this on or off. If an extension is set on the file_dialog using its set_extension method, the validation turns on.)

I think besides .map also .mask should be allowed.

For which dialog? Save Map As only, or somewhere else?

@soliton-
Copy link
Member Author

Yes, when saving maps .mask would be same as .map.

@babaissarkar
Copy link
Contributor

Yes, when saving maps .mask would be same as .map.

Implemented in b3128ff. File Dialog now has support for multiple extensions (previous commit). Extension validation only done when saving files.

babaissarkar added a commit that referenced this issue Jun 29, 2024
Map/Scenario Editor

* Rename Load Map to Load Map/Scenario (since it can load both), Edit Scenario to Edit Scenario Settings, Save Map to just Save.
* Rearrange menu order
* Add icon for the preferences menu item (used the preexisting settings.png icon)
* Open folder correctly at Add-on's scenario directory instead of editor/scenarios. (#8910)
* Show Save Scenario As only for Scenarios
* Use the settings.png icon for Preferences menu item
* Add functionality to "Loyal" checkbox (Unit tool -> Place unit -> Right click menu) (#8445)
* Show warning when maps are saved in scenarios folder or vice versa (#8911)
* Unit List moved to Units menu from File menu to reduce some pressure from the latter.
* Status Table menu item disabled since it does nothing. (Should be reenabled once the functionality has been added.)
* Improve reload functionality in Editor (F5). Reload happens directly from memory and no temp files are needed. Also, the undo/redo stacks will be preserved. (#9024)

Time Schedule Editor

* Browse buttons now set wesnoth style paths instead of just pasting the absolute path returned by the file dialog
* Change text boxes from inactive to uneditable.
* Code generation improvements
* Add copyright notice to tod_new_schedule
* Confirmation messages
* Preview buttons for image and sound files and new icons for the preview button (2 sets : preview image and preview sound)

Unit Type Editor
 * Confirmation messages
 * New icons for the preview button (2 sets : preview image and preview sound)

Add-on menu
 * Two new menu entries for (1) opening the Add-on selection dialog, (2) opening the folder corresponding to the Add-on
The open add-on folder option shows a GUI2 file dialog at the add-on's folder which can be used to open any file. If it is a loadable map/scenario it will be opened in the editor, otherwise the OS's default application for that file will be opened.

File Dialog
 * Redesigned with new icons
 * New Open External button that opens selected file/folder in the platform's default application (independently of what pressing Open would do). This could be used to quickly open a folder or preview the file before actually selecting it.
 * Extension checking and filename validation. (See #8911)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Editor Map/scenario editor issues. Enhancement Issues that are requests for new features or changes to existing ones. UI User interface issues, including both back-end and front-end issues.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants