Skip to content

Commit

Permalink
Any "UndertaleResource" can be opened in a new tab with MMB (in the a…
Browse files Browse the repository at this point in the history
…sset list).
  • Loading branch information
VladiStep committed Jun 17, 2022
1 parent d4630e5 commit 1501660
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
9 changes: 6 additions & 3 deletions UndertaleModTool/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@
</Button>
<TextBox Grid.Column="1" Name="SearchBox" ToolTip="Search" TextChanged="SearchBox_TextChanged"/>
</Grid>
<TreeView Grid.Column="0" Grid.Row="1" Margin="5" DataContext="{Binding Data}" SelectedItemChanged="TreeView_SelectedItemChanged" MouseDoubleClick="MainTree_MouseDoubleClick" KeyUp="MainTree_KeyUp" AllowDrop="True" Name="MainTree" KeyDown="MainTree_KeyDown" PreviewMouseRightButtonDown="MainTree_PreviewMouseRightButtonDown"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView Grid.Column="0" Grid.Row="1" Name="MainTree" Margin="5" DataContext="{Binding Data}" AllowDrop="True"
SelectedItemChanged="TreeView_SelectedItemChanged"
MouseDoubleClick="MainTree_MouseDoubleClick" PreviewMouseRightButtonDown="MainTree_PreviewMouseRightButtonDown" MouseDown="MainTree_MouseDown"
KeyUp="MainTree_KeyUp" KeyDown="MainTree_KeyDown"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.VirtualizationMode="Recycling">
<TreeView.Resources>
<ContextMenu x:Key="AddMenu">
<MenuItem Header="Add" Click="MenuItem_Add_Click"/>
Expand Down
22 changes: 21 additions & 1 deletion UndertaleModTool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEv
{
if (e.NewValue is TreeViewItem)
{
string item = (e.NewValue as TreeViewItem)?.Header?.ToString();
string item = (e.NewValue as TreeViewItem).Header?.ToString();

if (item == "Data")
{
Expand Down Expand Up @@ -1567,7 +1567,27 @@ private void MainTree_MouseDoubleClick(object sender, MouseButtonEventArgs e)

OpenInTab(Highlighted);
}
private void MainTree_MouseDown(object sender, MouseButtonEventArgs e)
{
HitTestResult result = VisualTreeHelper.HitTest(MainTree, e.GetPosition(MainTree));
DependencyObject obj = result.VisualHit;
if (obj is not TextBlock)
return;

if (GetNearestParent<TreeViewItem>(obj) is TreeViewItem item)
item.IsSelected = true;

if ((obj as FrameworkElement)?.DataContext is not UndertaleResource)
return;

if (e.ButtonState == MouseButtonState.Pressed && e.ChangedButton == System.Windows.Input.MouseButton.Middle)
{
if (Highlighted is UndertaleRoom room && Selected is not UndertaleRoom)
UndertaleRoomEditor.CheckAndRearrangeLayers(room);

OpenInTab(Highlighted, true);
}
}
private void MainTree_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Return)
Expand Down

0 comments on commit 1501660

Please sign in to comment.