changed main
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
/venv/
|
||||||
|
/.idea/
|
||||||
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@@ -2,8 +2,8 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
|
<module fileurl="file://$USER_HOME$/AppData/Roaming/Avorion/mods/WPE2/.idea/WPE2.iml" filepath="$USER_HOME$/AppData/Roaming/Avorion/mods/WPE2/.idea/WPE2.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/translation-generator.iml" filepath="$PROJECT_DIR$/.idea/translation-generator.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/translation-generator.iml" filepath="$PROJECT_DIR$/.idea/translation-generator.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/../weapon-project-extended/.idea/weapon-project-extended.iml" filepath="$PROJECT_DIR$/../weapon-project-extended/.idea/weapon-project-extended.iml" />
|
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
2
.idea/translation-generator.iml
generated
2
.idea/translation-generator.iml
generated
@@ -6,6 +6,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.10 (translation-generator)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.10 (translation-generator)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="weapon-project-extended" />
|
<orderEntry type="module" module-name="WPE2" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
2
.idea/vcs.xml
generated
2
.idea/vcs.xml
generated
@@ -2,6 +2,6 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/../weapon-project-extended" vcs="Git" />
|
<mapping directory="$USER_HOME$/AppData/Roaming/Avorion/mods/WPE2" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
43
main.py
43
main.py
@@ -20,6 +20,15 @@ def scan_files(path) -> list:
|
|||||||
return list_files
|
return list_files
|
||||||
|
|
||||||
|
|
||||||
|
def open_translate(arg, lang='ru'):
|
||||||
|
translation_file = arg + fr'/data/localization/{lang}.po'
|
||||||
|
with open(translation_file, 'r') as f:
|
||||||
|
translation_text = f.read()
|
||||||
|
translation_json = translation_text.split('\n\n')
|
||||||
|
print(translation_json)
|
||||||
|
return translation_json
|
||||||
|
|
||||||
|
|
||||||
def parsing_file(f):
|
def parsing_file(f):
|
||||||
with open(f) as _f:
|
with open(f) as _f:
|
||||||
_cached = _f.read()
|
_cached = _f.read()
|
||||||
@@ -39,21 +48,40 @@ def pars_file(name: str) -> list:
|
|||||||
:param name: name of file
|
:param name: name of file
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
list_to_translate: list = []
|
_list: list = []
|
||||||
for _str in parsing_file(name):
|
for _str in parsing_file(name):
|
||||||
string_to_translate = re.findall('"(.*[^/])(?: /\* (.*)\*/)?"%_[t|T]', _str)
|
_str_parsed = re.findall('"([^/\"]*)(?: /\*(.*)\*/)?"%_[t,T]', _str)
|
||||||
list_to_translate.append(string_to_translate)
|
_list.append(_str_parsed)
|
||||||
return list_to_translate
|
return _list
|
||||||
|
|
||||||
|
|
||||||
def all_to_translate(_dir):
|
def all_to_translate(_dir):
|
||||||
_files = scan_files(_dir)
|
_files = scan_files(_dir)
|
||||||
to_file: str = ''
|
_str = ''
|
||||||
for _file in _files:
|
for _file in _files:
|
||||||
_strings = pars_file(_file)
|
_strings = pars_file(_file)
|
||||||
if len(_strings) > 0: to_file = f'{_file}\n {_strings} \n {len(_strings)}\n\n\n'
|
_list = []
|
||||||
|
if len(_strings) > 0:
|
||||||
|
for _string in _strings:
|
||||||
|
_list.append(_string)
|
||||||
|
_title = f'# ========== {_file.split("WPE2")[1]} ==========\n'
|
||||||
|
_str = _str + _title
|
||||||
|
print(f'Generate translation file for {_file.split("WPE2")[1]}')
|
||||||
|
# print(_list)
|
||||||
|
for _name in _list:
|
||||||
|
_msgctxt = ''
|
||||||
|
if len(_name[0][1]) > 1:
|
||||||
|
_msgctxt = f'msgctxt "{_name[0][1]}"\n'
|
||||||
|
|
||||||
|
_msgid = f'msgid "{_name[0][0]}"\n'
|
||||||
|
|
||||||
|
_entity = f'#: {_file.split("WPE2")[1]}:\n{_msgctxt}{_msgid}msgstr ""\n\n'
|
||||||
|
_str = _str + _entity
|
||||||
with open('test.txt', 'w') as f:
|
with open('test.txt', 'w') as f:
|
||||||
f.write(to_file)
|
f.write(_str)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@@ -63,3 +91,4 @@ if __name__ == '__main__':
|
|||||||
arg = r'C:\Users\riksl\AppData\Roaming\Avorion\mods\WPE2'
|
arg = r'C:\Users\riksl\AppData\Roaming\Avorion\mods\WPE2'
|
||||||
|
|
||||||
all_to_translate(arg)
|
all_to_translate(arg)
|
||||||
|
# open_translate(arg)
|
||||||
|
|||||||
10
test.yml
10
test.yml
@@ -1,10 +0,0 @@
|
|||||||
image: python:3.10
|
|
||||||
|
|
||||||
.pre:
|
|
||||||
script:
|
|
||||||
- 'pip3 install requests'
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
stage: prepare
|
|
||||||
script:
|
|
||||||
- 'python3 main.py'
|
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
|
|
||||||
function WeaponGenerator.generateAutoCannon(rand, dps, tech, material, rarity)
|
|
||||||
local weapon = Weapon()
|
|
||||||
weapon:setProjectile()
|
|
||||||
|
|
||||||
dps = dps * 0.75
|
|
||||||
local fireDelay = rand:getFloat(1.5, 2.5)*0.5
|
|
||||||
local reach = rand:getFloat(1100, 1500)*0.7
|
|
||||||
local damage = dps * fireDelay
|
|
||||||
local speed = rand:getFloat(300, 400)*2
|
|
||||||
local existingTime = (reach / speed)*1.2
|
|
||||||
|
|
||||||
weapon.fireDelay = fireDelay
|
|
||||||
weapon.reach = reach
|
|
||||||
weapon.appearanceSeed = rand:getInt()
|
|
||||||
weapon.seeker = rand:test(1 / 2)
|
|
||||||
weapon.appearance = WeaponAppearance.Cannon
|
|
||||||
weapon.name = "Auto Cannon /* Weapon Name*/"%_t
|
|
||||||
weapon.prefix = "Auto Cannon /* Weapon Prefix*/"%_t
|
|
||||||
weapon.icon = "data/textures/icons/autocannon.png"
|
|
||||||
weapon.sound = "cannon"
|
|
||||||
weapon.accuracy = 0.99 - rand:getFloat(0, 0.03)
|
|
||||||
|
|
||||||
weapon.damage = damage
|
|
||||||
weapon.damageType = DamageType.Physical
|
|
||||||
weapon.impactParticles = ImpactParticles.Explosion
|
|
||||||
weapon.shieldDamageMultiplicator=1.1 + rarity.value * 0.1
|
|
||||||
weapon.impactSound = 1
|
|
||||||
weapon.impactExplosion = true
|
|
||||||
|
|
||||||
weapon.psize = rand:getFloat(0.2, 0.5)
|
|
||||||
weapon.pmaximumTime = existingTime
|
|
||||||
weapon.pvelocity = speed
|
|
||||||
weapon.pcolor = ColorHSV(rand:getFloat(10, 60), 0.7, 1)
|
|
||||||
|
|
||||||
WeaponGenerator.adaptWeapon(rand, weapon, tech, material, rarity)
|
|
||||||
|
|
||||||
-- these have to be assigned after the weapon was adjusted since the damage might be changed
|
|
||||||
weapon.recoil = weapon.damage * 20 * 0.75
|
|
||||||
weapon.explosionRadius = math.sqrt(weapon.damage * 6)
|
|
||||||
|
|
||||||
return weapon
|
|
||||||
end
|
|
||||||
|
|
||||||
generatorFunction[WeaponType.AutoCannon] = WeaponGenerator.generateAutoCannon
|
|
||||||
|
|
||||||
|
|
||||||
function WeaponGenerator.generateHeavyCannon(rand, dps, tech, material, rarity)
|
|
||||||
local weapon = Weapon()
|
|
||||||
weapon:setProjectile()
|
|
||||||
|
|
||||||
dps = dps * 1.85
|
|
||||||
local fireDelay = rand:getFloat(1.5, 2.0)*1.7
|
|
||||||
local reach = rand:getFloat(1100, 1500)*1.2
|
|
||||||
local damage = dps * fireDelay
|
|
||||||
local speed = rand:getFloat(600, 1000)*1.4
|
|
||||||
local existingTime = (reach / speed)*1.1
|
|
||||||
|
|
||||||
weapon.fireDelay = fireDelay
|
|
||||||
weapon.reach = reach
|
|
||||||
weapon.appearanceSeed = rand:getInt()
|
|
||||||
weapon.appearance = WeaponAppearance.Bolter
|
|
||||||
weapon.name = "Heavy Cannon /* Weapon Name*/"%_t
|
|
||||||
weapon.icon = "data/textures/icons/heavycannon.png"
|
|
||||||
weapon.sound = "cannon"
|
|
||||||
weapon.accuracy = 0.95 - rand:getFloat(0, 0.02)
|
|
||||||
|
|
||||||
weapon.damage = damage
|
|
||||||
weapon.damageType = DamageType.Physical
|
|
||||||
weapon.impactParticles = ImpactParticles.Explosion
|
|
||||||
weapon.impactSound = 1
|
|
||||||
weapon.impactExplosion = true
|
|
||||||
weapon.otherForce = dps*math.max(1, rarity.value)*89*5
|
|
||||||
|
|
||||||
|
|
||||||
weapon.psize = rand:getFloat(0.2, 0.5)
|
|
||||||
weapon.pmaximumTime = existingTime
|
|
||||||
weapon.pvelocity = speed
|
|
||||||
weapon.pcolor = ColorHSV(rand:getFloat(10, 60), 0.7, 1)
|
|
||||||
|
|
||||||
local Pen = rand:getInt(0, rarity.value)
|
|
||||||
if Pen > 0 then
|
|
||||||
weapon.blockPenetration = Pen
|
|
||||||
weapon.prefix = "Cumulative Heavy Cannon /* Weapon Prefix*/"%_t
|
|
||||||
else
|
|
||||||
weapon.prefix = "Heavy Cannon /* Weapon Prefix*/"%_t
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
WeaponGenerator.adaptWeapon(rand, weapon, tech, material, rarity)
|
|
||||||
|
|
||||||
-- these have to be assigned after the weapon was adjusted since the damage might be changed
|
|
||||||
weapon.recoil = weapon.damage * 50
|
|
||||||
weapon.explosionRadius = math.sqrt(weapon.damage * 7)
|
|
||||||
|
|
||||||
return weapon
|
|
||||||
end
|
|
||||||
|
|
||||||
generatorFunction[WeaponType.HeavyCannon] = WeaponGenerator.generateHeavyCannon
|
|
||||||
|
|
||||||
|
|
||||||
function WeaponGenerator.generateDiffuser(rand, dps, tech, material, rarity)
|
|
||||||
local weapon = Weapon()
|
|
||||||
weapon:setBeam()
|
|
||||||
|
|
||||||
local fireDelay = rand:getFloat(1, 2.5)*0.5
|
|
||||||
local reach = rand:getFloat(950, 1400)
|
|
||||||
local damage = dps * fireDelay
|
|
||||||
|
|
||||||
weapon.fireDelay = fireDelay
|
|
||||||
weapon.appearanceSeed = rand:getInt()
|
|
||||||
weapon.reach = reach
|
|
||||||
weapon.continuousBeam = false
|
|
||||||
weapon.appearance = WeaponAppearance.Tesla
|
|
||||||
weapon.name = "Diffuser /* Weapon Name*/"%_t
|
|
||||||
weapon.prefix = "Diffuser /* Weapon Prefix*/"%_t
|
|
||||||
weapon.icon = "data/textures/icons/diffuser.png"
|
|
||||||
weapon.sound = "railgun"
|
|
||||||
weapon.accuracy = 0.99 - rand:getFloat(0, 0.02)
|
|
||||||
|
|
||||||
weapon.damage = damage
|
|
||||||
weapon.damageType = DamageType.Energy
|
|
||||||
weapon.impactParticles = ImpactParticles.Energy
|
|
||||||
weapon.shieldDamageMultiplicator = 20 + rand:getFloat(0, 4) + rarity.value * 3
|
|
||||||
weapon.stoneDamageMultiplicator = 0
|
|
||||||
weapon.hullDamageMultiplicator = 0
|
|
||||||
weapon.impactSound = 1
|
|
||||||
|
|
||||||
weapon.blength = weapon.reach
|
|
||||||
weapon.bshape = BeamShape.Lightning
|
|
||||||
weapon.bwidth = 0.5
|
|
||||||
weapon.bauraWidth = 3
|
|
||||||
weapon.banimationSpeed = 0
|
|
||||||
weapon.banimationAcceleration = 0
|
|
||||||
weapon.bshapeSize = 13
|
|
||||||
|
|
||||||
-- shades of blue
|
|
||||||
weapon.bouterColor = ColorHSV(rand:getFloat(180, 260), rand:getFloat(0.5, 1), rand:getFloat(0.1, 0.5))
|
|
||||||
weapon.binnerColor = ColorHSV(rand:getFloat(180, 260), rand:getFloat(0.1, 0.5), 1)
|
|
||||||
|
|
||||||
WeaponGenerator.adaptWeapon(rand, weapon, tech, material, rarity)
|
|
||||||
|
|
||||||
weapon.recoil = weapon.damage * 5
|
|
||||||
|
|
||||||
return weapon
|
|
||||||
end
|
|
||||||
|
|
||||||
generatorFunction[WeaponType.Diffuser] = WeaponGenerator.generateDiffuser
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function WeaponGenerator.generateHarpoon(rand, dps, tech, material, rarity)
|
|
||||||
local weapon = Weapon()
|
|
||||||
weapon:setBeam()
|
|
||||||
|
|
||||||
local fireDelay = rand:getFloat(0.2, 0.5)
|
|
||||||
local reach = rand:getFloat(500, 900)
|
|
||||||
local damage = dps * fireDelay
|
|
||||||
|
|
||||||
weapon.fireDelay = fireDelay
|
|
||||||
weapon.appearanceSeed = rand:getInt()
|
|
||||||
weapon.reach = reach
|
|
||||||
weapon.continuousBeam = true
|
|
||||||
weapon.appearance = WeaponAppearance.Cannon
|
|
||||||
weapon.name = "Harpoon /* Weapon Name*/"%_t
|
|
||||||
weapon.prefix = "Harpoon /* Weapon Prefix*/"%_t
|
|
||||||
weapon.icon = "data/textures/icons/harpoon.png"
|
|
||||||
weapon.sound = "cannon"
|
|
||||||
weapon.accuracy = 0.99 - rand:getFloat(0, 0.02)
|
|
||||||
|
|
||||||
weapon.blockPenetration = rand:getInt(0, rarity.value) + 2
|
|
||||||
|
|
||||||
|
|
||||||
weapon.otherForce = -500 * dps * rarity.value
|
|
||||||
|
|
||||||
weapon.damage = damage
|
|
||||||
weapon.damageType = DamageType.Physical
|
|
||||||
weapon.impactParticles = ImpactParticles.Physical
|
|
||||||
weapon.shieldDamageMultiplicator = 0.75
|
|
||||||
weapon.stoneDamageMultiplicator = 1.2
|
|
||||||
weapon.hullDamageMultiplicator = 1
|
|
||||||
weapon.impactSound = 1
|
|
||||||
|
|
||||||
weapon.blength = weapon.reach
|
|
||||||
weapon.bshape = BeamShape.Swirly
|
|
||||||
weapon.bwidth = 0.5
|
|
||||||
weapon.bauraWidth = 3
|
|
||||||
weapon.banimationSpeed = 0
|
|
||||||
weapon.banimationAcceleration = 0
|
|
||||||
weapon.bshapeSize = 13
|
|
||||||
|
|
||||||
-- shades of blue
|
|
||||||
weapon.bouterColor = ColorHSV(0, 0, rand:getFloat(0.35, 0.65))
|
|
||||||
weapon.binnerColor = ColorHSV(1, 1, rand:getFloat(0.35, 0.65))
|
|
||||||
|
|
||||||
WeaponGenerator.adaptWeapon(rand, weapon, tech, material, rarity)
|
|
||||||
|
|
||||||
|
|
||||||
return weapon
|
|
||||||
end
|
|
||||||
|
|
||||||
generatorFunction[WeaponType.Harpoon] = WeaponGenerator.generateHarpoon
|
|
||||||
Reference in New Issue
Block a user