Maradonna90 / NewGAN-Manager

A tool to generate and manage xml configs for the Newgen Facepack.
GNU General Public License v3.0
171 stars 34 forks source link

[Bug / Contribution] Mapping folders ~fix #178

Closed guiseiz closed 8 months ago

guiseiz commented 1 year ago

Issue A lot of players faces don't show up when you press 'preserve'

Screenshot 2023-06-26 at 10 58 36 AM

I noticed that this was because the mapping of the asset to folder was wrong

<record from="Asian/Caucasian551" to="graphics/pictures/person/2002179270/portrait"/>
<record from="Seasian/Asian2324" to="graphics/pictures/person/2002174975/portrait"/>

šŸ‘† here the it's trying to find Asian2324.png in a Seasian folder and it wont find it -so the image returns blank

--

i have a quick script that

--

i've been using this python script locally with the terminal CleanShot 2023-06-26 at 15 41 15

but i don't know how to push it live - i keep running into issues with netlify

https://magical-torte-c64a84.netlify.app/ šŸ‘† the script doesnt seem to run when i deploy it :( maybe someone knows how to fix it

here's the source code in case someone knows how to work with servers :P newganfix.zip


šŸ‘‡ here's the script file to run locally

import re
import random

# Define maximum assets for each folder
folder_max_assets = {
    'EECA': 15999,
    'African': 11999,
    'Asian': 3999,
    'Caucasian': 15999,
    'Central European': 17999,
    'Italmed': 12999,
    'MENA': 5999,
    'MESA': 1991,
    'SAMed': 3999,
    'Scandinavian': 7999,
    'Seasian': 3999,
    'South American': 11999,
    'SpanMed': 7999,
    'YugoGreek': 9999
}

# Open config.xml file -- change this to be whatever file you're wanting changed -- and check if the the ethnicity thats before the '/' matches what's after. 

def correct_asset_names():
    with open('config.xml', 'r') as file:
        lines = file.readlines()

    with open('corrected_config.xml', 'w') as file:
        for line in lines:
            match = re.search(r'from="([^"]+)/([^"]+)"', line)
            if match:
                folder = match.group(1)
                asset = match.group(2)

                # Correct assets in other folders
                if folder in folder_max_assets:
                    asset_match = re.match(r'([a-zA-Z\s]+)(\d+)', asset) # This line has changed
                    if asset_match:
                        asset_name = asset_match.group(1)
                        asset_number = int(asset_match.group(2))
                        if asset_name != folder or asset_number > folder_max_assets[folder]:
                            asset_name = folder
                            asset_number = random.randint(1, folder_max_assets[folder])
                            line = line.replace(match.group(0), f'from="{folder}/{asset_name}{asset_number}"') # This line has changed
            file.write(line)

if __name__ == "__main__":
    correct_asset_names()

instructions

034georgie commented 9 months ago

I'm getting this bug a lot more often now - not familiar with python beyond just basic editing (copy pasting) some code in Atom, and other fix we can do by modifying possibly the mapper.py file?

034georgie commented 9 months ago

Quick note - noticed that this mapping issue only happens when using the preserve option.

nevemlaci commented 9 months ago

@034georgie You might want to upload that code as a repo to your github profile and share it so people can easily access it in the future and even help contribute to it if they feel like it:)

034georgie commented 9 months ago

@nevemlaci - sorry, as mentioned, I'm not too familiar with the code. Just rudimentary copy-pasting of existing pull requests into my own mapper.py to fix some issues. I just wanted to flag that whatever is causing this bug might have something to do with how the preserve function is coded, but I don't know how to fix it.

nevemlaci commented 8 months ago

@034georgie You could still upload it to github so others can help with bugs that could be present via PRs. :)

Maradonna90 commented 8 months ago

might be similar to #84

guiseiz commented 7 months ago

@034georgie You might want to upload that code as a repo to your github profile and share it so people can easily access it in the future and even help contribute to it if they feel like it:)

i think your comment was meant to be adressed to me. fixed now it seems :)