Skip to content

Commit b9885f9

Browse files
committed
Added Seconds until restart.
- Some set restart to 4/6 hours on restart for automatic restarts making the IsRestartPending flag less helpful. Fixed floating object view - Pointed to correct collection. - Added FloatingObjectsView Added information - Distance from center for all types. Added IEntityModel interface Added Multi-Selection for deleting more than one object at a time in their respective view. The main view is still one item at a time deletion. Added checkboxes to each item in their type view window. (For multi selection/deletion) Fixed missing inheritance document on TorchCommands.cs
1 parent 1a42791 commit b9885f9

19 files changed

Lines changed: 274 additions & 57 deletions

‎Torch.API/ITorchBase.cs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ public interface ITorchBase
138138
/// Has a restart been requested?
139139
/// </summary>
140140
bool IsRestartPending { get; set; }
141+
142+
/// <summary>
143+
/// How many seconds until the next restart?
144+
/// </summary>
145+
int SecondsUntilRestart { get; set; }
141146
}
142147

143148
/// <summary>

‎Torch.Server/Torch.Server.csproj‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
<Compile Include="ViewModels\Entities\CharacterViewModel.cs" />
278278
<Compile Include="ViewModels\ConfigDedicatedViewModel.cs" />
279279
<Compile Include="ViewModels\Entities\EntityControlViewModel.cs" />
280+
<Compile Include="ViewModels\Entities\IEntityModel.cs" />
280281
<Compile Include="ViewModels\ModItemInfo.cs" />
281282
<Compile Include="ViewModels\SessionSettingsViewModel.cs" />
282283
<Compile Include="ViewModels\WorldConfigurationViewModel.cs" />
@@ -290,6 +291,9 @@
290291
<Compile Include="Views\Entities\CharacterView.xaml.cs">
291292
<DependentUpon>CharacterView.xaml</DependentUpon>
292293
</Compile>
294+
<Compile Include="Views\Entities\FloatingObjectsView.xaml.cs">
295+
<DependentUpon>FloatingObjectsView.xaml</DependentUpon>
296+
</Compile>
293297
<Compile Include="Views\Extensions.cs" />
294298
<Compile Include="Views\LogEventViewer.xaml.cs">
295299
<DependentUpon>LogEventViewer.xaml</DependentUpon>
@@ -466,6 +470,7 @@
466470
<Generator>MSBuild:Compile</Generator>
467471
<SubType>Designer</SubType>
468472
</Page>
473+
<Page Include="Views\Entities\FloatingObjectsView.xaml" />
469474
<Page Include="Views\Entities\GridView.xaml">
470475
<SubType>Designer</SubType>
471476
<Generator>MSBuild:Compile</Generator>

‎Torch.Server/ViewModels/Entities/EntityControlViewModel.cs‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
using System.Windows;
1+
using System.Windows;
72

83
namespace Torch.Server.ViewModels.Entities
94
{

‎Torch.Server/ViewModels/Entities/EntityViewModel.cs‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace Torch.Server.ViewModels.Entities
2222
{
23-
public class EntityViewModel : ViewModel
23+
public class EntityViewModel : ViewModel, IEntityModel
2424
{
2525
protected EntityTreeViewModel Tree { get; }
2626

@@ -30,7 +30,7 @@ public class EntityViewModel : ViewModel
3030
public IMyEntity Entity
3131
{
3232
get => _backing;
33-
protected set
33+
private set
3434
{
3535
_backing = value;
3636
OnPropertyChanged();
@@ -139,7 +139,7 @@ public virtual int CompareToSort(EntityViewModel other, EntityTreeViewModel.Sort
139139

140140
public virtual string Position
141141
{
142-
get => Entity?.GetPosition().ToString();
142+
get => Entity?.GetPosition().ToString() ?? "nil";
143143
set
144144
{
145145
if (!Vector3D.TryParse(value, out Vector3D v))
@@ -155,6 +155,13 @@ public virtual string Position
155155

156156
public virtual bool CanDelete => true;
157157

158+
private bool _isMarkedForDelete;
159+
public bool IsMarkedForDelete
160+
{
161+
get => _isMarkedForDelete;
162+
set => SetValue(ref _isMarkedForDelete, value);
163+
}
164+
158165
public virtual void Delete()
159166
{
160167
Entity.Close();
@@ -185,5 +192,21 @@ public int Compare(EntityViewModel x, EntityViewModel y)
185192
return x.CompareToSort(y, _sort);
186193
}
187194
}
195+
196+
// Converts meters to a human-readable KM.
197+
public virtual string PrettyDistance
198+
{
199+
get
200+
{
201+
Vector3D? position = Entity?.GetPosition();
202+
if (position is null) return "nil";
203+
204+
var distance = Vector3D.Distance((Vector3D)position, Vector3D.Zero);
205+
if (distance < 1000)
206+
return $"{distance:N0} m";
207+
208+
return $"{distance / 1000:N2} km";
209+
}
210+
}
188211
}
189212
}
Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
using Sandbox.Game.Entities;
2-
using Torch.Server.ViewModels.Entities;
32

4-
namespace Torch.Server.ViewModels
3+
namespace Torch.Server.ViewModels.Entities
54
{
65
public class FloatingObjectViewModel : EntityViewModel
76
{
87
private MyFloatingObject Floating => (MyFloatingObject)Entity;
98

10-
public override string Name => $"{base.Name} ({Floating.Amount})";
9+
public string Amount
10+
{
11+
get
12+
{
13+
if (Floating == null)
14+
return "nil";
15+
var amt = (int)Floating.Amount.Value;
16+
return amt.ToString();
17+
}
18+
}
1119

1220
public FloatingObjectViewModel(MyFloatingObject floating, EntityTreeViewModel tree) : base(floating, tree) { }
21+
22+
public FloatingObjectViewModel()
23+
{
24+
25+
}
1326
}
1427
}

‎Torch.Server/ViewModels/Entities/GridViewModel.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public MtObservableSortedDictionary<MyCubeBlockDefinition, MtObservableSortedDic
5454
public GridViewModel()
5555
{
5656
}
57-
57+
5858
public GridViewModel(MyCubeGrid grid, EntityTreeViewModel tree) : base(grid, tree)
5959
{
6060
//DescriptiveName = $"{grid.DisplayName} ({grid.BlocksCount} blocks)";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Torch.Server.ViewModels.Entities
2+
{
3+
public interface IEntityModel
4+
{
5+
void Delete();
6+
}
7+
}

‎Torch.Server/ViewModels/EntityTreeViewModel.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public enum SortEnum
3232
//TODO: these should be sorted sets for speed
3333
public MtObservableSortedDictionary<long, GridViewModel> Grids { get; set; } = new MtObservableSortedDictionary<long, GridViewModel>();
3434
public MtObservableSortedDictionary<long, CharacterViewModel> Characters { get; set; } = new MtObservableSortedDictionary<long, CharacterViewModel>();
35-
public MtObservableSortedDictionary<long, EntityViewModel> FloatingObjects { get; set; } = new MtObservableSortedDictionary<long, EntityViewModel>();
35+
public MtObservableSortedDictionary<long, FloatingObjectViewModel> FloatingObjects { get; set; } = new MtObservableSortedDictionary<long, FloatingObjectViewModel>();
3636
public MtObservableSortedDictionary<long, VoxelMapViewModel> VoxelMaps { get; set; } = new MtObservableSortedDictionary<long, VoxelMapViewModel>();
3737
public Dispatcher ControlDispatcher => _control.Dispatcher;
3838

3939
public SortedView<GridViewModel> SortedGrids { get; }
4040
public SortedView<CharacterViewModel> SortedCharacters { get; }
41-
public SortedView<EntityViewModel> SortedFloatingObjects { get; }
41+
public SortedView<FloatingObjectViewModel> SortedFloatingObjects { get; }
4242
public SortedView<VoxelMapViewModel> SortedVoxelMaps { get; }
4343

4444
private EntityViewModel _currentEntity;
@@ -68,7 +68,7 @@ public EntityTreeViewModel(UserControl control)
6868
var comparer = new EntityViewModel.Comparer(_currentSort);
6969
SortedGrids = new SortedView<GridViewModel>(Grids.Values, comparer);
7070
SortedCharacters = new SortedView<CharacterViewModel>(Characters.Values, comparer);
71-
SortedFloatingObjects = new SortedView<EntityViewModel>(FloatingObjects.Values, comparer);
71+
SortedFloatingObjects = new SortedView<FloatingObjectViewModel>(FloatingObjects.Values, comparer);
7272
SortedVoxelMaps = new SortedView<VoxelMapViewModel>(VoxelMaps.Values, comparer);
7373
}
7474

‎Torch.Server/ViewModels/ILazyLoad.cs‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Torch.Server.ViewModels
1+
namespace Torch.Server.ViewModels
82
{
93
public interface ILazyLoad
104
{

‎Torch.Server/Views/Entities/CharacterView.xaml‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,45 @@
1818
<RowDefinition Height="Auto"/>
1919
<RowDefinition Height="Auto"/>
2020
<RowDefinition Height="Auto"/>
21+
<RowDefinition Height="Auto"/>
22+
<RowDefinition Height="Auto"/>
23+
<RowDefinition Height="Auto"/>
2124
<RowDefinition Height="*"/>
2225
</Grid.RowDefinitions>
2326
<StackPanel Grid.Row="0" Orientation="Horizontal">
24-
<Label Content="Name" Width="100"/>
27+
<Label Content="Name" Width="125"/>
2528
<TextBox Text="{Binding Name}" Margin="3"/>
2629
</StackPanel>
2730
<StackPanel Grid.Row="1" Orientation="Horizontal">
28-
<Label Content="Position" Width="100"/>
31+
<Label Content="Position" Width="125"/>
2932
<TextBox Text="{Binding Position}" Margin="3" />
3033
</StackPanel>
3134
<StackPanel Grid.Row="2" Orientation="Horizontal">
32-
<Label Content="SteamID" Width="100" />
33-
<TextBox Name="SelectedPlayerSteamID" Text="{Binding SteamID, Mode=OneWay}" Margin="3" IsReadOnly="True"/>
35+
<Label Content="Distance From Center" Width="125" />
36+
<TextBox Text="{Binding PrettyDistance, Mode=OneWay}" Margin="3" />
3437
</StackPanel>
3538
<StackPanel Grid.Row="3" Orientation="Horizontal">
36-
<Label Content="GameID" Width="100" />
37-
<TextBox Name="PlayerGameID" Text="{Binding GameID, Mode=OneWay}" Margin="3" IsReadOnly="True" />
39+
<Label Content="SteamID" Width="125" />
40+
<TextBox Name="SelectedPlayerSteamID" Text="{Binding SteamID, Mode=OneWay}" Margin="3" IsReadOnly="True"/>
3841
</StackPanel>
3942
<StackPanel Grid.Row="4" Orientation="Horizontal">
40-
<Label Content="Last Login" Width="100" />
41-
<TextBox Text="{Binding LoginTime, Mode=OneWay}" Margin="3" IsReadOnly="True" />
43+
<Label Content="GameID" Width="125" />
44+
<TextBox Name="PlayerGameID" Text="{Binding GameID, Mode=OneWay}" Margin="3" IsReadOnly="True" />
4245
</StackPanel>
4346
<StackPanel Grid.Row="5" Orientation="Horizontal">
44-
<Label Content="Speed" Width="100" />
47+
<Label Content="Last Login" Width="125" />
48+
<TextBox Text="{Binding LoginTime, Mode=OneWay}" Margin="3" IsReadOnly="True" />
49+
</StackPanel>
50+
<StackPanel Grid.Row="6" Orientation="Horizontal">
51+
<Label Content="Speed" Width="125" />
4552
<TextBox Text="{Binding Speed, Mode=OneWay}" Margin="3" IsReadOnly="True" />
4653
</StackPanel>
47-
<StackPanel Grid.Row="6" Orientation="Vertical">
54+
<StackPanel Grid.Row="7" Orientation="Vertical">
4855
<Label Content="Send DM" HorizontalAlignment="Left" />
4956
<TextBox x:Name="DM_TextToPlayer" Height="40" Margin="3"/>
5057
<Button Content="Send" Margin="3" Click="SendDM_ToPlayer"/>
5158
</StackPanel>
52-
<ScrollViewer Grid.Row="7" Margin="3" VerticalScrollBarVisibility="Auto">
59+
<ScrollViewer Grid.Row="8" Margin="3" VerticalScrollBarVisibility="Auto">
5360
<local:EntityControlsView DataContext="{Binding}"/>
5461
</ScrollViewer>
5562
</Grid>

0 commit comments

Comments
 (0)