-
Notifications
You must be signed in to change notification settings - Fork 237
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
New grid related features #931
Changes from 9 commits
829cdb4
cbd06f7
c2c8390
c29b1c2
cede4d8
22e85c0
9788734
6aa36e0
047c815
c37878b
2a9084f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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> | ||
|
@@ -81,12 +81,42 @@ | |
<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="OneWay"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the data bindings that you've changed/added should be |
||
<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> | ||
<MultiBinding Converter="{StaticResource GridConverter}"> | ||
<Binding Path="GridWidth" Mode="OneTime"/> | ||
<Binding Path="GridHeight" Mode="OneTime"/> | ||
<Binding Path="GridWidth" Mode="OneWay"/> | ||
<Binding Path="GridHeight" Mode="OneWay"/> | ||
</MultiBinding> | ||
</DrawingBrush.Viewport> | ||
<DrawingBrush.Drawing> | ||
|
@@ -95,22 +125,19 @@ | |
<RectangleGeometry> | ||
<RectangleGeometry.Rect> | ||
<MultiBinding Converter="{StaticResource GridConverter}"> | ||
<Binding Path="GridWidth" Mode="OneTime"/> | ||
<Binding Path="GridHeight" Mode="OneTime"/> | ||
<Binding Path="GridWidth" Mode="OneWay"/> | ||
<Binding Path="GridHeight" Mode="OneWay"/> | ||
</MultiBinding> | ||
</RectangleGeometry.Rect> | ||
</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> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,7 @@ private void UndertaleRoomEditor_DataContextChanged(object sender, DependencyPro | |
GameObjItems.Header = room.Flags.HasFlag(RoomEntryFlags.IsGMS2) | ||
? "Game objects (from all layers)" | ||
: "Game objects"; | ||
room.SetupRoom(); | ||
this.SetupRoomWithGrids(room); | ||
GenerateSpriteCache(DataContext as UndertaleRoom); | ||
|
||
if (room.Layers.Count > 0) // if GMS 2+ | ||
|
@@ -462,7 +462,7 @@ private void Rectangle_MouseUp(object sender, MouseButtonEventArgs e) | |
} | ||
|
||
// recalculates room grid size | ||
room.SetupRoom(); | ||
this.SetupRoomWithGrids(room); | ||
} | ||
else if (obj is GameObject gameObj) | ||
{ | ||
|
@@ -832,6 +832,7 @@ private void SelectObject(UndertaleObject obj) | |
|
||
resListView.IsExpanded = true; | ||
resListView.BringIntoView(); | ||
resListView.Focus(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be after line 856 ( |
||
resListView.UpdateLayout(); | ||
|
||
StackPanel resPanel = MainWindow.FindVisualChild<StackPanel>(resListView); | ||
|
@@ -1316,7 +1317,7 @@ public void Command_Paste(object sender, ExecutedRoutedEventArgs e) | |
} | ||
|
||
SelectObject(layer); | ||
room.SetupRoom(false); | ||
room.SetupRoom(false, false); | ||
} | ||
|
||
private void AddObjectInstance(UndertaleRoom room) | ||
|
@@ -1670,6 +1671,14 @@ private void LayerCanvas_Unloaded(object sender, RoutedEventArgs e) | |
if (canvas.CurrentLayer is not null) | ||
ObjElemDict.Remove(canvas.CurrentLayer); | ||
} | ||
private void SetupRoomWithGrids(UndertaleRoom room) | ||
{ | ||
if (Settings.Instance.GridWidthEnabled) | ||
room.GridWidth = Settings.Instance.GlobalGridWidth; | ||
if (Settings.Instance.GridHeightEnabled) | ||
room.GridHeight = Settings.Instance.GlobalGridHeight; | ||
room.SetupRoom(!Settings.Instance.GridWidthEnabled, !Settings.Instance.GridHeightEnabled); | ||
} | ||
} | ||
|
||
public partial class RoomCanvas : Canvas | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1478,7 +1478,7 @@ private void TreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEv | |
|
||
private void MainTree_MouseDoubleClick(object sender, MouseButtonEventArgs e) | ||
{ | ||
OpenInTab(Highlighted); | ||
OpenInTab(Highlighted, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is not mentioned on the PR description. |
||
} | ||
|
||
private void MainTree_KeyUp(object sender, KeyEventArgs e) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is slightly misleading, as in this code block the starting grid is not get from the settings as the grid isn't even recalculated in that case.