stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.64k stars 957 forks source link

[Enhancement] Save asset view options settings #147

Open Kryptos-FR opened 6 years ago

Kryptos-FR commented 6 years ago
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:

dadofboi commented 3 years ago

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?

herocrab commented 3 years ago

@dadofboi Yes, definitely! PRs are welcome!

dadofboi commented 3 years ago

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

manio143 commented 3 years ago

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.

dadofboi commented 3 years ago

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.

soorMSWE commented 5 months ago

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

Eideren commented 5 months ago

Definitely, please do !

soorMSWE commented 5 months ago

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:

Still have a few questions:

Eideren commented 5 months ago
  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 :)
soorMSWE commented 5 months ago

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

Kryptos-FR commented 5 months ago

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

soorMSWE commented 5 months ago

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?

Eideren commented 5 months ago

@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.

soorMSWE commented 5 months ago

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 commented 5 months ago

Hello,

I am currently looking at how to possibly put the current filters stored in ObservableSet 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?

Eideren commented 5 months ago

@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