Skip to content

Commit bae4ebd

Browse files
committed
feat: Implement Project selection/creation
1 parent 8078e65 commit bae4ebd

20 files changed

+619
-64
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
2+
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
using System;
4+
using System.Collections.Generic;
5+
using Avalonia.Media.Imaging;
6+
using Stride.Core.Assets.Templates;
7+
8+
namespace Stride.Core.Assets.Editor.Components.TemplateDescriptions.ViewModels
9+
{
10+
public interface ITemplateDescriptionViewModel
11+
{
12+
string Name { get; }
13+
14+
string Description { get; }
15+
16+
string FullDescription { get; }
17+
18+
string Group { get; }
19+
20+
Guid Id { get; }
21+
22+
string DefaultOutputName { get; }
23+
24+
Bitmap Icon { get; }
25+
26+
IEnumerable<Bitmap> Screenshots { get; }
27+
28+
TemplateDescription GetTemplate();
29+
}
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Stride.Core.Assets.Editor.Services;
2+
using Stride.Core.Presentation.Commands;
3+
using Stride.Core.Presentation.Services;
4+
using Stride.Core.Presentation.ViewModels;
5+
6+
namespace Stride.Core.Assets.Editor.Avalonia;
7+
8+
public class NewOrOpenSessionTemplateCollectionViewModel
9+
{
10+
private readonly IModalDialog dialog;
11+
private readonly IViewModelServiceProvider serviceProvider;
12+
public NewOrOpenSessionTemplateCollectionViewModel(IViewModelServiceProvider serviceProvider)
13+
{
14+
this.serviceProvider = serviceProvider;
15+
BrowseForExistingProjectCommand = new AnonymousTaskCommand(serviceProvider, BrowseForExistingProject);
16+
}
17+
public ICommandBase BrowseForExistingProjectCommand { get; }
18+
public bool AutoReloadSession { get; }
19+
20+
private async Task BrowseForExistingProject()
21+
{
22+
var filePath = await EditorDialogHelper.BrowseForExistingProject(serviceProvider);
23+
if (filePath != null)
24+
{
25+
SelectedTemplate = new ExistingProjectViewModel(ServiceProvider, filePath, RemoveExistingProjects);
26+
dialog?.RequestClose(DialogResult.Ok);
27+
}
28+
}
29+
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<UserControl xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="300"
6+
x:Class="Stride.Core.Assets.Editor.Avalonia.ObjectBrowserUserControl">
7+
<Grid ColumnDefinitions="*,5,3*,5,220">
8+
<TreeView Grid.Column="0" SelectionMode="Single"
9+
ItemsSource="{Binding HierarchyItemsSource, ElementName=ObjectBrowser, Mode=TwoWay}"
10+
SelectedItem="{Binding SelectedHierarchyItem, ElementName=ObjectBrowser, Mode=TwoWay}"
11+
ItemTemplate="{Binding HierarchyItemTemplate, ElementName=ObjectBrowser, Mode=TwoWay}" />
12+
13+
<GridSplitter Grid.Column="1" ResizeBehavior="PreviousAndNext" VerticalAlignment="Stretch" Width="5"/>
14+
15+
<ListBox Grid.Column="2"
16+
ItemsSource="{Binding ObjectItemsSource, ElementName=ObjectBrowser, Mode=TwoWay}"
17+
SelectedItem="{Binding SelectedObjectItem, ElementName=ObjectBrowser, Mode=TwoWay}"
18+
ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
19+
20+
<GridSplitter Grid.Column="3" ResizeBehavior="PreviousAndNext" VerticalAlignment="Stretch" Width="5"/>
21+
22+
<DockPanel Grid.Column="4" Background="{DynamicResource ControlBackgroundBrush}">
23+
<ScrollViewer x:Name="DescriptionScrollViewer" VerticalScrollBarVisibility="Auto">
24+
<ContentPresenter Content="{Binding SelectedObjectItem, ElementName=ObjectBrowser, Mode=TwoWay}"
25+
ContentTemplate="{Binding ObjectDescriptionTemplate, ElementName=ObjectBrowser, Mode=TwoWay}"/>
26+
</ScrollViewer>
27+
</DockPanel>
28+
</Grid>
29+
</UserControl>
30+
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
2+
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
4+
using System.Collections;
5+
using Avalonia;
6+
using Avalonia.Controls;
7+
using Avalonia.Controls.Templates;
8+
using Avalonia.Styling;
9+
10+
namespace Stride.Core.Assets.Editor.Avalonia;
11+
12+
public partial class ObjectBrowserUserControl : UserControl
13+
{
14+
public static readonly StyledProperty<IEnumerable> HierarchyItemsSourceProperty =
15+
AvaloniaProperty.Register<ObjectBrowserUserControl, IEnumerable>(nameof(HierarchyItemsSource));
16+
17+
public static readonly StyledProperty<object> SelectedHierarchyItemProperty =
18+
AvaloniaProperty.Register<ObjectBrowserUserControl, object>(nameof(SelectedHierarchyItem));
19+
20+
public static readonly StyledProperty<IDataTemplate> HierarchyItemTemplateProperty =
21+
AvaloniaProperty.Register<ObjectBrowserUserControl, IDataTemplate>(nameof(HierarchyItemTemplate));
22+
23+
public static readonly StyledProperty<IStyle> HierarchyItemContainerStyleProperty =
24+
AvaloniaProperty.Register<ObjectBrowserUserControl, IStyle>(nameof(HierarchyItemContainerStyle));
25+
26+
public static readonly StyledProperty<IEnumerable> ObjectItemsSourceProperty =
27+
AvaloniaProperty.Register<ObjectBrowserUserControl, IEnumerable>(nameof(ObjectItemsSource));
28+
29+
public static readonly StyledProperty<object> SelectedObjectItemProperty =
30+
AvaloniaProperty.Register<ObjectBrowserUserControl, object>(nameof(SelectedObjectItem));
31+
32+
public static readonly StyledProperty<IDataTemplate> ObjectItemTemplateProperty =
33+
AvaloniaProperty.Register<ObjectBrowserUserControl, IDataTemplate>(nameof(ObjectItemTemplate));
34+
35+
public static readonly StyledProperty<IDataTemplate> ObjectItemTemplateSelectorProperty =
36+
AvaloniaProperty.Register<ObjectBrowserUserControl, IDataTemplate>(nameof(ObjectItemTemplateSelector));
37+
38+
public static readonly StyledProperty<IStyle> ObjectItemContainerStyleProperty =
39+
AvaloniaProperty.Register<ObjectBrowserUserControl, IStyle>(nameof(ObjectItemContainerStyle));
40+
41+
public static readonly StyledProperty<IDataTemplate> ObjectDescriptionTemplateProperty =
42+
AvaloniaProperty.Register<ObjectBrowserUserControl, IDataTemplate>(nameof(ObjectDescriptionTemplate));
43+
44+
public static readonly StyledProperty<IDataTemplate> ObjectDescriptionTemplateSelectorProperty =
45+
AvaloniaProperty.Register<ObjectBrowserUserControl, IDataTemplate>(nameof(ObjectDescriptionTemplateSelector));
46+
47+
public ObjectBrowserUserControl()
48+
{
49+
InitializeComponent();
50+
}
51+
52+
public IEnumerable HierarchyItemsSource
53+
{
54+
get => GetValue(HierarchyItemsSourceProperty);
55+
set => SetValue(HierarchyItemsSourceProperty, value);
56+
}
57+
58+
public object SelectedHierarchyItem
59+
{
60+
get => GetValue(SelectedHierarchyItemProperty);
61+
set => SetValue(SelectedHierarchyItemProperty, value);
62+
}
63+
64+
public IDataTemplate HierarchyItemTemplate
65+
{
66+
get => GetValue(HierarchyItemTemplateProperty);
67+
set => SetValue(HierarchyItemTemplateProperty, value);
68+
}
69+
70+
public IStyle HierarchyItemContainerStyle
71+
{
72+
get => GetValue(HierarchyItemContainerStyleProperty);
73+
set => SetValue(HierarchyItemContainerStyleProperty, value);
74+
}
75+
76+
public IEnumerable ObjectItemsSource
77+
{
78+
get => GetValue(ObjectItemsSourceProperty);
79+
set => SetValue(ObjectItemsSourceProperty, value);
80+
}
81+
82+
public object SelectedObjectItem
83+
{
84+
get => GetValue(SelectedObjectItemProperty);
85+
set => SetValue(SelectedObjectItemProperty, value);
86+
}
87+
88+
public IDataTemplate ObjectItemTemplate
89+
{
90+
get => GetValue(ObjectItemTemplateProperty);
91+
set => SetValue(ObjectItemTemplateProperty, value);
92+
}
93+
94+
public IDataTemplate ObjectItemTemplateSelector
95+
{
96+
get => GetValue(ObjectItemTemplateSelectorProperty);
97+
set => SetValue(ObjectItemTemplateSelectorProperty, value);
98+
}
99+
100+
public IStyle ObjectItemContainerStyle
101+
{
102+
get => GetValue(ObjectItemContainerStyleProperty);
103+
set => SetValue(ObjectItemContainerStyleProperty, value);
104+
}
105+
106+
public IDataTemplate ObjectDescriptionTemplate
107+
{
108+
get => GetValue(ObjectDescriptionTemplateProperty);
109+
set => SetValue(ObjectDescriptionTemplateProperty, value);
110+
}
111+
112+
public IDataTemplate ObjectDescriptionTemplateSelector
113+
{
114+
get => GetValue(ObjectDescriptionTemplateSelectorProperty);
115+
set => SetValue(ObjectDescriptionTemplateSelectorProperty, value);
116+
}
117+
118+
// If you have a scroll viewer in your .axaml file:
119+
private void OnSelectedObjectItemChanged()
120+
{
121+
// ScrollViewer?.ScrollToTop(); // Placeholder: hook up actual ScrollViewer reference
122+
}
123+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<Window xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:avalonia="clr-namespace:Stride.Core.Assets.Editor.Avalonia"
6+
xmlns:sd="http://schemas.stride3d.net/xaml/presentation"
7+
mc:Ignorable="d"
8+
Height="768" Width="1024" ShowInTaskbar="False"
9+
x:Class="Stride.Core.Assets.Editor.Avalonia.ProjectSelectionWindow"
10+
d:DataContext="{d:DesignInstance avalonia:NewOrOpenSessionTemplateCollectionViewModel}">
11+
<DockPanel>
12+
<Grid DockPanel.Dock="Bottom">
13+
<DockPanel>
14+
<DockPanel DockPanel.Dock="Bottom" Margin="20">
15+
<Button DockPanel.Dock="Left" Content="{sd:LocalizeString Browse for existing project, Context=Button}" Command="{Binding BrowseForExistingProjectCommand}" Padding="20,6"/>
16+
<CheckBox IsChecked="{Binding AutoReloadSession}" Content="{sd:LocalizeString Reload last session automatically at startup, Context=Button}"
17+
VerticalAlignment="Center" Margin="8"/>
18+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
19+
<UniformGrid Rows="1">
20+
<Button Content="{sd:LocalizeString Select, Context=Button}" Padding="20,6" Margin="10,0,0,0"
21+
IsEnabled="{Binding SelectedTemplate, Converter={sd:ObjectToBool}}">
22+
</Button>
23+
<Button Content="{sd:LocalizeString Cancel, Context=Button}" Padding="20,6" Margin="10,0,0,0" IsCancel="True">
24+
</Button>
25+
</UniformGrid>
26+
</StackPanel>
27+
</DockPanel>
28+
<Grid ColumnDefinitions="Auto,2*,*" RowDefinitions="Auto,Auto,Auto,Auto">
29+
<TextBlock Grid.Row="0" Grid.Column="0" Text="{sd:LocalizeString Name:}" Margin="20,0" VerticalAlignment="Center"/>
30+
<TextBox Grid.Row="0" Grid.Column="1" Margin="2" Text="{Binding Name}"/>
31+
<TextBlock Grid.Row="1" Grid.Column="0" Text="{sd:LocalizeString Location:}" Margin="20,0" VerticalAlignment="Center"/>
32+
<DockPanel Grid.Row="1" Grid.Column="1">
33+
<Button DockPanel.Dock="Right" Command="{Binding BrowseDirectoryCommand}" CommandParameter="Location">
34+
</Button>
35+
<TextBox Margin="2" Text="{Binding Location}"/>
36+
</DockPanel>
37+
<TextBlock Grid.Row="2" Grid.Column="0" Text="{sd:LocalizeString Solution name:}" Margin="20,0" VerticalAlignment="Center"/>
38+
<TextBox Grid.Row="2" Grid.Column="1" Margin="2" Watermark="{sd:LocalizeString (Auto-generate solution name)}"
39+
Text="{Binding SolutionName}">
40+
</TextBox>
41+
<TextBlock Grid.Row="3" Grid.Column="0" Text="{sd:LocalizeString Solution location:}" Margin="20,0" VerticalAlignment="Center"/>
42+
<DockPanel Grid.Row="3" Grid.Column="1">
43+
<Button DockPanel.Dock="Right" Command="{Binding BrowseDirectoryCommand}" CommandParameter="SolutionLocation" />
44+
<TextBox Margin="2" Watermark="{sd:LocalizeString (Same location)}" Text="{Binding SolutionLocation}">
45+
</TextBox>
46+
</DockPanel>
47+
</Grid>
48+
</DockPanel>
49+
</Grid>
50+
51+
<avalonia:TemplateBrowserUserControl Margin="10"/>
52+
</DockPanel>
53+
</Window>
54+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
2+
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
4+
using Avalonia.Controls;
5+
6+
namespace Stride.Core.Assets.Editor.Avalonia;
7+
8+
public partial class ProjectSelectionWindow : Window
9+
{
10+
public ProjectSelectionWindow()
11+
{
12+
InitializeComponent();
13+
}
14+
}
15+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<UserControl xmlns="https://github.com/avaloniaui"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:avalonia="clr-namespace:Stride.Core.Assets.Editor.Avalonia"
6+
mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="300"
7+
xmlns:viewModels="clr-namespace:Stride.Core.Assets.Editor.Components.TemplateDescriptions.ViewModels"
8+
d:DataContext="{d:DesignInstance viewModels:TemplateDescriptionCollectionViewModel}"
9+
x:Class="Stride.Core.Assets.Editor.Avalonia.TemplateBrowserUserControl">
10+
<avalonia:ObjectBrowserUserControl HierarchyItemsSource="{Binding RootGroups}"
11+
SelectedHierarchyItem="{Binding SelectedGroup, Mode=TwoWay}"
12+
ObjectItemsSource="{Binding Templates}"
13+
SelectedObjectItem="{Binding SelectedTemplate}"
14+
ObjectItemTemplateSelector="{StaticResource DataTypeTemplateSelector}">
15+
<avalonia:ObjectBrowserUserControl.HierarchyItemTemplate>
16+
<TreeDataTemplate ItemsSource="{Binding SubGroups}" DataType="viewModels:TemplateDescriptionGroupViewModel">
17+
<TextBlock Text="{Binding Name}"/>
18+
</TreeDataTemplate>
19+
</avalonia:ObjectBrowserUserControl.HierarchyItemTemplate>
20+
<avalonia:ObjectBrowserUserControl.ObjectDescriptionTemplate>
21+
<DataTemplate DataType="viewModels:ITemplateDescriptionViewModel">
22+
<StackPanel DockPanel.Dock="Top">
23+
<TextBlock FontWeight="Bold" Text="{Binding Name}" Margin="10"/>
24+
<TextBlock Text="{Binding FullDescription}" Margin="10,20" TextWrapping="Wrap"/>
25+
26+
<ItemsControl ItemsSource="{Binding Screenshots}">
27+
<ItemsControl.ItemTemplate>
28+
<DataTemplate>
29+
<Image Margin="2,12" Source="{Binding}" MaxWidth="192" StretchDirection="DownOnly" />
30+
</DataTemplate>
31+
</ItemsControl.ItemTemplate>
32+
</ItemsControl>
33+
</StackPanel>
34+
</DataTemplate>
35+
</avalonia:ObjectBrowserUserControl.ObjectDescriptionTemplate>
36+
</avalonia:ObjectBrowserUserControl>
37+
</UserControl>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net)
2+
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
3+
4+
using Avalonia;
5+
using Avalonia.Controls;
6+
using Avalonia.Markup.Xaml;
7+
8+
namespace Stride.Core.Assets.Editor.Avalonia;
9+
10+
public partial class TemplateBrowserUserControl : UserControl
11+
{
12+
public TemplateBrowserUserControl()
13+
{
14+
InitializeComponent();
15+
}
16+
}
17+

0 commit comments

Comments
 (0)