diff --git a/Desktop/FunGame.Testing.Desktop.csproj b/Desktop/FunGame.Testing.Desktop.csproj index fe03116..e946b6e 100644 --- a/Desktop/FunGame.Testing.Desktop.csproj +++ b/Desktop/FunGame.Testing.Desktop.csproj @@ -25,6 +25,9 @@ + + Form + Form diff --git a/Desktop/Solutions/EntityCreator/CharacterManager.cs b/Desktop/Solutions/EntityCreator/CharacterManager.cs index c8bae63..06c408f 100644 --- a/Desktop/Solutions/EntityCreator/CharacterManager.cs +++ b/Desktop/Solutions/EntityCreator/CharacterManager.cs @@ -5,11 +5,13 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions { public class CharacterManager { + public string ModuleName { get; set; } = "EntityEditor"; + public string ConfigName { get; set; } = "characters"; public Dictionary LoadedCharacters { get; set; } = []; public void Load() { - EntityModuleConfig config = new("EntityEditor", "characters"); + EntityModuleConfig config = new(ModuleName, ConfigName); config.LoadConfig(); LoadedCharacters = new(config); foreach (Character c in LoadedCharacters.Values) @@ -30,7 +32,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions public void Save() { - EntityModuleConfig config = new("EntityEditor", "characters"); + EntityModuleConfig config = new(ModuleName, ConfigName); foreach (string key in LoadedCharacters.Keys) { config.Add(key, LoadedCharacters[key]); diff --git a/Desktop/Solutions/EntityCreator/EntityEditor.Designer.cs b/Desktop/Solutions/EntityCreator/EntityEditor.Designer.cs index 9e64579..e324df0 100644 --- a/Desktop/Solutions/EntityCreator/EntityEditor.Designer.cs +++ b/Desktop/Solutions/EntityCreator/EntityEditor.Designer.cs @@ -48,6 +48,7 @@ 重新读取全部 = new Button(); 删除角色物品 = new Button(); 删除角色技能 = new Button(); + 模组名称设置 = new Button(); 列表.SuspendLayout(); SuspendLayout(); // @@ -275,11 +276,24 @@ 删除角色技能.UseVisualStyleBackColor = true; 删除角色技能.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 // AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(674, 437); + Controls.Add(模组名称设置); Controls.Add(删除角色物品); Controls.Add(删除角色技能); Controls.Add(重新读取全部); @@ -330,5 +344,6 @@ private Button 重新读取全部; private Button 删除角色物品; private Button 删除角色技能; + private Button 模组名称设置; } } \ No newline at end of file diff --git a/Desktop/Solutions/EntityCreator/EntityEditor.cs b/Desktop/Solutions/EntityCreator/EntityEditor.cs index 92dfac0..db908f4 100644 --- a/Desktop/Solutions/EntityCreator/EntityEditor.cs +++ b/Desktop/Solutions/EntityCreator/EntityEditor.cs @@ -11,12 +11,14 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions private CharacterManager CharacterManager { get; } = new(); private SkillManager SkillManager { get; } = new(); private ItemManager ItemManager { get; } = new(); + private SetConfigName ConfigSettings { get; } private bool CheckSelectedIndex => 实际列表.SelectedIndex != -1 && 实际列表.SelectedIndex < 实际列表.Items.Count; private int nowClick = 0; public EntityEditor() { InitializeComponent(); + ConfigSettings = new(CharacterManager, SkillManager, ItemManager); GameModuleLoader = LoadModules(); CharacterManager.Load(); SkillManager.Load(); @@ -526,5 +528,10 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions return GameModuleLoader.LoadGameModules(FunGameInfo.FunGame.FunGame_Desktop, []); } + + private void 模组名称设置_Click(object sender, EventArgs e) + { + ConfigSettings.Show(); + } } } diff --git a/Desktop/Solutions/EntityCreator/ItemManager.cs b/Desktop/Solutions/EntityCreator/ItemManager.cs index 3194699..6eb763a 100644 --- a/Desktop/Solutions/EntityCreator/ItemManager.cs +++ b/Desktop/Solutions/EntityCreator/ItemManager.cs @@ -5,11 +5,13 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions { public class ItemManager { + public string ModuleName { get; set; } = "EntityEditor"; + public string ConfigName { get; set; } = "items"; public Dictionary LoadedItems { get; set; } = []; public void Load() { - EntityModuleConfig config = new("EntityEditor", "items"); + EntityModuleConfig config = new(ModuleName, ConfigName); config.LoadConfig(); LoadedItems = new(config); } @@ -26,7 +28,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions public void Save() { - EntityModuleConfig config = new("EntityEditor", "items"); + EntityModuleConfig config = new(ModuleName, ConfigName); foreach (string key in LoadedItems.Keys) { config.Add(key, LoadedItems[key]); diff --git a/Desktop/Solutions/EntityCreator/SetConfigName.Designer.cs b/Desktop/Solutions/EntityCreator/SetConfigName.Designer.cs new file mode 100644 index 0000000..b697261 --- /dev/null +++ b/Desktop/Solutions/EntityCreator/SetConfigName.Designer.cs @@ -0,0 +1,173 @@ +namespace Milimoe.FunGame.Testing.Desktop.Solutions +{ + partial class SetConfigName + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/Desktop/Solutions/EntityCreator/SetConfigName.cs b/Desktop/Solutions/EntityCreator/SetConfigName.cs new file mode 100644 index 0000000..5424094 --- /dev/null +++ b/Desktop/Solutions/EntityCreator/SetConfigName.cs @@ -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(); + } + } +} diff --git a/Desktop/Solutions/EntityCreator/SetConfigName.resx b/Desktop/Solutions/EntityCreator/SetConfigName.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Desktop/Solutions/EntityCreator/SetConfigName.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Desktop/Solutions/EntityCreator/SkillManager.cs b/Desktop/Solutions/EntityCreator/SkillManager.cs index 3438f4f..4d64c56 100644 --- a/Desktop/Solutions/EntityCreator/SkillManager.cs +++ b/Desktop/Solutions/EntityCreator/SkillManager.cs @@ -5,11 +5,13 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions { public class SkillManager { + public string ModuleName { get; set; } = "EntityEditor"; + public string ConfigName { get; set; } = "skills"; public Dictionary LoadedSkills { get; set; } = []; public void Load() { - EntityModuleConfig config = new("EntityEditor", "skills"); + EntityModuleConfig config = new(ModuleName, ConfigName); config.LoadConfig(); LoadedSkills = new(config); } @@ -26,7 +28,7 @@ namespace Milimoe.FunGame.Testing.Desktop.Solutions public void Save() { - EntityModuleConfig config = new("EntityEditor", "skills"); + EntityModuleConfig config = new(ModuleName, ConfigName); foreach (string key in LoadedSkills.Keys) { config.Add(key, LoadedSkills[key]);