Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved sprite texture entries removing. #932

Merged
merged 4 commits into from
May 25, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions UndertaleModTool/Controls/UndertaleObjectReference.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" IsReadOnly="True" Cursor="Arrow" ToolTip="This is an object reference. Drag and drop an object of matching type from the tree on the left to change it!" AllowDrop="True" PreviewDragOver="TextBox_DragOver" PreviewDrop="TextBox_Drop" PreviewMouseDoubleClick="TextBox_MouseDoubleClick" Text="{Binding ObjectReference, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<Button Grid.Column="1" Click="Details_Click">
<TextBox Grid.Column="0" Name="ObjectText" IsReadOnly="True" Cursor="Arrow" AllowDrop="True"
ToolTip="This is an object reference. Drag and drop an object of matching type from the tree on the left to change it!"
PreviewDragOver="TextBox_DragOver" PreviewDrop="TextBox_Drop" PreviewMouseDoubleClick="TextBox_MouseDoubleClick"
Text="{Binding ObjectReference, RelativeSource={RelativeSource AncestorType=UserControl}}"/>
<Button Grid.Column="1" Name="DetailsButton" Click="Details_Click">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Content" Value=" ... " />
Expand All @@ -36,7 +39,7 @@
</Style>
</Button.Style>
</Button>
<Button Grid.Column="2" Click="Remove_Click" Content=" X " ToolTip="Remove reference">
<Button Grid.Column="2" Name="RemoveButton" Click="Remove_Click" Content=" X " ToolTip="Remove reference">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
Expand Down
5 changes: 5 additions & 0 deletions UndertaleModTool/Controls/UndertaleObjectReference.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public UndertaleObjectReference()
InitializeComponent();
}

public void ClearRemoveClickHandler()
{
RemoveButton.Click -= Remove_Click;
}

private void Details_Click(object sender, RoutedEventArgs e)
{
if (ObjectReference is null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<local:DataUserControl x:Class="UndertaleModTool.UndertaleTexturePageItemDisplay"
<UserControl x:Class="UndertaleModTool.UndertaleTexturePageItemDisplay"
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"
Expand All @@ -21,4 +21,4 @@
</Border.Background>
</Border>
</Canvas>
</local:DataUserControl>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace UndertaleModTool
/// <summary>
/// Logika interakcji dla klasy UndertaleTexturePageItemDisplay.xaml
/// </summary>
public partial class UndertaleTexturePageItemDisplay : DataUserControl
public partial class UndertaleTexturePageItemDisplay : UserControl
{
public UndertaleTexturePageItemDisplay()
{
Expand Down
10 changes: 8 additions & 2 deletions UndertaleModTool/Editors/UndertaleSpriteEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@
</Grid>

<TextBlock Grid.Row="10" Grid.Column="0" Margin="3">Textures</TextBlock>
<DataGrid Grid.Row="10" Grid.Column="1" Margin="3" ItemsSource="{Binding Textures, Mode=OneWay}" Name="TextureList" AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True" HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" HeadersVisibility="None" SelectionMode="Single" SelectionUnit="FullRow" IsSynchronizedWithCurrentItem="True">
<DataGrid Grid.Row="10" Grid.Column="1" Margin="3" ItemsSource="{Binding Textures, Mode=OneWay}" Name="TextureList"
AutoGenerateColumns="False" CanUserAddRows="True" CanUserDeleteRows="True"
HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray"
HeadersVisibility="None" SelectionMode="Single" SelectionUnit="FullRow" IsSynchronizedWithCurrentItem="True">
<DataGrid.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="#FF26A0DA"/>
<Style TargetType="{x:Type DataGridCell}">
Expand Down Expand Up @@ -135,7 +138,10 @@
<DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<local:UndertaleObjectReference Margin="20,0,0,0" ObjectReference="{Binding Texture, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ObjectType="{x:Type undertale:UndertaleTexturePageItem}" CanRemove="False"/>
<local:UndertaleObjectReference Margin="20,0,0,0" CanRemove="True"
Loaded="UndertaleObjectReference_Loaded"
ObjectReference="{Binding Texture, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
ObjectType="{x:Type undertale:UndertaleTexturePageItem}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Expand Down
22 changes: 22 additions & 0 deletions UndertaleModTool/Editors/UndertaleSpriteEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,27 @@ private void MaskExport_Click(object sender, RoutedEventArgs e)
}
}
}

private void UndertaleObjectReference_Loaded(object sender, RoutedEventArgs e)
{
var objRef = sender as UndertaleObjectReference;

objRef.ClearRemoveClickHandler();
objRef.RemoveButton.Click += Remove_Click_Override;
objRef.RemoveButton.ToolTip = "Remove texture entry";
VladiStep marked this conversation as resolved.
Show resolved Hide resolved
objRef.RemoveButton.IsEnabled = true;
objRef.DetailsButton.ToolTip = "Open texture entry";
VladiStep marked this conversation as resolved.
Show resolved Hide resolved
objRef.ObjectText.PreviewKeyDown += ObjectText_PreviewKeyDown;
}
private void ObjectText_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete)
Remove_Click_Override(sender, null);
}
private void Remove_Click_Override(object sender, RoutedEventArgs e)
{
if (DataContext is UndertaleSprite spr && (sender as FrameworkElement).DataContext is UndertaleSprite.TextureEntry entry)
spr.Textures.Remove(entry);
VladiStep marked this conversation as resolved.
Show resolved Hide resolved
}
}
}