write shit

This commit is contained in:
2021-05-16 14:15:35 +08:00
parent dac0c36483
commit 2adefe86f4
10 changed files with 489 additions and 67 deletions

View File

@ -87,7 +87,7 @@ namespace BallanceTASEditor.UI {
if (mMode == ToolMode.Fill) throw new Exception("Read with wrong mode.");
if (!mIsStartConfirmed) throw new Exception("Data is not ready to read");
if (mMode == ToolMode.Cursor) return mStart;
if (mMode == ToolMode.Overwrite) return mStart;
else {
// cursor mode
if (mIsStartConfirmed) return mStart;
@ -95,6 +95,13 @@ namespace BallanceTASEditor.UI {
}
}
public FrameDataField GetPointField() {
if (mMode != ToolMode.Overwrite) throw new Exception("Read with wrong mode.");
if (!mIsStartConfirmed) throw new Exception("Data is not ready to read");
return mStartField;
}
public bool IsDataReady() {
switch (mMode) {
case ToolMode.Cursor:

View File

@ -1,4 +1,5 @@
using BallanceTASEditor.Core.TASStruct;
using BallanceTASEditor.Core;
using BallanceTASEditor.Core.TASStruct;
using System;
using System.Collections.Generic;
using System.Linq;
@ -26,6 +27,8 @@ namespace BallanceTASEditor.UI {
SetItemCount(1);
}
public event Action Click;
private int mItemCount;
private List<TASFlowUIItem> mItemList;
private Dictionary<Rectangle, CellPosition> mRectMap;
@ -147,10 +150,21 @@ namespace BallanceTASEditor.UI {
var pos = mRectMap[rect];
if (!mItemList[pos.column - 1].rawIsEnable) return;
if (e.MouseDevice.LeftButton == MouseButtonState.Pressed) {
SelectionHelp.FirstClick(mItemList[pos.column - 1].rawFrame, pos.field);
} else if (e.MouseDevice.RightButton == MouseButtonState.Pressed) {
SelectionHelp.LastClick(mItemList[pos.column - 1].rawFrame, pos.field);
if (KeyboardState.IsKeyPressed(KeyboardState.VirtualKeyStates.VK_SHIFT)) {
SelectionHelp.LastClick(mItemList[pos.column - 1].rawFrame, pos.field);
} else {
SelectionHelp.FirstClick(mItemList[pos.column - 1].rawFrame, pos.field);
}
}
// note main window to process it.
OnClick();
}
// only raised in overwrite mode
private void OnClick() {
if (SelectionHelp.GetToolMode() == ToolMode.Overwrite)
Click?.Invoke();
}
}
@ -159,12 +173,12 @@ namespace BallanceTASEditor.UI {
private static readonly Thickness DEFAULT_MARGIN = new Thickness(2);
private static readonly Thickness RECT_MARGIN = new Thickness(1);
private static readonly SolidColorBrush SEL_RECT_NORMAL_BRUSH = new SolidColorBrush(Colors.White);
private static readonly SolidColorBrush SEL_RECT_SELECTED_BRUSH = new SolidColorBrush(Colors.Orange);
private static readonly SolidColorBrush SEL_RECT_STROKE = new SolidColorBrush(Colors.Gray);
private static readonly SolidColorBrush SEL_RECT_SELECTED_BRUSH = new SolidColorBrush(Colors.OrangeRed);
private static readonly SolidColorBrush SEL_RECT_STROKE = new SolidColorBrush(Colors.LightGray);
private static readonly Color COLOR_SET = Color.FromRgb(30, 144, 255);
private static readonly Color COLOR_UNSET = Color.FromArgb(0, 255, 255, 255);
private static readonly Color COLOR_SELECTED = Colors.Orange;
private static readonly Color COLOR_UNSELECTED = Colors.Gray;
private static readonly Color COLOR_SELECTED = Colors.OrangeRed;
private static readonly Color COLOR_UNSELECTED = Colors.LightGray;
private const int KEY_COUNT = 9;
private const double SELECTION_HEADER_HEIGHT = 10.0f;
@ -185,7 +199,7 @@ namespace BallanceTASEditor.UI {
frame.Margin = DEFAULT_MARGIN;
deltaTime.Margin = DEFAULT_MARGIN;
sel_rect.StrokeThickness = 3;
sel_rect.StrokeThickness = 2;
sel_rect.Stroke = SEL_RECT_STROKE;
sel_rect.Height = SELECTION_HEADER_HEIGHT;
@ -246,6 +260,7 @@ namespace BallanceTASEditor.UI {
keystatesFill[7].Color = isEnable && fdd.key_esc ? COLOR_SET : COLOR_UNSET;
keystatesFill[8].Color = isEnable && fdd.key_enter ? COLOR_SET : COLOR_UNSET;
sel_rect.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed;
frame.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed;
deltaTime.Visibility = isEnable ? Visibility.Visible : Visibility.Collapsed;
for (int i = 0; i < KEY_COUNT; i++) {

View File

@ -33,6 +33,17 @@ namespace BallanceTASEditor.UI {
// bind event and source
mDataGrid.DataSources = mDataSource;
mDataGrid.SelectionHelp = mSelectionHelp;
mDataGrid.uiDataMenu_Set.Click += funcDataMenu_Set;
mDataGrid.uiDataMenu_Unset.Click += funcDataMenu_Unset;
mDataGrid.uiDataMenu_Copy.Click += funcDataMenu_Copy;
mDataGrid.uiDataMenu_Delete.Click += funcDataMenu_Delete;
mDataGrid.uiDataMenu_PasteAfter.Click += funcDataMenu_PasteAfter;
mDataGrid.uiDataMenu_PasteBefore.Click += funcDataMenu_PasteBefore;
mDataGrid.uiDataMenu_AddAfter.Click += funcDataMenu_AddAfter;
mDataGrid.uiDataMenu_AddBefore.Click += funcDataMenu_AddBefore;
mDataGrid.Click += funcDataMenu_Click;
mSlider.ValueChanged += sliderValueChanged;
// display data
@ -41,6 +52,17 @@ namespace BallanceTASEditor.UI {
public void Dispose() {
mDataGrid.DataSources = null;
mDataGrid.uiDataMenu_Set.Click -= funcDataMenu_Set;
mDataGrid.uiDataMenu_Unset.Click -= funcDataMenu_Unset;
mDataGrid.uiDataMenu_Copy.Click -= funcDataMenu_Copy;
mDataGrid.uiDataMenu_Delete.Click -= funcDataMenu_Delete;
mDataGrid.uiDataMenu_PasteAfter.Click -= funcDataMenu_PasteAfter;
mDataGrid.uiDataMenu_PasteBefore.Click -= funcDataMenu_PasteBefore;
mDataGrid.uiDataMenu_AddAfter.Click -= funcDataMenu_AddAfter;
mDataGrid.uiDataMenu_AddBefore.Click -= funcDataMenu_AddBefore;
mDataGrid.Click -= funcDataMenu_Click;
mSlider.ValueChanged -= sliderValueChanged;
}
@ -141,5 +163,51 @@ namespace BallanceTASEditor.UI {
mSelectionHelp.SetMode(mode);
}
#region data menu
private void funcDataMenu_AddBefore(object sender, RoutedEventArgs e) {
throw new NotImplementedException();
}
private void funcDataMenu_AddAfter(object sender, RoutedEventArgs e) {
throw new NotImplementedException();
}
private void funcDataMenu_PasteBefore(object sender, RoutedEventArgs e) {
throw new NotImplementedException();
}
private void funcDataMenu_PasteAfter(object sender, RoutedEventArgs e) {
throw new NotImplementedException();
}
private void funcDataMenu_Delete(object sender, RoutedEventArgs e) {
throw new NotImplementedException();
}
private void funcDataMenu_Copy(object sender, RoutedEventArgs e) {
throw new NotImplementedException();
}
private void funcDataMenu_Unset(object sender, RoutedEventArgs e) {
mFile.Set(mSelectionHelp.GetFieldRange(), mSelectionHelp.GetRange().GetRelative(mPosition), false);
RefreshDisplay(mPosition);
}
private void funcDataMenu_Set(object sender, RoutedEventArgs e) {
mFile.Set(mSelectionHelp.GetFieldRange(), mSelectionHelp.GetRange().GetRelative(mPosition), true);
RefreshDisplay(mPosition);
}
private void funcDataMenu_Click() {
var data = mSelectionHelp.GetPoint() - mPosition;
var field = (int)mSelectionHelp.GetPointField();
mFile.Set(new SelectionRange(field, field), new SelectionRange(data, data), null);
RefreshDisplay(mPosition);
}
#endregion
}
}