Skip to content

Instantly share code, notes, and snippets.

@AinTunez
Created January 9, 2019 17:59
Show Gist options
  • Select an option

  • Save AinTunez/b73e2d1df61f1429ad2c1c8630ab8d12 to your computer and use it in GitHub Desktop.

Select an option

Save AinTunez/b73e2d1df61f1429ad2c1c8630ab8d12 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SoulsFormats;
namespace DS3_Submesh_Deleter
{
public partial class GUI : Form
{
public FLVER flver = null;
public string flverPath = "";
public GUI()
{
InitializeComponent();
}
private void LoadFLVER(string path)
{
flver = FLVER.Read(path);
flverPath = path;
FLVER_Name.Text = Path.GetFileName(path);
for (int i = 0; i < flver.Meshes.Count(); i++)
{
var name = flver.Materials[flver.Meshes[i].MaterialIndex].Name;
submeshBox.Items.Add(name);
}
saveBtn.Enabled = true;
}
private void loadBtn_Click(object sender, EventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Title = "Select FLVER file.";
if (ofd.ShowDialog() == DialogResult.OK)
{
try
{
LoadFLVER(ofd.FileNames[0]);
} catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
private void deleteBtn_Click(object sender, EventArgs e)
{
int i = submeshBox.SelectedIndex;
if (i > -1)
{
flver.Meshes.RemoveAt(i);
submeshBox.Items.RemoveAt(i);
submeshBox.SelectedIndex = -1;
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
deleteBtn.Enabled = submeshBox.SelectedIndex > -1;
}
private void saveBtn_Click(object sender, EventArgs e)
{
if (!File.Exists(flverPath + ".bak")) File.Copy(flverPath, flverPath + ".bak");
File.WriteAllBytes(flverPath, flver.Write());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment