Skip to content

Commit

Permalink
See comment for list of changes in this update
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgamerz committed Jun 9, 2018
1 parent b0256bc commit f9f9353
Show file tree
Hide file tree
Showing 11 changed files with 499 additions and 165 deletions.
30 changes: 30 additions & 0 deletions ME3Explorer/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,36 @@ public static class TreeViewExtension
}
}

public static class TreeViewItemExtension
{
public static IEnumerable<System.Windows.Controls.TreeViewItem> FlattenTreeView(this System.Windows.Controls.TreeViewItem tv)
{
return tv.Items.Cast<System.Windows.Controls.TreeViewItem>().SelectMany(x => FlattenTree(x));

List<System.Windows.Controls.TreeViewItem> FlattenTree(System.Windows.Controls.TreeViewItem rootNode)
{
var nodes = new List<System.Windows.Controls.TreeViewItem> { rootNode };
foreach (System.Windows.Controls.TreeViewItem node in rootNode.Items)
{
nodes.AddRange(FlattenTree(node));
}
return nodes;
}
}

/// <summary>
/// Select specified item in a TreeView
/// </summary>
public static void SelectItem(this System.Windows.Controls.TreeViewItem treeView, object item)
{
var tvItem = treeView.ItemContainerGenerator.ContainerFromItem(item) as System.Windows.Controls.TreeViewItem;
if (tvItem != null)
{
tvItem.IsSelected = true;
}
}
}

public static class EnumerableExtensions
{
public static int FindOrAdd<T>(this List<T> list, T element)
Expand Down
17 changes: 11 additions & 6 deletions ME3Explorer/Interpreter/InterpreterWPF.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,26 @@
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="100" Width="240" />
<ColumnDefinition Width="5" />
<ColumnDefinition MinWidth="100" Width="285" />
<ColumnDefinition Width="1" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ToolBar Grid.Row="0" Grid.ColumnSpan="3" ToolBarTray.IsLocked="True">
<Button Content="Save Hex Changes" Click="Interpreter_SaveHexChanged_Click"/>
<Button Name="SaveHexChange_Button" Content="Save Hex Changes" Click="Interpreter_SaveHexChanged_Click"/>
<TextBlock Text="Changes not yet saved" VerticalAlignment="Center" Foreground="Red" Visibility="Collapsed"/>
<Button Content="Toggle Hexbox Width" Click="Interpreter_ToggleHexboxWidth_Click"/>
</ToolBar>
<!--<control:HexEditor Name="Interpreter_HexBox" Grid.Column="0" Grid.Row="1" Width="Auto" Height="Auto" BytePerLine="4" AllowAutoHightLighSelectionByte="False" StatusBarVisibility="Collapsed" AllowDeleteByte="True" AllowExtend="True" />-->
<WindowsFormsHost Name="Interpreter_Hexbox_Host" Background="Yellow" Grid.Row="10" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
<hb1:HexBox MinBytesPerLine="4" MaxBytesPerLine="16" ColumnInfoVisible="True" LineInfoVisible="True" Font="Courier New,10" BoldFont="Consolas,10" StringViewVisible="True">
<WindowsFormsHost Name="Interpreter_Hexbox_Host" Grid.Row="10" Grid.ColumnSpan="2" HorizontalAlignment="Stretch">
<hb1:HexBox MinBytesPerLine="4" MaxBytesPerLine="16" ColumnInfoVisible="True" LineInfoVisible="True" Font="Courier New,10" BoldFont="Consolas,10" StringViewVisible="True" VScrollBarVisible="True">
</hb1:HexBox>
</WindowsFormsHost>
<GridSplitter Grid.Column="1" Width="5" MaxWidth="5" Grid.Row="1" HorizontalAlignment="Stretch"/>
<GridSplitter Grid.Column="1"
Grid.Row="1" HorizontalAlignment="Stretch"
Margin="-5,0"
BorderThickness="5,0"
BorderBrush="Transparent"
Panel.ZIndex="60"/>
<TreeView Name="Interpreter_TreeView" Grid.Row="1" Grid.Column="2" Width="Auto" FontFamily="Consolas" SelectedItemChanged="Interpreter_TreeViewSelectedItemChanged"/>
</Grid>
</UserControl>
32 changes: 21 additions & 11 deletions ME3Explorer/Interpreter/InterpreterWPF.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class InterpreterWPF : UserControl
private BioTlkFileSet tlkset;
private BioTlkFileSet editorTlkSet;
int readerpos;
IExportEntry export;
public IExportEntry CurrentLoadedExport;

public struct PropHeader
{
Expand Down Expand Up @@ -110,7 +110,7 @@ public InterpreterWPF()
public void loadNewExport(IExportEntry export)
{
pcc = export.FileRef;
this.export = export;
CurrentLoadedExport = export;
memory = export.Data;
memsize = memory.Length;
//List<byte> bytes = export.Data.ToList();
Expand Down Expand Up @@ -147,19 +147,19 @@ private void StartScan(IEnumerable<string> expandedItems = null, string topNodeN
//resetPropEditingControls();
//Interpreter_TreeView.BeginUpdate();
Interpreter_TreeView.Items.Clear();
readerpos = export.GetPropertyStart();
readerpos = CurrentLoadedExport.GetPropertyStart();

TreeViewItem topLevelTree = new TreeViewItem()
{
Header = "0000 : " + export.ObjectName,
Header = "0000 : " + CurrentLoadedExport.ObjectName,
IsExpanded = true
};
topLevelTree.Tag = nodeType.Root;
topLevelTree.Name = "_" + "0";

try
{
PropertyCollection props = export.GetProperties(includeNoneProperties: true);
PropertyCollection props = CurrentLoadedExport.GetProperties(includeNoneProperties: true);
foreach (UProperty prop in props)
{
GenerateTreeForProperty(prop, topLevelTree);
Expand Down Expand Up @@ -238,7 +238,7 @@ private void GenerateTreeForProperty(UProperty prop, TreeViewItem parent)
{
string s = prop.Offset.ToString("X4") + ": ";
s += "\"" + prop.Name + "\" ";
s += "Type: \"" + prop.PropType + "\"";
s += "Type: " + prop.PropType;
//s += "Size: " + prop.
var nodeColor = Brushes.Black;

Expand Down Expand Up @@ -285,9 +285,17 @@ private void GenerateTreeForProperty(UProperty prop, TreeViewItem parent)
break;
case PropertyType.ArrayProperty:
{
s += " Array Size: " + (prop as ArrayPropertyBase).ValuesAsProperties.Count();
s += ", Array Size: " + (prop as ArrayPropertyBase).ValuesAsProperties.Count();
}
break;
case PropertyType.NameProperty:
s += " Value: ";
s += (prop as NameProperty).NameTableIndex + " " + (prop as NameProperty).Value;
break;
case PropertyType.StructProperty:
s += ", ";
s += (prop as StructProperty).StructType;
break;
}
}
Debug.WriteLine(s);
Expand Down Expand Up @@ -1314,12 +1322,12 @@ private ArrayType GetArrayType(int propName, string typeName = null)
switch (pcc.Game)
{
case MEGame.ME1:
return ME1UnrealObjectInfo.getArrayType(typeName, pcc.getNameEntry(propName), export: export);
return ME1UnrealObjectInfo.getArrayType(typeName, pcc.getNameEntry(propName), export: CurrentLoadedExport);
case MEGame.ME2:
return ME2UnrealObjectInfo.getArrayType(typeName, pcc.getNameEntry(propName), export: export);
return ME2UnrealObjectInfo.getArrayType(typeName, pcc.getNameEntry(propName), export: CurrentLoadedExport);
case MEGame.ME3:
case MEGame.UDK:
return ME3UnrealObjectInfo.getArrayType(typeName, pcc.getNameEntry(propName), export: export);
return ME3UnrealObjectInfo.getArrayType(typeName, pcc.getNameEntry(propName), export: CurrentLoadedExport);
}
return ArrayType.Int;
}
Expand Down Expand Up @@ -1366,6 +1374,8 @@ private void UpdateHexboxPosition(object tvi)
{
var hexPosStr = newSelectedItem.Name.Substring(1); //remove _
int hexPos = Convert.ToInt32(hexPosStr);
Interpreter_Hexbox.SelectionStart = hexPos;
Interpreter_Hexbox.SelectionLength = 1;
//Interpreter_HexBox.SetPosition(hexPos);
// Debug.WriteLine(newSelectedItem.Name);
}
Expand All @@ -1385,7 +1395,7 @@ private void Interpreter_SaveHexChanged_Click(object sender, System.Windows.Rout
MemoryStream m = new MemoryStream();
for (int i = 0; i < provider.Length; i++)
m.WriteByte(provider.ReadByte(i));
export.Data = m.ToArray();
CurrentLoadedExport.Data = m.ToArray();
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ME3Explorer/ME3Explorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
<Compile Include="PackageEditor\PackageEditorWPF.xaml.cs">
<DependentUpon>PackageEditorWPF.xaml</DependentUpon>
</Compile>
<Compile Include="PackageEditor\PackageEditorWPFCommands.cs" />
<Compile Include="Packages\UDKPackage.cs" />
<Compile Include="Packages\MEPackage.cs" />
<Compile Include="Pathfinding Editor\SplineNodes.cs" />
Expand Down
Loading

1 comment on commit f9f9353

@Mgamerz
Copy link
Member Author

@Mgamerz Mgamerz commented on f9f9353 Jun 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Implement SelectItem for TreeView in PackageEditorWPF
  • PackageEditorWPF indexing is now UnrealIndex based rather than Imports at Negative, Exports at 0+. Now nothing should be assigned to 0, like unreal. This will need to be redone as 0-based for handleUpdate() as other tools run on 0-based
  • CTRL+F focuses the Find box
  • CTRL+G focuses the Goto box
  • Modified entries(only by that tool's instance) are highlighted as yellow with a tooltip stating it has unsaved changes
  • HasUnsavedChanges for ExportEntry now includes header changes
  • InterpreterWPF splitter is bigger
  • InterpreterWPF SaveHexChanges now works
  • Implemented some more property parsing text
  • Clicking on stuff in interpreterWPF makes it highlight start of property. May change to highlight the value of the property instead with right click menu for go to start
  • Imports/Exports metadata tab now updates to reflect what can be edited, with proper offsets
  • Focus of combobox or textfield in metadata tab causes highlight in hexbox showing what data is going to be edited
  • Find and Goto now work in PackageEditorWPF
  • Pretty much completely redid Metadata tab
  • Fixed bug where as data loaded it would say things were modified for Exports/Imports

Please sign in to comment.