-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Armor + Virindi Color Tool feature * Removed some useless declarations * Fixed issue with trying to view armor before opening dats
- Loading branch information
Showing
30 changed files
with
2,555 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ACViewer.Data | ||
{ | ||
|
||
public static class LootArmorList | ||
{ | ||
public static Dictionary<uint, LootItem> Loot{ get; set; } | ||
|
||
static LootArmorList() | ||
{ | ||
Loot = new Dictionary<uint, LootItem>(); | ||
} | ||
|
||
public static void Load() | ||
{ | ||
var filename = @"Data\LootArmor.txt"; | ||
|
||
var lines = File.ReadAllLines(filename); | ||
|
||
for (var i = 0; i < lines.Length; i++) | ||
{ | ||
var line = lines[i]; | ||
|
||
// comment | ||
if (line.StartsWith("#")) | ||
continue; | ||
|
||
var pieces = line.Split(','); | ||
|
||
if (pieces.Length != 5) | ||
{ | ||
Console.WriteLine($"LootArmor.Load({filename}): line {i + 1} length {pieces.Length}"); | ||
continue; | ||
} | ||
|
||
var wcid = pieces[0].Length > 0 ? Convert.ToUInt32(pieces[0]) : 0; | ||
var name = pieces[1].Length > 0 ? pieces[1] : ""; | ||
var clothingBase = pieces[2].Length > 0 ? pieces[2].ToUpper() : ""; | ||
var palTemp = pieces[3].Length > 0 ? Convert.ToUInt32(pieces[3]) : 0; | ||
var shade = pieces[4].Length > 0 ? Convert.ToSingle(pieces[4]) : 0; | ||
|
||
var item = new LootItem(wcid); | ||
item.Name = name; | ||
item.ClothingBase = clothingBase; | ||
item.PaletteTemplate = palTemp; | ||
item.Shade = shade; | ||
|
||
Loot.Add(wcid, item); | ||
} | ||
} | ||
|
||
public static LootItem Get(uint wcid) | ||
{ | ||
Loot.TryGetValue(wcid, out var lootItem); | ||
return lootItem; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace ACViewer.Data | ||
{ | ||
public class LootItem : IEquatable<LootItem> | ||
{ | ||
public uint WCID { get; set; } | ||
public string Name { get; set; } | ||
public string ClothingBase { get; set; } | ||
public uint PaletteTemplate { get; set; } | ||
public float Shade{ get; set; } | ||
|
||
public LootItem() { } | ||
|
||
public LootItem(uint wcid) | ||
{ | ||
WCID = wcid; | ||
} | ||
|
||
public bool Equals(LootItem table) | ||
{ | ||
return WCID.Equals(table.WCID); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return WCID.GetHashCode(); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Window x:Class="ACViewer.View.ArmorList" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:ACViewer.View" | ||
mc:Ignorable="d" | ||
WindowStartupLocation="CenterOwner" | ||
ShowInTaskbar="False" | ||
Icon="../Icons/armor.png" | ||
Title="Search Armor..." Height="335" Width="350"> | ||
<Grid Margin="0,0,0,0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="90" /> | ||
<RowDefinition Height=".1*" /> | ||
</Grid.RowDefinitions> | ||
<Canvas Grid.Row="0"> | ||
<Label Content="Name:" HorizontalAlignment="Left" VerticalAlignment="Top" RenderTransformOrigin="0.5,1.173" Margin="19,10,0,0"/> | ||
<TextBox Name="txtArmor" HorizontalAlignment="Left" Height="24" TextWrapping="Wrap" VerticalAlignment="Top" Width="257" Canvas.Left="63" Canvas.Top="12"/> | ||
<Button Content="Close" HorizontalAlignment="Center" VerticalAlignment="Top" Width="75" RenderTransformOrigin="0.884,0.55" IsCancel="True" Canvas.Left="245" Canvas.Top="50"/> | ||
</Canvas> | ||
<DataGrid x:Name="dgArmorResults" Grid.Row="1"> | ||
<DataGrid.Resources> | ||
<Style TargetType="{x:Type DataGridCell}"> | ||
<EventSetter Event="MouseDoubleClick" Handler="DataGridCell_MouseDoubleClick"/> | ||
</Style> | ||
</DataGrid.Resources> | ||
|
||
<DataGrid.Columns> | ||
<DataGridTextColumn Header="WCID" Binding="{Binding Path=WCID}" IsReadOnly="True" Width="60"/> | ||
<DataGridTextColumn Header="Name" Binding="{Binding Path=Name}" IsReadOnly="True" Width="1*"></DataGridTextColumn> | ||
</DataGrid.Columns> | ||
</DataGrid> | ||
|
||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
|
||
using ACViewer.Data; | ||
using ACE.DatLoader; | ||
|
||
namespace ACViewer.View | ||
{ | ||
/// <summary> | ||
/// Interaction logic for ArmorList.xaml | ||
/// </summary> | ||
public partial class ArmorList : Window | ||
{ | ||
public ArmorList() | ||
{ | ||
InitializeComponent(); | ||
|
||
this.Owner = App.Current.MainWindow; | ||
|
||
txtArmor.TextChanged += new TextChangedEventHandler(txtArmor_TextChanged); | ||
txtArmor.Focus(); | ||
} | ||
|
||
private void txtArmor_TextChanged(object sender, TextChangedEventArgs e) | ||
{ | ||
SearchArmor(txtArmor.Text.Trim()); | ||
} | ||
|
||
private void SearchArmor(string criteria) | ||
{ | ||
if (criteria != "") | ||
{ | ||
dgArmorResults.Items.Clear(); | ||
|
||
criteria = criteria.ToLower(); | ||
var results = LootArmorList.Loot.Where(x => x.Value.Name.ToLower().Contains(criteria)).OrderBy(x => x.Key); | ||
foreach (var s in results) | ||
{ | ||
dgArmorResults.Items.Add(s.Value); | ||
} | ||
} | ||
} | ||
|
||
// Get the ClothingBase of the item and load it in the window | ||
// - This should be so much easier, Optim hates WPF | ||
// Ref https://wpfadventures.wordpress.com/2008/12/02/wpf-datagrid-detecting-clicked-cell-and-row/ | ||
private void DataGridCell_MouseDoubleClick(object sender, MouseButtonEventArgs e) | ||
{ | ||
if (DatManager.PortalDat == null) | ||
{ | ||
MessageBox.Show($"Please load the DATs before trying to view item."); | ||
return; | ||
} | ||
|
||
DependencyObject dep = (DependencyObject)e.OriginalSource; | ||
|
||
// iteratively traverse the visual tree | ||
while ((dep != null) && | ||
!(dep is DataGridRow)) | ||
{ | ||
dep = VisualTreeHelper.GetParent(dep); | ||
} | ||
|
||
if (dep == null) | ||
return; | ||
|
||
DataGridRow row = dep as DataGridRow; | ||
// find the object that is related to this row | ||
object data = row.Item; | ||
|
||
// extract the property value | ||
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(data); | ||
PropertyDescriptor cbProperty = properties["ClothingBase"]; | ||
string clothingBaseString = cbProperty.GetValue(data).ToString(); | ||
|
||
PropertyDescriptor wcidProperty = properties["WCID"]; | ||
uint wcid = Convert.ToUInt32(wcidProperty.GetValue(data)); | ||
var lootItem = LootArmorList.Get(wcid); | ||
|
||
if (!uint.TryParse(lootItem.ClothingBase, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var clothingBase)) | ||
{ | ||
// input invalid -- throw error? | ||
MessageBox.Show($"Invalid DID format: {lootItem.ClothingBase}"); | ||
return; | ||
} | ||
|
||
|
||
uint filetype = 0; | ||
|
||
if (DatManager.PortalDat.AllFiles.TryGetValue(clothingBase, out var portalFile)) | ||
{ | ||
filetype = clothingBase >> 24; | ||
var fileTypeSelect = FileExplorer.FileTypes.FirstOrDefault(i => i.ID == filetype); | ||
if (fileTypeSelect == null) | ||
{ | ||
Console.WriteLine($"Unknown filetype {clothingBase:X8} found in Portal Dat"); | ||
return; | ||
} | ||
|
||
var items = FileExplorer.Instance.FileType.Items; | ||
|
||
foreach (var item in items) | ||
{ | ||
if (item is Entity.FileType entityFileType && entityFileType.ID == filetype) | ||
{ | ||
FileExplorer.Instance.FileType.SelectedItem = item; | ||
var didStr = clothingBase.ToString("X8"); | ||
foreach (var file in FileExplorer.Instance.Files.Items) | ||
{ | ||
if (file.ToString().Equals(didStr)) | ||
{ | ||
FileExplorer.Instance.Files.SelectedItem = file; | ||
FileExplorer.Instance.Files.ScrollIntoView(file); | ||
|
||
var clothing = DatManager.PortalDat.ReadFromDat<ACE.DatLoader.FileTypes.ClothingTable>(clothingBase); | ||
ClothingTableList.Instance.OnClickClothingBase(clothing, clothingBase, lootItem.PaletteTemplate, lootItem.Shade); | ||
this.Close(); | ||
} | ||
} | ||
break; | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.