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 def057d
Show file tree
Hide file tree
Showing 2 changed files with 29 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
24 changes: 23 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,29 @@ private void MainTree_MouseDoubleClick(object sender, MouseButtonEventArgs e)

OpenInTab(Highlighted);
}
private void MainTree_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ButtonState == MouseButtonState.Pressed && e.ChangedButton == System.Windows.Input.MouseButton.Middle)
{
DependencyObject obj = MainTree.InputHitTest(e.GetPosition(MainTree)) as DependencyObject;
if (obj is not TextBlock)
return;

TreeViewItem item = GetNearestParent<TreeViewItem>(obj);
if (item is null)
return;

item.IsSelected = true;

if (item.DataContext is not UndertaleResource)
return;

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 def057d

Please sign in to comment.