Skip to content

Commit

Permalink
Merge pull request #1001 from Miepee/grid
Browse files Browse the repository at this point in the history
Make room grid be in front, instead of in back
  • Loading branch information
Grossley committed Jun 27, 2022
2 parents cdb5bbb + 9d24456 commit 1942930
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 24 deletions.
47 changes: 37 additions & 10 deletions UndertaleModTool/Controls/UndertaleRoomRenderer.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<local:DataUserControl x:Class="UndertaleModTool.UndertaleRoomRenderer"
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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:UndertaleModTool"
xmlns:undertale="clr-namespace:UndertaleModLib.Models;assembly=UndertaleModLib"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance undertale:UndertaleRoom}" x:Name="RoomRenderer"
DataContextChanged="RoomRenderer_DataContextChanged">
Expand Down Expand Up @@ -52,7 +52,7 @@
<Border Background="{x:Static SystemColors.WindowBrush}" Grid.Row="0" Grid.Column="0" Panel.ZIndex="1">
<TextBlock HorizontalAlignment="Center" Text="{Binding ., Mode=OneTime, Converter={StaticResource RoomCaptionConverter}}" FontSize="14" FontStyle="Italic" Margin="5"/>
</Border>
<ItemsControl Grid.Column="0" Grid.Row="1" Panel.ZIndex="0" Name="RoomGraphics" Background="Black" ClipToBounds="True">
<ItemsControl Grid.Column="0" Grid.Row="1" Panel.ZIndex="0" Name="RoomGraphics" Background="Gray" ClipToBounds="True">
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Style.Triggers>
Expand Down Expand Up @@ -81,6 +81,36 @@
<Canvas x:Name="RoomCanvas" Width="{Binding Width, Mode=OneTime}" Height="{Binding Height, Mode=OneTime}" IsItemsHost="True" AllowDrop="True" ClipToBounds="True"
SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="NearestNeighbor"
Loaded="RoomCanvas_Loaded">
<Canvas.OpacityMask>
<DrawingBrush TileMode="Tile" ViewportUnits="Absolute">
<DrawingBrush.Viewport>
<MultiBinding Converter="{StaticResource GridConverter}">
<Binding Path="GridWidth" Mode="OneTime"/>
<Binding Path="GridHeight" Mode="OneTime"/>
</MultiBinding>
</DrawingBrush.Viewport>
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry>
<RectangleGeometry.Rect>
<MultiBinding Converter="{StaticResource GridConverter}">
<Binding Path="GridWidth" Mode="OneTime"/>
<Binding Path="GridHeight" Mode="OneTime"/>
</MultiBinding>
</RectangleGeometry.Rect>
</RectangleGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Black"></SolidColorBrush>
</GeometryDrawing.Brush>
<GeometryDrawing.Pen>
<Pen Brush="Transparent" Thickness="{Binding GridThicknessPx, Mode=OneTime}"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</Canvas.OpacityMask>
<Canvas.Background>
<DrawingBrush TileMode="Tile" ViewportUnits="Absolute">
<DrawingBrush.Viewport>
Expand All @@ -102,15 +132,12 @@
</RectangleGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<!-- that binding replaces itself with proper one -->
<!-- this binding replaces itself with proper one -->
<MultiBinding Mode="OneTime" Converter="{StaticResource BGColorConverter}">
<Binding Path="." RelativeSource="{RelativeSource Self}" Mode="OneTime"/>
<Binding Path="Flags" Mode="OneTime"/>
</MultiBinding>
</GeometryDrawing.Brush>
<GeometryDrawing.Pen>
<Pen Brush="Gray" Thickness="{Binding GridThicknessPx, Mode=OneTime}"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
Expand Down Expand Up @@ -158,7 +185,7 @@
</Rectangle.RenderTransform>
<Rectangle.Fill>
<ImageBrush
ImageSource="{Binding BackgroundDefinition.Texture, Converter={StaticResource UndertaleCachedImageLoader}, Mode=OneTime}"
ImageSource="{Binding BackgroundDefinition.Texture, Converter={StaticResource UndertaleCachedImageLoader}, Mode=OneTime}"
ViewportUnits="Absolute"
AlignmentX="Left" AlignmentY="Top"
TileMode="None"
Expand Down
51 changes: 39 additions & 12 deletions UndertaleModTool/Editors/UndertaleRoomEditor.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<local:DataUserControl x:Class="UndertaleModTool.UndertaleRoomEditor"
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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:UndertaleModTool"
xmlns:undertale="clr-namespace:UndertaleModLib.Models;assembly=UndertaleModLib"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance undertale:UndertaleRoom}" x:Name="RoomEditor">
<UserControl.Resources>
<local:GridConverter x:Key="GridConverter"/>
Expand Down Expand Up @@ -576,7 +576,7 @@
<TextBlock Grid.Row="1" Grid.Column="0" Margin="3">Image speed</TextBlock>
<TextBox Grid.Row="1" Grid.Column="2" Margin="3" Text="{Binding ImageSpeed}"/>
</Grid>

<TextBlock Grid.Row="8" Grid.Column="0" Margin="3">Pre Create code</TextBlock>
<local:UndertaleObjectReference Grid.Row="9" Grid.Column="2" Margin="3" ObjectReference="{Binding PreCreateCode}" ObjectType="{x:Type undertale:UndertaleCode}" ObjectEventType="{x:Static undertale:EventType.PreCreate}" ObjectEventSubtype="0"/>
</Grid>
Expand Down Expand Up @@ -973,7 +973,7 @@

<!-- Don't forget to modify "UndertaleRoomRenderer" control as well -->
<ScrollViewer Name="RoomGraphicsScroll" Margin="0,8,0,0" Grid.Column="0" Grid.Row="2" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible" ScrollChanged="ScrollViewer_ScrollChanged">
<ItemsControl Name="RoomGraphics" Background="Black" MouseDown="RectangleBackground_MouseDown" MouseMove="RectangleBackground_MouseMove" MouseUp="RectangleBackground_MouseUp" MouseWheel="Canvas_MouseWheel">
<ItemsControl Name="RoomGraphics" Background="Gray" MouseDown="RectangleBackground_MouseDown" MouseMove="RectangleBackground_MouseMove" MouseUp="RectangleBackground_MouseUp" MouseWheel="Canvas_MouseWheel">
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Style.Triggers>
Expand Down Expand Up @@ -1011,6 +1011,36 @@
<ItemsPanelTemplate>
<local:RoomCanvas x:Name="RoomCanvas" Width="{Binding Width, Mode=OneWay}" Height="{Binding Height, Mode=OneWay}" IsItemsHost="True" AllowDrop="True"
DragOver="Canvas_DragOver" Drop="Canvas_Drop" Loaded="RoomCanvas_Loaded">
<Canvas.OpacityMask>
<DrawingBrush TileMode="Tile" ViewportUnits="Absolute">
<DrawingBrush.Viewport>
<MultiBinding Converter="{StaticResource GridConverter}">
<Binding Path="GridWidth" Mode="OneWay"/>
<Binding Path="GridHeight" Mode="OneWay"/>
</MultiBinding>
</DrawingBrush.Viewport>
<DrawingBrush.Drawing>
<GeometryDrawing>
<GeometryDrawing.Geometry>
<RectangleGeometry>
<RectangleGeometry.Rect>
<MultiBinding Converter="{StaticResource GridConverter}">
<Binding Path="GridWidth" Mode="OneWay"/>
<Binding Path="GridHeight" Mode="OneWay"/>
</MultiBinding>
</RectangleGeometry.Rect>
</RectangleGeometry>
</GeometryDrawing.Geometry>
<GeometryDrawing.Brush>
<SolidColorBrush Color="Black"></SolidColorBrush>
</GeometryDrawing.Brush>
<GeometryDrawing.Pen>
<Pen Brush="Transparent" Thickness="{Binding GridThicknessPx, Mode=OneWay}"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
</Canvas.OpacityMask>
<Canvas.Background>
<DrawingBrush TileMode="Tile" ViewportUnits="Absolute">
<DrawingBrush.Viewport>
Expand Down Expand Up @@ -1038,9 +1068,6 @@
<Binding Path="Flags" Mode="OneTime"/>
</MultiBinding>
</GeometryDrawing.Brush>
<GeometryDrawing.Pen>
<Pen Brush="Gray" Thickness="{Binding GridThicknessPx, Mode=OneWay}"/>
</GeometryDrawing.Pen>
</GeometryDrawing>
</DrawingBrush.Drawing>
</DrawingBrush>
Expand Down Expand Up @@ -1098,7 +1125,7 @@
</Rectangle.Style>
<Rectangle.Fill>
<ImageBrush
ImageSource="{Binding BackgroundDefinition.Texture, Mode=OneWay, Converter={StaticResource UndertaleCachedImageLoader}}"
ImageSource="{Binding BackgroundDefinition.Texture, Mode=OneWay, Converter={StaticResource UndertaleCachedImageLoader}}"
ViewportUnits="Absolute"
AlignmentX="Left" AlignmentY="Top"
TileMode="None"
Expand Down Expand Up @@ -1228,7 +1255,7 @@
</Rectangle.Style>
<Rectangle.Fill>
<ImageBrush
ImageSource="{Binding Sprite.Textures[0].Texture, Mode=OneWay, Converter={StaticResource UndertaleCachedImageLoader}}"
ImageSource="{Binding Sprite.Textures[0].Texture, Mode=OneWay, Converter={StaticResource UndertaleCachedImageLoader}}"
ViewportUnits="Absolute"
AlignmentX="Left" AlignmentY="Top"
TileMode="None"
Expand Down Expand Up @@ -1285,7 +1312,7 @@
</ItemsControl.ItemsSource>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<Canvas
<Canvas
Width="{Binding ParentLayer.ParentRoom.Width, Mode=OneWay}" Height="{Binding ParentLayer.ParentRoom.Height, Mode=OneWay}"
MouseDown="Rectangle_MouseDown"/>
</ItemsPanelTemplate>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ string exportedTexturesFolder = PromptChooseDirectory("Choose an export folder")
if (exportedTexturesFolder == null)
throw new ScriptException("The export folder was not set, stopping script.");

bool displayGrid = ScriptQuestion("Draw background grid?");
bool displayGrid = ScriptQuestion("Draw room grid?");

if (mainWindow.IsGMS2 == Visibility.Visible)
if (!ScriptQuestion("Use the memory economy mode (uses less RAM, but slower)?"))
Expand Down Expand Up @@ -105,4 +105,4 @@ void DumpRoom(string roomName, bool last)
}

IncProgress();
}
}

0 comments on commit 1942930

Please sign in to comment.