### MabiEnvironment Class - Game Installation Detection Source: https://context7.com/logue/mabipack/llms.txt Detects Mabinogi installation directory, reads version information, fetches server patch details, and can launch the game client. ```APIDOC ## MabiEnvironment Class - Game Installation Detection The `MabiEnvironment` class detects the Mabinogi game installation directory from the Windows registry and reads version information. It can also fetch server patch information and launch the game client with proper parameters. ### Properties - **MabinogiDir** (string) - The detected Mabinogi installation directory. - **LocalVersion** (uint) - The local client version read from version.dat. - **isDownloadable** (bool) - Indicates if server patch information is available. - **ServerVersion** (uint) - The version of the game server. - **PatchServer** (string) - The URL of the patch server. - **LoginIP** (string) - The IP address for game login. ### Constructor `MabiEnvironment()` `MabiEnvironment(string patchUrl)` ### Request Example ```csharp using MabiPacker.Library; using System; // Basic usage - detect local installation MabiEnvironment env = new MabiEnvironment(); // Get Mabinogi installation directory (from registry) string mabiDir = env.MabinogiDir; Console.WriteLine($"Mabinogi Directory: {mabiDir}"); // Get local client version from version.dat uint localVersion = env.LocalVersion; Console.WriteLine($"Local Version: {localVersion}"); // Build paths to common locations string packageDir = $"{mabiDir}\package"; string customPackPath = $"{packageDir}\custom-{localVersion + 1}.pack"; Console.WriteLine($"Package Directory: {packageDir}"); Console.WriteLine($"Custom Pack Path: {customPackPath}"); // Advanced usage - fetch server patch information string patchUrl = "http://patch.mabinogi.nexon.net/patch/patch.txt"; MabiEnvironment serverEnv = new MabiEnvironment(patchUrl); if (serverEnv.isDownloadable) { Console.WriteLine($"Server Version: {serverEnv.ServerVersion}"); Console.WriteLine($"Patch Server: {serverEnv.PatchServer}"); Console.WriteLine($"Login IP: {serverEnv.LoginIP}"); } ``` ### Response #### Success Response (200) (Properties are populated with detected information.) #### Response Example ``` Mabinogi Directory: C:\Nexon\Mabinogi Local Version: 439 Package Directory: C:\Nexon\Mabinogi\package Custom Pack Path: C:\Nexon\Mabinogi\package\custom-440.pack Server Version: 439 Patch Server: http://patch.mabinogi.nexon.net Login IP: 127.0.0.1 ``` ``` -------------------------------- ### Detect Mabinogi Installation and Version Source: https://context7.com/logue/mabipack/llms.txt The MabiEnvironment class detects the Mabinogi installation directory from the Windows registry and reads version information. It can also fetch server patch information and launch the game client. ```csharp using MabiPacker.Library; using System; // Basic usage - detect local installation MabiEnvironment env = new MabiEnvironment(); // Get Mabinogi installation directory (from registry) string mabiDir = env.MabinogiDir; Console.WriteLine($"Mabinogi Directory: {mabiDir}"); // Get local client version from version.dat uint localVersion = env.LocalVersion; Console.WriteLine($"Local Version: {localVersion}"); // Build paths to common locations string packageDir = $"{mabiDir}\package"; string customPackPath = $"{packageDir}\custom-{localVersion + 1}.pack"; Console.WriteLine($"Package Directory: {packageDir}"); Console.WriteLine($"Custom Pack Path: {customPackPath}"); // Advanced usage - fetch server patch information string patchUrl = "http://patch.mabinogi.nexon.net/patch/patch.txt"; MabiEnvironment serverEnv = new MabiEnvironment(patchUrl); if (serverEnv.isDownloadable) { Console.WriteLine($"Server Version: {serverEnv.ServerVersion}"); Console.WriteLine($"Patch Server: {serverEnv.PatchServer}"); Console.WriteLine($"Login IP: {serverEnv.LoginIP}"); } ``` -------------------------------- ### Pack directories via CLI Source: https://context7.com/logue/mabipack/llms.txt Use these commands to pack directories into .pack files with optional output paths and compression levels. ```bash MabiPacker.exe /input "C:\MyMods\data" /version 220101 ``` ```bash MabiPacker.exe /input "C:\MyMods\data" /output "C:\CustomPack.pack" /version 220101 ``` ```bash MabiPacker.exe /input "C:\MyMods\data" /output "C:\CustomPack.pack" /version 220101 /level 6 ``` -------------------------------- ### Open Pack Browser programmatically Source: https://context7.com/logue/mabipack/llms.txt Instantiate and display the PackBrowser window to navigate and preview .pack file contents. ```csharp // Programmatically open the Pack Browser window using MabiPacker.View; string packFile = @"C:\Nexon\Mabinogi\package\language.pack"; // Create and show the pack browser window PackBrowser browser = new PackBrowser(packFile); browser.Show(); // The browser provides: // - Tree view navigation of pack contents // - Double-click to preview files // - Built-in DDS/TGA image rendering via Pfim library // - Syntax-highlighted text viewing via AvalonEdit // - Hex editor for binary files via WPFHexaEditor // - Export individual files to disk ``` -------------------------------- ### Command-Line Interface Source: https://context7.com/logue/mabipack/llms.txt Utilize MabiPacker via the command line for batch operations like packing and unpacking. ```APIDOC ## Command-Line Interface MabiPacker provides a console interface for batch operations and scripting. The mode (pack or unpack) is automatically determined based on whether the input path is a file or directory. ### Usage `MabiPacker.exe [options]` ### Options - **/help**: Displays help information. - **/input **: Specifies the input file (.pack) or directory to process. - **/output **: Specifies the output directory for unpacked files. If not provided, uses the default location. ### Examples ```bash # Display help MabiPacker.exe /help # Unpack a .pack file to default directory (Mabinogi package folder) MabiPacker.exe /input "C:\Nexon\Mabinogi\package\438_to_439.pack" # Unpack to specific output directory MabiPacker.exe /input "C:\Nexon\Mabinogi\package\438_to_439.pack" /output "C:\ExtractedData" ``` ``` -------------------------------- ### Pack Directory to .pack File with MabiPacker Source: https://context7.com/logue/mabipack/llms.txt Use the Packer class to compress a directory of files into a Mabinogi-compatible .pack file. Supports progress reporting and cancellation. Ensure the MabiPacker.Library namespace is included. ```csharp using MabiPacker.Library; using System; using System.Threading; // Create a packer instance with parameters: // - OutputFile: Path to the .pack file to create // - Destination: Source directory containing files to pack // - Version: Pack file version number (typically matches game version) // - Level: Compression level (-1 = auto, 0-9 for manual control) string outputFile = @"C:\Nexon\Mabinogi\package\custom-220101.pack"; string sourceDirectory = @"C:\MyMods\data"; uint version = 220101; int compressionLevel = -1; // Auto using (Packer packer = new Packer(outputFile, sourceDirectory, version, compressionLevel)) { // Get total file count for progress tracking uint totalFiles = packer.Count(); Console.WriteLine($"Packing {totalFiles} files..."); // Set up progress reporting Progress progress = new Progress((Entry entry) => { Console.WriteLine($"{entry.Index}/{totalFiles}: {entry.Name}"); }); // Option 1: Pack with cancellation support CancellationTokenSource cts = new CancellationTokenSource(); bool success = packer.Pack(progress, cts.Token); // Option 2: Pack without cancellation // bool success = packer.Pack(progress); if (success) { Console.WriteLine("Pack file created successfully!"); } } ``` -------------------------------- ### MabiPacker CLI Help and Usage Source: https://context7.com/logue/mabipack/llms.txt The MabiPacker command-line interface supports batch operations. The mode (pack or unpack) is automatically determined by the input path type. Use /help for a list of commands. ```bash # Display help MabiPacker.exe /help ``` ```bash # Unpack a .pack file to default directory (Mabinogi package folder) MabiPacker.exe /input "C:\Nexon\Mabinogi\package\438_to_439.pack" ``` ```bash # Unpack to specific output directory MabiPacker.exe /input "C:\Nexon\Mabinogi\package\438_to_439.pack" /output "C:\ExtractedData" ``` -------------------------------- ### Extract Files from .pack Archive with MabiPacker Source: https://context7.com/logue/mabipack/llms.txt Utilize the Unpacker class to extract contents from a Mabinogi .pack file to a specified directory. Preserves file timestamps and supports progress reporting and cancellation. Requires the MabiPacker.Library namespace. ```csharp using MabiPacker.Library; using System; using System.Collections.Generic; using System.Threading; string packFile = @"C:\Nexon\Mabinogi\package\438_to_439.pack"; string outputDirectory = @"C:\ExtractedData"; // Create unpacker with input file and output directory using (Unpacker unpacker = new Unpacker(packFile, outputDirectory)) { // Get total file count uint totalFiles = unpacker.Count(); Console.WriteLine($"Pack contains {totalFiles} files"); // List all entries in the pack file List entries = unpacker.Entries(); foreach (Entry entry in entries) { Console.WriteLine($" [{entry.Index}] {entry.File} ({entry.Size} bytes)"); } // Extract all files with progress reporting Progress progress = new Progress((Entry entry) => { Console.WriteLine($"Extracting: {entry.Name} ({entry.Index}/{totalFiles})"); }); // Unpack with cancellation support CancellationTokenSource cts = new CancellationTokenSource(); unpacker.Unpack(progress, cts.Token); // Or unpack without cancellation // unpacker.Unpack(progress); Console.WriteLine("Extraction complete!"); } ``` -------------------------------- ### Read File Contents from Pack Archive Source: https://context7.com/logue/mabipack/llms.txt Use GetContent to read file contents directly into memory. Files can be accessed by name or index. Ensure the Unpacker is disposed of properly. ```csharp using MabiPacker.Library; using System; using System.Text; string packFile = @"C:\Nexon\Mabinogi\package\language.pack"; using (Unpacker unpacker = new Unpacker(packFile)) { // Get file content by filename byte[] xmlData = unpacker.GetContent("xml/local/localstr.xml"); string xmlContent = Encoding.UTF8.GetString(xmlData); Console.WriteLine($"XML Content (first 200 chars):\n{xmlContent.Substring(0, Math.Min(200, xmlContent.Length))}"); // Get file content by index byte[] fileData = unpacker.GetContent(0); Console.WriteLine($"File at index 0: {fileData.Length} bytes"); } ``` -------------------------------- ### Entry Struct - File Entry Information Source: https://context7.com/logue/mabipack/llms.txt Represents metadata for a file within a pack archive, including path, name, extension, index, and size. ```APIDOC ## Entry Struct - File Entry Information The `Entry` struct represents a file entry within a pack archive or during packing operations. It contains metadata including the file path, name, extension, index position, and size. ### Properties - **File** (string) - Full relative path of the file (e.g., "gfx/image/logo.dds"). - **Name** (string) - File name only (e.g., "logo.dds"). - **Extension** (string) - File extension (e.g., ".dds"). - **Index** (int) - Position of the file in the pack archive. - **Size** (long) - Size of the file in bytes. ### Request Example ```csharp using MabiPacker.Library; using System; using System.Collections.Generic; string packFile = @"C:\Nexon\Mabinogi\package\data.pack"; using (Unpacker unpacker = new Unpacker(packFile)) { // Get all entries List entries = unpacker.Entries(); // Filter and display by extension foreach (Entry entry in entries) { if (entry.Extension == ".xml") { Console.WriteLine($"[{entry.Index}] {entry.File} - {entry.Size} bytes"); } } // Count files by type int imageCount = entries.FindAll(e => e.Extension == ".dds" || e.Extension == ".png" || e.Extension == ".jpg").Count; Console.WriteLine($"Total image files: {imageCount}"); } ``` ### Response #### Success Response (200) - **List** - A list of Entry structs representing all files in the archive. ``` -------------------------------- ### Access File Entry Information Source: https://context7.com/logue/mabipack/llms.txt The Entry struct represents a file entry within a pack archive, containing metadata like path, name, extension, index, and size. Use this to filter and process files within a pack. ```csharp using MabiPacker.Library; using System; using System.Collections.Generic; string packFile = @"C:\Nexon\Mabinogi\package\data.pack"; using (Unpacker unpacker = new Unpacker(packFile)) { // Get all entries List entries = unpacker.Entries(); // Filter and display by extension foreach (Entry entry in entries) { // Entry properties: // - entry.File: Full relative path (e.g., "gfx/image/logo.dds") // - entry.Name: File name only (e.g., "logo.dds") // - entry.Extension: File extension (e.g., ".dds") // - entry.Index: Position in pack file // - entry.Size: File size in bytes if (entry.Extension == ".xml") { Console.WriteLine($"[{entry.Index}] {entry.File} - {entry.Size} bytes"); } } // Count files by type int imageCount = entries.FindAll(e => e.Extension == ".dds" || e.Extension == ".png" || e.Extension == ".jpg").Count; Console.WriteLine($"Total image files: {imageCount}"); } ``` -------------------------------- ### Unpacker.Extract - Extract Individual Files Source: https://context7.com/logue/mabipack/llms.txt Extracts a single file from the pack archive to disk, optionally to a custom directory. Supports extraction by name or index. ```APIDOC ## Unpacker.Extract - Extract Individual Files The `Extract` method extracts a single file from the pack archive, preserving its original timestamps. Files can be extracted by name or index, with an optional custom output directory. ### Method `void Extract(string fileName)` `void Extract(int index)` `void Extract(string fileName, string outputDirectory)` `void Extract(int index, string outputDirectory)` ### Parameters #### Path Parameters - **fileName** (string) - Required - The name of the file to extract. - **index** (int) - Required - The index of the file to extract. - **outputDirectory** (string) - Optional - The custom directory to extract the file to. If not provided, it extracts to the default location. ### Request Example ```csharp using MabiPacker.Library; using System; string packFile = @"C:\Nexon\Mabinogi\package\438_to_439.pack"; string customOutputDir = @"C:\MyExtracts"; using (Unpacker unpacker = new Unpacker(packFile)) { // Extract file by name to default location unpacker.Extract("gfx/image/title_logo.dds"); // Extract file by index to default location unpacker.Extract(5); // Extract file by name to custom directory unpacker.Extract("xml/local/localstr.xml", customOutputDir); // Extract file by index to custom directory unpacker.Extract(10, customOutputDir); Console.WriteLine("Files extracted successfully!"); } ``` ### Response #### Success Response (200) (No explicit return value, operation is performed) #### Response Example (Files are extracted to the specified or default directory.) ``` -------------------------------- ### Extract Individual Files from Pack Archive Source: https://context7.com/logue/mabipack/llms.txt The Extract method preserves original timestamps. Files can be extracted by name or index, with an optional custom output directory. Ensure the Unpacker is disposed of properly. ```csharp using MabiPacker.Library; using System; string packFile = @"C:\Nexon\Mabinogi\package\438_to_439.pack"; string customOutputDir = @"C:\MyExtracts"; using (Unpacker unpacker = new Unpacker(packFile)) { // Extract file by name to default location unpacker.Extract("gfx/image/title_logo.dds"); // Extract file by index to default location unpacker.Extract(5); // Extract file by name to custom directory unpacker.Extract("xml/local/localstr.xml", customOutputDir); // Extract file by index to custom directory unpacker.Extract(10, customOutputDir); Console.WriteLine("Files extracted successfully!"); } ``` -------------------------------- ### Unpacker.GetContent - Read File Contents Source: https://context7.com/logue/mabipack/llms.txt Reads file contents from a pack archive directly into memory. Supports access by filename or index. ```APIDOC ## Unpacker.GetContent - Read File Contents in Memory The `GetContent` method reads a file's contents directly from the pack archive into memory without extracting to disk. This is useful for previewing files or processing them programmatically. Files can be accessed by name or by index number. ### Method `byte[] GetContent(string fileName)` `byte[] GetContent(int index)` ### Parameters #### Path Parameters - **fileName** (string) - Required - The name of the file to read. - **index** (int) - Required - The index of the file to read. ### Request Example ```csharp using MabiPacker.Library; using System; using System.Text; string packFile = @"C:\Nexon\Mabinogi\package\language.pack"; using (Unpacker unpacker = new Unpacker(packFile)) { // Get file content by filename byte[] xmlData = unpacker.GetContent("xml/local/localstr.xml"); string xmlContent = Encoding.UTF8.GetString(xmlData); Console.WriteLine($"XML Content (first 200 chars):\n{xmlContent.Substring(0, Math.Min(200, xmlContent.Length))}"); // Get file content by index byte[] fileData = unpacker.GetContent(0); Console.WriteLine($"File at index 0: {fileData.Length} bytes"); } ``` ### Response #### Success Response (200) - **byte[]** - The content of the file as a byte array. #### Response Example (Binary data representing file content) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.