using System.ComponentModel; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; namespace BinXmlConverter; public sealed partial class ConverterSuiteForm : Form { private sealed class ConversionProfile { public required string Key { get; init; } public required string DisplayName { get; init; } public required string PackageFileName { get; init; } public required string Category { get; init; } public required string Description { get; init; } public required string StructReference { get; init; } public required string Notes { get; init; } public required string[] BinInputs { get; init; } public required string[] XmlFiles { get; init; } public Action? ToXmlAction { get; init; } public Action? ToBinAction { get; init; } public override string ToString() => DisplayName; } private BinToXml? _legacyBasic; private BinToXml2? _legacyAdvanced; private readonly List _profiles = new(); private List _filteredProfiles = new(); private const int LeftPanelPreferredWidth = 255; private const int LeftPanelMinWidth = 255; private const int RightPanelMinWidth = 840; private static readonly Color TitleColor = Color.Black; private static readonly Color MetaColor = Color.DimGray; private static readonly Color SelectedRowColor = Color.FromArgb(240, 244, 252); private string DataRoot => Path.Combine(AppContext.BaseDirectory, "DATA"); private string XmlRoot => Path.Combine(AppContext.BaseDirectory, "XML"); private string BinRoot => Path.Combine(AppContext.BaseDirectory, "BIN"); private static bool IsDesignerHosted => LicenseManager.UsageMode == LicenseUsageMode.Designtime; public ConverterSuiteForm() { InitializeComponent(); if (IsDesignerHosted) { return; } _legacyBasic = new BinToXml(showAdvancedForm: false); _legacyAdvanced = new BinToXml2(); InitializeRuntimeUi(); InitializeProfiles(); ApplyFilter(); FormClosed += (_, _) => { _legacyAdvanced?.Dispose(); _legacyBasic?.Dispose(); }; Shown += (_, _) => { UpdateSplitDistance(); Log($"Ready. Profiles loaded: {_profiles.Count}."); UpdateStatus("Ready"); }; } private void InitializeRuntimeUi() { _searchBox.TextChanged += (_, _) => ApplyFilter(); _profileList.DrawItem += ProfileList_DrawItem; _profileList.SelectedIndexChanged += (_, _) => UpdateSelectedProfile(); _buttonOpenData.Click += (_, _) => OpenFolder(DataRoot); _buttonOpenXml.Click += (_, _) => OpenFolder(XmlRoot); _buttonOpenBin.Click += (_, _) => OpenFolder(BinRoot); _validateButton.Click += (_, _) => ValidateSelectedProfile(showSuccessMessage: true); _toXmlButton.Click += (_, _) => RunSelectedConversion(toXml: true); _toBinButton.Click += (_, _) => RunSelectedConversion(toXml: false); } private void UpdateSplitDistance() { if (_mainSplit.Width <= 0) { return; } _mainSplit.Panel1MinSize = 0; _mainSplit.Panel2MinSize = 0; int maxDistance = _mainSplit.Width - RightPanelMinWidth - _mainSplit.SplitterWidth; int minDistance = LeftPanelMinWidth; if (maxDistance < minDistance) { maxDistance = minDistance; } int desiredDistance = Math.Min(LeftPanelPreferredWidth, maxDistance); desiredDistance = Math.Max(minDistance, desiredDistance); if (desiredDistance >= minDistance && desiredDistance <= _mainSplit.Width - RightPanelMinWidth) { _mainSplit.SplitterDistance = desiredDistance; } _mainSplit.Panel1MinSize = LeftPanelMinWidth; _mainSplit.Panel2MinSize = RightPanelMinWidth; } private void InitializeProfiles() { _profiles.Clear(); _profiles.AddRange(new[] { Profile("Digimon_List", "Digimon List", "Digimon_List.bin", "Digimon", "Converts Digimon_List.bin to the Digimon package XML and back.", @"LibProj/CsFileTable/Digimon.h", new[] { "DATA/Digimon_List.bin" }, new[] { "XML/Digimon_List/DigimonList.xml" }, "Primary Digimon gameplay package. C++ struct is the truth for field order, types, and hidden padding.", () => _legacyBasic!.InvokeLegacyAction("Digimon_ListToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("Digimon_ListToBin_Click")), Profile("AddExp", "Add Experience", "AddExp.bin", "Combat", "Converts AddExp.bin package.", @"LibProj/CsFileTable/AddExp.h", new[] { "DATA/AddExp.bin" }, new[] { "XML/AddExp/AddExp.xml" }, "Fixed-record package built directly from the client AddExp struct.", () => _legacyBasic!.InvokeLegacyAction("AddExpToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("AddExpToBin_Click")), Profile("Model", "Model", "Model.dat", "Digimon", "Handles model metadata conversion between Model.dat and Model.xml.", @"Classes/ModelInfo.cs", new[] { "DATA/Model.dat" }, new[] { "XML/Model.xml" }, "Model metadata package used by client rendering references.", () => _legacyBasic!.InvokeLegacyAction("ModelToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("ModelToBin_Click")), Profile("DigimonEvo", "Digimon Evolution", "DigimonEvo.bin", "Digimon", "Converts DigimonEvo.bin into evolution-tree XML plus the trailing battle-evolution settings XML.", @"LibProj/CsFileTable/DigimonEvolveObj.h; LibProj/CsFileTable/CDigimonEvolution.h", new[] { "DATA/DigimonEvo.bin" }, new[] { "XML/DigimonEvo/DigimonEvo.xml", "XML/DigimonEvo/BattleEvo.xml" }, "Two XML files verified from the client BIN layout: main evolution tree data and the trailing battle evolution block.", () => _legacyBasic!.InvokeLegacyAction("DigimonEvoToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("DigimonEvoToBin_Click")), Profile("Ride", "Ride", "Ride.bin", "Digimon", "Converts Ride.bin package.", @"LibProj/CsFileTable/Ride.h; LibProj/CsFileTable/DigimonMng.cpp", new[] { "DATA/Ride.bin" }, new[] { "XML/Ride/Ride.xml" }, "Flat ride package rebuilt from CsRide::sINFO. Two fixed open-info entries are preserved in order and no fake fields are exposed.", () => _legacyBasic!.InvokeLegacyAction("RideToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("RideToBin_Click")), Profile("CharCreateTable", "Character Create Table", "CharCreateTable.bin", "Character", "Converts CharCreateTable.bin package into tamer and digimon create XML files.", @"LibProj/CsFileTable/CharacterCreateListInfo.h", new[] { "DATA/CharCreateTable.bin" }, new[] { "XML/CharCreateTable/TamerCreate.xml", "XML/CharCreateTable/DigimonCreate.xml" }, "Two-section package rebuilt from the client save/load order: tamer create rows and digimon create rows.", () => _legacyBasic!.InvokeLegacyAction("CharCreateTableToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("CharCreateTableToBin_CLick")), Profile("Cuid", "CUID", "Cuid.bin", "UI", "Converts Cuid.bin package into blocked-ID and blocked-chat XML files.", @"LibProj/CsFileTable/CUID.h; LibProj/CsFileTable/CUID_Chat.h", new[] { "DATA/Cuid.bin" }, new[] { "XML/Cuid/CuidId.xml", "XML/Cuid/CuidChat.xml" }, "Two fixed-struct sections verified from the client manager: CUID ID filters and chat bad-word filters.", () => _legacyBasic!.InvokeLegacyAction("CuidToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("CuidToBin_Click")), Profile("Npc", "NPC", "Npc.bin", "NPC", "Converts Npc.bin package into NPC, model-info, and NPC-event XML files.", @"LibProj/CsFileTable/Npc.h; LibProj/CsFileTable/NpcMng.h; LibProj/CsFileTable/NpcType.h; LibProj/CsFileTable/NpcExtra.h", new[] { "DATA/Npc.bin" }, new[] { "XML/Npc/Npc.xml", "XML/Npc/ModelInfo.xml", "XML/Npc/NpcEvent.xml" }, "Three-section package rebuilt from the client NPC manager: NPC rows, model info rows, and fixed NPC event structs. Hidden padding stays internal.", () => _legacyBasic!.InvokeLegacyAction("NpcToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("NpcToBin_Click")), Profile("DMBase", "DM Base", "DMBase.bin", "Digimon", "Converts DMBase.bin package into its base, map, guild, limit, store, evolution, and expansion XML files.", @"LibProj/CsFileTable/Base.h; LibProj/CsFileTable/BaseMng.h", new[] { "DATA/DMBase.bin" }, new[] { "XML/DMBase/TamerBaseInfo.xml", "XML/DMBase/DigimonBaseInfo.xml", "XML/DMBase/CsBaseMapInfo.xml", "XML/DMBase/JumpBooster.xml", "XML/DMBase/Party.xml", "XML/DMBase/Guild.xml", "XML/DMBase/Limit.xml", "XML/DMBase/Store.xml", "XML/DMBase/PaneltyInfo.xml", "XML/DMBase/EvolutionBaseApply.xml", "XML/DMBase/DigimonEvoMaxSkill.xml", "XML/DMBase/ExpansionData.xml" }, "Large multi-section package. XML now writes to a dedicated DMBase folder so each section stays organized.", () => _legacyBasic!.InvokeLegacyAction("DMBaseToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("DMBaseToBin_Click")), Profile("Skill", "Skill", "Skill.bin", "Combat", "Converts Skill.bin package into skill, tamer-skill, and area-check XML files.", @"LibProj/CsFileTable/Skill.h; LibProj/CsFileTable/SkillMng.h; LibProj/CsFileTable/SkillMng.cpp; LibProj/CsFileTable/_SkillDefine.h", new[] { "DATA/Skill.bin" }, new[] { "XML/Skill/Skill.xml", "XML/Skill/TamerSkill.xml", "XML/Skill/AreaCheck.xml" }, "Three-section package rebuilt from the client raw struct writes: skill rows, tamer skill rows, and area check rows. Hidden alignment bytes stay internal and fake legacy fields are removed.", () => _legacyBasic!.InvokeLegacyAction("SkillToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("SkillToBin_Click")), Profile("Buff", "Buff", "Buff.bin", "Combat", "Converts Buff.bin package.", @"LibProj/CsFileTable/Buff.h", new[] { "DATA/Buff.bin" }, new[] { "XML/Buff/Buff.xml" }, "Buff package rebuilt from the client struct, including hidden alignment bytes in the BIN layout.", () => _legacyBasic!.InvokeLegacyAction("BuffToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("BuffToBinClick")), Profile("ItemList", "Item List", "ItemList.bin", "Items", "Converts ItemList.bin package.", @"Classes/ItemList.cs", new[] { "DATA/ItemList.bin" }, new[] { "XML/ItemList/ItemList.xml", "XML/ItemList/ItemTap.xml", "XML/ItemList/ItemCoolTime.xml", "XML/ItemList/ItemDisplay.xml", "XML/ItemList/ItemTypeName.xml", "XML/ItemList/ItemRank.xml", "XML/ItemList/ElementItem.xml", "XML/ItemList/ElementItem1.xml", "XML/ItemList/ItemExchange.xml", "XML/ItemList/ItemAcessorys.xml", "XML/ItemList/AcessorysEnchant.xml", "XML/ItemList/ItemMaking.xml", "XML/ItemList/ItemMakingGroupList.xml", "XML/ItemList/ItemXai.xml", "XML/ItemList/ItemRankEffectList.xml", "XML/ItemList/ItemLook.xml" }, "Large multi-file item package. Base item data plus all supporting item tables now stay under XML/ItemList/.", () => _legacyBasic!.InvokeLegacyAction("ItemListToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("ItemListToBin_Click")), Profile("EffectList", "Effect List", "EffectList.bin", "Items", "Converts EffectList.bin package.", @"LibProj/CsFileTable/EffectMng.h", new[] { "DATA/EffectList.bin" }, new[] { "XML/EffectList/EffectList.xml" }, "Equip effect lookup package from the client effect manager.", () => _legacyBasic!.InvokeLegacyAction("EffectListToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("EffectListToBin_Click")), Profile("Event", "Event", "Event.bin", "Event", "Converts Event.bin package.", @"LibProj/CsFileTable/Event.h", new[] { "DATA/Event.bin" }, new[] { "XML/Event/AttendenceTime.xml", "XML/Event/Event.xml", "XML/Event/MensalEvent.xml", "XML/Event/MonthlyEvent.xml", "XML/Event/TimeEvent.xml", "XML/Event/Event100Days.xml" }, "Multi-file event package with attendance, daily, monthly, time, and 100-day sections.", () => _legacyBasic!.InvokeLegacyAction("EventToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("EventToBin_Click")), Profile("Gotcha", "Gotcha", "Gotcha.bin", "Shop", "Converts Gotcha package and child XML files.", @"LibProj/CsFileTable/CsGotcha.h", new[] { "DATA/Gotcha.bin" }, new[] { "XML/Gotcha/Gotcha.xml", "XML/Gotcha/GotchaItems.xml", "XML/Gotcha/GotchaRareItems.xml", "XML/Gotcha/GotchaMysteryItems.xml", "XML/Gotcha/GotchaMysteryCoins.xml" }, "Multi-file package rebuilt around the client Gotcha structs. Hidden padding stays internal.", () => _legacyBasic!.InvokeLegacyAction("GotchaToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("GotchaToBin_Click")), Profile("InfiniteWar", "Infinite War", "InfiniteWar.bin", "Combat", "Converts InfiniteWar.bin package into stage, summon, reward, and award NPC XML files.", @"LibProj/CsFileTable/InfiniteWarManager.h; LibProj/CsFileTable/TableStruct_InfiniteWar.h", new[] { "DATA/InfiniteWar.bin" }, new[] { "XML/InfiniteWar/StageInfo.xml", "XML/InfiniteWar/SummonMonster.xml", "XML/InfiniteWar/DailyReward.xml", "XML/InfiniteWar/RankReward.xml", "XML/InfiniteWar/AwardNpc.xml" }, "Five-section package verified from the client save/load order: stage data, summon groups, daily rewards, rank rewards, and award NPC text.", () => _legacyBasic!.InvokeLegacyAction("InfiniteWarToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("InfiniteWarToBin_Click")), Profile("MasterCard", "Master Card", "MasterCard.bin", "Cards", "Converts MasterCard.bin package into card, leader, path, and filter XML files.", @"LibProj/CsFileTable/Master_Card.h; LibProj/CsFileTable/Master_CardMng.h", new[] { "DATA/MasterCard.bin" }, new[] { "XML/MasterCard/MasterCards.xml", "XML/MasterCard/Leaders.xml", "XML/MasterCard/LeaderAbilities.xml", "XML/MasterCard/DigimonImgPaths.xml", "XML/MasterCard/PlatePaths.xml", "XML/MasterCard/Elementals.xml", "XML/MasterCard/Attributes.xml", "XML/MasterCard/MasterFilters.xml" }, "Eight-section package rebuilt from the client Master_Card manager. Hidden alignment stays internal and fake legacy fields are removed.", () => _legacyAdvanced!.InvokeLegacyAction("MastercardToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MastercardToBin_Click")), Profile("Achieve", "Achievement", "Achieve.bin", "Event", "Converts Achieve.bin package.", @"Classes/Achieve.cs", new[] { "DATA/Achieve.bin" }, new[] { "XML/Achieve/Achieve.xml", "XML/Achieve/AchieveHeader.xml" }, "Two-file achievement package with header/group data plus achievement rows.", () => _legacyAdvanced!.InvokeLegacyAction("AchieveToXML_Click"), () => _legacyAdvanced!.InvokeLegacyAction("AchieveToBin_Click")), Profile("BattleTable", "Battle Table", "BattleTable.bin", "Combat", "Converts BattleTable.bin package and its related XML files.", @"LibProj/CsFileTable/BattleTableMng.h", new[] { "DATA/BattleTable.bin" }, new[] { "XML/BattleTable/BattleInfo.xml", "XML/BattleTable/BattleReward.xml", "XML/BattleTable/BattleEnterable.xml" }, "Three-section package derived directly from the client save/load order: battle info, rewards, and enterable digimon.", () => _legacyAdvanced!.InvokeLegacyAction("BattleTableToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("BattleTableToBin_Click")), Profile("Digimon_Book", "Digimon Book", "Digimon_Book.bin", "Digimon", "Converts Digimon_Book.bin package into encyclopedia option, exception, deck option, and deck composition XML files.", @"LibProj/CsFileTable/Digimon.h", new[] { "DATA/Digimon_Book.bin" }, new[] { "XML/Digimon_Book/BookInfo.xml", "XML/Digimon_Book/EncyclopediaException.xml", "XML/Digimon_Book/DeckOption.xml", "XML/Digimon_Book/DeckComposition.xml" }, "Four-section package rebuilt from the client encyclopedia save/load order. Hidden alignment stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("Digimon_BookToXML_Click"), () => _legacyAdvanced!.InvokeLegacyAction("Digimon_BookToBin_Click")), Profile("DigimonParcel", "Digimon Parcel", "DigimonParcel.bin", "Digimon", "Converts DigimonParcel.bin into the parcel digimon XML list.", @"LibProj/CsFileTable/DigimonParcelManager.h", new[] { "DATA/DigimonParcel.bin" }, new[] { "XML/DigimonParcel/DigimonParcel.xml" }, "Simple parcel digimon list package. One count followed by Digimon IDs.", () => _legacyBasic!.InvokeLegacyAction("DigimonParcelToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("DigimonParcelToBin_Click")), Profile("Data_Exchange", "Data Exchange", "Data_Exchange.bin", "Digimon", "Converts Data_Exchange.bin package into grouped exchange XML.", @"LibProj/CsFileTable/Digimon.h", new[] { "DATA/Data_Exchange.bin" }, new[] { "XML/Data_Exchange/DataExchange.xml" }, "Grouped package built from CsData_Exchange rows inside the Digimon file-table manager.", () => _legacyAdvanced!.InvokeLegacyAction("DataExchangeToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("DataExchangeToBin_Click")), Profile("MapNpc", "Map NPC", "MapNpc.bin", "Maps", "Converts MapNpc.bin package.", @"LibProj/CsFileTable/MapNpc.h", new[] { "DATA/MapNpc.bin" }, new[] { "XML/MapNpc/MapNpc.xml" }, "Flat map NPC placement package rebuilt directly from CsMapNpc::sINFO.", () => _legacyAdvanced!.InvokeLegacyAction("MapNpcToXML_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapNpcToBin_Click")), Profile("UIText", "UI Text", "UIText.bin", "UI", "Converts UIText.bin package.", @"LibProj/CsFileTable/UI_Text.h; LibProj/CsFileTable/UI_Text.cpp", new[] { "DATA/UIText.bin" }, new[] { "XML/UIText/UIText.xml" }, "Single-section UI text package rebuilt from the client manager. Each row stores an INT64 hash key plus a length-prefixed UTF-16 message.", () => _legacyAdvanced!.InvokeLegacyAction("UitextToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("UitextToBin_Click")), Profile("MapMonsterList", "Map Monster List", "MapMonsterList.bin", "Maps", "Converts MapMonsterList.bin package.", @"LibProj/CsFileTable/MapMonster.h; LibProj/CsFileTable/MapMonsterMng.h", new[] { "DATA/MapMonsterList.bin" }, new[] { "XML/MapMonsterList/MapMonsterList.xml" }, "Grouped map monster spawn package rebuilt from the client save/load order. Hidden struct padding stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("MapMonstersToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapMonsterToBin_Click")), Profile("Monster", "Monster", "Monster.bin", "Combat", "Converts Monster.bin package and its related XML files.", @"LibProj/CsFileTable/Monster.h", new[] { "DATA/Monster.bin" }, new[] { "XML/Monster/Monster.xml", "XML/Monster/MonsterHit.xml", "XML/Monster/MonsterSkill.xml", "XML/Monster/MonsterSkillTerms.xml" }, "Monster package was rebuilt around the client structs. Padding stays internal and XML output is structured by package folder.", () => _legacyAdvanced!.InvokeLegacyAction("MonstersToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MonstersToBin_Click")), Profile("MapList", "Map List", "MapList.bin", "Maps", "Converts MapList.bin package.", @"LibProj/CsFileTable/MapList.h", new[] { "DATA/MapList.bin" }, new[] { "XML/MapList/MapList.xml" }, "Map list package rebuilt from the client save/load order, including width, height, descriptions, fatigue settings, and battle-tag flags.", () => _legacyAdvanced!.InvokeLegacyAction("MapListToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapListToBin_Click")), Profile("MapCharLight", "Map Character Light", "MapCharLight.bin", "Maps", "Converts MapCharLight.bin package.", @"LibProj/CsFileTable/MapCharLight.h", new[] { "DATA/MapCharLight.bin" }, new[] { "XML/MapCharLight/MapCharLight.xml" }, "Grouped map character lighting package with direction and point light records. Raw struct padding stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("MapCharLightToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapCharLightToBin_Click")), Profile("Nature", "Nature", "Nature.bin", "Digimon", "Converts Nature.bin into nature values and base-element comparison XML files.", @"LibProj/CsFileTable/Nature.h; LibProj/CsFileTable/NatureMng.h; LibProj/CsFileTable/BaseElement.h", new[] { "DATA/Nature.bin" }, new[] { "XML/Nature/Nature.xml", "XML/Nature/BaseElement.xml" }, "Two-section package verified from the client nature manager: fixed nature rows plus grouped base-element comparison data.", () => _legacyAdvanced!.InvokeLegacyAction("NatureToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("NatureToBin_Click")), Profile("New_Element", "New Element", "New_Element.bin", "Digimon", "Converts New_Element.bin into attribute UI and nature UI XML files.", @"LibProj/CsFileTable/ElementUI.h; LibProj/CsFileTable/DigimonMng.h", new[] { "DATA/New_Element.bin" }, new[] { "XML/New_Element/AttributeTypeUI.xml", "XML/New_Element/NatureTypeUI.xml" }, "Two fixed-record UI sections from the client digimon manager. No fake fields or guessed padding in visible XML.", () => _legacyAdvanced!.InvokeLegacyAction("NewElementToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("NewElementToBin_Click")), Profile("Passive_Ability", "Passive Ability", "Passive_Ability.bin", "Digimon", "Converts Passive_Ability.bin into passive ability XML grouped by passive type.", @"LibProj/CsFileTable/Digimon.h; LibProj/CsFileTable/DigimonMng.h", new[] { "DATA/Passive_Ability.bin" }, new[] { "XML/Passive_Ability/PassiveAbility.xml" }, "Grouped passive-ability package rebuilt from the client Digimon manager. Hidden struct padding stays internal.", () => _legacyBasic!.InvokeLegacyAction("PassiveAbilityToXml_Click"), () => _legacyBasic!.InvokeLegacyAction("PassiveAbilityToBin_Click")), Profile("Quest", "Quest", "Quest.bin", "Quest", "Converts Quest.bin package into a clean nested quest XML package.", @"LibProj/CsFileTable/Quest.h; LibProj/CsFileTable/QuestMng.h; LibProj/CsFileTable/QuestApplyRequite.h; LibProj/CsFileTable/QuestPreRequire.h; LibProj/CsFileTable/QuestCompRequire.h; LibProj/CsFileTable/QuestRequite.h", new[] { "DATA/Quest.bin" }, new[] { "XML/Quest/Quest.xml" }, "Quest package rebuilt from the client save/load order. Immediate and ResetQuest are real bool fields, nested quest groups are preserved, and no fake unknown bytes are exposed.", () => _legacyAdvanced!.InvokeLegacyAction("QuestsToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("QuestToBin_Click")), Profile("Reward", "Reward", "Reward.bin", "Event", "Converts Reward.bin package into grouped reward XML by server index.", @"LibProj/CsFileTable/Reward.h; LibProj/CsFileTable/RewardMng.h", new[] { "DATA/Reward.bin" }, new[] { "XML/Reward/Reward.xml" }, "Reward package rebuilt from the client manager. Hidden alignment around the fixed reward struct stays internal; visible XML only exposes real reward data.", () => _legacyAdvanced!.InvokeLegacyAction("RewardToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("RewardToBin_Click")), Profile("ExtraExchange", "Extra Exchange", "ExtraExchange.bin", "Items", "Converts ExtraExchange.bin package.", @"LibProj/CsFileTable/TableStruct_ExtraEvolution.h", new[] { "DATA/ExtraExchange.bin" }, new[] { "XML/ExtraExchange/ExtraExchange.xml" }, "Nested extra-exchange package with NPC groups, exchange IDs, and required materials.", () => _legacyAdvanced!.InvokeLegacyAction("ExtraExchangeToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("ExtraExchangeToBin_Click")), Profile("Tactics", "Tactics", "Tactics.bin", "Combat", "Converts Tactics.bin package into the full client tactics XML package.", @"LibProj/CsFileTable/Tactics.h; LibProj/CsFileTable/TacticsExplain.h; LibProj/CsFileTable/TacticsEnchant.h; LibProj/CsFileTable/TacticsTranscend.h; LibProj/CsFileTable/TacticsMng.h", new[] { "DATA/Tactics.bin" }, new[] { "XML/Tactics/TDBTactic.xml", "XML/Tactics/TacticsPlain.xml", "XML/Tactics/EnchantItemInfo.xml", "XML/Tactics/EnchantStatInfo.xml", "XML/Tactics/TranscendCorrect.xml", "XML/Tactics/TranscendInfo.xml", "XML/Tactics/TranscendEvo.xml", "XML/Tactics/ExpDigimon.xml" }, "Eight-section package rebuilt from the client save/load order. This build uses the upgraded 2-grade tactics layout, and all hidden padding stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("TacticsToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("TacticsToBin_Click")), Profile("MapPortal", "Map Portal", "MapPortal.bin", "Maps", "Converts MapPortal.bin package.", @"LibProj/CsFileTable/MapPortal.h; LibProj/CsFileTable/MapPortalMng.h", new[] { "DATA/MapPortal.bin" }, new[] { "XML/MapPortal/MapPortal.xml" }, "Grouped portal package rebuilt from the client save/load order. Each group stores a portal count followed by fixed CsMapPortal::sINFO rows.", () => _legacyAdvanced!.InvokeLegacyAction("MapPortalToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapPortalToBin_Click")), Profile("Talk", "Talk", "Talk.bin", "UI", "Converts Talk.bin package into the client talk XML files.", @"LibProj/CsFileTable/Talk_Digimon.h; LibProj/CsFileTable/Talk_Event.h; LibProj/CsFileTable/Talk_Message.h; LibProj/CsFileTable/Talk_Tip.h; LibProj/CsFileTable/TalkMng.h", new[] { "DATA/Talk.bin" }, new[] { "XML/Talk/TalkDigimon.xml", "XML/Talk/TalkEvent.xml", "XML/Talk/TalkMessage.xml", "XML/Talk/TalkTip.xml", "XML/Talk/TalkLoadingTip.xml" }, "Five-section Talk.bin package rebuilt from the client manager. Tutorial.bin remains separate, and the hidden Digimon tail padding stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("TalkToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("button26_Click")), Profile("TimeCharge", "Time Charge", "TimeCharge.bin", "Items", "Converts TimeCharge.bin into charge item, bit code, and cash code XML files.", @"LibProj/CsFileTable/TimeCharge.h; LibProj/CsFileTable/TimeChargeMng.h", new[] { "DATA/TimeCharge.bin" }, new[] { "XML/TimeCharge/ChargeItem.xml", "XML/TimeCharge/BitCode.xml", "XML/TimeCharge/CashCode.xml" }, "Three-section package rebuilt from the client manager: charge-item links, bit-code timings, and grouped cash-code requirements. No fake fields or guessed padding in visible XML.", () => _legacyAdvanced!.InvokeLegacyAction("TimeChargeToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("TimeChargeToBin_Click")), Profile("Tutorial", "Tutorial", "Tutorial.bin", "UI", "Converts Tutorial.bin into the client tutorial text XML package.", @"LibProj/CsFileTable/Talk_Tutorial.h; LibProj/CsFileTable/TalkMng_Tutorial.cpp", new[] { "DATA/Tutorial.bin" }, new[] { "XML/Tutorial/Tutorial.xml" }, "Single-section Tutorial.bin package rebuilt from the client tutorial talk manager. The BIN stores fixed 256-char Unicode text rows only, and XML index is derived from row order.", () => _legacyAdvanced!.InvokeLegacyAction("TutorialToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("TutorialToBin_Click")), Profile("WorldMap", "World Map", "WorldMap.bin", "Maps", "Converts WorldMap.bin package.", @"LibProj/CsFileTable/WorldMap.h; LibProj/CsFileTable/AreaMap.h; LibProj/CsFileTable/WorldMapMng.h", new[] { "DATA/WorldMap.bin" }, new[] { "XML/WorldMap/WorldMap.xml", "XML/WorldMap/AreaMap.xml" }, "Two-section package rebuilt from the client save/load order. World rows keep the internal alignment byte after s_nWorldType, and area rows follow the real fixed struct sizes.", () => _legacyAdvanced!.InvokeLegacyAction("WorldMapToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("WorlMapToBin_Click")), Profile("Weather", "Weather", "Weather.bin", "Maps", "Converts Weather.bin package.", @"LibProj/CsFileTable/Weather.h; LibProj/CsFileTable/WeatherGroup.h; LibProj/CsFileTable/WeatherMng.h", new[] { "DATA/Weather.bin" }, new[] { "XML/Weather/Weather.xml" }, "Grouped weather package rebuilt from the client manager: outer weather groups, nested weather records, and nested weather elements. Hidden tail padding on sELEMENT stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("WeatherToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("WeatherToBin_Click")), Profile("MapObject", "Map Object", "MapObject.bin", "Maps", "Converts MapObject.bin package.", @"LibProj/CsFileTable/MapObject.h; LibProj/CsFileTable/MapObjectMng.h", new[] { "DATA/MapObject.bin" }, new[] { "XML/MapObject/MapObject.xml" }, "Grouped map object package rebuilt from the client save/load order: map group, object bucket, object instance, then factor rows.", () => _legacyAdvanced!.InvokeLegacyAction("MapObjectToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapObjectToBin_Click")), Profile("MapRegion", "Map Region", "MapRegion.bin", "Maps", "Converts MapRegion.bin package.", @"LibProj/CsFileTable/MapRegion.h; LibProj/CsFileTable/MapRegionMng.h", new[] { "DATA/MapRegion.bin" }, new[] { "XML/MapRegion/MapRegion.xml", "XML/MapRegion/MapLimitEvo.xml", "XML/MapRegion/MapBuffRegion.xml" }, "Three-section map region package rebuilt from the client binary save/load order: map regions, limit-evo regions, and buff regions. Tail padding stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("MapRegionToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("MapRegionToBin_Click")), Profile("Scene", "Scene", "Scene.bin", "Maps", "Converts Scene.bin package into scene data XML plus the target table XML.", @"LibProj/CsFileTable/SceneData.h; LibProj/CsFileTable/SceneDataMng.h", new[] { "DATA/Scene.bin" }, new[] { "XML/Scene/SceneData.xml", "XML/Scene/SceneTargets.xml" }, "Two-section package derived directly from the client save/load order: scene headers with nested action rows, then the target table. Hidden struct padding stays internal.", () => _legacyAdvanced!.InvokeLegacyAction("SceneToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("SceneToBin_Click")), Profile("CashShop", "Cash Shop", "CashShop.bin", "Shop", "Converts CashShop.bin into clean source-faithful hierarchy XML plus web data XML.", @"LibProj/CsFileTable/CashShop.h; LibProj/CsFileTable/CashShopMng.h", new[] { "DATA/CashShop.bin" }, new[] { "XML/CashShop/CashShopTables.xml", "XML/CashShop/CashShopWebData.xml" }, "Clean package rebuilt from the real client hierarchy: table type, main category, subcategory, product group, product, then web data. Discord XML remains reference only.", () => _legacyAdvanced!.InvokeLegacyAction("CashShopToXml_Click"), () => _legacyAdvanced!.InvokeLegacyAction("CashShopToBin_Click")) }); AddPlaceholderProfilesForUnimplementedPackages(); } private void AddPlaceholderProfilesForUnimplementedPackages() { var existingKeys = new HashSet(_profiles.Select(profile => profile.Key), StringComparer.OrdinalIgnoreCase); foreach (var package in GetCanonicalPackageCatalog()) { if (existingKeys.Contains(package.Key)) { continue; } _profiles.Add(new ConversionProfile { Key = package.Key, DisplayName = package.DisplayName, PackageFileName = package.FileName, Category = package.Category, Description = $"{package.FileName} support is still in progress. XML split/count must be confirmed from client source before conversion is enabled.", StructReference = package.StructReference, Notes = package.Notes, BinInputs = new[] { $"DATA/{package.FileName}" }, XmlFiles = new[] { package.XmlPlaceholder }, ToXmlAction = null, ToBinAction = null }); } } private static IEnumerable<(string Key, string DisplayName, string FileName, string Category, string StructReference, string XmlPlaceholder, string Notes)> GetCanonicalPackageCatalog() { return new[] { ("Achieve", "Achievement", "Achieve.bin", "Event", @"Classes/Achieve.cs", "XML/Achieve/Achieve.xml", "2 XML files verified."), ("AddExp", "Add Experience", "AddExp.bin", "Combat", @"LibProj/CsFileTable/AddExp.h", "XML/AddExp/AddExp.xml", "1 XML file verified."), ("BattleTable", "Battle Table", "BattleTable.bin", "Combat", @"LibProj/CsFileTable/BattleTableMng.h", "XML/BattleTable/BattleInfo.xml", "3 XML files verified from client source order."), ("Buff", "Buff", "Buff.bin", "Combat", @"LibProj/CsFileTable/Buff.h", "XML/Buff/Buff.xml", "1 XML file verified from client struct."), ("CashShop", "Cash Shop", "CashShop.bin", "Shop", @"LibProj/CsFileTable/CashShop.h; LibProj/CsFileTable/CashShopMng.h", "XML/CashShop/CashShopTables.xml", "Clean hierarchy package verified against the client save/load order. Web data is exported separately."), ("CharCreateTable", "Character Create Table", "CharCreateTable.bin", "Character", @"LibProj/CsFileTable/CharacterCreateListInfo.h", "XML/CharCreateTable/TamerCreate.xml", "2 XML files verified from client source order."), ("Cuid", "CUID", "Cuid.bin", "UI", @"LibProj/CsFileTable/CUID.h; LibProj/CsFileTable/CUID_Chat.h", "XML/Cuid/CuidId.xml", "2 XML files verified from fixed client structs."), ("Data_Exchange", "Data Exchange", "Data_Exchange.bin", "Digimon", @"LibProj/CsFileTable/Digimon.h", "XML/Data_Exchange/DataExchange.xml", "1 XML file verified from Digimon manager save/load order."), ("Digimon_Book", "Digimon Book", "Digimon_Book.bin", "Digimon", @"LibProj/CsFileTable/Digimon.h", "XML/Digimon_Book/BookInfo.xml", "4 XML files verified from encyclopedia save/load order."), ("Digimon_List", "Digimon List", "Digimon_List.bin", "Digimon", @"LibProj/CsFileTable/Digimon.h", "XML/Digimon_List/DigimonList.xml", "1 XML file verified."), ("DigimonEvo", "Digimon Evolution", "DigimonEvo.bin", "Digimon", @"LibProj/CsFileTable/DigimonEvolveObj.h; LibProj/CsFileTable/CDigimonEvolution.h", "XML/DigimonEvo/DigimonEvo.xml", "2 XML files verified from client source."), ("DigimonParcel", "Digimon Parcel", "DigimonParcel.bin", "Digimon", @"LibProj/CsFileTable/DigimonParcelManager.h", "XML/DigimonParcel/DigimonParcel.xml", "1 XML file verified from the parcel digimon list manager."), ("DMBase", "DM Base", "DMBase.bin", "Digimon", @"LibProj/CsFileTable/Base.h; LibProj/CsFileTable/BaseMng.h", "XML/DMBase/TamerBaseInfo.xml", "Multi-section package. Current exporter writes organized XML files under XML/DMBase/."), ("EffectList", "Effect List", "EffectList.bin", "Items", @"LibProj/CsFileTable/EffectMng.h", "XML/EffectList/EffectList.xml", "1 XML file verified."), ("Event", "Event", "Event.bin", "Event", @"Classes/EventTotal.cs", "XML/Event/Event.xml", "6 XML files verified from the current package layout."), ("ExtraExchange", "Extra Exchange", "ExtraExchange.bin", "Items", @"Classes/ExtraExchanges.cs", "XML/ExtraExchange/ExtraExchange.xml", "1 XML file verified."), ("Gotcha", "Gotcha", "Gotcha.bin", "Shop", @"LibProj/CsFileTable/CsGotcha.h", "XML/Gotcha/Gotcha.xml", "5 XML files verified from the client Gotcha structs."), ("InfiniteWar", "Infinite War", "InfiniteWar.bin", "Combat", @"LibProj/CsFileTable/InfiniteWarManager.h; LibProj/CsFileTable/TableStruct_InfiniteWar.h", "XML/InfiniteWar/StageInfo.xml", "5 XML files verified from the client save/load order."), ("ItemList", "Item List", "ItemList.bin", "Items", @"Classes/ItemList.cs", "XML/ItemList/ItemList.xml", "16 XML files verified from the current item package layout."), ("MapList", "Map List", "MapList.bin", "Maps", @"LibProj/CsFileTable/MapList.h", "XML/MapList/MapList.xml", "1 XML file verified."), ("MapMonsterList", "Map Monster List", "MapMonsterList.bin", "Maps", @"LibProj/CsFileTable/MapMonster.h; LibProj/CsFileTable/MapMonsterMng.h", "XML/MapMonsterList/MapMonsterList.xml", "1 XML file verified from grouped client BIN layout."), ("MapNpc", "Map NPC", "MapNpc.bin", "Maps", @"LibProj/CsFileTable/MapNpc.h", "XML/MapNpc/MapNpc.xml", "1 XML file verified from CsMapNpc::sINFO."), ("MapObject", "Map Object", "MapObject.bin", "Maps", @"LibProj/CsFileTable/MapObject.h; LibProj/CsFileTable/MapObjectMng.h", "XML/MapObject/MapObject.xml", "1 XML file verified from grouped client BIN layout."), ("MapPortal", "Map Portal", "MapPortal.bin", "Maps", @"LibProj/CsFileTable/MapPortal.h; LibProj/CsFileTable/MapPortalMng.h", "XML/MapPortal/MapPortal.xml", "1 XML file verified from grouped client BIN layout."), ("MapRegion", "Map Region", "MapRegion.bin", "Maps", @"LibProj/CsFileTable/MapRegion.h; LibProj/CsFileTable/MapRegionMng.h", "XML/MapRegion/MapRegion.xml", "3 XML files verified from grouped client BIN layout."), ("MasterCard", "Master Card", "MasterCard.bin", "Cards", @"LibProj/CsFileTable/Master_Card.h; LibProj/CsFileTable/Master_CardMng.h", "XML/MasterCard/MasterCards.xml", "8 XML files verified from client package layout."), ("Model", "Model", "Model.dat", "Digimon", @"Classes/ModelInfo.cs", "XML/Model.xml", "Reference DAT package included in catalog."), ("Monster", "Monster", "Monster.bin", "Combat", @"LibProj/CsFileTable/Monster.h", "XML/Monster/Monster.xml", "4 XML files verified."), ("Nature", "Nature", "Nature.bin", "Digimon", @"LibProj/CsFileTable/Nature.h; LibProj/CsFileTable/NatureMng.h; LibProj/CsFileTable/BaseElement.h", "XML/Nature/Nature.xml", "2 XML files verified from client package layout."), ("New_Element", "New Element", "New_Element.bin", "Digimon", @"LibProj/CsFileTable/ElementUI.h; LibProj/CsFileTable/DigimonMng.h", "XML/New_Element/AttributeTypeUI.xml", "2 XML files verified from client package layout."), ("NewTutorial", "New Tutorial", "NewTutorial.bin", "In Progress", @"Source lookup pending", "XML/InProgress/NewTutorial.xml", "In progress. No trusted XML split locked yet."), ("Npc", "NPC", "Npc.bin", "NPC", @"LibProj/CsFileTable/Npc.h; LibProj/CsFileTable/NpcMng.h; LibProj/CsFileTable/NpcType.h; LibProj/CsFileTable/NpcExtra.h", "XML/Npc/Npc.xml", "3 XML files verified from the client NPC manager."), ("Passive_Ability", "Passive Ability", "Passive_Ability.bin", "Digimon", @"LibProj/CsFileTable/Digimon.h; LibProj/CsFileTable/DigimonMng.h", "XML/Passive_Ability/PassiveAbility.xml", "1 XML file verified from the client Digimon passive-ability section."), ("Quest", "Quest", "Quest.bin", "Quest", @"LibProj/CsFileTable/Quest.h; LibProj/CsFileTable/QuestMng.h", "XML/Quest/Quest.xml", "1 XML file verified from the client save/load order."), ("Reward", "Reward", "Reward.bin", "Event", @"LibProj/CsFileTable/Reward.h; LibProj/CsFileTable/RewardMng.h", "XML/Reward/Reward.xml", "1 XML file verified from grouped client reward data."), ("Ride", "Ride", "Ride.bin", "Digimon", @"LibProj/CsFileTable/Ride.h; LibProj/CsFileTable/DigimonMng.cpp", "XML/Ride/Ride.xml", "1 XML file verified from CsRide::sINFO."), ("Scene", "Scene", "Scene.bin", "Maps", @"LibProj/CsFileTable/SceneData.h; LibProj/CsFileTable/SceneDataMng.h", "XML/Scene/SceneData.xml", "2 XML files verified from client source order."), ("ServerTransfer", "Server Transfer", "ServerTransfer.bin", "UI", @"LibProj/CsFileTable/ServerRelocateTable.h; LibProj/CsFileTable/ServerRelocateTable.cpp", "XML/ServerTransfer/ServerTransfer.xml", "1 XML file verified from grouped server transfer data with nested limit rows."), ("Skill", "Skill", "Skill.bin", "Combat", @"LibProj/CsFileTable/Skill.h; LibProj/CsFileTable/SkillMng.h; LibProj/CsFileTable/SkillMng.cpp; LibProj/CsFileTable/_SkillDefine.h", "XML/Skill/Skill.xml", "3 XML files verified from client struct layout."), ("Spirit_NPC", "Spirit NPC", "Spirit_NPC.bin", "In Progress", @"Source lookup pending", "XML/InProgress/Spirit_NPC.xml", "In progress. No trusted XML split locked yet."), ("SvLineUp", "Server Line Up", "SvLineUp.bin", "In Progress", @"Source lookup pending", "XML/InProgress/SvLineUp.xml", "In progress. No trusted XML split locked yet."), ("Tactics", "Tactics", "Tactics.bin", "Combat", @"LibProj/CsFileTable/Tactics.h; LibProj/CsFileTable/TacticsExplain.h; LibProj/CsFileTable/TacticsEnchant.h; LibProj/CsFileTable/TacticsTranscend.h; LibProj/CsFileTable/TacticsMng.h", "XML/Tactics/TDBTactic.xml", "8 XML files verified from the client save/load order."), ("Talk", "Talk", "Talk.bin", "UI", @"LibProj/CsFileTable/Talk_Digimon.h; LibProj/CsFileTable/Talk_Event.h; LibProj/CsFileTable/Talk_Message.h; LibProj/CsFileTable/Talk_Tip.h; LibProj/CsFileTable/TalkMng.h", "XML/Talk/TalkDigimon.xml", "5 XML files verified from the client talk managers."), ("TamerList", "Tamer List", "TamerList.bin", "In Progress", @"Source lookup pending", "XML/InProgress/TamerList.xml", "In progress. No trusted XML split locked yet."), ("TimeCharge", "Time Charge", "TimeCharge.bin", "Items", @"LibProj/CsFileTable/TimeCharge.h; LibProj/CsFileTable/TimeChargeMng.h", "XML/TimeCharge/ChargeItem.xml", "3 XML files verified from the client time-charge manager."), ("Tutorial", "Tutorial", "Tutorial.bin", "UI", @"LibProj/CsFileTable/Talk_Tutorial.h; LibProj/CsFileTable/TalkMng_Tutorial.cpp", "XML/Tutorial/Tutorial.xml", "1 XML file verified from the client tutorial talk manager."), ("UIText", "UI Text", "UIText.bin", "UI", @"LibProj/CsFileTable/UI_Text.h; LibProj/CsFileTable/UI_Text.cpp", "XML/UIText/UIText.xml", "1 XML file verified from the client UI text manager."), ("Weather", "Weather", "Weather.bin", "Maps", @"LibProj/CsFileTable/Weather.h; LibProj/CsFileTable/WeatherGroup.h; LibProj/CsFileTable/WeatherMng.h", "XML/Weather/Weather.xml", "1 XML file verified from the client grouped weather manager."), ("WorldMap", "World Map", "WorldMap.bin", "Maps", @"LibProj/CsFileTable/WorldMap.h; LibProj/CsFileTable/AreaMap.h; LibProj/CsFileTable/WorldMapMng.h", "XML/WorldMap/WorldMap.xml", "2 XML files verified from the client world-map manager.") }; } private ConversionProfile Profile(string key, string displayName, string packageFileName, string category, string description, string structReference, string[] binInputs, string[] xmlFiles, string notes, Action? toXmlAction, Action? toBinAction) { return new ConversionProfile { Key = key, DisplayName = displayName, PackageFileName = packageFileName, Category = category, Description = description, StructReference = structReference, Notes = notes, BinInputs = binInputs, XmlFiles = xmlFiles, ToXmlAction = toXmlAction, ToBinAction = toBinAction }; } private void ApplyFilter() { string query = (_searchBox.Text ?? string.Empty).Trim(); var packageOrder = GetCanonicalPackageCatalog() .Select((package, index) => new { package.FileName, index }) .ToDictionary(item => item.FileName, item => item.index, StringComparer.OrdinalIgnoreCase); _filteredProfiles = _profiles .Where(profile => string.IsNullOrWhiteSpace(query) || GetPackageLabel(profile).Contains(query, StringComparison.OrdinalIgnoreCase) || profile.DisplayName.Contains(query, StringComparison.OrdinalIgnoreCase) || profile.Category.Contains(query, StringComparison.OrdinalIgnoreCase) || profile.Key.Contains(query, StringComparison.OrdinalIgnoreCase) || profile.Description.Contains(query, StringComparison.OrdinalIgnoreCase) || profile.XmlFiles.Any(path => path.Contains(query, StringComparison.OrdinalIgnoreCase))) .OrderBy(profile => packageOrder.TryGetValue(profile.PackageFileName, out int order) ? order : int.MaxValue) .ThenBy(profile => profile.PackageFileName, StringComparer.OrdinalIgnoreCase) .ToList(); _profileList.BeginUpdate(); _profileList.Items.Clear(); foreach (var profile in _filteredProfiles) { _profileList.Items.Add(profile); } _profileList.EndUpdate(); _profileCountLabel.Text = $"{_filteredProfiles.Count} profiles"; if (_profileList.Items.Count > 0) { _profileList.SelectedIndex = 0; } else { UpdateSelectedProfile(); } } private void UpdateSelectedProfile() { var profile = SelectedProfile; if (profile == null) { _profileNameValue.Text = "Select a profile"; _descriptionBox.Clear(); _structBox.Clear(); _notesBox.Clear(); _binFilesList.Items.Clear(); _xmlFilesList.Items.Clear(); _validateButton.Enabled = false; _toXmlButton.Enabled = false; _toBinButton.Enabled = false; UpdateStatus("No profile selected"); return; } _profileNameValue.Text = GetPackageLabel(profile); _descriptionBox.Text = profile.Description; _structBox.Text = profile.StructReference; _notesBox.Text = profile.Notes; _binFilesList.Items.Clear(); foreach (var path in profile.BinInputs) { _binFilesList.Items.Add(path); } _xmlFilesList.Items.Clear(); foreach (var path in profile.XmlFiles) { _xmlFilesList.Items.Add(path); } _validateButton.Enabled = true; _toXmlButton.Enabled = profile.ToXmlAction != null; _toBinButton.Enabled = profile.ToBinAction != null; UpdateStatus($"Selected {GetPackageLabel(profile)}"); } private ConversionProfile? SelectedProfile => _profileList.SelectedItem as ConversionProfile; private bool ValidateSelectedProfile(bool showSuccessMessage, bool forToXml = true) { var profile = SelectedProfile; if (profile == null) { MessageBox.Show("Select a conversion profile first.", "No Profile Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return false; } var issues = new List(); ValidateRoot(DataRoot, "DATA", issues); ValidateRoot(XmlRoot, "XML", issues); ValidateRoot(BinRoot, "BIN", issues); string[] requiredFiles = forToXml ? profile.BinInputs : profile.XmlFiles; foreach (string relativePath in requiredFiles) { string absolutePath = Path.Combine(AppContext.BaseDirectory, relativePath); if (!File.Exists(absolutePath)) { issues.Add($"Missing {(forToXml ? "source" : "XML")} file: {relativePath}"); } } if (issues.Count > 0) { string message = string.Join(Environment.NewLine, issues); Log($"Validation failed for {profile.DisplayName}:{Environment.NewLine}{message}"); UpdateStatus("Validation failed"); MessageBox.Show(message, "Validation Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } Log($"Validation passed for {profile.DisplayName}."); UpdateStatus("Validation passed"); if (showSuccessMessage) { string mode = forToXml ? "BIN -> XML" : "XML -> BIN"; MessageBox.Show($"{profile.DisplayName} is ready for {mode}.", "Validation Passed", MessageBoxButtons.OK, MessageBoxIcon.Information); } return true; } private static void ValidateRoot(string path, string label, List issues) { if (!Directory.Exists(path)) { issues.Add($"Missing {label} root: {path}"); } } private void RunSelectedConversion(bool toXml) { var profile = SelectedProfile; if (profile == null) { MessageBox.Show("Select a conversion profile first.", "No Profile Selected", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!ValidateSelectedProfile(showSuccessMessage: false, forToXml: toXml)) { return; } Action? action = toXml ? profile.ToXmlAction : profile.ToBinAction; if (action == null) { MessageBox.Show($"{profile.DisplayName} does not support this direction yet.", "Action Not Available", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } string direction = toXml ? "BIN -> XML" : "XML -> BIN"; try { Log($"Running {direction} for {profile.DisplayName}."); UpdateStatus($"Running {direction}..."); action(); Log($"Completed {direction} for {profile.DisplayName}."); UpdateStatus($"{direction} completed"); } catch (Exception ex) { Log($"Failed {direction} for {profile.DisplayName}: {ex.Message}"); UpdateStatus($"{direction} failed"); MessageBox.Show(ex.ToString(), "Conversion Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void OpenFolder(string path) { Directory.CreateDirectory(path); Process.Start(new ProcessStartInfo { FileName = path, UseShellExecute = true }); Log($"Opened folder: {path}"); } private void UpdateStatus(string text) { _statusValue.Text = text; } private void Log(string message) { _activityLog.AppendText($"[{DateTime.Now:HH:mm:ss}] {message}{Environment.NewLine}"); _activityLog.SelectionStart = _activityLog.TextLength; _activityLog.ScrollToCaret(); } private void ProfileList_DrawItem(object? sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index < 0 || e.Index >= _profileList.Items.Count) { return; } var profile = (ConversionProfile)_profileList.Items[e.Index]!; bool selected = (e.State & DrawItemState.Selected) == DrawItemState.Selected; Color background = selected ? SelectedRowColor : Color.White; Color borderColor = selected ? Color.FromArgb(118, 162, 232) : Color.FromArgb(214, 214, 214); using var backgroundBrush = new SolidBrush(background); using var borderPen = new Pen(borderColor); using var titleBrush = new SolidBrush(TitleColor); using var metaBrush = new SolidBrush(MetaColor); using var titleFont = new Font("Segoe UI Semibold", 10F, FontStyle.Bold); using var metaFont = new Font("Segoe UI", 8.5F); Rectangle cardBounds = new Rectangle(e.Bounds.Left + 6, e.Bounds.Top + 5, e.Bounds.Width - 18, e.Bounds.Height - 10); e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; using (GraphicsPath cardPath = CreateRoundedRectanglePath(cardBounds, 10)) { e.Graphics.FillPath(backgroundBrush, cardPath); e.Graphics.DrawPath(borderPen, cardPath); } Rectangle contentBounds = Rectangle.Inflate(cardBounds, -14, -10); e.Graphics.DrawString(GetPackageLabel(profile), titleFont, titleBrush, new PointF(contentBounds.Left, contentBounds.Top)); e.Graphics.DrawString(GetProfileSubtitle(profile), metaFont, metaBrush, new PointF(contentBounds.Left, contentBounds.Top + 32)); e.DrawFocusRectangle(); } private static GraphicsPath CreateRoundedRectanglePath(Rectangle bounds, int radius) { int diameter = radius * 2; var path = new GraphicsPath(); path.AddArc(bounds.Left, bounds.Top, diameter, diameter, 180, 90); path.AddArc(bounds.Right - diameter, bounds.Top, diameter, diameter, 270, 90); path.AddArc(bounds.Right - diameter, bounds.Bottom - diameter, diameter, diameter, 0, 90); path.AddArc(bounds.Left, bounds.Bottom - diameter, diameter, diameter, 90, 90); path.CloseFigure(); return path; } private static string GetPackageLabel(ConversionProfile profile) { return profile.PackageFileName; } private static string GetProfileSubtitle(ConversionProfile profile) { int xmlCount = profile.XmlFiles.Length; string xmlLabel = xmlCount == 1 ? "1 XML file" : $"{xmlCount} XML files"; return $"{xmlLabel} � {profile.Category.ToLowerInvariant()} package"; } }