Skip to content

About

GUI tool for Medieval 2 Total War mods: converts TGA textures to DDS and replaces originals with placeholders to save disk space

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

MEDIEVAL 2 TOTAL WAR - TEXTURE OPTIMIZER
=======================================

DESCRIPTION:
This tool optimizes texture files for Medieval 2 Total War mods by:
1. Converting TGA files to DDS format (saves disk space and improves loading)
2. Replacing original TGA files with zero-byte placeholders (further space savings)
3. Keeping a persistent backup of every original so the change can be reverted

REQUIRED FILES (same folder as texture_optimizer_gui.py):
- texconv.exe (Microsoft DirectX texture converter)
- zero_bytes.tga (an empty TGA file template)

RUNNING IT:
Double-click M2TW_Texture_Optimizer.bat, or run:
  python texture_optimizer_gui.py

HOW THE GUI WORKS:
1. Medieval II installation - auto-detected via the registry key the game's
   own installer writes (HKLM\SOFTWARE\SEGA\Medieval II Total War, AppPath),
   falling back to the default Steam path. You can also Browse manually.
2. Mods - every folder under <Medieval II>\mods is listed with a checkbox.
   Use "Add mod folder..." to include a mod that lives somewhere else.
3. Target folders - which subfolders inside each selected mod get scanned
   (defaults: data/models_strat, data/terrain/aerial_map). Add more with
   "Add folder...".
4. Manual folder - set this to ignore everything above and scan just that
   one folder (recursively). "Clear" goes back to the mod/folder selection.

Then use the buttons at the bottom:
- Test:     read-only scan. Reports total TGA/DDS counts, a DXT1/DXT5/etc.
            breakdown of existing DDS files, how many TGAs still need
            converting, how many already have a DDS but haven't been zeroed
            yet, how many are already optimized, and any DDS files whose TGA
            is missing entirely.
- Optimize: converts TGAs that need it, backs up every original once, then
            replaces it with a zero-byte placeholder. Files whose DDS
            already existed are backed up and replaced directly (no
            reconversion). DDS files with no TGA at all get a placeholder
            TGA created for them.
- Revert:   restores originals from backup wherever the current file is
            still a zero-byte placeholder. Files you've already restored
            (or that were never touched) are left alone.

BACKUPS:
Each mod/folder gets its own "texture_backups/originals/..." folder that
mirrors its structure. A file is backed up there ONCE, the first time it's
optimized - if you run Optimize again later (when the live file is already a
zero-byte placeholder), the existing backup is never overwritten, so the
real original is never at risk of being replaced by a placeholder copy.

TROUBLESHOOTING:
- If Optimize reports conversion failures, the log now shows texconv's own
  error output for that file.
- "UNRECOVERABLE" in a Test report means a TGA is a zero-byte placeholder,
  has no matching DDS, and there is no backup on record - there's no way for
  this tool to restore that file's original content.

OLDER SCRIPTS:
Previous console-based versions (texture_optimizer.py through _4, plus old
batch files) have been moved to the Old/ folder and are no longer used by
M2TW_Texture_Optimizer.bat.

CREDITS:
- ProJYeet - made the actual script
- medik - tool idea and original script
- Gigantus - testing and creating the installer

Contact projyeet on Discord if any issues.

About

GUI tool for Medieval 2 Total War mods: converts TGA textures to DDS and replaces originals with placeholders to save disk space

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages