-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Settings Window #2816
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
Merged
Kryptos-FR
merged 4 commits into
stride3d:xplat-editor
from
Color-Rise:feature/xplat/settings
Jun 17, 2025
Merged
feat: Settings Window #2816
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
sources/editor/Stride.Core.Assets.Editor.Avalonia/Themes/PropertyViewTheme.axaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| <ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:sd="http://schemas.stride3d.net/xaml/presentation" | ||
| xmlns:caecp="using:Stride.Core.Assets.Editor.Components.Properties" | ||
| xmlns:caev="using:Stride.Core.Assets.Editor.Avalonia.Views" | ||
| xmlns:cpqvm="using:Stride.Core.Presentation.Quantum.ViewModels"> | ||
| <ControlTheme x:Key="PropertyExpanderTheme" TargetType="Expander"> | ||
| <Setter Property="Padding" Value="10,0,0,0"/> | ||
| <Setter Property="Template"> | ||
| <ControlTemplate TargetType="Expander"> | ||
| <Border BorderThickness="0" Margin="0" Padding="0" | ||
| HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> | ||
| <ContentPresenter Content="{TemplateBinding Content}" | ||
| ContentTemplate="{TemplateBinding ContentTemplate}" | ||
| HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | ||
| VerticalAlignment="{TemplateBinding VerticalContentAlignment}" | ||
| IsVisible="{TemplateBinding IsExpanded}" | ||
| Focusable="False"/> | ||
| </Border> | ||
| </ControlTemplate> | ||
| </Setter> | ||
| </ControlTheme> | ||
| <ControlTheme x:Key="{x:Type sd:PropertyView}" TargetType="sd:PropertyView" BasedOn="{StaticResource {x:Type ItemsControl}}"> | ||
| <Setter Property="HorizontalAlignment" Value="Stretch"/> | ||
| <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> | ||
| <Setter Property="Template"> | ||
| <ControlTemplate TargetType="sd:PropertyView"> | ||
| <Border Padding="{TemplateBinding Padding}" | ||
| Background="{TemplateBinding Background}" | ||
| BorderBrush="{TemplateBinding BorderBrush}" | ||
| BorderThickness="{TemplateBinding BorderThickness}" | ||
| CornerRadius="{TemplateBinding CornerRadius}"> | ||
| <ScrollViewer AllowAutoHide="False" | ||
| HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" | ||
| VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" > | ||
| <ItemsPresenter Name="PART_ItemsPresenter" | ||
| ItemsPanel="{TemplateBinding ItemsPanel}" /> | ||
| </ScrollViewer> | ||
| </Border> | ||
| </ControlTemplate> | ||
| </Setter> | ||
| </ControlTheme> | ||
| <ControlTheme x:Key="{x:Type sd:PropertyViewItem}" TargetType="sd:PropertyViewItem" | ||
| x:DataType="cpqvm:NodeViewModel"> | ||
| <Setter Property="Background" Value="Transparent"/> | ||
| <Setter Property="Increment" Value="12"/> | ||
| <Setter Property="HorizontalAlignment" Value="Stretch"/> | ||
| <Setter Property="HeaderTemplate"> | ||
| <TreeDataTemplate ItemsSource="{Binding Children, Mode=OneWay}" DataType="cpqvm:NodeViewModel"> | ||
| <ContentPresenter Content="{Binding}" | ||
| ContentTemplate="{x:Static caev:PropertyViewHelper.HeaderProviders}"/> | ||
| </TreeDataTemplate> | ||
| </Setter> | ||
| <Setter Property="Template"> | ||
| <ControlTemplate TargetType="sd:PropertyViewItem"> | ||
| <Border BorderBrush="{TemplateBinding Border.BorderBrush}" | ||
| BorderThickness="{TemplateBinding Border.BorderThickness}" | ||
| IsVisible="{Binding IsVisible}"> | ||
| <DockPanel> | ||
| <Border DockPanel.Dock="Top" Background="{TemplateBinding Background}"> | ||
| <ContentPresenter Name="PART_Header" | ||
| Content="{TemplateBinding HeaderedContentControl.Header}" | ||
| ContentTemplate="{TemplateBinding HeaderTemplate}" | ||
| HorizontalAlignment="{TemplateBinding Control.HorizontalAlignment}" | ||
| IsVisible="{sd:MultiBinding {Binding !$parent[sd:PropertyView].((caecp:SessionObjectPropertiesViewModel)DataContext).ShowOverridesOnly, FallbackValue={sd:True}}, | ||
| {Binding [IsOverridden]}, | ||
| {Binding ![HasBase]}, | ||
| Converter={sd:OrMulti}}"/> | ||
| </Border> | ||
| <Expander IsEnabled="True" IsExpanded="{Binding IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" | ||
| HorizontalAlignment="Stretch" | ||
| Theme="{StaticResource PropertyExpanderTheme}"> | ||
| <StackPanel> | ||
| <ItemsPresenter Name="ItemsHost"/> | ||
| <ContentPresenter Name="PART_Footer" | ||
| Content="{TemplateBinding HeaderedContentControl.Header}" | ||
| ContentTemplate="{x:Static caev:PropertyViewHelper.FooterProviders}" | ||
| HorizontalAlignment="{TemplateBinding Control.HorizontalAlignment}" | ||
| IsVisible="{sd:MultiBinding {Binding !$parent[sd:PropertyView].((caecp:SessionObjectPropertiesViewModel)DataContext).ShowOverridesOnly, FallbackValue={sd:True}}, | ||
| {Binding [IsOverridden]}, | ||
| {Binding ![HasBase]}, | ||
| Converter={sd:OrMulti}}"/> | ||
| </StackPanel> | ||
| </Expander> | ||
| </DockPanel> | ||
| </Border> | ||
| </ControlTemplate> | ||
| </Setter> | ||
| </ControlTheme> | ||
| </ResourceDictionary> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
sources/editor/Stride.Core.Assets.Editor.Avalonia/Views/PropertyTemplateProviderSelector.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...e.Core.Assets.Editor.Avalonia/Views/SettingsStringFromAcceptableValuesTemplateProvider.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) | ||
| // Distributed under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
|
||
| using Stride.Core.Assets.Editor.Quantum.NodePresenters.Keys; | ||
| using Stride.Core.Presentation.Quantum.ViewModels; | ||
|
|
||
| namespace Stride.Core.Assets.Editor.Avalonia.Views; | ||
|
|
||
| public class SettingsStringFromAcceptableValuesTemplateProvider : NodeViewModelTemplateProvider | ||
| { | ||
| public override string Name => "StringFromAcceptableValues"; | ||
|
|
||
| public override bool MatchNode(NodeViewModel node) | ||
| { | ||
| return node.Parent != null && (node.Parent.AssociatedData.TryGetValue(SettingsData.HasAcceptableValues, out var hasAcceptableValues) && (bool)hasAcceptableValues); | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
sources/editor/Stride.Core.Assets.Editor/Quantum/NodePresenters/Keys/SettingsData.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) | ||
| // Distributed under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
|
||
| namespace Stride.Core.Assets.Editor.Quantum.NodePresenters.Keys; | ||
|
|
||
| public static class SettingsData | ||
| { | ||
| public const string HasAcceptableValues = nameof(HasAcceptableValues); | ||
| public const string AcceptableValues = nameof(AcceptableValues); | ||
| public static readonly PropertyKey<bool> HasAcceptableValuesKey = new(HasAcceptableValues, typeof(SettingsData)); | ||
| public static readonly PropertyKey<IEnumerable<object>> AcceptableValuesKey = new(AcceptableValues, typeof(SettingsData)); | ||
| } |
21 changes: 21 additions & 0 deletions
21
.../Stride.Core.Assets.Editor/Quantum/NodePresenters/Updaters/SettingsPropertyNodeUpdater.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) | ||
| // Distributed under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
|
||
| using Stride.Core.Assets.Editor.Quantum.NodePresenters.Keys; | ||
| using Stride.Core.Assets.Editor.Settings; | ||
| using Stride.Core.Presentation.Quantum.Presenters; | ||
|
|
||
| namespace Stride.Core.Assets.Editor.Quantum.NodePresenters.Updaters; | ||
|
|
||
| public sealed class SettingsPropertyNodeUpdater : NodePresenterUpdaterBase | ||
| { | ||
| public override void UpdateNode(INodePresenter node) | ||
| { | ||
| if (node.Value is PackageSettingsWrapper.SettingsKeyWrapper settingsKey) | ||
| { | ||
| var acceptableValues = settingsKey.Key.AcceptableValues.ToList(); | ||
| node.AttachedProperties.Add(SettingsData.HasAcceptableValuesKey, acceptableValues.Count > 0); | ||
| node.AttachedProperties.Add(SettingsData.AcceptableValuesKey, acceptableValues); | ||
| } | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
sources/editor/Stride.Core.Assets.Editor/Settings/EditorSettings.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| // Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) | ||
| // Distributed under the MIT license. See the LICENSE.md file in the project root for more information. | ||
|
|
||
| using Stride.Core.Settings; | ||
| using Stride.Core.Translation; | ||
|
|
||
| namespace Stride.Core.Assets.Editor.Settings; | ||
|
|
||
| public static class EditorSettings | ||
| { | ||
| private static SettingsProfile? profile; | ||
| public static SettingsContainer SettingsContainer { get; } = new(); | ||
|
|
||
| // Categories | ||
| public static readonly string Interface = Tr._p("Settings", "Interface"); | ||
|
|
||
| static EditorSettings() | ||
| { | ||
| Language = new SettingsKey<string>("Interface/Language", SettingsContainer, "MachineDefault") | ||
| { | ||
| DisplayName = $"{Interface}/{Tr._p("Settings", "Language")}", | ||
| }; | ||
| } | ||
|
|
||
| public static SettingsKey<string> Language { get; } | ||
|
|
||
| public static bool NeedRestart { get; set; } | ||
|
|
||
| public static void Initialize() | ||
| { | ||
| profile = SettingsContainer.LoadSettingsProfile(EditorPath.EditorConfigPath, true) ?? SettingsContainer.CreateSettingsProfile(true); | ||
|
|
||
| // Settings that requires a restart must register here | ||
| Language.ChangesValidated += (_, _) => NeedRestart = true; | ||
| } | ||
|
|
||
| public static void Save() | ||
| { | ||
| SettingsContainer.SaveSettingsProfile(profile!, EditorPath.EditorConfigPath); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why make it a singleton?
it forces to have only one setting, what about swapping between settings etc, no need for it to be singleton and static?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by swapping between settings? Can you explain the use cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you have a folder with X different settings bundles and you should be able to swap between them
like there is no reason for it to be singleton, graphicscontext is also not a singleton for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you have different bundles of settings files for the editor? Those are basic settings like theme, language, list of recent projects, etc.
If you think about having several user profiles, that could be a new feature but it is out of scope for the rewrite effort. Here I'm just porting the existing settings system from the old editor, and such feature is not implemented there either. Feel free to open a feature request.