-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Models/Textures/Mapped Images Validation Checks #2577
base: main
Are you sure you want to change the base?
Add Models/Textures/Mapped Images Validation Checks #2577
Conversation
…base name while ignoring file extensions (.tga, .dds).
Patch104pZH/Design/Scripts/textures/generated_original/duplicate_mapped_textures.txt
Outdated
Show resolved
Hide resolved
Optimized the script and added a check for invalid textures in W3D files. |
Patch104pZH/Design/Scripts/textures/get_mapped_textures_info.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/get_mapped_textures_info.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/get_mapped_textures_info.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/get_mapped_textures_info.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/missing_tga_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/get_mapped_textures_info.py
Outdated
Show resolved
Hide resolved
optimized the code and updated various functions/variables names for better clarity. |
Added validation for textures/images
|
I think I've now covered all the necessary validation for images and textures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the txt file names need an improvement pass to clarify what they refer to.
Patch104pZH/Design/Scripts/textures/generated_edited/invalid_images_in_ini_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/invalid_textures_in_ini_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_images_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_images_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_images_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_images_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_textures_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/invalid_wnd_images.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/missing_textures_files.txt
Outdated
Show resolved
Hide resolved
Improvements and fixes, added checking for unused textures/images in the game.dat file, and added the SCPatchUserInterface512.INI file that was missing from the repo. the reports were updated and also include Generals 1.08 files. Also, saw your YouTube review of my code. Yes, I know regex isn't everyone's cup of tea, but without it I'd be drowning in manual parsing. It's a necessary tool for this job, Oh, and a little secret: I'm also using AI to craft those regex monsters, so really, we are on the same boat! 😉 |
...104pZH/GameFilesOriginalZH/Data/INI/MappedImages/TextureSize_512/SCPatchUserInterface512.INI
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/find_mappd_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/find_mappd_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_mapped_images.txt
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/unused_textures.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/invalid_textures_in_ini_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_mapped_images.txt
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_mapped_images.txt
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_textures.txt
Show resolved
Hide resolved
Update: |
Patch104pZH/Design/Scripts/textures/find_mappad_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_edited/unused_textures.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/invalid_textures_in_ini_files.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/find_mappad_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/find_mappad_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
textures, models = get_textures_models_from_csv(folder_paths['csv']) | ||
textures_files = textures.union( | ||
get_files_from_folder(folder_paths['textures'])).union( | ||
get_files_from_folder(folder_paths['ani'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we can classify ani files as cursors instead of textures to show them in separate lists.
Update: fix script name and maps references and remove |
Patch104pZH/Design/Scripts/textures/find_mapped_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/find_mapped_images_and_textures_errors.py
Outdated
Show resolved
Hide resolved
'wnd': f'{edited_folder_paths}/Window', | ||
'w3d': f'{edited_folder_paths}/Art/W3D', | ||
'ani': f'{edited_folder_paths}/Data/Cursors', | ||
'textures': f'{edited_folder_paths}/Art/Textures', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that we also have a GameFilesOptional folder that adds optional assets on top of the core assets (GameFilesEdited). Perhaps it would be a consideration to also add that, but that would add another layer of complexity.
https://github.com/TheSuperHackers/GeneralsGamePatch/tree/main/Patch104pZH/GameFilesOptional
Additionally, we also have assets that are generated via Mod Builder and defined in the json files:
https://github.com/TheSuperHackers/GeneralsGamePatch/blob/main/Patch104pZH/ModBundleCoreItems.json
https://github.com/TheSuperHackers/GeneralsGamePatch/blob/main/Patch104pZH/ModBundleOptionalItems.json
For example:
{
"source": "Art/Textures/GenerateMip/cbapt01_n.psd",
"target": "Art/Textures/cbapt01_sn.dds"
},
{
"source": "Art/Textures/GenerateMip/cbapt01_ng.psd",
"target": "Art/Textures/cbapt01_sng.dds"
},
{
"source": "Art/Textures/GenerateMip/cbapt01_dn.psd",
"target": "Art/Textures/cbapt01_dsn.dds"
},
{
"source": "Art/Textures/GenerateMip/cbapt01_dng.psd",
"target": "Art/Textures/cbapt01_dsng.dds"
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the additional lists will only contribute to unused lists, while our main concern is fixing broken references that can disrupt the game engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes ideally Optional files do not solely fix Core issues, but they could if we made mistakes (and I am sure we did).
|
Patch104pZH/Design/Scripts/textures/Graphical_Assets_Location.md
Outdated
Show resolved
Hide resolved
EXRedSmokePuff | ||
EXSateliteHack1 | ||
EXthunderRadar | ||
EXthunderWave |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this not written as "EXthunderWave.tga" as per the original value in the INI file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the comparison was always without suffixes, so I did not capture them, I will include the suffixes for the reports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a "Texture.psd" also match for a "Texture.tga" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, assuming that Mod Builder
converts it to dds/tga
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically yes, but Mod Builder can also build a "Texture.psd" as "AnotherTexture.dds", and I assume the script will not catch that.
Perhaps it would be worthwhile to check against files in Patch104pZH\.Build\RawBundleItems
(the files generated before archiving into big files), but this would require building (all languages) before running the script and likely make it more complicated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the ModBundleOptionalItems.json
file be sufficient for processing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently ModBundleCoreItems.json
and ModBundleOptionalItems.json
.
You could try search through all files listed in ModJsonFiles.json
and find texture and model targets that are not *.ext
. Perhaps that would suffice.
Patch104pZH/Design/Scripts/textures/generated_edited/languages/French.txt
Outdated
Show resolved
Hide resolved
|
||
CItoxic | ||
CItoxic_B | ||
CItoxic_C |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 are textures, not models.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but they are in the W3D folder instead of the Textures folder, so the function defines it as a model, if it is okay for texture files to be in the models folder, I will update the function to only look for w3d files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a good question why textures are located in the w3d folder. I do not know what is up with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[The current update only includes *.w3d
files. So if there are texture files in the folder, they are not scanned at all.]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are definitely texture files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, do I need to scan them? Does the game engine scan them? Because right now my code only scans by folder paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know that. We would need to test if the game can load textures from that folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the file Data\English\Art\Textures\Defeated.tga
and replaced it with the French version, it worked.
I moved it to the W3D folder, the English version appeared, meaning it didn't work.
I deleted it, now there is no Data\English\Art\Textures\Defeated.tga
file at all, it still appeared in the English version, meaning the file is also in game.dat
, but a hex scan yielded no results. I was confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The texture is not in game.dat
Defeated.tga is still inside original big file that is underlying Patch files.
Reads as if texture is not loaded from W3D folder, which means these 3 files are misplaced in the German language.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deleted all the big files after extracting.
Patch104pZH/Design/Scripts/textures/generated_original/languages/Chinese.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/languages/Chinese.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/languages/Chinese.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/generated_original/unused_textures.txt
Outdated
Show resolved
Hide resolved
Patch104pZH/Design/Scripts/textures/find_graphical_assets_errors.py
Outdated
Show resolved
Hide resolved
Added file extensions and improved naming. Note that since we only catch with an extension, it was found that the |
Patch104pZH/Design/Scripts/textures/generated_edited/languages/Brazilian.txt
Outdated
Show resolved
Hide resolved
Merge this or is anything left to do? |
Improve TODO:
|
This PR introduces comprehensive validation checks for graphical assets, including mapped images, textures, models, and language-specific assets. It also identifies unused assets and ensures that references are correctly accounted for, reporting any missing, duplicate, or invalid items. The changes include:
Mapped Image Parsing:
.ini
mapped files for texture and image references, ensuring that all referenced images are validated and duplicates are reported.Missing Texture/Model Files (General):
.ini
files against a provided CSV file and reports any missing texture or model files.Unused Graphical Assets (General):
.ini
,.wnd
, or.w3d
file. These unused assets are reported, indicating potential dead assets.Invalid Images in WND Files:
.wnd
files for references to images. Missing images that are referenced in WND files but not present in the mapped images are reported.Invalid Textures in W3D Files:
Language-Specific Asset Analysis:
Interactive Main Menu:
Output Files:
mapped_images_list.txt
: A list of all image mappings.duplicate_mapped_images.txt
: A list of duplicate image mappings.invalid_textures_in_ini_files.txt
: A list of invalid texture files found in INI filesinvalid_mapped_images_in_ini_files.txt
: A list of invalid mapped images found in INI filesinvalid_models_in_ini_files.txt
: A list of invalid model files found in INI filesinvalid_textures_in_mapped_images_folder.txt
: A list of invalid textures found in the mapped images folderinvalid_mapped_images_in_wnd_files.txt
: A list of invalid mapped images found in WND files.unused_textures.txt
: A list of unused texture files.unused_models.txt
: A list of unused model files.unused_mapped_images.txt
: A list of unused image files.invalid_textures_in_w3d_files.txt
: A list of invalid textures found in W3D files.Configurable Scanning Options:
Documentation:
Graphical_Assets_Location.md
. If there are any additional locations or patterns not currently documented in that file, please let me know.