136 lines
4.1 KiB
C#
136 lines
4.1 KiB
C#
using LibW4M;
|
|
using LibW4M.Data.WeaponFactory;
|
|
using LibXom;
|
|
using LibXom.Data;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using W4Gui.Tabs;
|
|
|
|
namespace W4Gui
|
|
{
|
|
public partial class Main : Form
|
|
{
|
|
private static int lastTabIndex = -1;
|
|
private const string defaultTitle = "Worms 4: Mayhem! (Save Editor)";
|
|
public Main()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void W4Gui_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void openToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
OpenFileDialog fd = new OpenFileDialog();
|
|
fd.Filter = "Worms 4: Mayhem Save File|*.xom";
|
|
fd.Title = "Open Worms 4 Save File";
|
|
if(fd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataManager.SaveFile = new W4SaveFile(XomReader.ReadXomFile(fd.FileName));
|
|
|
|
this.mainTabControl.Enabled = true;
|
|
this.saveToolStripMenuItem.Enabled = true;
|
|
this.convertToolStripMenuItem.Enabled = true;
|
|
|
|
this.Text = defaultTitle + " [" + fd.FileName + "]";
|
|
|
|
DataManager.LoadAll();
|
|
}
|
|
}
|
|
|
|
private void saveToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
SaveFileDialog fd = new SaveFileDialog();
|
|
fd.Filter = "Worms 4: Mayhem Save File|*.xom";
|
|
fd.Title = "Save Worms 4 Save File";
|
|
fd.FileName = "SaveGame.xom";
|
|
if (fd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
this.mainTabControl.Enabled = false;
|
|
|
|
DataManager.SaveAll();
|
|
DataManager.SaveFile.Save(fd.FileName);
|
|
|
|
this.mainTabControl.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void extractAllXomContainersToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
FolderBrowserDialog fbd = new FolderBrowserDialog();
|
|
fbd.Description = "Select folder to extract XomContainers too.";
|
|
if(fbd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
|
|
this.mainTabControl.Enabled = false;
|
|
|
|
DataManager.SaveFile.ExtractAllContainers(fbd.SelectedPath);
|
|
|
|
this.mainTabControl.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void mainTabControl_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (lastTabIndex >= 0)
|
|
{
|
|
foreach (Control ctrl in this.mainTabControl.TabPages[lastTabIndex].Controls)
|
|
{
|
|
try
|
|
{
|
|
TabEntry? tab = ctrl as TabEntry;
|
|
if (tab is TabEntry)
|
|
tab.SaveFromControl();
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
|
|
|
|
if (this.mainTabControl.SelectedIndex >= 0)
|
|
{
|
|
foreach (Control ctrl in this.mainTabControl.TabPages[this.mainTabControl.SelectedIndex].Controls)
|
|
{
|
|
try
|
|
{
|
|
TabEntry? tab = ctrl as TabEntry;
|
|
if (tab is TabEntry)
|
|
tab.LoadIntoControl();
|
|
}
|
|
catch { }
|
|
}
|
|
}
|
|
|
|
|
|
lastTabIndex = this.mainTabControl.SelectedIndex;
|
|
}
|
|
|
|
private void convertToPS2ToolStripMenuItem_Click(object sender, EventArgs e)
|
|
{
|
|
SaveFileDialog fd = new SaveFileDialog();
|
|
fd.Filter = "Worms 4: Mayhem PlayStation 2 Save File|*";
|
|
fd.Title = "Save Worms 4 PlayStation 2 Save File";
|
|
fd.FileName = "BESLES-53096W4MA";
|
|
if (fd.ShowDialog() == DialogResult.OK)
|
|
{
|
|
this.mainTabControl.Enabled = false;
|
|
|
|
DataManager.SaveAll();
|
|
DataManager.SaveFile.SavePS2(fd.FileName);
|
|
|
|
this.mainTabControl.Enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|