Skip to content

Commit

Permalink
Misc + perf fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
zcanann committed Mar 19, 2022
1 parent 4ba974d commit e2195de
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Twilight/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<ResourceDictionary Source="/Twilight;component/View/Styles/Button.xaml" />
<ResourceDictionary Source="/Twilight;component/View/Styles/CheckBox.xaml" />
<ResourceDictionary Source="/Twilight;component/View/Styles/ComboBox.xaml" />
<ResourceDictionary Source="/Twilight;component/View/Styles/ContextMenu.xaml" />
<!--<ResourceDictionary Source="/Twilight;component/View/Styles/ContextMenu.xaml" />-->
<ResourceDictionary Source="/Twilight;component/View/Styles/GroupBox.xaml" />
<ResourceDictionary Source="/Twilight;component/View/Styles/MenuItem.xaml" />
<ResourceDictionary Source="/Twilight;component/View/Styles/ScrollViewer.xaml" />
Expand Down
Binary file modified Twilight/Content/Images/AppIcon.ico
Binary file not shown.
Binary file modified Twilight/Content/Images/AppIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 48 additions & 24 deletions Twilight/Source/HeapVisualizer/ActorReferenceCountTableSlot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ public String Name
return this.name;
}

private set
set
{
this.name = value;
this.RaisePropertyChanged(nameof(this.Name));
if (this.name != value)
{
this.name = value;
this.RaisePropertyChanged(nameof(this.Name));
}
}
}

Expand All @@ -85,10 +88,13 @@ public UInt16 ReferenceCount
return this.referenceCount;
}

private set
set
{
this.referenceCount = value;
this.RaisePropertyChanged(nameof(this.ReferenceCount));
if (this.referenceCount != value)
{
this.referenceCount = value;
this.RaisePropertyChanged(nameof(this.ReferenceCount));
}
}
}

Expand All @@ -99,10 +105,13 @@ public UInt16 Padding
return this.padding;
}

private set
set
{
this.padding = value;
this.RaisePropertyChanged(nameof(this.Padding));
if (this.padding != value)
{
this.padding = value;
this.RaisePropertyChanged(nameof(this.Padding));
}
}
}

Expand All @@ -113,10 +122,13 @@ public Int32 MDMCommandPtr
return this.mDMCommandPtr;
}

private set
set
{
this.mDMCommandPtr = value;
this.RaisePropertyChanged(nameof(this.MDMCommandPtr));
if (this.mDMCommandPtr != value)
{
this.mDMCommandPtr = value;
this.RaisePropertyChanged(nameof(this.MDMCommandPtr));
}
}
}

Expand All @@ -127,10 +139,13 @@ public Int32 MArchivePtr
return this.mArchivePtr;
}

private set
set
{
this.mArchivePtr = value;
this.RaisePropertyChanged(nameof(this.MArchivePtr));
if (this.mArchivePtr != value)
{
this.mArchivePtr = value;
this.RaisePropertyChanged(nameof(this.MArchivePtr));
}
}
}

Expand All @@ -141,10 +156,13 @@ public Int32 HeapPtr
return this.heapPtr;
}

private set
set
{
this.heapPtr = value;
this.RaisePropertyChanged(nameof(this.HeapPtr));
if (this.heapPtr != value)
{
this.heapPtr = value;
this.RaisePropertyChanged(nameof(this.HeapPtr));
}
}
}

Expand All @@ -155,10 +173,13 @@ public Int32 MDataHeapPtr
return this.mDataHeapPtr;
}

private set
set
{
this.mDataHeapPtr = value;
this.RaisePropertyChanged(nameof(this.MDataHeapPtr));
if (this.mDataHeapPtr != value)
{
this.mDataHeapPtr = value;
this.RaisePropertyChanged(nameof(this.MDataHeapPtr));
}
}
}

Expand All @@ -169,10 +190,13 @@ public Int32 MResPtrPtr
return this.mResPtrPtr;
}

private set
set
{
this.mResPtrPtr = value;
this.RaisePropertyChanged(nameof(this.MResPtrPtr));
if (this.mResPtrPtr != value)
{
this.mResPtrPtr = value;
this.RaisePropertyChanged(nameof(this.MResPtrPtr));
}
}
}

Expand Down
14 changes: 13 additions & 1 deletion Twilight/Source/HeapVisualizer/HeapVisualizerViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
namespace Twilight.Source.HeapVisualizer
{
using GalaSoft.MvvmLight.Command;
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Twilight.Engine.Common;
Expand Down Expand Up @@ -143,7 +145,17 @@ private void RunUpdateLoop()
for (int actorSlotIndex = 0; actorSlotIndex < ActorReferenceCountTableMaxEntries; actorSlotIndex++)
{
Array.Copy(actorReferenceCountTable, actorSlotIndex * ActorSlotStructSize, slotData, 0, ActorSlotStructSize);
this.ActorReferenceCountSlots[actorSlotIndex] = ActorReferenceCountTableSlot.FromByteArray(slotData);
ActorReferenceCountTableSlot result = ActorReferenceCountTableSlot.FromByteArray(slotData);

// Copy data over field by field to avoid triggering the FullyObservableCollection changes.
this.ActorReferenceCountSlots[actorSlotIndex].Name = result.Name;
this.ActorReferenceCountSlots[actorSlotIndex].ReferenceCount = result.ReferenceCount;
this.ActorReferenceCountSlots[actorSlotIndex].Padding = result.Padding;
this.ActorReferenceCountSlots[actorSlotIndex].MDMCommandPtr = result.MDMCommandPtr;
this.ActorReferenceCountSlots[actorSlotIndex].MArchivePtr = result.MArchivePtr;
this.ActorReferenceCountSlots[actorSlotIndex].HeapPtr = result.HeapPtr;
this.ActorReferenceCountSlots[actorSlotIndex].MDataHeapPtr = result.MDataHeapPtr;
this.ActorReferenceCountSlots[actorSlotIndex].MResPtrPtr = result.MResPtrPtr;

this.ColorActorSlotMemory(actorSlotIndex, 0, this.ActorReferenceCountSlots[actorSlotIndex].ReferenceCount > 0 ? Color.FromRgb(255, 0, 0) : Color.FromRgb(0, 0, 0));
}
Expand Down
1 change: 1 addition & 0 deletions Twilight/Twilight.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<NoWarn>$(NoWarn);NU1605</NoWarn>
<SignAssembly>false</SignAssembly>
<StartupObject>Twilight.App</StartupObject>
<ApplicationIcon />
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand Down
5 changes: 3 additions & 2 deletions Twilight/View/HeapVisualizer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<TextBlock Grid.Row="0" Foreground="White">Actor Reference Counts</TextBlock>
<Image Grid.Row="1" x:Name="heap0Viz" Margin="2" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Source="{Binding Path=HeapBitmaps[0]}" Stretch="Fill" />
<DataGrid
Name="ActorDataGrid"
Grid.Row="2"
Name="ScanResultsDataGrid"
behaviors:ScrollToTopBehavior.ScrollToTop="True"
AutoGenerateColumns="False"
Background="Transparent"
Expand All @@ -40,9 +40,10 @@
ItemsSource="{Binding Path=ActorReferenceCountSlots}"
RowHeaderWidth="0"
SelectionMode="Extended"
SelectionUnit="CellOrRowHeader"
EnableColumnVirtualization="False"
EnableRowVirtualization="False"
SelectionUnit="Cell">
>
<!-- Click and Selection events
<intr:Interaction.Triggers>
<intr:EventTrigger EventName="SelectionChanged">
Expand Down
2 changes: 1 addition & 1 deletion Twilight/View/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
xmlns:types="clr-namespace:Twilight.Engine.Common;assembly=Twilight.Engine.Common"
xmlns:view="clr-namespace:Twilight.View"
x:Name="TwilightWindow"
Title="Twilight"
Title="Twilight Princess Visualization Tools"
Width="1280"
Height="960"
x:ClassModifier="public"
Expand Down

0 comments on commit e2195de

Please sign in to comment.