feat: Troops.json support added
This commit is contained in:
parent
d12d850b4e
commit
3e3c44697d
1 changed files with 34 additions and 1 deletions
|
|
@ -44,7 +44,7 @@ CODE122 = False
|
|||
CODE101 = False
|
||||
CODE355655 = False
|
||||
CODE357 = False
|
||||
CODE356 = True
|
||||
CODE356 = False
|
||||
|
||||
# Regex
|
||||
subVarRegex = r'(\\+[a-zA-Z]+)\[([a-zA-Z0-9一-龠ぁ-ゔァ-ヴー\s]+)\]'
|
||||
|
|
@ -121,6 +121,10 @@ def openFiles(filename):
|
|||
elif 'Skills' in filename:
|
||||
translatedData = parseSS(data, filename)
|
||||
|
||||
# Troops File
|
||||
elif 'Troops' in filename:
|
||||
translatedData = parseTroops(data, filename)
|
||||
|
||||
# States File
|
||||
elif 'States' in filename:
|
||||
translatedData = parseSS(data, filename)
|
||||
|
|
@ -200,6 +204,31 @@ def parseCommonEvents(data, filename):
|
|||
except Exception as e:
|
||||
return [data, totalTokens, e]
|
||||
return [data, totalTokens, None]
|
||||
|
||||
def parseTroops(data, filename):
|
||||
totalTokens = 0
|
||||
totalLines = 0
|
||||
global LOCK
|
||||
|
||||
# Get total for progress bar
|
||||
for troop in data:
|
||||
if troop is not None:
|
||||
for page in troop['pages']:
|
||||
totalLines += len(page['list']) + 1 # The +1 is because each page has a name.
|
||||
|
||||
with tqdm(bar_format=BAR_FORMAT, position=POSITION, total=totalLines, leave=LEAVE) as pbar:
|
||||
pbar.desc=filename
|
||||
pbar.total=totalLines
|
||||
for troop in data:
|
||||
if troop is not None:
|
||||
with ThreadPoolExecutor(max_workers=THREADS) as executor:
|
||||
futures = [executor.submit(searchCodes, page, pbar) for page in troop['pages'] if page is not None]
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
totalTokens += future.result()
|
||||
except Exception as e:
|
||||
return [data, totalTokens, e]
|
||||
return [data, totalTokens, None]
|
||||
|
||||
def parseNames(data, filename, context):
|
||||
totalTokens = 0
|
||||
|
|
@ -573,6 +602,10 @@ def searchCodes(page, pbar):
|
|||
if not re.search(r'[一-龠]+|[ぁ-ゔ]+|[ァ-ヴー]+', jaString):
|
||||
continue
|
||||
|
||||
# Want to translate this script
|
||||
if 'DTEXT' not in jaString:
|
||||
continue
|
||||
|
||||
# Need to remove outside code and put it back later
|
||||
startString = re.search(r'^[^ぁ-んァ-ン一-龯\<\>【】]+', jaString)
|
||||
jaString = re.sub(r'^[^ぁ-んァ-ン一-龯\<\>【】]+', '', jaString)
|
||||
|
|
|
|||
Loading…
Reference in a new issue