$ show jie65535/GrasscutterCommandGenerator
GrasscutterCommandGenerator is a Windows Forms (.NET Framework 4.8) desktop application that serves as a comprehensive administration and command-generation tool for Grasscutter, a Genshin Impact private server emulator. It provides a GUI to generate and execute server commands (e.g., give items, teleport, spawn entities, set weather), edit server configuration files (gacha banners, drops, shops, activities), manage player accounts and permissions, and run a MITM proxy to intercept game traffic. The application is heavily data-driven, relying on embedded localized text files for game entity IDs and names, and uses Newtonsoft.Json for serialization. It supports multi-language UI (Chinese, English, Russian, Traditional Chinese) and integrates with a remote command plugin (gc-opencommand-plugin) for direct server interaction. The architecture is a monolith WinForms application with a tabbed page interface. The main entry point is Program.cs, which initializes the main form (FormMain) that hosts multiple pages (e.g., PageGiveItem, PageAvatar, PageQuest, PageProxy) and modal editors (FormGachaBannerEditor, FormShopEditor). A base class (BasePage) provides common lifecycle and command execution methods. The application communicates with the Grasscutter server via HTTP (OpenCommandAPI) and can also modify system proxy settings to redirect game traffic. External dependencies include the .NET Framework, Newtonsoft.Json (embedded), and Windows API calls for proxy and hotkey management. Key data flows involve loading game data from embedded resource files at startup, constructing command strings from user input, and optionally sending them to the server. The proxy module (Eavesdrop) captures and forwards HTTP/HTTPS traffic between the game client and server. The tool also supports importing/exporting player data in the GOOD (Genshin Open Object Description) format. While the codebase is functional and well-organized for its domain, it is tightly coupled to the Grasscutter server API and game data, requiring manual updates with each game patch. No automated tests are present, and the reliance on hardcoded data and Windows-specific features limits portability.
The LLM identified 6 files worth highlighting for reuse:
Implements a memory-efficient, range-based set data structure for fast membership checks. Used to filter illegal item IDs (e.g., illegalWeaponIds, illegalRelicIds) in the game data loading process. The pattern is self-contained and could be reused in any project requiring efficient inclusion/exclusion checks over large ID ranges.
Provides a generic mapping from integer IDs to localized names, with support for grouping (ItemMapGroup) and filtering by category. This pattern is used extensively throughout the application to populate combo boxes and list boxes with game entity names. It is isolated from the rest of the codebase and could be extracted for any project needing hierarchical ID-to-name lookups.
A lightweight async HTTP client wrapper that performs GET and POST requests and deserializes JSON responses using Newtonsoft.Json. It includes error handling and timeout management. This utility is reusable in any .NET application requiring simple HTTP communication with JSON payloads.
Contains utility methods for WinForms UI enhancements: filtering list box items with pinyin (Chinese phonetic) support, animating buttons after actions, and opening URLs. The filtering pattern is particularly non-trivial and could be reused in any application needing search-as-you-type functionality over list controls.
Implements runtime language switching for WinForms applications by leveraging ComponentResourceManager to reload resources for all controls on a form. This pattern allows the UI to switch languages without restarting the application. It is self-contained and demonstrates a clean approach to multi-language support in .NET WinForms.
Defines the Genshin Open Object Description (GOOD) data model for exporting/importing player artifacts, weapons, and characters as JSON. This format is standardized across the Genshin Impact community. The class handles serialization and deserialization of the GOOD schema, making it reusable for any tool that needs to exchange game inventory data.