Fixed: item names
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -22,22 +22,20 @@ from PySide2 import QtGui
|
||||
from PySide2 import QtCore
|
||||
|
||||
from . import weapon
|
||||
from . import names
|
||||
from . import assets
|
||||
from . import async_request
|
||||
|
||||
Style = collections.namedtuple('Style', 'bg')
|
||||
|
||||
def weapon_info(items):
|
||||
tier_re = re.compile(r"(T\d+).*")
|
||||
enchant_re = re.compile(r".*@(\d+)")
|
||||
enchant_re = re.compile(r"(.*)@(\d+)")
|
||||
def map_name(name):
|
||||
|
||||
match = enchant_re.match(name)
|
||||
if match:
|
||||
return names.map_name(match[1])
|
||||
|
||||
if 'weapon' in items:
|
||||
tier = tier_re.match(items['weapon'])
|
||||
enchant = enchant_re.match(items['weapon'])
|
||||
if tier:
|
||||
return f'{tier[1] if tier else ""}@{enchant[1] if enchant else 0}'
|
||||
|
||||
return ''
|
||||
return names.map_name(name)
|
||||
|
||||
# T8_MAIN_NATURESTAFF@3
|
||||
# T8_MAIN_NATURESTAF
|
||||
@@ -120,7 +118,7 @@ class DmgList(QListView):
|
||||
|
||||
self.setBackground(brush)
|
||||
icon = player_icon(self.player.items['weapon'])
|
||||
self.setToolTip('\n'.join([f'{k}: {v}' for (k,v) in self.player.items.items() if v]))
|
||||
self.setToolTip('\n'.join([f'{k}: {map_name(v)}' for (k,v) in self.player.items.items() if v]))
|
||||
if icon:
|
||||
self.setIcon(icon)
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
import json
|
||||
|
||||
from . import assets
|
||||
|
||||
_mappings = None
|
||||
|
||||
def map_name(name):
|
||||
global _mappings
|
||||
|
||||
if not _mappings:
|
||||
with open(assets.path('localization.json')) as m:
|
||||
_mappings = json.loads(m.read())
|
||||
|
||||
return _mappings[name] if name in _mappings else name
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
file = sys.argv[1]
|
||||
|
||||
item_re = re.compile("@ITEMS_(.*)")
|
||||
|
||||
def add_item(db, name, desc):
|
||||
match = item_re.match(name)
|
||||
if match:
|
||||
db[match[1]] = desc
|
||||
|
||||
nd = {}
|
||||
tree = ET.parse(file)
|
||||
root = tree.getroot()
|
||||
|
||||
for child in root[0]:
|
||||
tuid = child.attrib['tuid']
|
||||
for loc in child:
|
||||
if loc.attrib['{http://www.w3.org/XML/1998/namespace}lang'] == 'EN-US':
|
||||
for desc in loc:
|
||||
add_item(nd, tuid, desc.text)
|
||||
|
||||
print(json.dumps(nd))
|
||||
Reference in New Issue
Block a user