mirror of
https://github.com/milimoe/FunGame-Testing.git
synced 2025-12-05 08:09:04 +00:00
修改名称,确定为实体编辑器
This commit is contained in:
parent
28a7763ac4
commit
f829b4ae11
@ -25,10 +25,10 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Solutions\EntityCreator\CreateItem.cs">
|
||||
<Compile Update="Solutions\EntityEditor\ItemCreator.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Update="Solutions\EntityCreator\CreateSkill.cs">
|
||||
<Compile Update="Solutions\EntityEditor\SkillCreator.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
@ -14,7 +14,7 @@ namespace Desktop
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
//Application.Run(new ChessBoardExample.ChessBoardExample());
|
||||
Application.Run(new EntityCreator());
|
||||
Application.Run(new EntityEditor());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
partial class CreateCharacter
|
||||
partial class CharacterCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -1,47 +1,205 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public class CharacterCreator
|
||||
public partial class CharacterCreator : Form
|
||||
{
|
||||
public Dictionary<string, Character> LoadedCharacters { get; set; } = [];
|
||||
private CharacterManager CharacterManager { get; }
|
||||
private Character? EditCharacter { get; }
|
||||
|
||||
public void Load()
|
||||
public CharacterCreator(CharacterManager manager, Character? character = null)
|
||||
{
|
||||
EntityModuleConfig<Character> config = new("EntityCreator", "character.creator");
|
||||
config.LoadConfig();
|
||||
LoadedCharacters = new(config);
|
||||
foreach (Character c in LoadedCharacters.Values)
|
||||
InitializeComponent();
|
||||
CharacterManager = manager;
|
||||
if (character != null)
|
||||
{
|
||||
c.Recovery();
|
||||
Text = "角色编辑器";
|
||||
BtnCreate.Text = "编辑";
|
||||
EditCharacter = character;
|
||||
TextName.Text = character.Name;
|
||||
TextCode.Text = manager.LoadedCharacters.Where(kv => kv.Value == character).Select(kv => kv.Key).FirstOrDefault() ?? "";
|
||||
TextFirstName.Text = character.FirstName;
|
||||
TextNickName.Text = character.NickName;
|
||||
TextATK.Text = character.InitialATK.ToString();
|
||||
TextHP.Text = character.InitialHP.ToString();
|
||||
TextMP.Text = character.InitialMP.ToString();
|
||||
TextHR.Text = character.InitialHR.ToString();
|
||||
TextMR.Text = character.InitialMR.ToString();
|
||||
ComboPA.Text = CharacterSet.GetPrimaryAttributeName(character.PrimaryAttribute);
|
||||
TextSTR.Text = character.InitialSTR.ToString();
|
||||
TextGrowthSTR.Text = character.STRGrowth.ToString();
|
||||
TextAGI.Text = character.InitialAGI.ToString();
|
||||
TextGrowthAGI.Text = character.AGIGrowth.ToString();
|
||||
TextINT.Text = character.InitialINT.ToString();
|
||||
TextGrowthINT.Text = character.INTGrowth.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Add(string name, Character character)
|
||||
private void BtnCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
return LoadedCharacters.TryAdd(name, character);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
{
|
||||
return LoadedCharacters.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
EntityModuleConfig<Character> config = new("EntityCreator", "character.creator");
|
||||
foreach (string key in LoadedCharacters.Keys)
|
||||
Character c;
|
||||
if (EditCharacter != null)
|
||||
{
|
||||
config.Add(key, LoadedCharacters[key]);
|
||||
c = EditCharacter;
|
||||
}
|
||||
config.SaveConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
c = Factory.GetCharacter();
|
||||
}
|
||||
string name;
|
||||
|
||||
public void OpenCreator(Character? character = null)
|
||||
{
|
||||
CreateCharacter creator = new(this, character);
|
||||
creator.ShowDialog();
|
||||
if (TextName.Text.Trim() != "")
|
||||
{
|
||||
c.Name = TextName.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("姓不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextCode.Text.Trim() != "")
|
||||
{
|
||||
name = TextCode.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("角色存档标识不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextFirstName.Text.Trim() != "")
|
||||
{
|
||||
c.FirstName = TextFirstName.Text.Trim();
|
||||
}
|
||||
|
||||
if (TextNickName.Text.Trim() != "")
|
||||
{
|
||||
c.NickName = TextNickName.Text.Trim();
|
||||
}
|
||||
|
||||
if (TextATK.Text.Trim() != "" && double.TryParse(TextATK.Text.Trim(), out double atk))
|
||||
{
|
||||
c.InitialATK = atk;
|
||||
}
|
||||
|
||||
if (TextHP.Text.Trim() != "" && double.TryParse(TextHP.Text.Trim(), out double hp))
|
||||
{
|
||||
c.InitialHP = hp;
|
||||
}
|
||||
|
||||
if (TextMP.Text.Trim() != "" && double.TryParse(TextMP.Text.Trim(), out double mp))
|
||||
{
|
||||
c.InitialMP = mp;
|
||||
}
|
||||
|
||||
if (TextHR.Text.Trim() != "" && double.TryParse(TextHR.Text.Trim(), out double hr))
|
||||
{
|
||||
c.InitialHR = hr;
|
||||
}
|
||||
|
||||
if (TextMR.Text.Trim() != "" && double.TryParse(TextMR.Text.Trim(), out double mr))
|
||||
{
|
||||
c.InitialMR = mr;
|
||||
}
|
||||
|
||||
if (ComboPA.Text.Trim() != "")
|
||||
{
|
||||
string pa = ComboPA.Text.Trim();
|
||||
if (pa == "敏捷")
|
||||
{
|
||||
c.PrimaryAttribute = PrimaryAttribute.AGI;
|
||||
}
|
||||
else if (pa == "智力")
|
||||
{
|
||||
c.PrimaryAttribute = PrimaryAttribute.INT;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.PrimaryAttribute = PrimaryAttribute.STR;
|
||||
}
|
||||
}
|
||||
|
||||
if (TextSTR.Text.Trim() != "" && double.TryParse(TextSTR.Text.Trim(), out double str))
|
||||
{
|
||||
c.InitialSTR = str;
|
||||
}
|
||||
|
||||
if (TextGrowthSTR.Text.Trim() != "" && double.TryParse(TextGrowthSTR.Text.Trim(), out double strg))
|
||||
{
|
||||
c.STRGrowth = strg;
|
||||
}
|
||||
|
||||
if (TextAGI.Text.Trim() != "" && double.TryParse(TextAGI.Text.Trim(), out double agi))
|
||||
{
|
||||
c.InitialAGI = agi;
|
||||
}
|
||||
|
||||
if (TextGrowthAGI.Text.Trim() != "" && double.TryParse(TextGrowthAGI.Text.Trim(), out double agig))
|
||||
{
|
||||
c.AGIGrowth = agig;
|
||||
}
|
||||
|
||||
if (TextINT.Text.Trim() != "" && double.TryParse(TextINT.Text.Trim(), out double @int))
|
||||
{
|
||||
c.InitialINT = @int;
|
||||
}
|
||||
|
||||
if (TextGrowthINT.Text.Trim() != "" && double.TryParse(TextGrowthINT.Text.Trim(), out double intg))
|
||||
{
|
||||
c.INTGrowth = intg;
|
||||
}
|
||||
|
||||
if (TextSPD.Text.Trim() != "" && double.TryParse(TextSPD.Text.Trim(), out double spd))
|
||||
{
|
||||
c.InitialSPD = spd;
|
||||
}
|
||||
|
||||
if (EditCharacter != null)
|
||||
{
|
||||
MessageBox.Show("保存成功!");
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CharacterManager.Add(name, c))
|
||||
{
|
||||
ShowDetail d = new(CharacterManager, null, null);
|
||||
d.SetText(-1, c, c.GetInfo());
|
||||
d.Text = "预览模式";
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
if (MessageBox.Show("添加成功!是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
TextName.Text = "";
|
||||
TextCode.Text = "";
|
||||
TextFirstName.Text = "";
|
||||
TextNickName.Text = "";
|
||||
TextATK.Text = "";
|
||||
TextHP.Text = "";
|
||||
TextMP.Text = "";
|
||||
TextHR.Text = "";
|
||||
TextMR.Text = "";
|
||||
ComboPA.Text = "";
|
||||
TextSTR.Text = "";
|
||||
TextGrowthSTR.Text = "";
|
||||
TextAGI.Text = "";
|
||||
TextGrowthAGI.Text = "";
|
||||
TextINT.Text = "";
|
||||
TextGrowthINT.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
47
Desktop/Solutions/EntityCreator/CharacterManager.cs
Normal file
47
Desktop/Solutions/EntityCreator/CharacterManager.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public class CharacterManager
|
||||
{
|
||||
public Dictionary<string, Character> LoadedCharacters { get; set; } = [];
|
||||
|
||||
public void Load()
|
||||
{
|
||||
EntityModuleConfig<Character> config = new("EntityEditor", "characters");
|
||||
config.LoadConfig();
|
||||
LoadedCharacters = new(config);
|
||||
foreach (Character c in LoadedCharacters.Values)
|
||||
{
|
||||
c.Recovery();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Add(string name, Character character)
|
||||
{
|
||||
return LoadedCharacters.TryAdd(name, character);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
{
|
||||
return LoadedCharacters.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
EntityModuleConfig<Character> config = new("EntityEditor", "characters");
|
||||
foreach (string key in LoadedCharacters.Keys)
|
||||
{
|
||||
config.Add(key, LoadedCharacters[key]);
|
||||
}
|
||||
config.SaveConfig();
|
||||
}
|
||||
|
||||
public void OpenCreator(Character? character = null)
|
||||
{
|
||||
CharacterCreator manager = new(this, character);
|
||||
manager.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,205 +0,0 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public partial class CreateCharacter : Form
|
||||
{
|
||||
private CharacterCreator CharacterCreator { get; }
|
||||
private Character? EditCharacter { get; }
|
||||
|
||||
public CreateCharacter(CharacterCreator creator, Character? character = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
CharacterCreator = creator;
|
||||
if (character != null)
|
||||
{
|
||||
Text = "角色编辑器";
|
||||
BtnCreate.Text = "编辑";
|
||||
EditCharacter = character;
|
||||
TextName.Text = character.Name;
|
||||
TextCode.Text = creator.LoadedCharacters.Where(kv => kv.Value == character).Select(kv => kv.Key).FirstOrDefault() ?? "";
|
||||
TextFirstName.Text = character.FirstName;
|
||||
TextNickName.Text = character.NickName;
|
||||
TextATK.Text = character.InitialATK.ToString();
|
||||
TextHP.Text = character.InitialHP.ToString();
|
||||
TextMP.Text = character.InitialMP.ToString();
|
||||
TextHR.Text = character.InitialHR.ToString();
|
||||
TextMR.Text = character.InitialMR.ToString();
|
||||
ComboPA.Text = CharacterSet.GetPrimaryAttributeName(character.PrimaryAttribute);
|
||||
TextSTR.Text = character.InitialSTR.ToString();
|
||||
TextGrowthSTR.Text = character.STRGrowth.ToString();
|
||||
TextAGI.Text = character.InitialAGI.ToString();
|
||||
TextGrowthAGI.Text = character.AGIGrowth.ToString();
|
||||
TextINT.Text = character.InitialINT.ToString();
|
||||
TextGrowthINT.Text = character.INTGrowth.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Character c;
|
||||
if (EditCharacter != null)
|
||||
{
|
||||
c = EditCharacter;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = Factory.GetCharacter();
|
||||
}
|
||||
string name;
|
||||
|
||||
if (TextName.Text.Trim() != "")
|
||||
{
|
||||
c.Name = TextName.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("姓不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextCode.Text.Trim() != "")
|
||||
{
|
||||
name = TextCode.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("角色存档标识不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextFirstName.Text.Trim() != "")
|
||||
{
|
||||
c.FirstName = TextFirstName.Text.Trim();
|
||||
}
|
||||
|
||||
if (TextNickName.Text.Trim() != "")
|
||||
{
|
||||
c.NickName = TextNickName.Text.Trim();
|
||||
}
|
||||
|
||||
if (TextATK.Text.Trim() != "" && double.TryParse(TextATK.Text.Trim(), out double atk))
|
||||
{
|
||||
c.InitialATK = atk;
|
||||
}
|
||||
|
||||
if (TextHP.Text.Trim() != "" && double.TryParse(TextHP.Text.Trim(), out double hp))
|
||||
{
|
||||
c.InitialHP = hp;
|
||||
}
|
||||
|
||||
if (TextMP.Text.Trim() != "" && double.TryParse(TextMP.Text.Trim(), out double mp))
|
||||
{
|
||||
c.InitialMP = mp;
|
||||
}
|
||||
|
||||
if (TextHR.Text.Trim() != "" && double.TryParse(TextHR.Text.Trim(), out double hr))
|
||||
{
|
||||
c.InitialHR = hr;
|
||||
}
|
||||
|
||||
if (TextMR.Text.Trim() != "" && double.TryParse(TextMR.Text.Trim(), out double mr))
|
||||
{
|
||||
c.InitialMR = mr;
|
||||
}
|
||||
|
||||
if (ComboPA.Text.Trim() != "")
|
||||
{
|
||||
string pa = ComboPA.Text.Trim();
|
||||
if (pa == "敏捷")
|
||||
{
|
||||
c.PrimaryAttribute = PrimaryAttribute.AGI;
|
||||
}
|
||||
else if (pa == "智力")
|
||||
{
|
||||
c.PrimaryAttribute = PrimaryAttribute.INT;
|
||||
}
|
||||
else
|
||||
{
|
||||
c.PrimaryAttribute = PrimaryAttribute.STR;
|
||||
}
|
||||
}
|
||||
|
||||
if (TextSTR.Text.Trim() != "" && double.TryParse(TextSTR.Text.Trim(), out double str))
|
||||
{
|
||||
c.InitialSTR = str;
|
||||
}
|
||||
|
||||
if (TextGrowthSTR.Text.Trim() != "" && double.TryParse(TextGrowthSTR.Text.Trim(), out double strg))
|
||||
{
|
||||
c.STRGrowth = strg;
|
||||
}
|
||||
|
||||
if (TextAGI.Text.Trim() != "" && double.TryParse(TextAGI.Text.Trim(), out double agi))
|
||||
{
|
||||
c.InitialAGI = agi;
|
||||
}
|
||||
|
||||
if (TextGrowthAGI.Text.Trim() != "" && double.TryParse(TextGrowthAGI.Text.Trim(), out double agig))
|
||||
{
|
||||
c.AGIGrowth = agig;
|
||||
}
|
||||
|
||||
if (TextINT.Text.Trim() != "" && double.TryParse(TextINT.Text.Trim(), out double @int))
|
||||
{
|
||||
c.InitialINT = @int;
|
||||
}
|
||||
|
||||
if (TextGrowthINT.Text.Trim() != "" && double.TryParse(TextGrowthINT.Text.Trim(), out double intg))
|
||||
{
|
||||
c.INTGrowth = intg;
|
||||
}
|
||||
|
||||
if (TextSPD.Text.Trim() != "" && double.TryParse(TextSPD.Text.Trim(), out double spd))
|
||||
{
|
||||
c.InitialSPD = spd;
|
||||
}
|
||||
|
||||
if (EditCharacter != null)
|
||||
{
|
||||
MessageBox.Show("保存成功!");
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CharacterCreator.Add(name, c))
|
||||
{
|
||||
ShowDetail d = new(CharacterCreator, null, null);
|
||||
d.SetText(-1, c, c.GetInfo());
|
||||
d.Text = "预览模式";
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
if (MessageBox.Show("添加成功!是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
TextName.Text = "";
|
||||
TextCode.Text = "";
|
||||
TextFirstName.Text = "";
|
||||
TextNickName.Text = "";
|
||||
TextATK.Text = "";
|
||||
TextHP.Text = "";
|
||||
TextMP.Text = "";
|
||||
TextHR.Text = "";
|
||||
TextMR.Text = "";
|
||||
ComboPA.Text = "";
|
||||
TextSTR.Text = "";
|
||||
TextGrowthSTR.Text = "";
|
||||
TextAGI.Text = "";
|
||||
TextGrowthAGI.Text = "";
|
||||
TextINT.Text = "";
|
||||
TextGrowthINT.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,199 +0,0 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public partial class CreateItem : Form
|
||||
{
|
||||
private ItemCreator ItemCreator { get; }
|
||||
private Item? EditItem { get; }
|
||||
|
||||
public CreateItem(ItemCreator creator, Item? item = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
ItemCreator = creator;
|
||||
if (item != null)
|
||||
{
|
||||
Text = "物品编辑器";
|
||||
BtnCreate.Text = "编辑";
|
||||
EditItem = item;
|
||||
TextID.Text = item.Id.ToString();
|
||||
TextName.Text = item.Name;
|
||||
TextCode.Text = creator.LoadedItems.Where(kv => kv.Value.Equals(item)).Select(kv => kv.Key).FirstOrDefault() ?? "";
|
||||
ComboItemType.Text = ItemSet.GetItemTypeName(item.ItemType);
|
||||
CheckboxIsWeapon.Checked = item.ItemType == ItemType.Weapon;
|
||||
ComboWeapon.Text = ItemSet.GetWeaponTypeName(item.WeaponType);
|
||||
ComboWeapon.Enabled = item.ItemType == ItemType.Weapon;
|
||||
CheckboxIsEquip.Checked = item.Equipable;
|
||||
ComboEquip.Text = ItemSet.GetEquipSlotTypeName(item.EquipSlotType);
|
||||
ComboEquip.Enabled = item.Equipable;
|
||||
CheckboxIsPurchasable.Checked = item.IsPurchasable;
|
||||
TextPrice.Text = item.Price.ToString();
|
||||
TextPrice.Enabled = item.IsPurchasable;
|
||||
CheckboxIsSellable.Checked = item.IsSellable;
|
||||
CheckboxIsTradable.Checked = item.IsTradable;
|
||||
if (item.NextSellableTime > DateTime.Now && item.NextSellableTime < DateTime.MaxValue) DateTimePickerSell.Value = item.NextSellableTime;
|
||||
DateTimePickerSell.Enabled = !item.IsSellable;
|
||||
if (item.NextTradableTime > DateTime.Now && item.NextTradableTime < DateTime.MaxValue) DateTimePickerTrade.Value = item.NextTradableTime;
|
||||
DateTimePickerTrade.Enabled = !item.IsTradable;
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckboxIsWeapon.Checked = false;
|
||||
ComboWeapon.Enabled = false;
|
||||
CheckboxIsEquip.Checked = false;
|
||||
ComboEquip.Enabled = false;
|
||||
CheckboxIsPurchasable.Checked = false;
|
||||
TextPrice.Enabled = false;
|
||||
CheckboxIsSellable.Checked = true;
|
||||
CheckboxIsTradable.Checked = true;
|
||||
DateTimePickerSell.Value = DateTime.Now;
|
||||
DateTimePickerSell.Enabled = false;
|
||||
DateTimePickerTrade.Value = DateTime.Now;
|
||||
DateTimePickerTrade.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Item i;
|
||||
if (EditItem != null)
|
||||
{
|
||||
i = EditItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = Factory.GetItem();
|
||||
}
|
||||
string name;
|
||||
|
||||
if (TextID.Text.Trim() != "" && long.TryParse(TextID.Text.Trim(), out long id))
|
||||
{
|
||||
i.Id = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("ID不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextName.Text.Trim() != "")
|
||||
{
|
||||
i.Name = TextName.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("名称不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextCode.Text.Trim() != "")
|
||||
{
|
||||
name = TextCode.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("物品存档标识不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CheckboxIsWeapon.Checked && ComboWeapon.Text.Trim() != "")
|
||||
{
|
||||
i.WeaponType = ItemSet.GetWeaponTypeFromName(ComboWeapon.Text.Trim());
|
||||
}
|
||||
|
||||
if (CheckboxIsEquip.Checked && ComboEquip.Text.Trim() != "")
|
||||
{
|
||||
i.EquipSlotType = ItemSet.GetEquipSlotTypeFromName(ComboEquip.Text.Trim());
|
||||
}
|
||||
|
||||
if (CheckboxIsPurchasable.Checked && TextPrice.Text.Trim() != "" && double.TryParse(TextPrice.Text.Trim(), out double price))
|
||||
{
|
||||
i.Price = price;
|
||||
}
|
||||
|
||||
if (!CheckboxIsSellable.Checked && DateTime.Now < DateTimePickerSell.Value)
|
||||
{
|
||||
i.NextSellableTime = DateTimePickerSell.Value;
|
||||
}
|
||||
|
||||
if (!CheckboxIsTradable.Checked && DateTime.Now < DateTimePickerTrade.Value)
|
||||
{
|
||||
i.NextTradableTime = DateTimePickerTrade.Value;
|
||||
}
|
||||
|
||||
if (EditItem != null)
|
||||
{
|
||||
MessageBox.Show("保存成功!");
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ItemCreator.Add(name, i))
|
||||
{
|
||||
ShowDetail d = new(null, null, ItemCreator);
|
||||
d.SetText(-1, i, i.ToString());
|
||||
d.Text = "预览模式";
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
if (MessageBox.Show("添加成功!是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
TextID.Text = "";
|
||||
TextName.Text = "";
|
||||
TextCode.Text = "";
|
||||
ComboItemType.Text = "";
|
||||
CheckboxIsWeapon.Checked = false;
|
||||
ComboWeapon.Text = "";
|
||||
ComboWeapon.Enabled = false;
|
||||
CheckboxIsEquip.Checked = false;
|
||||
ComboEquip.Text = "";
|
||||
ComboEquip.Enabled = false;
|
||||
CheckboxIsPurchasable.Checked = false;
|
||||
TextPrice.Text = "";
|
||||
TextPrice.Enabled = false;
|
||||
CheckboxIsSellable.Checked = true;
|
||||
CheckboxIsTradable.Checked = true;
|
||||
DateTimePickerSell.Value = DateTime.Now;
|
||||
DateTimePickerSell.Enabled = false;
|
||||
DateTimePickerTrade.Value = DateTime.Now;
|
||||
DateTimePickerTrade.Enabled = false;
|
||||
}
|
||||
|
||||
private void CheckboxIsWeapon_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ComboWeapon.Enabled = CheckboxIsWeapon.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsEquip_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ComboEquip.Enabled = CheckboxIsEquip.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsPurchasable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
TextPrice.Enabled = CheckboxIsPurchasable.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsSellable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateTimePickerSell.Enabled = !CheckboxIsSellable.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsTradable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateTimePickerTrade.Enabled = !CheckboxIsTradable.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,104 +0,0 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public partial class CreateSkill : Form
|
||||
{
|
||||
private SkillCreator SkillCreator { get; }
|
||||
private Skill? EditSkill { get; }
|
||||
|
||||
public CreateSkill(SkillCreator creator, Skill? skill = null)
|
||||
{
|
||||
InitializeComponent();
|
||||
SkillCreator = creator;
|
||||
if (skill != null)
|
||||
{
|
||||
Text = "技能编辑器";
|
||||
BtnCreate.Text = "编辑";
|
||||
EditSkill = skill;
|
||||
TextID.Text = skill.Id.ToString();
|
||||
TextCode.Text = creator.LoadedSkills.Where(kv => kv.Value.Equals(skill)).Select(kv => kv.Key).FirstOrDefault() ?? "";
|
||||
TextName.Text = skill.Name;
|
||||
ComboSkillType.Text = SkillSet.GetSkillTypeName(skill.SkillType);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Skill s;
|
||||
if (EditSkill != null)
|
||||
{
|
||||
s = EditSkill;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = Factory.GetSkill();
|
||||
}
|
||||
string name;
|
||||
|
||||
if (TextID.Text.Trim() != "" && long.TryParse(TextID.Text.Trim(), out long id))
|
||||
{
|
||||
s.Id = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("ID不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextName.Text.Trim() != "")
|
||||
{
|
||||
s.Name = TextName.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("名称不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextCode.Text.Trim() != "")
|
||||
{
|
||||
name = TextCode.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("技能存档标识不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (EditSkill != null)
|
||||
{
|
||||
MessageBox.Show("保存成功!");
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SkillCreator.Add(name, s))
|
||||
{
|
||||
ShowDetail d = new(null, SkillCreator, null);
|
||||
d.SetText(-1, s, s.ToString());
|
||||
d.Text = "预览模式";
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
if (MessageBox.Show("添加成功!是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
TextID.Text = "";
|
||||
TextCode.Text = "";
|
||||
TextName.Text = "";
|
||||
ComboSkillType.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
partial class EntityCreator
|
||||
partial class EntityEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -275,7 +275,7 @@
|
||||
删除角色技能.UseVisualStyleBackColor = true;
|
||||
删除角色技能.Click += 删除角色技能_Click;
|
||||
//
|
||||
// EntityCreator
|
||||
// EntityEditor
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
@ -299,9 +299,11 @@
|
||||
Controls.Add(查看现有物品);
|
||||
Controls.Add(查看现有技能);
|
||||
Controls.Add(查看现有角色);
|
||||
Name = "EntityCreator";
|
||||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||
MaximizeBox = false;
|
||||
Name = "EntityEditor";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "实体创建器";
|
||||
Text = "实体编辑器";
|
||||
列表.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
@ -1,27 +1,26 @@
|
||||
using Microsoft.VisualBasic;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Common.Addon;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public partial class EntityCreator : Form
|
||||
public partial class EntityEditor : Form
|
||||
{
|
||||
private static GameModuleLoader? GameModuleLoader { get; set; } = null;
|
||||
private CharacterCreator CharacterCreator { get; } = new();
|
||||
private SkillCreator SkillCreator { get; } = new();
|
||||
private ItemCreator ItemCreator { get; } = new();
|
||||
private CharacterManager CharacterManager { get; } = new();
|
||||
private SkillManager SkillManager { get; } = new();
|
||||
private ItemManager ItemManager { get; } = new();
|
||||
private bool CheckSelectedIndex => 实际列表.SelectedIndex != -1 && 实际列表.SelectedIndex < 实际列表.Items.Count;
|
||||
private int nowClick = 0;
|
||||
|
||||
public EntityCreator()
|
||||
public EntityEditor()
|
||||
{
|
||||
InitializeComponent();
|
||||
GameModuleLoader = LoadModules();
|
||||
CharacterCreator.Load();
|
||||
SkillCreator.Load();
|
||||
ItemCreator.Load();
|
||||
CharacterManager.Load();
|
||||
SkillManager.Load();
|
||||
ItemManager.Load();
|
||||
查看现有技能方法();
|
||||
查看现有物品方法();
|
||||
查看现有角色方法();
|
||||
@ -30,9 +29,9 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
private void 查看现有角色方法()
|
||||
{
|
||||
实际列表.Items.Clear();
|
||||
foreach (string name in CharacterCreator.LoadedCharacters.Keys)
|
||||
foreach (string name in CharacterManager.LoadedCharacters.Keys)
|
||||
{
|
||||
实际列表.Items.Add(CharacterCreator.LoadedCharacters[name]);
|
||||
实际列表.Items.Add(CharacterManager.LoadedCharacters[name]);
|
||||
}
|
||||
nowClick = 0;
|
||||
}
|
||||
@ -40,9 +39,9 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
private void 查看现有技能方法()
|
||||
{
|
||||
实际列表.Items.Clear();
|
||||
foreach (string name in SkillCreator.LoadedSkills.OrderBy(kv => kv.Value.Id).Select(kv => kv.Key))
|
||||
foreach (string name in SkillManager.LoadedSkills.OrderBy(kv => kv.Value.Id).Select(kv => kv.Key))
|
||||
{
|
||||
实际列表.Items.Add(GetSkillDisplayName(SkillCreator, name));
|
||||
实际列表.Items.Add(GetSkillDisplayName(SkillManager, name));
|
||||
}
|
||||
nowClick = 1;
|
||||
}
|
||||
@ -50,9 +49,9 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
private void 查看现有物品方法()
|
||||
{
|
||||
实际列表.Items.Clear();
|
||||
foreach (string name in ItemCreator.LoadedItems.OrderBy(kv => kv.Value.Id).Select(kv => kv.Key))
|
||||
foreach (string name in ItemManager.LoadedItems.OrderBy(kv => kv.Value.Id).Select(kv => kv.Key))
|
||||
{
|
||||
实际列表.Items.Add(GetItemDisplayName(ItemCreator, name));
|
||||
实际列表.Items.Add(GetItemDisplayName(ItemManager, name));
|
||||
}
|
||||
nowClick = 2;
|
||||
}
|
||||
@ -83,27 +82,27 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 全部保存_Click(object sender, EventArgs e)
|
||||
{
|
||||
CharacterCreator.Save();
|
||||
SkillCreator.Save();
|
||||
ItemCreator.Save();
|
||||
CharacterManager.Save();
|
||||
SkillManager.Save();
|
||||
ItemManager.Save();
|
||||
MessageBox.Show("保存成功!");
|
||||
}
|
||||
|
||||
private void 保存角色_Click(object sender, EventArgs e)
|
||||
{
|
||||
CharacterCreator.Save();
|
||||
CharacterManager.Save();
|
||||
MessageBox.Show("保存成功!");
|
||||
}
|
||||
|
||||
private void 保存技能_Click(object sender, EventArgs e)
|
||||
{
|
||||
SkillCreator.Save();
|
||||
SkillManager.Save();
|
||||
MessageBox.Show("保存成功!");
|
||||
}
|
||||
|
||||
private void 保存物品_Click(object sender, EventArgs e)
|
||||
{
|
||||
ItemCreator.Save();
|
||||
ItemManager.Save();
|
||||
MessageBox.Show("保存成功!");
|
||||
}
|
||||
|
||||
@ -143,16 +142,16 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
if (CheckSelectedIndex)
|
||||
{
|
||||
ShowDetail d = new(CharacterCreator, SkillCreator, ItemCreator);
|
||||
ShowDetail d = new(CharacterManager, SkillManager, ItemManager);
|
||||
switch (nowClick)
|
||||
{
|
||||
case 0:
|
||||
Character? character = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Character? character = CharacterManager.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
d.SetText(nowClick, character, character?.GetInfo() ?? "");
|
||||
d.ShowDialog();
|
||||
break;
|
||||
case 1:
|
||||
Skill? s = SkillCreator.LoadedSkills.Where(kv => GetSkillDisplayName(SkillCreator, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).Select(kv => kv.Value).FirstOrDefault();
|
||||
Skill? s = SkillManager.LoadedSkills.Where(kv => GetSkillDisplayName(SkillManager, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).Select(kv => kv.Value).FirstOrDefault();
|
||||
if (s != null)
|
||||
{
|
||||
Skill? s2 = 从模组加载器中获取技能(s.Id, s.Name, s.SkillType);
|
||||
@ -165,7 +164,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Item? i = ItemCreator.LoadedItems.Where(kv => GetItemDisplayName(ItemCreator, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).Select(kv => kv.Value).FirstOrDefault();
|
||||
Item? i = ItemManager.LoadedItems.Where(kv => GetItemDisplayName(ItemManager, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).Select(kv => kv.Value).FirstOrDefault();
|
||||
if (i != null)
|
||||
{
|
||||
Item? i2 = 从模组加载器中获取物品(i.Id, i.Name, i.ItemType);
|
||||
@ -187,14 +186,14 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 为角色添加技能方法()
|
||||
{
|
||||
if (SkillCreator.LoadedSkills.Count != 0)
|
||||
if (SkillManager.LoadedSkills.Count != 0)
|
||||
{
|
||||
ShowList l = new();
|
||||
l.AddListItem(SkillCreator.LoadedSkills.OrderBy(kv => kv.Value.Id).Where(kv => kv.Value.SkillType != SkillType.Item).Select(kv => GetSkillDisplayName(SkillCreator, kv.Key)).ToArray());
|
||||
l.AddListItem(SkillManager.LoadedSkills.OrderBy(kv => kv.Value.Id).Where(kv => kv.Value.SkillType != SkillType.Item).Select(kv => GetSkillDisplayName(SkillManager, kv.Key)).ToArray());
|
||||
l.ShowDialog();
|
||||
string selected = l.SelectItem;
|
||||
Character? c = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Skill? s = SkillCreator.LoadedSkills.Where(kv => GetSkillDisplayName(SkillCreator, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
Character? c = CharacterManager.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Skill? s = SkillManager.LoadedSkills.Where(kv => GetSkillDisplayName(SkillManager, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
if (c != null && s != null)
|
||||
{
|
||||
Skill? s2 = 从模组加载器中获取技能(s.Id, s.Name, s.SkillType);
|
||||
@ -214,14 +213,14 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 为角色添加物品方法()
|
||||
{
|
||||
if (ItemCreator.LoadedItems.Count != 0)
|
||||
if (ItemManager.LoadedItems.Count != 0)
|
||||
{
|
||||
ShowList l = new();
|
||||
l.AddListItem(ItemCreator.LoadedItems.OrderBy(kv => kv.Value.Id).Select(kv => GetItemDisplayName(ItemCreator, kv.Key)).ToArray());
|
||||
l.AddListItem(ItemManager.LoadedItems.OrderBy(kv => kv.Value.Id).Select(kv => GetItemDisplayName(ItemManager, kv.Key)).ToArray());
|
||||
l.ShowDialog();
|
||||
string selected = l.SelectItem;
|
||||
Character? c = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Item? i = ItemCreator.LoadedItems.Where(kv => GetItemDisplayName(ItemCreator, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
Character? c = CharacterManager.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Item? i = ItemManager.LoadedItems.Where(kv => GetItemDisplayName(ItemManager, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
if (c != null && i != null)
|
||||
{
|
||||
Item? i2 = 从模组加载器中获取物品(i.Id, i.Name, i.ItemType);
|
||||
@ -241,7 +240,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 删除角色技能方法()
|
||||
{
|
||||
Character? c = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Character? c = CharacterManager.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
if (c != null)
|
||||
{
|
||||
if (c.Skills.Count != 0)
|
||||
@ -262,7 +261,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 删除角色物品方法()
|
||||
{
|
||||
Character? c = CharacterCreator.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
Character? c = CharacterManager.LoadedCharacters.Values.Where(c => c.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault();
|
||||
if (c != null)
|
||||
{
|
||||
if (c.Items.Count != 0)
|
||||
@ -318,19 +317,19 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 创建角色_Click(object sender, EventArgs e)
|
||||
{
|
||||
CharacterCreator.OpenCreator();
|
||||
CharacterManager.OpenCreator();
|
||||
查看现有角色方法();
|
||||
}
|
||||
|
||||
private void 创建技能_Click(object sender, EventArgs e)
|
||||
{
|
||||
SkillCreator.OpenCreator();
|
||||
SkillManager.OpenCreator();
|
||||
查看现有技能方法();
|
||||
}
|
||||
|
||||
private void 创建物品_Click(object sender, EventArgs e)
|
||||
{
|
||||
ItemCreator.OpenCreator();
|
||||
ItemManager.OpenCreator();
|
||||
查看现有物品方法();
|
||||
}
|
||||
|
||||
@ -338,8 +337,8 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
if (CheckSelectedIndex && nowClick == 0 && MessageBox.Show("是否删除", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
string name = CharacterCreator.LoadedCharacters.Where(ky => ky.Value.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? "";
|
||||
if (CharacterCreator.Remove(name))
|
||||
string name = CharacterManager.LoadedCharacters.Where(ky => ky.Value.ToString() == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? "";
|
||||
if (CharacterManager.Remove(name))
|
||||
{
|
||||
MessageBox.Show("删除成功!");
|
||||
查看现有角色方法();
|
||||
@ -355,8 +354,8 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
if (CheckSelectedIndex && nowClick == 1 && MessageBox.Show("是否删除", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
string name = SkillCreator.LoadedSkills.Where(kv => GetSkillDisplayName(SkillCreator, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? "";
|
||||
if (SkillCreator.Remove(name))
|
||||
string name = SkillManager.LoadedSkills.Where(kv => GetSkillDisplayName(SkillManager, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? "";
|
||||
if (SkillManager.Remove(name))
|
||||
{
|
||||
MessageBox.Show("删除成功!");
|
||||
查看现有技能方法();
|
||||
@ -372,8 +371,8 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
if (CheckSelectedIndex && nowClick == 2 && MessageBox.Show("是否删除", "删除", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
string name = ItemCreator.LoadedItems.Where(kv => GetItemDisplayName(ItemCreator, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? "";
|
||||
if (ItemCreator.Remove(name))
|
||||
string name = ItemManager.LoadedItems.Where(kv => GetItemDisplayName(ItemManager, kv.Key) == 实际列表.Items[实际列表.SelectedIndex].ToString()).FirstOrDefault().Key ?? "";
|
||||
if (ItemManager.Remove(name))
|
||||
{
|
||||
MessageBox.Show("删除成功!");
|
||||
查看现有物品方法();
|
||||
@ -389,16 +388,16 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
if (MessageBox.Show("重新读取会丢失未保存的数据,是否确认重新读取全部?", "重新读取全部", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
||||
{
|
||||
CharacterCreator.Load();
|
||||
SkillCreator.Load();
|
||||
ItemCreator.Load();
|
||||
CharacterManager.Load();
|
||||
SkillManager.Load();
|
||||
ItemManager.Load();
|
||||
查看现有技能方法();
|
||||
查看现有物品方法();
|
||||
查看现有角色方法();
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSkillDisplayName(SkillCreator skillCreator, string name)
|
||||
public static string GetSkillDisplayName(SkillManager skillCreator, string name)
|
||||
{
|
||||
if (skillCreator.LoadedSkills.TryGetValue(name, out Skill? skill) && skill != null)
|
||||
{
|
||||
@ -407,7 +406,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
return "";
|
||||
}
|
||||
|
||||
public static string GetItemDisplayName(ItemCreator itemCreator, string name)
|
||||
public static string GetItemDisplayName(ItemManager itemCreator, string name)
|
||||
{
|
||||
if (itemCreator.LoadedItems.TryGetValue(name, out Item? item) && item != null)
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
partial class CreateItem
|
||||
partial class ItemCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -1,43 +1,199 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public class ItemCreator
|
||||
public partial class ItemCreator : Form
|
||||
{
|
||||
public Dictionary<string, Item> LoadedItems { get; set; } = [];
|
||||
private ItemManager ItemManager { get; }
|
||||
private Item? EditItem { get; }
|
||||
|
||||
public void Load()
|
||||
public ItemCreator(ItemManager manager, Item? item = null)
|
||||
{
|
||||
EntityModuleConfig<Item> config = new("EntityCreator", "item.creator");
|
||||
config.LoadConfig();
|
||||
LoadedItems = new(config);
|
||||
}
|
||||
|
||||
public bool Add(string name, Item item)
|
||||
{
|
||||
return LoadedItems.TryAdd(name, item);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
{
|
||||
return LoadedItems.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
EntityModuleConfig<Item> config = new("EntityCreator", "item.creator");
|
||||
foreach (string key in LoadedItems.Keys)
|
||||
InitializeComponent();
|
||||
ItemManager = manager;
|
||||
if (item != null)
|
||||
{
|
||||
config.Add(key, LoadedItems[key]);
|
||||
Text = "物品编辑器";
|
||||
BtnCreate.Text = "编辑";
|
||||
EditItem = item;
|
||||
TextID.Text = item.Id.ToString();
|
||||
TextName.Text = item.Name;
|
||||
TextCode.Text = manager.LoadedItems.Where(kv => kv.Value.Equals(item)).Select(kv => kv.Key).FirstOrDefault() ?? "";
|
||||
ComboItemType.Text = ItemSet.GetItemTypeName(item.ItemType);
|
||||
CheckboxIsWeapon.Checked = item.ItemType == ItemType.Weapon;
|
||||
ComboWeapon.Text = ItemSet.GetWeaponTypeName(item.WeaponType);
|
||||
ComboWeapon.Enabled = item.ItemType == ItemType.Weapon;
|
||||
CheckboxIsEquip.Checked = item.Equipable;
|
||||
ComboEquip.Text = ItemSet.GetEquipSlotTypeName(item.EquipSlotType);
|
||||
ComboEquip.Enabled = item.Equipable;
|
||||
CheckboxIsPurchasable.Checked = item.IsPurchasable;
|
||||
TextPrice.Text = item.Price.ToString();
|
||||
TextPrice.Enabled = item.IsPurchasable;
|
||||
CheckboxIsSellable.Checked = item.IsSellable;
|
||||
CheckboxIsTradable.Checked = item.IsTradable;
|
||||
if (item.NextSellableTime > DateTime.Now && item.NextSellableTime < DateTime.MaxValue) DateTimePickerSell.Value = item.NextSellableTime;
|
||||
DateTimePickerSell.Enabled = !item.IsSellable;
|
||||
if (item.NextTradableTime > DateTime.Now && item.NextTradableTime < DateTime.MaxValue) DateTimePickerTrade.Value = item.NextTradableTime;
|
||||
DateTimePickerTrade.Enabled = !item.IsTradable;
|
||||
}
|
||||
else
|
||||
{
|
||||
CheckboxIsWeapon.Checked = false;
|
||||
ComboWeapon.Enabled = false;
|
||||
CheckboxIsEquip.Checked = false;
|
||||
ComboEquip.Enabled = false;
|
||||
CheckboxIsPurchasable.Checked = false;
|
||||
TextPrice.Enabled = false;
|
||||
CheckboxIsSellable.Checked = true;
|
||||
CheckboxIsTradable.Checked = true;
|
||||
DateTimePickerSell.Value = DateTime.Now;
|
||||
DateTimePickerSell.Enabled = false;
|
||||
DateTimePickerTrade.Value = DateTime.Now;
|
||||
DateTimePickerTrade.Enabled = false;
|
||||
}
|
||||
config.SaveConfig();
|
||||
}
|
||||
|
||||
public void OpenCreator(Item? item = null)
|
||||
private void BtnCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateItem creator = new(this, item);
|
||||
creator.ShowDialog();
|
||||
Item i;
|
||||
if (EditItem != null)
|
||||
{
|
||||
i = EditItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = Factory.GetItem();
|
||||
}
|
||||
string name;
|
||||
|
||||
if (TextID.Text.Trim() != "" && long.TryParse(TextID.Text.Trim(), out long id))
|
||||
{
|
||||
i.Id = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("ID不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextName.Text.Trim() != "")
|
||||
{
|
||||
i.Name = TextName.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("名称不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextCode.Text.Trim() != "")
|
||||
{
|
||||
name = TextCode.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("物品存档标识不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CheckboxIsWeapon.Checked && ComboWeapon.Text.Trim() != "")
|
||||
{
|
||||
i.WeaponType = ItemSet.GetWeaponTypeFromName(ComboWeapon.Text.Trim());
|
||||
}
|
||||
|
||||
if (CheckboxIsEquip.Checked && ComboEquip.Text.Trim() != "")
|
||||
{
|
||||
i.EquipSlotType = ItemSet.GetEquipSlotTypeFromName(ComboEquip.Text.Trim());
|
||||
}
|
||||
|
||||
if (CheckboxIsPurchasable.Checked && TextPrice.Text.Trim() != "" && double.TryParse(TextPrice.Text.Trim(), out double price))
|
||||
{
|
||||
i.Price = price;
|
||||
}
|
||||
|
||||
if (!CheckboxIsSellable.Checked && DateTime.Now < DateTimePickerSell.Value)
|
||||
{
|
||||
i.NextSellableTime = DateTimePickerSell.Value;
|
||||
}
|
||||
|
||||
if (!CheckboxIsTradable.Checked && DateTime.Now < DateTimePickerTrade.Value)
|
||||
{
|
||||
i.NextTradableTime = DateTimePickerTrade.Value;
|
||||
}
|
||||
|
||||
if (EditItem != null)
|
||||
{
|
||||
MessageBox.Show("保存成功!");
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ItemManager.Add(name, i))
|
||||
{
|
||||
ShowDetail d = new(null, null, ItemManager);
|
||||
d.SetText(-1, i, i.ToString());
|
||||
d.Text = "预览模式";
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
if (MessageBox.Show("添加成功!是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
TextID.Text = "";
|
||||
TextName.Text = "";
|
||||
TextCode.Text = "";
|
||||
ComboItemType.Text = "";
|
||||
CheckboxIsWeapon.Checked = false;
|
||||
ComboWeapon.Text = "";
|
||||
ComboWeapon.Enabled = false;
|
||||
CheckboxIsEquip.Checked = false;
|
||||
ComboEquip.Text = "";
|
||||
ComboEquip.Enabled = false;
|
||||
CheckboxIsPurchasable.Checked = false;
|
||||
TextPrice.Text = "";
|
||||
TextPrice.Enabled = false;
|
||||
CheckboxIsSellable.Checked = true;
|
||||
CheckboxIsTradable.Checked = true;
|
||||
DateTimePickerSell.Value = DateTime.Now;
|
||||
DateTimePickerSell.Enabled = false;
|
||||
DateTimePickerTrade.Value = DateTime.Now;
|
||||
DateTimePickerTrade.Enabled = false;
|
||||
}
|
||||
|
||||
private void CheckboxIsWeapon_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ComboWeapon.Enabled = CheckboxIsWeapon.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsEquip_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
ComboEquip.Enabled = CheckboxIsEquip.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsPurchasable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
TextPrice.Enabled = CheckboxIsPurchasable.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsSellable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateTimePickerSell.Enabled = !CheckboxIsSellable.Checked;
|
||||
}
|
||||
|
||||
private void CheckboxIsTradable_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
DateTimePickerTrade.Enabled = !CheckboxIsTradable.Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
Desktop/Solutions/EntityCreator/ItemManager.cs
Normal file
43
Desktop/Solutions/EntityCreator/ItemManager.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public class ItemManager
|
||||
{
|
||||
public Dictionary<string, Item> LoadedItems { get; set; } = [];
|
||||
|
||||
public void Load()
|
||||
{
|
||||
EntityModuleConfig<Item> config = new("EntityEditor", "items");
|
||||
config.LoadConfig();
|
||||
LoadedItems = new(config);
|
||||
}
|
||||
|
||||
public bool Add(string name, Item item)
|
||||
{
|
||||
return LoadedItems.TryAdd(name, item);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
{
|
||||
return LoadedItems.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
EntityModuleConfig<Item> config = new("EntityEditor", "items");
|
||||
foreach (string key in LoadedItems.Keys)
|
||||
{
|
||||
config.Add(key, LoadedItems[key]);
|
||||
}
|
||||
config.SaveConfig();
|
||||
}
|
||||
|
||||
public void OpenCreator(Item? item = null)
|
||||
{
|
||||
ItemCreator manager = new(this, item);
|
||||
manager.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,18 +4,18 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public partial class ShowDetail : Form
|
||||
{
|
||||
private CharacterCreator? CharacterCreator { get; }
|
||||
private SkillCreator? SkillCreator { get; }
|
||||
private ItemCreator? ItemCreator { get; }
|
||||
private CharacterManager? CharacterManager { get; }
|
||||
private SkillManager? SkillManager { get; }
|
||||
private ItemManager? ItemManager { get; }
|
||||
private int NowClick { get; set; } = -1;
|
||||
private BaseEntity? BaseEntity { get; set; }
|
||||
|
||||
public ShowDetail(CharacterCreator? characterCreator, SkillCreator? skillCreator, ItemCreator? itemCreator)
|
||||
public ShowDetail(CharacterManager? characterManager, SkillManager? skillManager, ItemManager? itemManager)
|
||||
{
|
||||
InitializeComponent();
|
||||
CharacterCreator = characterCreator;
|
||||
SkillCreator = skillCreator;
|
||||
ItemCreator = itemCreator;
|
||||
CharacterManager = characterManager;
|
||||
SkillManager = skillManager;
|
||||
ItemManager = itemManager;
|
||||
Text = "详细信息查看";
|
||||
}
|
||||
|
||||
@ -62,32 +62,32 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
if (NowClick == 0 && BaseEntity is Character c)
|
||||
{
|
||||
CharacterCreator?.OpenCreator(c);
|
||||
CharacterManager?.OpenCreator(c);
|
||||
}
|
||||
else if (NowClick == 1 && BaseEntity is Skill s)
|
||||
{
|
||||
SkillCreator?.OpenCreator(s);
|
||||
SkillManager?.OpenCreator(s);
|
||||
}
|
||||
else if (NowClick == 2 && BaseEntity is Item i)
|
||||
{
|
||||
ItemCreator?.OpenCreator(i);
|
||||
ItemManager?.OpenCreator(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void 加物品_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (NowClick == 0 && ItemCreator != null && BaseEntity is Character c)
|
||||
if (NowClick == 0 && ItemManager != null && BaseEntity is Character c)
|
||||
{
|
||||
if (ItemCreator.LoadedItems.Count != 0)
|
||||
if (ItemManager.LoadedItems.Count != 0)
|
||||
{
|
||||
ShowList l = new();
|
||||
l.AddListItem(ItemCreator.LoadedItems.OrderBy(kv => kv.Value.Id).Select(kv => EntityCreator.GetItemDisplayName(ItemCreator, kv.Key)).ToArray());
|
||||
l.AddListItem(ItemManager.LoadedItems.OrderBy(kv => kv.Value.Id).Select(kv => EntityEditor.GetItemDisplayName(ItemManager, kv.Key)).ToArray());
|
||||
l.ShowDialog();
|
||||
string selected = l.SelectItem;
|
||||
Item? i = ItemCreator.LoadedItems.Where(kv => EntityCreator.GetItemDisplayName(ItemCreator, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
Item? i = ItemManager.LoadedItems.Where(kv => EntityEditor.GetItemDisplayName(ItemManager, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
if (c != null && i != null)
|
||||
{
|
||||
Item? i2 = EntityCreator.从模组加载器中获取物品(i.Id, i.Name, i.ItemType);
|
||||
Item? i2 = EntityEditor.从模组加载器中获取物品(i.Id, i.Name, i.ItemType);
|
||||
if (i2 != null)
|
||||
{
|
||||
i.SetPropertyToItemModuleNew(i2);
|
||||
@ -106,18 +106,18 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
|
||||
private void 加技能_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (NowClick == 0 && SkillCreator != null && BaseEntity is Character c)
|
||||
if (NowClick == 0 && SkillManager != null && BaseEntity is Character c)
|
||||
{
|
||||
if (SkillCreator.LoadedSkills.Count != 0)
|
||||
if (SkillManager.LoadedSkills.Count != 0)
|
||||
{
|
||||
ShowList l = new();
|
||||
l.AddListItem(SkillCreator.LoadedSkills.OrderBy(kv => kv.Value.Id).Where(kv => kv.Value.SkillType != Core.Library.Constant.SkillType.Item).Select(kv => EntityCreator.GetSkillDisplayName(SkillCreator, kv.Key)).ToArray());
|
||||
l.AddListItem(SkillManager.LoadedSkills.OrderBy(kv => kv.Value.Id).Where(kv => kv.Value.SkillType != Core.Library.Constant.SkillType.Item).Select(kv => EntityEditor.GetSkillDisplayName(SkillManager, kv.Key)).ToArray());
|
||||
l.ShowDialog();
|
||||
string selected = l.SelectItem;
|
||||
Skill? s = SkillCreator.LoadedSkills.Where(kv => EntityCreator.GetSkillDisplayName(SkillCreator, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
Skill? s = SkillManager.LoadedSkills.Where(kv => EntityEditor.GetSkillDisplayName(SkillManager, kv.Key) == selected).Select(kv => kv.Value).FirstOrDefault();
|
||||
if (c != null && s != null)
|
||||
{
|
||||
Skill? s2 = EntityCreator.从模组加载器中获取技能(s.Id, s.Name, s.SkillType);
|
||||
Skill? s2 = EntityEditor.从模组加载器中获取技能(s.Id, s.Name, s.SkillType);
|
||||
if (s2 != null)
|
||||
{
|
||||
s = s2;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
partial class CreateSkill
|
||||
partial class SkillCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@ -1,43 +1,104 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
using Milimoe.FunGame.Core.Library.Constant;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public class SkillCreator
|
||||
public partial class SkillCreator : Form
|
||||
{
|
||||
public Dictionary<string, Skill> LoadedSkills { get; set; } = [];
|
||||
private SkillManager SkillManager { get; }
|
||||
private Skill? EditSkill { get; }
|
||||
|
||||
public void Load()
|
||||
public SkillCreator(SkillManager manager, Skill? skill = null)
|
||||
{
|
||||
EntityModuleConfig<Skill> config = new("EntityCreator", "skill.creator");
|
||||
config.LoadConfig();
|
||||
LoadedSkills = new(config);
|
||||
}
|
||||
|
||||
public bool Add(string name, Skill skill)
|
||||
{
|
||||
return LoadedSkills.TryAdd(name, skill);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
{
|
||||
return LoadedSkills.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
EntityModuleConfig<Skill> config = new("EntityCreator", "skill.creator");
|
||||
foreach (string key in LoadedSkills.Keys)
|
||||
InitializeComponent();
|
||||
SkillManager = manager;
|
||||
if (skill != null)
|
||||
{
|
||||
config.Add(key, LoadedSkills[key]);
|
||||
Text = "技能编辑器";
|
||||
BtnCreate.Text = "编辑";
|
||||
EditSkill = skill;
|
||||
TextID.Text = skill.Id.ToString();
|
||||
TextCode.Text = manager.LoadedSkills.Where(kv => kv.Value.Equals(skill)).Select(kv => kv.Key).FirstOrDefault() ?? "";
|
||||
TextName.Text = skill.Name;
|
||||
ComboSkillType.Text = SkillSet.GetSkillTypeName(skill.SkillType);
|
||||
}
|
||||
config.SaveConfig();
|
||||
}
|
||||
|
||||
public void OpenCreator(Skill? skill = null)
|
||||
private void BtnCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateSkill creator = new(this, skill);
|
||||
creator.ShowDialog();
|
||||
Skill s;
|
||||
if (EditSkill != null)
|
||||
{
|
||||
s = EditSkill;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = Factory.GetSkill();
|
||||
}
|
||||
string name;
|
||||
|
||||
if (TextID.Text.Trim() != "" && long.TryParse(TextID.Text.Trim(), out long id))
|
||||
{
|
||||
s.Id = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("ID不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextName.Text.Trim() != "")
|
||||
{
|
||||
s.Name = TextName.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("名称不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextCode.Text.Trim() != "")
|
||||
{
|
||||
name = TextCode.Text.Trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("技能存档标识不能为空。");
|
||||
return;
|
||||
}
|
||||
|
||||
if (EditSkill != null)
|
||||
{
|
||||
MessageBox.Show("保存成功!");
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (SkillManager.Add(name, s))
|
||||
{
|
||||
ShowDetail d = new(null, SkillManager, null);
|
||||
d.SetText(-1, s, s.ToString());
|
||||
d.Text = "预览模式";
|
||||
d.ShowDialog();
|
||||
d.Dispose();
|
||||
if (MessageBox.Show("添加成功!是否继续添加?", "提示", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
Dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("添加失败!");
|
||||
}
|
||||
}
|
||||
|
||||
TextID.Text = "";
|
||||
TextCode.Text = "";
|
||||
TextName.Text = "";
|
||||
ComboSkillType.Text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
43
Desktop/Solutions/EntityCreator/SkillManager.cs
Normal file
43
Desktop/Solutions/EntityCreator/SkillManager.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using Milimoe.FunGame.Core.Api.Utility;
|
||||
using Milimoe.FunGame.Core.Entity;
|
||||
|
||||
namespace Milimoe.FunGame.Testing.Desktop.Solutions
|
||||
{
|
||||
public class SkillManager
|
||||
{
|
||||
public Dictionary<string, Skill> LoadedSkills { get; set; } = [];
|
||||
|
||||
public void Load()
|
||||
{
|
||||
EntityModuleConfig<Skill> config = new("EntityEditor", "skills");
|
||||
config.LoadConfig();
|
||||
LoadedSkills = new(config);
|
||||
}
|
||||
|
||||
public bool Add(string name, Skill skill)
|
||||
{
|
||||
return LoadedSkills.TryAdd(name, skill);
|
||||
}
|
||||
|
||||
public bool Remove(string name)
|
||||
{
|
||||
return LoadedSkills.Remove(name);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
EntityModuleConfig<Skill> config = new("EntityEditor", "skills");
|
||||
foreach (string key in LoadedSkills.Keys)
|
||||
{
|
||||
config.Add(key, LoadedSkills[key]);
|
||||
}
|
||||
config.SaveConfig();
|
||||
}
|
||||
|
||||
public void OpenCreator(Skill? skill = null)
|
||||
{
|
||||
SkillCreator manager = new(this, skill);
|
||||
manager.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user