write shit successfully
This commit is contained in:
@ -29,7 +29,11 @@ namespace BallanceTASEditor.Core {
|
|||||||
Clipboard.SetDataObject(data, true);
|
Clipboard.SetDataObject(data, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
#if DEBUG
|
||||||
|
} catch (Exception e) {
|
||||||
|
#else
|
||||||
} catch {
|
} catch {
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +59,11 @@ namespace BallanceTASEditor.Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#if DEBUG
|
||||||
|
} catch (Exception e) {
|
||||||
|
#else
|
||||||
} catch {
|
} catch {
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -92,7 +92,7 @@ namespace BallanceTASEditor.Core {
|
|||||||
// if state is true, it mean the deleted content is placed before pointer previously.
|
// if state is true, it mean the deleted content is placed before pointer previously.
|
||||||
// so we need shift the pointer to the head of selection range.
|
// so we need shift the pointer to the head of selection range.
|
||||||
// and we should consider 2 situations, the full delete of LinkedList and delete from head
|
// and we should consider 2 situations, the full delete of LinkedList and delete from head
|
||||||
if (mPointerIndex <= absoluteRange.end) {
|
if (mPointerIndex >= absoluteRange.start) {
|
||||||
var newIndex = absoluteRange.start - 1;
|
var newIndex = absoluteRange.start - 1;
|
||||||
if (newIndex < 0) {
|
if (newIndex < 0) {
|
||||||
// this contains 2 situation
|
// this contains 2 situation
|
||||||
|
|||||||
19
Core/Util.cs
19
Core/Util.cs
@ -8,6 +8,19 @@ using System.Text;
|
|||||||
|
|
||||||
namespace BallanceTASEditor.Core {
|
namespace BallanceTASEditor.Core {
|
||||||
public static class Util {
|
public static class Util {
|
||||||
|
public static Int32 ToInt32(this double value) {
|
||||||
|
return (Int32)Math.Floor(value);
|
||||||
|
}
|
||||||
|
public static Int64 ToInt64(this double value) {
|
||||||
|
return (Int64)Math.Floor(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int Clamp(int value, int min, int max) {
|
||||||
|
if (value < min) return min;
|
||||||
|
if (value > max) return max;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool ToBool(this UInt32 num) {
|
public static bool ToBool(this UInt32 num) {
|
||||||
return (num != 0);
|
return (num != 0);
|
||||||
}
|
}
|
||||||
@ -29,11 +42,11 @@ namespace BallanceTASEditor.Core {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LinkedListNode<FrameData> FastGetNode(this LinkedList<FrameData> ls, LinkedListNode<FrameData> refNode, long refIndex, long targetIndex) {
|
public static LinkedListNode<FrameData> FastGetNode(this LinkedList<FrameData> ls, LinkedListNode<FrameData> refNode, long refIndex, long targetIndex) {
|
||||||
long count = ls.Count;
|
long count = ls.Count - 1;
|
||||||
if (targetIndex >= count || refIndex >= count) throw new Exception("Index is invalid!");
|
if (targetIndex > count || refIndex > count) throw new Exception("Index is invalid!");
|
||||||
var span = new StupidSortStruct[3] {
|
var span = new StupidSortStruct[3] {
|
||||||
new StupidSortStruct() { type = 1, data = targetIndex },
|
new StupidSortStruct() { type = 1, data = targetIndex },
|
||||||
new StupidSortStruct() { type = 2, data = count - targetIndex },
|
new StupidSortStruct() { type = 2, data = targetIndex - count },
|
||||||
new StupidSortStruct() { type = 3, data = targetIndex - refIndex }
|
new StupidSortStruct() { type = 3, data = targetIndex - refIndex }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:BallanceTASEditor"
|
xmlns:local="clr-namespace:BallanceTASEditor"
|
||||||
xmlns:controls="clr-namespace:BallanceTASEditor.UI"
|
xmlns:controls="clr-namespace:BallanceTASEditor.UI"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Ballance TAS Editor" Height="500" Width="800">
|
Title="Ballance TAS Editor" Height="500" Width="800" KeyUp="funcWindow_KeyUp">
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -85,14 +85,14 @@
|
|||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Button Grid.Column="0" Margin="2" HorizontalAlignment="Center">
|
<Button x:Name="uiBtn_FastMovePrev" Grid.Column="0" Margin="2" HorizontalAlignment="Center" Click="funcBtn_FastMovePrev">
|
||||||
<Viewbox Width="16" Height="16">
|
<Viewbox Width="16" Height="16">
|
||||||
<Canvas Width="24" Height="24">
|
<Canvas Width="24" Height="24">
|
||||||
<Path Fill="Black" Data="M11.5,12L20,18V6M11,18V6L2.5,12L11,18Z" />
|
<Path Fill="Black" Data="M11.5,12L20,18V6M11,18V6L2.5,12L11,18Z" />
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</Viewbox>
|
</Viewbox>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="1" Margin="2" HorizontalAlignment="Center">
|
<Button x:Name="uiBtn_MovePrev" Grid.Column="1" Margin="2" HorizontalAlignment="Center" Click="funcBtn_MovePrev">
|
||||||
<Viewbox Width="16" Height="16" RenderTransformOrigin="0.5,0.5">
|
<Viewbox Width="16" Height="16" RenderTransformOrigin="0.5,0.5">
|
||||||
<Viewbox.RenderTransform>
|
<Viewbox.RenderTransform>
|
||||||
<RotateTransform Angle="-90"/>
|
<RotateTransform Angle="-90"/>
|
||||||
@ -102,7 +102,7 @@
|
|||||||
</Canvas>
|
</Canvas>
|
||||||
</Viewbox>
|
</Viewbox>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="2" Margin="2" HorizontalAlignment="Center">
|
<Button x:Name="uiBtn_MoveNext" Grid.Column="2" Margin="2" HorizontalAlignment="Center" Click="funcBtn_MoveNext">
|
||||||
<Viewbox Width="16" Height="16" RenderTransformOrigin="0.5,0.5">
|
<Viewbox Width="16" Height="16" RenderTransformOrigin="0.5,0.5">
|
||||||
<Viewbox.RenderTransform>
|
<Viewbox.RenderTransform>
|
||||||
<RotateTransform Angle="-90"/>
|
<RotateTransform Angle="-90"/>
|
||||||
@ -112,7 +112,7 @@
|
|||||||
</Canvas>
|
</Canvas>
|
||||||
</Viewbox>
|
</Viewbox>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Column="3" Margin="2" HorizontalAlignment="Center">
|
<Button x:Name="uiBtn_FastMoveNext" Grid.Column="3" Margin="2" HorizontalAlignment="Center" Click="funcBtn_FastMoveNext">
|
||||||
<Viewbox Width="16" Height="16">
|
<Viewbox Width="16" Height="16">
|
||||||
<Canvas Width="24" Height="24">
|
<Canvas Width="24" Height="24">
|
||||||
<Path Fill="Black" Data="M13,6V18L21.5,12M4,18L12.5,12L4,6V18Z" />
|
<Path Fill="Black" Data="M13,6V18L21.5,12M4,18L12.5,12L4,6V18Z" />
|
||||||
|
|||||||
@ -86,6 +86,43 @@ namespace BallanceTASEditor {
|
|||||||
ChangeToolMode(ToolMode.Overwrite);
|
ChangeToolMode(ToolMode.Overwrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// move btn
|
||||||
|
|
||||||
|
private void funcBtn_FastMovePrev(object sender, RoutedEventArgs e) {
|
||||||
|
MoveSliderManually(true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void funcBtn_MovePrev(object sender, RoutedEventArgs e) {
|
||||||
|
MoveSliderManually(true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void funcBtn_MoveNext(object sender, RoutedEventArgs e) {
|
||||||
|
MoveSliderManually(false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void funcBtn_FastMoveNext(object sender, RoutedEventArgs e) {
|
||||||
|
MoveSliderManually(false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// move keyboard
|
||||||
|
|
||||||
|
private void funcWindow_KeyUp(object sender, KeyEventArgs e) {
|
||||||
|
switch(e.Key) {
|
||||||
|
case Key.A:
|
||||||
|
MoveSliderManually(true, true);
|
||||||
|
break;
|
||||||
|
case Key.S:
|
||||||
|
MoveSliderManually(true, false);
|
||||||
|
break;
|
||||||
|
case Key.D:
|
||||||
|
MoveSliderManually(false, false);
|
||||||
|
break;
|
||||||
|
case Key.F:
|
||||||
|
MoveSliderManually(false, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@ -151,5 +188,10 @@ namespace BallanceTASEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MoveSliderManually(bool isPrev, bool isFast) {
|
||||||
|
var step = isFast ? mViewer.GetItemCountInPage() : 1;
|
||||||
|
uiTASSlider.Value = Util.Clamp(uiTASSlider.Value.ToInt32() + (isPrev ? -1 : 1) * step, uiTASSlider.Minimum.ToInt32(), uiTASSlider.Maximum.ToInt32());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:BallanceTASEditor.UI"
|
xmlns:local="clr-namespace:BallanceTASEditor.UI"
|
||||||
xmlns:converter="clr-namespace:BallanceTASEditor.UI"
|
xmlns:converter="clr-namespace:BallanceTASEditor.UI"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Add Item" Height="200" Width="400">
|
Title="Add Item" Height="200" Width="400" WindowStyle="ToolWindow" WindowStartupLocation="CenterOwner">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<converter:AddItemConverter x:Key="conv_addItem"/>
|
<converter:AddItemConverter x:Key="conv_addItem"/>
|
||||||
<converter:FPS2DeltaTimeConverter x:Key="conv_fps2DeltaTime"/>
|
<converter:FPS2DeltaTimeConverter x:Key="conv_fps2DeltaTime"/>
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:BallanceTASEditor.UI"
|
xmlns:local="clr-namespace:BallanceTASEditor.UI"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="400" d:DesignWidth="800">
|
d:DesignHeight="400" d:DesignWidth="800">
|
||||||
<Grid x:Name="uiCoreWindow">
|
<Grid x:Name="uiCoreWindow" Background="#ffffff">
|
||||||
<Grid.ContextMenu>
|
<Grid.ContextMenu>
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem x:Name="uiDataMenu_Set" Header="Set"/>
|
<MenuItem x:Name="uiDataMenu_Set" Header="Set"/>
|
||||||
|
|||||||
@ -76,7 +76,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
List<FrameDataDisplay> mDataSource;
|
List<FrameDataDisplay> mDataSource;
|
||||||
|
|
||||||
private void sliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
private void sliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) {
|
||||||
long pos = Convert.ToInt64(Math.Floor(e.NewValue));
|
long pos = e.NewValue.ToInt64();
|
||||||
mFile.Shift(pos);
|
mFile.Shift(pos);
|
||||||
|
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
@ -159,7 +159,9 @@ namespace BallanceTASEditor.UI {
|
|||||||
mSelectionHelp.SetMode(mode);
|
mSelectionHelp.SetMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int GetItemCountInPage() {
|
||||||
|
return mListLength;
|
||||||
|
}
|
||||||
|
|
||||||
#region data menu
|
#region data menu
|
||||||
|
|
||||||
@ -168,6 +170,7 @@ namespace BallanceTASEditor.UI {
|
|||||||
|
|
||||||
var pos = mSelectionHelp.GetPoint();
|
var pos = mSelectionHelp.GetPoint();
|
||||||
mFile.Add(pos, count, deltaTime, true);
|
mFile.Add(pos, count, deltaTime, true);
|
||||||
|
updateSliderRange();
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,23 +179,39 @@ namespace BallanceTASEditor.UI {
|
|||||||
|
|
||||||
var pos = mSelectionHelp.GetPoint();
|
var pos = mSelectionHelp.GetPoint();
|
||||||
mFile.Add(pos, count, deltaTime, false);
|
mFile.Add(pos, count, deltaTime, false);
|
||||||
|
updateSliderRange();
|
||||||
RefreshDisplay();
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcDataMenu_PasteBefore(object sender, RoutedEventArgs e) {
|
private void funcDataMenu_PasteBefore(object sender, RoutedEventArgs e) {
|
||||||
throw new NotImplementedException();
|
var data = new LinkedList<FrameData>();
|
||||||
|
if (ClipboardUtil.GetFrameData(data)) {
|
||||||
|
mFile.Insert(mSelectionHelp.GetPoint(), data, true);
|
||||||
|
updateSliderRange();
|
||||||
|
RefreshDisplay();
|
||||||
|
} else MessageBox.Show("Fail to paste due to unknow reason or blank clipboard!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcDataMenu_PasteAfter(object sender, RoutedEventArgs e) {
|
private void funcDataMenu_PasteAfter(object sender, RoutedEventArgs e) {
|
||||||
throw new NotImplementedException();
|
var data = new LinkedList<FrameData>();
|
||||||
|
if (ClipboardUtil.GetFrameData(data)) {
|
||||||
|
mFile.Insert(mSelectionHelp.GetPoint(), data, false);
|
||||||
|
updateSliderRange();
|
||||||
|
RefreshDisplay();
|
||||||
|
} else MessageBox.Show("Fail to paste due to unknow reason or blank clipboard!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcDataMenu_Delete(object sender, RoutedEventArgs e) {
|
private void funcDataMenu_Delete(object sender, RoutedEventArgs e) {
|
||||||
throw new NotImplementedException();
|
mFile.Remove(mSelectionHelp.GetRange());
|
||||||
|
updateSliderRange();
|
||||||
|
RefreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcDataMenu_Copy(object sender, RoutedEventArgs e) {
|
private void funcDataMenu_Copy(object sender, RoutedEventArgs e) {
|
||||||
throw new NotImplementedException();
|
var data = new LinkedList<FrameData>();
|
||||||
|
mFile.Copy(mSelectionHelp.GetRange(), data);
|
||||||
|
if (!ClipboardUtil.SetFrameData(data))
|
||||||
|
MessageBox.Show("Fail to copy due to unknow reason!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void funcDataMenu_Unset(object sender, RoutedEventArgs e) {
|
private void funcDataMenu_Unset(object sender, RoutedEventArgs e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user