Worms4Editor/W4Gui/Tabs/WeaponsTab.cs

70 lines
2.5 KiB
C#
Raw Normal View History

2023-01-12 03:50:02 +00:00
using LibW4M.Data.Teams;
using LibW4M.Data.WeaponFactory;
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.Components;
namespace W4Gui.Tabs
{
public partial class WeaponsTab : TabEntry
{
public override void SaveFromControl()
{
2023-01-13 12:28:44 +00:00
if(weaponList.List.IsItemSelected)
2023-01-12 03:50:02 +00:00
weaponList_Unselected(null, null);
}
public override void LoadIntoControl()
{
2023-01-13 12:28:44 +00:00
weaponList.List.LoadCollective(DataManager.SaveFile.WeaponFactoryCollective);
2023-01-12 03:50:02 +00:00
weaponClusterTabControl.Enabled = false;
2023-01-14 01:00:48 +00:00
}
2023-01-12 03:50:02 +00:00
public WeaponsTab()
{
InitializeComponent();
2023-01-14 01:00:48 +00:00
this.weaponList.List.Selected += weaponList_Selected;
this.weaponList.List.Unselected += weaponList_Unselected;
2023-01-12 03:50:02 +00:00
}
private void weaponList_Unselected(object sender, EventArgs e)
{
2023-01-13 12:28:44 +00:00
WeaponStore store = DataManager.SaveFile.WeaponFactoryCollective[weaponList.List.LastSelected] as WeaponStore;
2023-01-12 03:50:02 +00:00
weaponPanel.SaveWeaponData(ref store.Weapon);
clusterPanel.SaveWeaponData(ref store.Cluster);
2023-01-15 00:32:46 +00:00
store.StockWeapon = selStockWeapon.Checked;
2023-01-13 12:28:44 +00:00
weaponList.List.UpdateName(weaponList.List.LastSelected, store.Weapon.Name.Value);
2023-01-12 03:50:02 +00:00
}
private void weaponList_Selected(object sender, EventArgs e)
{
2023-01-13 12:28:44 +00:00
WeaponStore store = DataManager.SaveFile.WeaponFactoryCollective[weaponList.List.CurrentlySelected] as WeaponStore;
2023-01-12 03:50:02 +00:00
weaponPanel.LoadWeaponData(store.Weapon);
clusterPanel.LoadWeaponData(store.Cluster);
2023-01-15 03:46:18 +00:00
selStockWeapon.Checked = store.StockWeapon; weaponClusterTabControl.Enabled = true;
2023-01-12 03:50:02 +00:00
}
private void weaponList_NewButton(object sender, EventArgs e)
{
throw new NotImplementedException("Adding new weapons from here not implemented yet ;)");
}
private void weaponList_DeleteButton(object sender, EventArgs e)
{
throw new NotImplementedException("Removing weapons from here not implemented yet ;)");
2023-01-13 12:28:44 +00:00
int sel = weaponList.List.CurrentlySelected;
2023-01-12 03:50:02 +00:00
WeaponStore store = DataManager.SaveFile.WeaponFactoryCollective[sel] as WeaponStore;
DataManager.SaveFile.WeaponFactoryCollective.Delete(store);
2023-01-13 12:28:44 +00:00
weaponList.List.Delete(sel);
2023-01-12 03:50:02 +00:00
}
}
}