This commit is contained in:
milimoe 2024-09-22 20:30:43 +08:00
parent 6a7e5460b0
commit 5f41ff32b8
Signed by: milimoe
GPG Key ID: 05D280912DA6C69E
9 changed files with 406 additions and 6 deletions

View File

@ -25,6 +25,9 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Update="Solutions\EntityCreator\SetConfigName.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="Solutions\EntityEditor\ItemCreator.cs"> <Compile Update="Solutions\EntityEditor\ItemCreator.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>

View File

@ -5,11 +5,13 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
{ {
public class CharacterManager public class CharacterManager
{ {
public string ModuleName { get; set; } = "EntityEditor";
public string ConfigName { get; set; } = "characters";
public Dictionary<string, Character> LoadedCharacters { get; set; } = []; public Dictionary<string, Character> LoadedCharacters { get; set; } = [];
public void Load() public void Load()
{ {
EntityModuleConfig<Character> config = new("EntityEditor", "characters"); EntityModuleConfig<Character> config = new(ModuleName, ConfigName);
config.LoadConfig(); config.LoadConfig();
LoadedCharacters = new(config); LoadedCharacters = new(config);
foreach (Character c in LoadedCharacters.Values) foreach (Character c in LoadedCharacters.Values)
@ -30,7 +32,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
public void Save() public void Save()
{ {
EntityModuleConfig<Character> config = new("EntityEditor", "characters"); EntityModuleConfig<Character> config = new(ModuleName, ConfigName);
foreach (string key in LoadedCharacters.Keys) foreach (string key in LoadedCharacters.Keys)
{ {
config.Add(key, LoadedCharacters[key]); config.Add(key, LoadedCharacters[key]);

View File

@ -48,6 +48,7 @@
= new Button(); = new Button();
= new Button(); = new Button();
= new Button(); = new Button();
= new Button();
.SuspendLayout(); .SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@ -275,11 +276,24 @@
.UseVisualStyleBackColor = true; .UseVisualStyleBackColor = true;
.Click += _Click; .Click += _Click;
// //
// 设置配置名称
//
.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
.Font = new Font("Microsoft YaHei UI", 8F);
.Location = new Point(460, 185);
.Name = "模组名称设置";
.Size = new Size(98, 35);
.TabIndex = 18;
.Text = "模组名称设置";
.UseVisualStyleBackColor = true;
.Click += _Click;
//
// EntityEditor // EntityEditor
// //
AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(674, 437); ClientSize = new Size(674, 437);
Controls.Add();
Controls.Add(); Controls.Add();
Controls.Add(); Controls.Add();
Controls.Add(); Controls.Add();
@ -330,5 +344,6 @@
private Button ; private Button ;
private Button ; private Button ;
private Button ; private Button ;
private Button ;
} }
} }

View File

@ -11,12 +11,14 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
private CharacterManager CharacterManager { get; } = new(); private CharacterManager CharacterManager { get; } = new();
private SkillManager SkillManager { get; } = new(); private SkillManager SkillManager { get; } = new();
private ItemManager ItemManager { get; } = new(); private ItemManager ItemManager { get; } = new();
private SetConfigName ConfigSettings { get; }
private bool CheckSelectedIndex => .SelectedIndex != -1 && .SelectedIndex < .Items.Count; private bool CheckSelectedIndex => .SelectedIndex != -1 && .SelectedIndex < .Items.Count;
private int nowClick = 0; private int nowClick = 0;
public EntityEditor() public EntityEditor()
{ {
InitializeComponent(); InitializeComponent();
ConfigSettings = new(CharacterManager, SkillManager, ItemManager);
GameModuleLoader = LoadModules(); GameModuleLoader = LoadModules();
CharacterManager.Load(); CharacterManager.Load();
SkillManager.Load(); SkillManager.Load();
@ -526,5 +528,10 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
return GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Desktop, []); return GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Desktop, []);
} }
private void _Click(object sender, EventArgs e)
{
ConfigSettings.Show();
}
} }
} }

View File

@ -5,11 +5,13 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
{ {
public class ItemManager public class ItemManager
{ {
public string ModuleName { get; set; } = "EntityEditor";
public string ConfigName { get; set; } = "items";
public Dictionary<string, Item> LoadedItems { get; set; } = []; public Dictionary<string, Item> LoadedItems { get; set; } = [];
public void Load() public void Load()
{ {
EntityModuleConfig<Item> config = new("EntityEditor", "items"); EntityModuleConfig<Item> config = new(ModuleName, ConfigName);
config.LoadConfig(); config.LoadConfig();
LoadedItems = new(config); LoadedItems = new(config);
} }
@ -26,7 +28,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
public void Save() public void Save()
{ {
EntityModuleConfig<Item> config = new("EntityEditor", "items"); EntityModuleConfig<Item> config = new(ModuleName, ConfigName);
foreach (string key in LoadedItems.Keys) foreach (string key in LoadedItems.Keys)
{ {
config.Add(key, LoadedItems[key]); config.Add(key, LoadedItems[key]);

View File

@ -0,0 +1,173 @@
namespace Milimoe.FunGame.Testing.Desktop.Solutions
{
partial class SetConfigName
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
TipSkill = new Label();
TextCharacter = new TextBox();
TextSkill = new TextBox();
TipCharacter = new Label();
BtnSave = new Button();
TextItem = new TextBox();
TipItem = new Label();
TextModule = new TextBox();
TipModule = new Label();
SuspendLayout();
//
// TipSkill
//
TipSkill.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TipSkill.Font = new Font("等线", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134);
TipSkill.Location = new Point(78, 95);
TipSkill.Name = "TipSkill";
TipSkill.Size = new Size(129, 27);
TipSkill.TabIndex = 0;
TipSkill.Text = "技能配置名";
TipSkill.TextAlign = ContentAlignment.MiddleCenter;
//
// TextCharacter
//
TextCharacter.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TextCharacter.Font = new Font("等线", 14.25F);
TextCharacter.Location = new Point(213, 45);
TextCharacter.Name = "TextCharacter";
TextCharacter.Size = new Size(201, 27);
TextCharacter.TabIndex = 0;
TextCharacter.WordWrap = false;
//
// TextSkill
//
TextSkill.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TextSkill.Font = new Font("等线", 14.25F);
TextSkill.Location = new Point(213, 95);
TextSkill.Name = "TextSkill";
TextSkill.Size = new Size(201, 27);
TextSkill.TabIndex = 1;
TextSkill.WordWrap = false;
//
// TipCharacter
//
TipCharacter.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TipCharacter.Font = new Font("等线", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134);
TipCharacter.Location = new Point(78, 45);
TipCharacter.Name = "TipCharacter";
TipCharacter.Size = new Size(129, 27);
TipCharacter.TabIndex = 2;
TipCharacter.Text = "角色配置名";
TipCharacter.TextAlign = ContentAlignment.MiddleCenter;
//
// BtnSave
//
BtnSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
BtnSave.Font = new Font("等线", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134);
BtnSave.Location = new Point(420, 216);
BtnSave.Name = "BtnSave";
BtnSave.Size = new Size(103, 45);
BtnSave.TabIndex = 4;
BtnSave.Text = "保存";
BtnSave.UseVisualStyleBackColor = true;
BtnSave.Click += BtnSave_Click;
//
// TextItem
//
TextItem.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TextItem.Font = new Font("等线", 14.25F);
TextItem.Location = new Point(213, 144);
TextItem.Name = "TextItem";
TextItem.Size = new Size(201, 27);
TextItem.TabIndex = 6;
TextItem.WordWrap = false;
//
// TipItem
//
TipItem.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TipItem.Font = new Font("等线", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134);
TipItem.Location = new Point(78, 144);
TipItem.Name = "TipItem";
TipItem.Size = new Size(129, 27);
TipItem.TabIndex = 5;
TipItem.Text = "技能配置名";
TipItem.TextAlign = ContentAlignment.MiddleCenter;
//
// TextModule
//
TextModule.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TextModule.Font = new Font("等线", 14.25F);
TextModule.Location = new Point(213, 226);
TextModule.Name = "TextModule";
TextModule.Size = new Size(201, 27);
TextModule.TabIndex = 7;
TextModule.WordWrap = false;
//
// TipModule
//
TipModule.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
TipModule.Font = new Font("等线", 14.25F, FontStyle.Regular, GraphicsUnit.Point, 134);
TipModule.Location = new Point(78, 225);
TipModule.Name = "TipModule";
TipModule.Size = new Size(129, 27);
TipModule.TabIndex = 8;
TipModule.Text = "模组名称";
TipModule.TextAlign = ContentAlignment.MiddleCenter;
//
// SetConfigName
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(535, 273);
Controls.Add(TipModule);
Controls.Add(TextModule);
Controls.Add(TextItem);
Controls.Add(TipItem);
Controls.Add(BtnSave);
Controls.Add(TextSkill);
Controls.Add(TipCharacter);
Controls.Add(TextCharacter);
Controls.Add(TipSkill);
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
Name = "SetConfigName";
StartPosition = FormStartPosition.CenterScreen;
Text = "模组名称设置";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label TipSkill;
private TextBox TextCharacter;
private TextBox TextSkill;
private Label TipCharacter;
private Button BtnSave;
private TextBox TextItem;
private Label TipItem;
private TextBox TextModule;
private Label TipModule;
}
}

View File

@ -0,0 +1,76 @@
using Milimoe.FunGame.Core.Api.Utility;
namespace Milimoe.FunGame.Testing.Desktop.Solutions
{
public partial class SetConfigName : Form
{
public string FileName { get; set; } = "";
public string ModuleName { get; set; } = "";
public CharacterManager CharacterManager { get; }
public SkillManager SkillManager { get; }
public ItemManager ItemManager { get; }
public SetConfigName(CharacterManager cm, SkillManager sm, ItemManager im)
{
InitializeComponent();
CharacterManager = cm;
SkillManager = sm;
ItemManager = im;
FileName = "Module.ini";
ModuleName = "EntityEditor";
if (INIHelper.ExistINIFile(FileName))
{
ModuleName = INIHelper.ReadINI("ModuleName", "Module", FileName);
string character = INIHelper.ReadINI("ModuleName", "Character", FileName);
string skill = INIHelper.ReadINI("ModuleName", "Skill", FileName);
string item = INIHelper.ReadINI("ModuleName", "Item", FileName);
if (ModuleName.Trim() == "") ModuleName = "EntityEditor";
else ModuleName = ModuleName.Trim();
if (character.Trim() == "") character = "characters";
else character = character.Trim();
if (skill.Trim() == "") skill = "skills";
else skill = skill.Trim();
if (item.Trim() == "") item = "items";
else item = item.Trim();
CharacterManager.ModuleName = ModuleName;
SkillManager.ModuleName = ModuleName;
ItemManager.ModuleName = ModuleName;
CharacterManager.ConfigName = character;
SkillManager.ConfigName = skill;
ItemManager.ConfigName = item;
}
else
{
INIHelper.WriteINI("ModuleName", "Module", "EntityEditor", FileName);
INIHelper.WriteINI("ModuleName", "Character", "characters", FileName);
INIHelper.WriteINI("ModuleName", "Skill", "skills", FileName);
INIHelper.WriteINI("ModuleName", "Item", "items", FileName);
}
FormClosing += SetConfigName_FormClosing;
TextModule.Text = ModuleName;
TextCharacter.Text = CharacterManager.ConfigName;
TextSkill.Text = SkillManager.ConfigName;
TextItem.Text = ItemManager.ConfigName;
}
private void SetConfigName_FormClosing(object? sender, FormClosingEventArgs e)
{
Hide();
e.Cancel = true;
}
private void BtnSave_Click(object sender, EventArgs e)
{
ModuleName = TextModule.Text;
CharacterManager.ConfigName = TextCharacter.Text;
SkillManager.ConfigName = TextSkill.Text;
ItemManager.ConfigName = TextItem.Text;
INIHelper.WriteINI("ModuleName", "Module", ModuleName, FileName);
INIHelper.WriteINI("ModuleName", "Character", CharacterManager.ConfigName, FileName);
INIHelper.WriteINI("ModuleName", "Skill", SkillManager.ConfigName, FileName);
INIHelper.WriteINI("ModuleName", "Item", ItemManager.ConfigName, FileName);
MessageBox.Show("保存成功!");
Hide();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -5,11 +5,13 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
{ {
public class SkillManager public class SkillManager
{ {
public string ModuleName { get; set; } = "EntityEditor";
public string ConfigName { get; set; } = "skills";
public Dictionary<string, Skill> LoadedSkills { get; set; } = []; public Dictionary<string, Skill> LoadedSkills { get; set; } = [];
public void Load() public void Load()
{ {
EntityModuleConfig<Skill> config = new("EntityEditor", "skills"); EntityModuleConfig<Skill> config = new(ModuleName, ConfigName);
config.LoadConfig(); config.LoadConfig();
LoadedSkills = new(config); LoadedSkills = new(config);
} }
@ -26,7 +28,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions
public void Save() public void Save()
{ {
EntityModuleConfig<Skill> config = new("EntityEditor", "skills"); EntityModuleConfig<Skill> config = new(ModuleName, ConfigName);
foreach (string key in LoadedSkills.Keys) foreach (string key in LoadedSkills.Keys)
{ {
config.Add(key, LoadedSkills[key]); config.Add(key, LoadedSkills[key]);