2017-09-29 20:23:37 +08:00
|
|
|
|
using CodeWalker.GameFiles;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
2019-10-31 12:01:20 +08:00
|
|
|
|
using System.IO;
|
2017-09-29 20:23:37 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace CodeWalker.Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class YcdForm : Form
|
|
|
|
|
{
|
|
|
|
|
|
2017-10-04 11:35:39 +08:00
|
|
|
|
YcdFile Ycd;
|
|
|
|
|
|
2017-09-29 20:23:37 +08:00
|
|
|
|
private string fileName;
|
|
|
|
|
public string FileName
|
|
|
|
|
{
|
|
|
|
|
get { return fileName; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
fileName = value;
|
|
|
|
|
UpdateFormTitle();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string FilePath { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public YcdForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2019-10-31 12:01:20 +08:00
|
|
|
|
|
|
|
|
|
MainListView.ContextMenu = new ContextMenu(new[]
|
|
|
|
|
{
|
|
|
|
|
new MenuItem("Export to openFormats (.onim)...", this.ExportOnim_Click)
|
|
|
|
|
});
|
2017-09-29 20:23:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-31 12:01:20 +08:00
|
|
|
|
private void ExportOnim_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MainListView.SelectedItems[0].Tag is Animation anim)
|
|
|
|
|
{
|
|
|
|
|
var saveFileDialog = new SaveFileDialog();
|
|
|
|
|
|
|
|
|
|
string newfn = $"{Path.GetFileNameWithoutExtension(Ycd.Name)}_{MainListView.SelectedItems[0].Text}.onim";
|
2017-09-29 20:23:37 +08:00
|
|
|
|
|
2019-10-31 12:01:20 +08:00
|
|
|
|
saveFileDialog.FileName = newfn;
|
|
|
|
|
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
string path = saveFileDialog.FileName;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var file = File.OpenWrite(path))
|
|
|
|
|
{
|
|
|
|
|
Ycd.SaveOpenFormatsAnimation(anim, file);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Error saving file " + path + ":\n" + ex.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-29 20:23:37 +08:00
|
|
|
|
|
|
|
|
|
private void UpdateFormTitle()
|
|
|
|
|
{
|
|
|
|
|
Text = fileName + " - Clip Dictionary Inspector - CodeWalker by dexyfex";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadYcd(YcdFile ycd)
|
|
|
|
|
{
|
2017-10-04 11:35:39 +08:00
|
|
|
|
Ycd = ycd;
|
|
|
|
|
|
2017-09-29 20:23:37 +08:00
|
|
|
|
fileName = ycd?.Name;
|
|
|
|
|
if (string.IsNullOrEmpty(fileName))
|
|
|
|
|
{
|
|
|
|
|
fileName = ycd?.RpfFileEntry?.Name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateFormTitle();
|
|
|
|
|
|
2017-10-04 11:35:39 +08:00
|
|
|
|
//MainPropertyGrid.SelectedObject = ycd;
|
|
|
|
|
|
|
|
|
|
MainListView.Items.Clear();
|
|
|
|
|
|
|
|
|
|
if (ycd?.ClipMapEntries != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var cme in ycd.ClipMapEntries)
|
|
|
|
|
{
|
|
|
|
|
if (cme != null)
|
|
|
|
|
{
|
|
|
|
|
var lvi = MainListView.Items.Add(cme.Clip?.ShortName ?? cme.Hash.ToString());
|
|
|
|
|
lvi.Tag = cme.Clip;
|
|
|
|
|
lvi.Group = MainListView.Groups["Clips"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ycd?.AnimMapEntries != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ame in ycd.AnimMapEntries)
|
|
|
|
|
{
|
|
|
|
|
if (ame != null)
|
|
|
|
|
{
|
|
|
|
|
var lvi = MainListView.Items.Add(ame.Hash.ToString());
|
|
|
|
|
lvi.Tag = ame.Animation;
|
|
|
|
|
lvi.Group = MainListView.Groups["Anims"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-29 20:23:37 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-10-04 11:35:39 +08:00
|
|
|
|
|
|
|
|
|
private void MainListView_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MainListView.SelectedItems.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
MainPropertyGrid.SelectedObject = MainListView.SelectedItems[0].Tag;
|
2019-10-31 12:01:20 +08:00
|
|
|
|
|
|
|
|
|
if (MainPropertyGrid.SelectedObject is Animation)
|
|
|
|
|
{
|
|
|
|
|
MainListView.ContextMenu.MenuItems[0].Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MainListView.ContextMenu.MenuItems[0].Enabled = false;
|
|
|
|
|
}
|
2017-10-04 11:35:39 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2019-10-31 12:01:20 +08:00
|
|
|
|
MainListView.ContextMenu.MenuItems[0].Enabled = false;
|
2017-10-04 11:35:39 +08:00
|
|
|
|
//MainPropertyGrid.SelectedObject = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-09-29 20:23:37 +08:00
|
|
|
|
}
|
2019-10-31 12:01:20 +08:00
|
|
|
|
}
|