Merge pull request #203 from TorchAPI/character-vm
Character view model and fixed character display
This commit is contained in:
@@ -245,6 +245,9 @@
|
|||||||
<Compile Include="Views\Converters\ListConverter.cs" />
|
<Compile Include="Views\Converters\ListConverter.cs" />
|
||||||
<Compile Include="MultiTextWriter.cs" />
|
<Compile Include="MultiTextWriter.cs" />
|
||||||
<Compile Include="RichTextBoxWriter.cs" />
|
<Compile Include="RichTextBoxWriter.cs" />
|
||||||
|
<Compile Include="Views\Entities\CharacterView.xaml.cs">
|
||||||
|
<DependentUpon>CharacterView.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\ValidationRules\ListConverterValidationRule.cs" />
|
<Compile Include="Views\ValidationRules\ListConverterValidationRule.cs" />
|
||||||
<Compile Include="Views\Entities\EntityControlHost.xaml.cs">
|
<Compile Include="Views\Entities\EntityControlHost.xaml.cs">
|
||||||
<DependentUpon>EntityControlHost.xaml</DependentUpon>
|
<DependentUpon>EntityControlHost.xaml</DependentUpon>
|
||||||
@@ -378,6 +381,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Entities\CharacterView.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Entities\GridView.xaml">
|
<Page Include="Views\Entities\GridView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
@@ -6,7 +6,12 @@ namespace Torch.Server.ViewModels.Entities
|
|||||||
{
|
{
|
||||||
public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
|
public CharacterViewModel(MyCharacter character, EntityTreeViewModel tree) : base(character, tree)
|
||||||
{
|
{
|
||||||
|
character.ControllerInfo.ControlAcquired += (x) => { OnPropertyChanged(nameof(Name)); };
|
||||||
|
character.ControllerInfo.ControlReleased += (x) => { OnPropertyChanged(nameof(Name)); };
|
||||||
|
}
|
||||||
|
|
||||||
|
public CharacterViewModel()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using Sandbox.Game.World;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
using Torch.Collections;
|
using Torch.Collections;
|
||||||
using Torch.Server.Managers;
|
using Torch.Server.Managers;
|
||||||
|
using VRage.Game.Entity;
|
||||||
using VRage.Game.ModAPI;
|
using VRage.Game.ModAPI;
|
||||||
using VRage.ModAPI;
|
using VRage.ModAPI;
|
||||||
using VRageMath;
|
using VRageMath;
|
||||||
@@ -32,10 +34,11 @@ namespace Torch.Server.ViewModels.Entities
|
|||||||
|
|
||||||
public virtual string Name
|
public virtual string Name
|
||||||
{
|
{
|
||||||
get => Entity?.DisplayName;
|
get => Entity?.DisplayName ?? (Entity != null ? $"eid:{Entity.EntityId}" : "nil");
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
if (Entity!=null)
|
||||||
|
TorchBase.Instance.InvokeBlocking(() => Entity.DisplayName = value);
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,7 +51,8 @@ namespace Torch.Server.ViewModels.Entities
|
|||||||
if (!Vector3D.TryParse(value, out Vector3D v))
|
if (!Vector3D.TryParse(value, out Vector3D v))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
if (Entity != null)
|
||||||
|
TorchBase.Instance.InvokeBlocking(() => Entity.SetPosition(v));
|
||||||
OnPropertyChanged();
|
OnPropertyChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
30
Torch.Server/Views/Entities/CharacterView.xaml
Normal file
30
Torch.Server/Views/Entities/CharacterView.xaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<UserControl x:Class="Torch.Server.Views.Entities.CharacterView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:entities="clr-namespace:Torch.Server.ViewModels.Entities"
|
||||||
|
xmlns:local="clr-namespace:Torch.Server.Views.Entities"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
<UserControl.DataContext>
|
||||||
|
<entities:CharacterViewModel />
|
||||||
|
</UserControl.DataContext>
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel Grid.Row="0" Orientation="Horizontal">
|
||||||
|
<Label Content="Name" Width="100"/>
|
||||||
|
<TextBox Text="{Binding Name}" Margin="3"/>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="1" Orientation="Horizontal">
|
||||||
|
<Label Content="Position" Width="100"/>
|
||||||
|
<TextBox Text="{Binding Position}" Margin="3" />
|
||||||
|
</StackPanel>
|
||||||
|
<ScrollViewer Grid.Row="2" Margin="3" VerticalScrollBarVisibility="Auto">
|
||||||
|
<local:EntityControlsView DataContext="{Binding}"/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
28
Torch.Server/Views/Entities/CharacterView.xaml.cs
Normal file
28
Torch.Server/Views/Entities/CharacterView.xaml.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace Torch.Server.Views.Entities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for GridView.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class CharacterView : UserControl
|
||||||
|
{
|
||||||
|
public CharacterView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -54,7 +54,7 @@
|
|||||||
<TextBlock Text="{Binding Grids.Count, StringFormat=Grids ({0})}" />
|
<TextBlock Text="{Binding Grids.Count, StringFormat=Grids ({0})}" />
|
||||||
</TreeViewItem.Header>
|
</TreeViewItem.Header>
|
||||||
</TreeViewItem>
|
</TreeViewItem>
|
||||||
<TreeViewItem ItemsSource="{Binding Characters}">
|
<TreeViewItem ItemsSource="{Binding Characters.Values}">
|
||||||
<TreeViewItem.Header>
|
<TreeViewItem.Header>
|
||||||
<TextBlock Text="{Binding Characters.Count, StringFormat=Characters ({0})}" />
|
<TextBlock Text="{Binding Characters.Count, StringFormat=Characters ({0})}" />
|
||||||
</TreeViewItem.Header>
|
</TreeViewItem.Header>
|
||||||
|
@@ -48,6 +48,8 @@ namespace Torch.Server.Views
|
|||||||
EditorFrame.Content = new BlockView {DataContext = bvm};
|
EditorFrame.Content = new BlockView {DataContext = bvm};
|
||||||
if (e.NewValue is VoxelMapViewModel vvm)
|
if (e.NewValue is VoxelMapViewModel vvm)
|
||||||
EditorFrame.Content = new VoxelMapView {DataContext = vvm};
|
EditorFrame.Content = new VoxelMapView {DataContext = vvm};
|
||||||
|
if (e.NewValue is CharacterViewModel cvm)
|
||||||
|
EditorFrame.Content = new CharacterView {DataContext = cvm};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user