stride icon indicating copy to clipboard operation
stride copied to clipboard

[Enhancement] Save asset view options settings

Open Kryptos-FR opened this issue 7 years ago • 16 comments
trafficstars

Good first issue
Issues reserved for newcomers. Consider taking it only if it's your first time working on a feature or a bug in Xenko.

The view options (such as level of zoom, filters, grid or tile view, etc.) are not saved in the settings and thus use their default value when restarting the Game Studio.

Starting point:

  • AssetViewUserControl.xaml in Xenko.Core.Assets.Editor
  • EditorSettings in Xenko.Core.Assets.Editor
  • AssetCollectionViewModel in Xenko.Core.Assets.Editor

Kryptos-FR avatar Aug 26 '18 02:08 Kryptos-FR

Hi there, I'm new to Stride (actually, I've never actually participated in an open-source project before this), and I'm interested in helping out. My coding experience is limited to programing business software, so I think that this issue would be a good fit for me as a starting point, since it doesn't seem to require technical knowledge specific to game engine development.

Would it be OK if I tried to solve this issue?

dadofboi avatar May 08 '21 19:05 dadofboi

@dadofboi Yes, definitely! PRs are welcome!

herocrab avatar May 08 '21 20:05 herocrab

Hi, I've been trying to look through the XAML files and whenever I try to view the Designer tab, I get this error. Everything works perfectly fine when building Stride though, or when I create another WPF project.

invalid-markup-error

Is this a bug, or is it actually expected behavior? I'm not familiar at all with WPF so sorry if this is a trivial issue.

Edit: For reference, here are the error messages: error-message

Editing the attributes causing the errors gave me this error instead: null-reference-exception

Commenting out the Window.Resources node allow me the load the designer, but with other errors: window-resources designer-window

dadofboi avatar May 10 '21 15:05 dadofboi

In complex WPF applications you can't really use the designer because there's a lot of dynamic parts to the views - depending on the data you're working on in the project. So you wouldn't be working with a designer but straight with XAML. While debugging you can use VS tools to select a part of the window (a control or panel) and show it in the visual tree view which can allow you to map it back to a line in the XAML file.

manio143 avatar May 10 '21 22:05 manio143

Thanks for the help! My company still uses WinForms (yeah, I know), so I had no idea this is how WPF works. In that case I'll spend some time learning about WPF and then try to tackle this issue again.

dadofboi avatar May 11 '21 03:05 dadofboi

Hello, is it okay if I take a stab at implementing this enhancement?

soorMSWE avatar May 31 '24 20:05 soorMSWE

Definitely, please do !

Eideren avatar May 31 '24 21:05 Eideren

Been looking at this and I think I have a good understanding on this system and what needs to be done, but just in case I was hoping to get some feedback real quick:

  • So the fields we want to save (These view options) will essentially need to be added to the EditorSettings as new SettingsKey objects.
  • In the EditorSettings the load and save behaviors are performed so the idea here would be mainly to get these fields and link them to the SettingsKey objects to be properly saved and loaded as needed.
  • In order to access for example the thumbnail size, this TileThumbnailSizeProperty will need to be somehow linked to the SettingsKey object from EditorSettings.

Still have a few questions:

  • In the AssetViewUserControl.xaml file, we can see the tile and grid size properties are set from the UI from user input, would we need to access those size vars from its corresponding cs file? (IE from the AssetViewUserControl.xaml.cs)
  • At first I think getting one property to save and load would be easiest to implement and test but what other fields should be saved eventually? I know the issue mentions Filter (from AssetCollectionViewModel.cs),Tile and Grid Views and Current Zoom level.
  • In terms of debugging this in vs, I was having some trouble finding the specific UI that these actions (like thumbnail and grid size changes) are performed in.

soorMSWE avatar May 31 '24 22:05 soorMSWE

  1. Yes
  2. You can keep it as just the options listed over here: image So, as the first post mentions, the filter, display, sort and view type, although for that last one I'm not sure if there is any other views but the tiles, maybe @Kryptos-FR could clarify this issue further, but what I've listed should be good enough.
  3. From what I understood, the screenshot above should clarify this, let me know if that's not enough and I could send a short clip over. Or maybe I just didn't understand the question properly, in which case let me know as well :)

Eideren avatar Jun 01 '24 10:06 Eideren

Thank you so much for the quick response! These help very much, and I look forward to implementing this!

soorMSWE avatar Jun 01 '24 23:06 soorMSWE

I'll come back to you with some details. Remind me in a few days if I forget.

Kryptos-FR avatar Jun 04 '24 16:06 Kryptos-FR

I am looking into saving the selected settings in the editor as a settings key in internalSettings.cs. The issue I am running into is how to access the ObservableListSelectedContent in AssetCollectionViewModel.cs to save it as a settings key in InternalSettings.cs. Do you have any suggestions on how I should approach this?

soorMSWE avatar Jun 07 '24 21:06 soorMSWE

@soorMSWE What are you trying to do specifically here, saving and restoring the assets that were selected in the last session ? If that's the case, best to avoid it for now since this is actually quite complex in comparison to what this issue is about. Not sure the settings serialization is prepared for that.

Eideren avatar Jun 08 '24 13:06 Eideren

Hello,

I confused myself with what I was trying to do. I am actually trying to save the asset filters and not the selected assets. I am currently looking into it. Please let me know if you have any suggestions!

soorMSWE avatar Jun 08 '24 21:06 soorMSWE

Hello,

I am currently looking at how to possibly put the current filters stored in ObservableSet<AssetFilterViewModel> into a SettingsKey but its proving to be a bit tricky. I was thinking maybe pulling out the stored strings in the AssetFilterViewModel objects and storing them in a settingsKey since I dont think the AssetFilterViewModel objects can be simply saved out a settingsKey directly. Are we able to save out the lists through the SettingsKeys?

soorMSWE avatar Jun 09 '24 21:06 soorMSWE

@soorMSWE

Are we able to save out the lists through the SettingsKeys?

Afaict, yes, we have tests covering those here https://github.com/stride3d/stride/blob/master/sources/core/Stride.Core.Design.Tests/TestSettings.cs And one actual usage over there https://github.com/stride3d/stride/blob/master/sources/editor/Stride.GameStudio/Settings/GameStudioInternalSettings.cs#L16

I was thinking maybe pulling out the stored strings in the AssetFilterViewModel objects and storing them in a settingsKey

Sounds good, just a note, there's also the FilterCategory Category which should be saved alongside the string that way you can properly differentiate between name, tag and type filters.

If you create a new data type to store those two variables into, make sure to decorate it with [DataContract] for it to be properly serialized. If you need more info on how the serialization works in this engine there's a fairly thin document over there https://doc.stride3d.net/latest/en/manual/scripts/serialization.html

Eideren avatar Jun 10 '24 01:06 Eideren