mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-08-21 01:19:21 +08:00
Merged changes to YcdForm - export .onim (experimental)
This commit is contained in:
parent
7adc4b6eea
commit
6e004329f4
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@ -33,9 +34,40 @@ namespace CodeWalker.Forms
|
|||||||
public YcdForm()
|
public YcdForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
MainListView.ContextMenu = new ContextMenu(new[]
|
||||||
|
{
|
||||||
|
new MenuItem("Export to openFormats (.onim)...", this.ExportOnim_Click)
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void UpdateFormTitle()
|
private void UpdateFormTitle()
|
||||||
{
|
{
|
||||||
@ -95,9 +127,19 @@ namespace CodeWalker.Forms
|
|||||||
if (MainListView.SelectedItems.Count == 1)
|
if (MainListView.SelectedItems.Count == 1)
|
||||||
{
|
{
|
||||||
MainPropertyGrid.SelectedObject = MainListView.SelectedItems[0].Tag;
|
MainPropertyGrid.SelectedObject = MainListView.SelectedItems[0].Tag;
|
||||||
|
|
||||||
|
if (MainPropertyGrid.SelectedObject is Animation)
|
||||||
|
{
|
||||||
|
MainListView.ContextMenu.MenuItems[0].Enabled = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
MainListView.ContextMenu.MenuItems[0].Enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainListView.ContextMenu.MenuItems[0].Enabled = false;
|
||||||
//MainPropertyGrid.SelectedObject = null;
|
//MainPropertyGrid.SelectedObject = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user