sh*t
This commit is contained in:
@ -56,8 +56,11 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="StyleConverter.cs" />
|
||||
<Compile Include="TASViewer.cs" />
|
||||
<Compile Include="UI\StyleConverter.cs" />
|
||||
<Compile Include="UI\TASFlow.xaml.cs">
|
||||
<DependentUpon>TASFlow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="UI\TASViewer.cs" />
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@ -70,11 +73,15 @@
|
||||
<Compile Include="Core\TASStruct.cs" />
|
||||
<Compile Include="Core\Util.cs" />
|
||||
<Compile Include="Core\ZlibUtil.cs" />
|
||||
<Compile Include="DialogUtil.cs" />
|
||||
<Compile Include="UI\DialogUtil.cs" />
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="UI\TASFlow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
|
||||
@ -38,15 +38,26 @@ namespace BallanceTASEditor.Core {
|
||||
}
|
||||
}
|
||||
|
||||
public int Get(ObservableCollection<FrameDataDisplay> container, long startIndex, int count) {
|
||||
if (mPointer == null) return 0;
|
||||
public void Get(List<FrameDataDisplay> container, long startIndex, int count) {
|
||||
// no item. clean container
|
||||
if (mPointer == null) {
|
||||
for(int j = 0; j < count; j++) {
|
||||
container[j].isEnable = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// fill container
|
||||
var cachePointer = mPointer;
|
||||
int i;
|
||||
for(i = 0; i < count && cachePointer != null; i++, startIndex++) {
|
||||
container[i].Reload(startIndex, cachePointer.Value);
|
||||
container[i].isEnable = true;
|
||||
cachePointer = cachePointer.Next;
|
||||
}
|
||||
return i;
|
||||
for(; i < count; i++) {
|
||||
container[i].isEnable = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Set(FrameDataField field, long prevRange, long nextRange, bool isSet) {
|
||||
|
||||
@ -8,6 +8,7 @@ using System.Text;
|
||||
namespace BallanceTASEditor.Core.TASStruct {
|
||||
public class FrameDataDisplay : INotifyPropertyChanged {
|
||||
public FrameDataDisplay(long index, FrameData fd) {
|
||||
isEnable = true;
|
||||
Reload(index, fd);
|
||||
}
|
||||
|
||||
@ -26,6 +27,7 @@ namespace BallanceTASEditor.Core.TASStruct {
|
||||
this.keystates = fd.keystates;
|
||||
}
|
||||
|
||||
public bool isEnable { get; set; }
|
||||
public long index { get; set; }
|
||||
public float deltaTime { get; set; }
|
||||
public UInt32 keystates {
|
||||
|
||||
225
MainWindow.xaml
225
MainWindow.xaml
@ -4,14 +4,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:BallanceTASEditor"
|
||||
xmlns:converter="clr-namespace:BallanceTASEditor"
|
||||
xmlns:controls="clr-namespace:BallanceTASEditor.UI"
|
||||
mc:Ignorable="d"
|
||||
Title="Ballance TAS Editor" Height="800" Width="500">
|
||||
<Window.Resources>
|
||||
<converter:BackgroundConverter x:Key="bgConv"></converter:BackgroundConverter>
|
||||
<converter:FloatConverter x:Key="floatConv"></converter:FloatConverter>
|
||||
<converter:LongConverter x:Key="longConv"></converter:LongConverter>
|
||||
</Window.Resources>
|
||||
Title="Ballance TAS Editor" Height="500" Width="800">
|
||||
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@ -27,6 +22,9 @@
|
||||
<MenuItem x:Name="uiMenu_File_SaveAs" Header="Save As..." Click="funcMenu_File_SaveAs"/>
|
||||
<MenuItem x:Name="uiMenu_File_Close" Header="Close" Click="funcMenu_File_Close"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Display">
|
||||
<MenuItem x:Name="uiMenu_Display_ItemCount" Header="Item Count"/>
|
||||
</MenuItem>
|
||||
<MenuItem Header="Help">
|
||||
<MenuItem x:Name="uiMenu_Help_ReportBugs" Header="Report bugs" Click="funcMenu_Help_ReportBugs"/>
|
||||
<MenuItem x:Name="uiMenu_Help_About" Header="About" Click="funcMenu_Help_About"/>
|
||||
@ -39,11 +37,8 @@
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="0" Grid.ColumnSpan="2">
|
||||
<Button x:Name="uiBtn_Select" Margin="5" Padding="5">
|
||||
@ -78,181 +73,55 @@
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<DataGrid x:Name="uiTASData" ItemsSource="{Binding}" Grid.Column="0" Grid.Row="1" CanUserReorderColumns="False" CanUserSortColumns="False" IsReadOnly="true" AutoGenerateColumns="False" SelectionUnit="Cell" SelectionMode="Single" Background="#00000000" BorderThickness="1" Margin="5" HorizontalScrollBarVisibility="Visible">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Frame" Binding="{Binding index,Converter={StaticResource longConv},Mode=OneWay}"/>
|
||||
<DataGridTextColumn Header="Delta Time" Binding="{Binding deltaTime,Converter={StaticResource floatConv},Mode=OneWay}"/>
|
||||
<controls:TASFlow x:Name="uiTASData" Grid.Row="1" Margin="5" BorderThickness="1" BorderBrush="Gray">
|
||||
</controls:TASFlow>
|
||||
|
||||
<DataGridTemplateColumn Header="^" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_up,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="v" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_down,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="<" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_left,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header=">" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_right,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="shift" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_shift,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="space" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_space,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="q" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_q,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="esc" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_esc,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTemplateColumn Header="enter" Width="30" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid>
|
||||
<Grid.Background>
|
||||
<SolidColorBrush Color="{Binding key_enter,Converter={StaticResource bgConv},Mode=OneWay}"/>
|
||||
</Grid.Background>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
<Grid Grid.Row="2" Margin="5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem x:Name="uiDataMenu_Set" Header="Set"/>
|
||||
<MenuItem x:Name="uiDataMenu_Unset" Header="Unset"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_Copy" Header="Copy"/>
|
||||
<MenuItem x:Name="uiDataMenu_Delete" Header="Delete"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_PasteAfter" Header="Paste after this"/>
|
||||
<MenuItem x:Name="uiDataMenu_PasteBefore" Header="Paste before this"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_AddAfter" Header="Add blank item after this"/>
|
||||
<MenuItem x:Name="uiDataMenu_AddBefore" Header="Add blank item before this"/>
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
</DataGrid>
|
||||
|
||||
<Grid Grid.Column="1" Grid.Row="1" Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Button Grid.Row="0" RenderTransformOrigin="0.5,0.5" Margin="2" HorizontalAlignment="Center">
|
||||
<Button.RenderTransform>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Button.RenderTransform>
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M13,6V18L21.5,12M4,18L12.5,12L4,6V18Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Row="1" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M7,15L12,10L17,15H7Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Slider x:Name="uiTASSlider" Margin="0, 5, 0, 5" Grid.Row="2" Orientation="Vertical" RenderTransformOrigin="0.5,0.5" SmallChange="1" LargeChange="10" Maximum="1" HorizontalAlignment="Center">
|
||||
<Slider.LayoutTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleY="-1" ScaleX="1"/>
|
||||
<SkewTransform AngleY="0" AngleX="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform/>
|
||||
</TransformGroup>
|
||||
</Slider.LayoutTransform>
|
||||
</Slider>
|
||||
<Button Grid.Row="3" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M7,10L12,15L17,10H7Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Row="4" RenderTransformOrigin="0.5,0.5" Margin="2" HorizontalAlignment="Center">
|
||||
<Button.RenderTransform>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Button.RenderTransform>
|
||||
<Button Grid.Column="0" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M11.5,12L20,18V6M11,18V6L2.5,12L11,18Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Column="1" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16" RenderTransformOrigin="0.5,0.5">
|
||||
<Viewbox.RenderTransform>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Viewbox.RenderTransform>
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M7,15L12,10L17,15H7Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Column="2" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16" RenderTransformOrigin="0.5,0.5">
|
||||
<Viewbox.RenderTransform>
|
||||
<RotateTransform Angle="-90"/>
|
||||
</Viewbox.RenderTransform>
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M7,10L12,15L17,10H7Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Button Grid.Column="3" Margin="2" HorizontalAlignment="Center">
|
||||
<Viewbox Width="16" Height="16">
|
||||
<Canvas Width="24" Height="24">
|
||||
<Path Fill="Black" Data="M13,6V18L21.5,12M4,18L12.5,12L4,6V18Z" />
|
||||
</Canvas>
|
||||
</Viewbox>
|
||||
</Button>
|
||||
<Slider x:Name="uiTASSlider" Margin="5,0,0,0" Grid.Column="4" SmallChange="1" LargeChange="10" Maximum="1" VerticalAlignment="Center">
|
||||
</Slider>
|
||||
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using BallanceTASEditor.Core;
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using BallanceTASEditor.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
namespace BallanceTASEditor.UI {
|
||||
public class DialogUtil {
|
||||
|
||||
public static string OpenFileDialog() {
|
||||
@ -6,7 +6,7 @@ using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
namespace BallanceTASEditor.UI {
|
||||
|
||||
[ValueConversion(typeof(bool), typeof(Color))]
|
||||
public class BackgroundConverter : IValueConverter {
|
||||
56
UI/TASFlow.xaml
Normal file
56
UI/TASFlow.xaml
Normal file
@ -0,0 +1,56 @@
|
||||
<UserControl x:Class="BallanceTASEditor.UI.TASFlow"
|
||||
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:local="clr-namespace:BallanceTASEditor.UI"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="400" d:DesignWidth="800">
|
||||
<Grid x:Name="uiCoreWindow">
|
||||
<Grid.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem x:Name="uiDataMenu_Set" Header="Set"/>
|
||||
<MenuItem x:Name="uiDataMenu_Unset" Header="Unset"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_Copy" Header="Copy"/>
|
||||
<MenuItem x:Name="uiDataMenu_Delete" Header="Delete"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_PasteAfter" Header="Paste after this"/>
|
||||
<MenuItem x:Name="uiDataMenu_PasteBefore" Header="Paste before this"/>
|
||||
<Separator/>
|
||||
<MenuItem x:Name="uiDataMenu_AddAfter" Header="Add blank item after this"/>
|
||||
<MenuItem x:Name="uiDataMenu_AddBefore" Header="Add blank item before this"/>
|
||||
</ContextMenu>
|
||||
</Grid.ContextMenu>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="0" Text="Frame"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="1" Text="Delta Time"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="2" Text="^"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="3" Text="v"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="4" Text="<"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="5" Text=">"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="6" Text="shift"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="7" Text="space"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="8" Text="q"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="9" Text="esc"/>
|
||||
<TextBlock Padding="2" Background="#afafaf" Grid.Column="0" Grid.Row="10" Text="enter"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
154
UI/TASFlow.xaml.cs
Normal file
154
UI/TASFlow.xaml.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using BallanceTASEditor.Core.TASStruct;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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 BallanceTASEditor.UI {
|
||||
/// <summary>
|
||||
/// TASFlow.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class TASFlow : UserControl {
|
||||
public TASFlow() {
|
||||
InitializeComponent();
|
||||
mItemList = new List<TASFlowUIItem>();
|
||||
mItemCount = 0;
|
||||
SetItemCount(1);
|
||||
}
|
||||
|
||||
private int mItemCount;
|
||||
private List<TASFlowUIItem> mItemList;
|
||||
public List<FrameDataDisplay> DataSources { get; set; }
|
||||
|
||||
public void RefreshDataSources() {
|
||||
if (DataSources == null) return;
|
||||
|
||||
for (int i = 0; i < mItemCount; i++) {
|
||||
mItemList[i].Reload(DataSources[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetItemCount(int newCount) {
|
||||
var offset = newCount - mItemCount;
|
||||
var abs = Math.Abs(offset);
|
||||
if (offset == 0) return;
|
||||
|
||||
// change column defination first
|
||||
if (offset > 0) {
|
||||
for(int i = 0; i < abs; i++) {
|
||||
var item = new ColumnDefinition();
|
||||
item.Width = GridLength.Auto;
|
||||
uiCoreWindow.ColumnDefinitions.Add(item);
|
||||
}
|
||||
} else {
|
||||
uiCoreWindow.ColumnDefinitions.RemoveRange(newCount + 1, abs); // the first col is sheet header, so add 1 additionally
|
||||
}
|
||||
|
||||
// add / remove item
|
||||
if (offset > 0) {
|
||||
for (int i = 0; i < abs; i++) {
|
||||
var newItem = new TASFlowUIItem(mItemCount + 1 + i); // the first col is sheet header, so add 1 additionally
|
||||
newItem.Add(uiCoreWindow);
|
||||
mItemList.Add(newItem);
|
||||
}
|
||||
} else {
|
||||
for(int i = 0; i < abs; i++) {
|
||||
mItemList[mItemCount].Remove(uiCoreWindow);
|
||||
}
|
||||
mItemList.RemoveRange(newCount, abs);
|
||||
}
|
||||
|
||||
// apply new count
|
||||
mItemCount = newCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class TASFlowUIItem {
|
||||
private static readonly Thickness DEFAULT_MARGIN = new Thickness(2);
|
||||
private static readonly Thickness RECT_MARGIN = new Thickness(1);
|
||||
private static readonly SolidColorBrush RECT_STROKE = new SolidColorBrush(Colors.Gray);
|
||||
private static readonly Color COLOR_SET = Color.FromRgb(30, 144, 255);
|
||||
private static readonly Color COLOR_UNSET = Color.FromArgb(0, 255, 255, 255);
|
||||
private const int KEY_COUNT = 9;
|
||||
|
||||
public TASFlowUIItem(int column) {
|
||||
// basic item
|
||||
frame = new TextBlock();
|
||||
deltaTime = new TextBlock();
|
||||
|
||||
Grid.SetRow(frame, 0);
|
||||
Grid.SetRow(deltaTime, 1);
|
||||
Grid.SetColumn(frame, column);
|
||||
Grid.SetColumn(deltaTime, column);
|
||||
|
||||
frame.Margin = DEFAULT_MARGIN;
|
||||
deltaTime.Margin = DEFAULT_MARGIN;
|
||||
|
||||
// keystates item
|
||||
keystates = new Rectangle[KEY_COUNT];
|
||||
keystatesFill = new SolidColorBrush[KEY_COUNT];
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
keystates[i] = new Rectangle();
|
||||
keystatesFill[i] = new SolidColorBrush(COLOR_UNSET);
|
||||
Grid.SetRow(keystates[i], 2 + i);
|
||||
Grid.SetColumn(keystates[i], column);
|
||||
keystates[i].Margin = RECT_MARGIN;
|
||||
keystates[i].StrokeThickness = 1;
|
||||
keystates[i].Stroke = RECT_STROKE;
|
||||
keystates[i].Fill = keystatesFill[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void Add(Grid target) {
|
||||
target.Children.Add(frame);
|
||||
target.Children.Add(deltaTime);
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
target.Children.Add(keystates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Remove(Grid target) {
|
||||
target.Children.Remove(frame);
|
||||
target.Children.Remove(deltaTime);
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
target.Children.Remove(keystates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reload(FrameDataDisplay fdd) {
|
||||
var isEnable = fdd.isEnable;
|
||||
frame.Text = isEnable ? fdd.index.ToString() : "";
|
||||
deltaTime.Text = isEnable ? fdd.deltaTime.ToString() : "";
|
||||
keystatesFill[0].Color = isEnable && fdd.key_up ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[1].Color = isEnable && fdd.key_down ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[2].Color = isEnable && fdd.key_left ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[3].Color = isEnable && fdd.key_right ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[4].Color = isEnable && fdd.key_shift ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[5].Color = isEnable && fdd.key_space ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[6].Color = isEnable && fdd.key_q ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[7].Color = isEnable && fdd.key_esc ? COLOR_SET : COLOR_UNSET;
|
||||
keystatesFill[8].Color = isEnable && fdd.key_enter ? COLOR_SET : COLOR_UNSET;
|
||||
|
||||
frame.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed;
|
||||
deltaTime.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed;
|
||||
for (int i = 0; i < KEY_COUNT; i++) {
|
||||
keystates[i].Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
public TextBlock frame;
|
||||
public TextBlock deltaTime;
|
||||
public Rectangle[] keystates;
|
||||
private SolidColorBrush[] keystatesFill;
|
||||
}
|
||||
}
|
||||
@ -8,9 +8,9 @@ using System.Collections.ObjectModel;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows;
|
||||
|
||||
namespace BallanceTASEditor {
|
||||
namespace BallanceTASEditor.UI {
|
||||
public class TASViewer : IDisposable {
|
||||
public TASViewer(TASFile file, Slider slider, DataGrid datagrid) {
|
||||
public TASViewer(TASFile file, Slider slider, TASFlow datagrid) {
|
||||
mFile = file;
|
||||
mSlider = slider;
|
||||
mDataGrid = datagrid;
|
||||
@ -21,7 +21,7 @@ namespace BallanceTASEditor {
|
||||
|
||||
// init data
|
||||
mPosition = 0;
|
||||
mDataSource = new ObservableCollection<FrameDataDisplay>();
|
||||
mDataSource = new List<FrameDataDisplay>();
|
||||
INVALID_FRAME_DATA = new FrameData(-1f, 0);
|
||||
for (int i = 0; i < DATA_LIST_LENGTH; i++) {
|
||||
mDataSource.Add(new FrameDataDisplay(0, INVALID_FRAME_DATA));
|
||||
@ -29,32 +29,32 @@ namespace BallanceTASEditor {
|
||||
mFile.Get(mDataSource, 0, DATA_LIST_LENGTH);
|
||||
|
||||
// bind event and source
|
||||
mDataGrid.ItemsSource = mDataSource;
|
||||
mDataGrid.SetItemCount(DATA_LIST_LENGTH);
|
||||
mDataGrid.DataSources = mDataSource;
|
||||
mDataGrid.RefreshDataSources();
|
||||
mSlider.ValueChanged += sliderValueChanged;
|
||||
}
|
||||
public void Dispose() {
|
||||
mDataGrid.ItemsSource = null;
|
||||
mDataGrid.DataSources = null;
|
||||
mSlider.ValueChanged -= sliderValueChanged;
|
||||
}
|
||||
|
||||
const int DATA_LIST_LENGTH = 30;
|
||||
const int DATA_LIST_LENGTH = 15;
|
||||
FrameData INVALID_FRAME_DATA;
|
||||
TASFile mFile;
|
||||
Slider mSlider;
|
||||
DataGrid mDataGrid;
|
||||
TASFlow mDataGrid;
|
||||
long mPosition;
|
||||
ObservableCollection<FrameDataDisplay> mDataSource;
|
||||
List<FrameDataDisplay> mDataSource;
|
||||
|
||||
private void sliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||
long pos = Convert.ToInt64(Math.Floor(e.NewValue));
|
||||
long offset = pos - mPosition;
|
||||
mFile.Shift(offset);
|
||||
var gotten = mFile.Get(mDataSource, pos, DATA_LIST_LENGTH);
|
||||
for(; gotten < DATA_LIST_LENGTH; gotten++) {
|
||||
mDataSource[gotten].Reload(-1, INVALID_FRAME_DATA);
|
||||
}
|
||||
mFile.Get(mDataSource, pos, DATA_LIST_LENGTH);
|
||||
|
||||
mPosition = pos;
|
||||
mDataGrid.RefreshDataSources();
|
||||
}
|
||||
|
||||
private void updateSliderRange() {
|
||||
Reference in New Issue
Block a user