|
8 | 8 | from mgtools.enumerators.game import Game |
9 | 9 | from mgtools.mg1.constants import RESOURCE_SECTION_COUNT as MG1_SECTION_COUNT |
10 | 10 | from mgtools.mg2.constants import RESOURCE_SECTION_COUNT as MG2_SECTION_COUNT |
| 11 | +from mgtools.mgs_font import export_mgs_font, import_mgs_font |
11 | 12 | from mgtools.resource import Resource |
12 | 13 |
|
13 | 14 | app = typer.Typer(help="Tools for modding PC ports of Metal Gear / Metal Gear 2") |
|
21 | 22 | ) |
22 | 23 | ctxr_app = typer.Typer(help="Tools for working with ctxr textures") |
23 | 24 | app.add_typer(ctxr_app, name="ctxr", help="Tools for working with ctxr textures") |
| 25 | +mgs_font_app = typer.Typer( |
| 26 | + help="Tools for working with MGS font files (MGS_Font_nht.raw)" |
| 27 | +) |
| 28 | +app.add_typer( |
| 29 | + mgs_font_app, |
| 30 | + name="mgs-font", |
| 31 | + help="Tools for working with MGS font files (MGS_Font.raw, MGS_Font_nht.raw)", |
| 32 | +) |
24 | 33 |
|
25 | 34 |
|
26 | 35 | @res_app.command( |
@@ -115,3 +124,37 @@ def ctxr_import( |
115 | 124 | continue |
116 | 125 |
|
117 | 126 | import_ctxr(png_file, output_dir) |
| 127 | + |
| 128 | + |
| 129 | +@mgs_font_app.command( |
| 130 | + "export", help="Export MGS font file to a folder with glyph images and metadata." |
| 131 | +) |
| 132 | +def mgs_font_export( |
| 133 | + input_file: Annotated[ |
| 134 | + Path, typer.Argument(exists=True, file_okay=True, readable=True) |
| 135 | + ], |
| 136 | + output_dir: Annotated[ |
| 137 | + Path | None, typer.Argument(file_okay=False, writable=True) |
| 138 | + ] = None, |
| 139 | +): |
| 140 | + if output_dir is None: |
| 141 | + output_dir = input_file.parent / input_file.stem |
| 142 | + |
| 143 | + export_mgs_font(input_file, output_dir) |
| 144 | + |
| 145 | + |
| 146 | +@mgs_font_app.command( |
| 147 | + "import", help="Import glyph images and metadata back into MGS font file." |
| 148 | +) |
| 149 | +def mgs_font_import( |
| 150 | + input_dir: Annotated[ |
| 151 | + Path, typer.Argument(exists=True, dir_okay=True, readable=True) |
| 152 | + ], |
| 153 | + output_file: Annotated[ |
| 154 | + Path | None, typer.Argument(file_okay=True, writable=True) |
| 155 | + ] = None, |
| 156 | +): |
| 157 | + if output_file is None: |
| 158 | + output_file = input_dir.parent / f"{input_dir.name}.raw" |
| 159 | + |
| 160 | + import_mgs_font(input_dir, output_file) |
0 commit comments