Skip to content

Commit

Permalink
Showing 6 changed files with 21 additions and 6 deletions.
5 changes: 4 additions & 1 deletion Source/Tech Tree/Parts Browser/ecm_data.py
Original file line number Diff line number Diff line change
@@ -3,6 +3,9 @@
import sys
from os import listdir
from os.path import isfile, join
import os

output_dir = os.getenv('PB_OUTPUT_DIR', "../../../GameData/RP-0/Tree/")

class ECMNodeEncoder(json.JSONEncoder):
def default(self, obj):
@@ -63,7 +66,7 @@ def get_data(self):
return json_data

def load_ecm_data(self, parts):
with open('../../../GameData/RP-0/Tree/EntryCostModifiers.cfg', newline="\n") as ecm_file:
with open(output_dir + 'EntryCostModifiers.cfg', newline="\n") as ecm_file:
line_count = 0
for line in ecm_file:
line_count += 1
4 changes: 3 additions & 1 deletion Source/Tech Tree/Parts Browser/ecm_engines_cfg_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import part_data
import os
from string import Template

tree_ecm_engines_header = """
@@ -15,6 +16,7 @@
{
"""

output_dir = os.getenv('PB_OUTPUT_DIR', "../../../GameData/RP-0/Tree/")
module_part_config_template = Template(" ${name} = ${ecm}\n")
tree_ecm_engines_footer = "}"

@@ -26,7 +28,7 @@ def generate_ecm_engines(parts):
# for purposes I don't full understand, we replace all '.' and '_' characters with '-'
# and '?' with ' '. That's what the downstream code expects for whatever reason.
ecm_configs += module_part_config_template.substitute(name=part['name'].replace('_','-').replace('.','-').replace('?',' '), ecm=part['entry_cost_mods'])
text_file = open("../../../GameData/RP-0/Tree/ECM-Engines.cfg", "w", newline='\n')
text_file = open(output_dir + "ECM-Engines.cfg", "w", newline='\n')
text_file.write(tree_ecm_engines_header)
text_file.write(ecm_configs)
text_file.write(tree_ecm_engines_footer)
4 changes: 3 additions & 1 deletion Source/Tech Tree/Parts Browser/ecm_parts_cfg_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import part_data
import os
from string import Template

tree_ecm_parts_header = """
@@ -15,6 +16,7 @@
{
"""

output_dir = os.getenv('PB_OUTPUT_DIR', "../../../GameData/RP-0/Tree/")
module_part_config_template = Template(" ${name} = ${ecm}\n")
tree_ecm_parts_footer = "}"

@@ -27,7 +29,7 @@ def generate_ecm_parts(parts):
# for purposes I don't full understand, we replace all '.' and '_' characters with '-'
# and '?' with ' ' in the part names. That's what the downstream code expects for whatever reason.
ecm_configs += module_part_config_template.substitute(name=part['name'].replace('_','-').replace('.','-').replace('?',' '), ecm=part['entry_cost_mods'])
text_file = open("../../../GameData/RP-0/Tree/ECM-Parts.cfg", "w", newline='\n')
text_file = open(output_dir + "ECM-Parts.cfg", "w", newline='\n')
text_file.write(tree_ecm_parts_header)
text_file.write(ecm_configs)
text_file.write(tree_ecm_parts_footer)
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import part_data
from string import Template

@@ -12,6 +13,7 @@
//*********************************************************************************************
"""

output_dir = os.getenv('PB_OUTPUT_DIR', "../../../GameData/RP-0/Tree/")
identical_part_template = Template("@PART[${name}]:FOR[xxxRP0] { %identicalParts = ${identical_parts} }\n")

def generate_identical_parts(parts):
@@ -33,7 +35,7 @@ def generate_identical_parts(parts):
sorted_parts.sort()
identical_part_configs += identical_part_template.substitute(name=name, identical_parts=",".join(sorted_parts))

text_file = open("../../../GameData/RP-0/Tree/identicalParts.cfg", "w", newline='\n')
text_file = open(output_dir + "identicalParts.cfg", "w", newline='\n')
text_file.write(identical_parts_header)
text_file.write(identical_part_configs)
text_file.close()
5 changes: 4 additions & 1 deletion Source/Tech Tree/Parts Browser/tree_engine_cfg_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
import part_data
from string import Template

output_dir = os.getenv('PB_OUTPUT_DIR', "../../../GameData/RP-0/Tree/")

tree_engine_header = """
//*********************************************************************************************
// ENGINE_CONFIG TECH TREE PLACEMENT
@@ -54,7 +57,7 @@ def generate_engine_tree(parts):
engine_configs += generate_engine_config(part)
if 'upgrade' in part and part['upgrade'] is True:
part_upgrades += generate_part_upgrade_config(part)
text_file = open("../../../GameData/RP-0/Tree/TREE-Engines.cfg", "w", newline='\n')
text_file = open(output_dir + "TREE-Engines.cfg", "w", newline='\n')
text_file.write(tree_engine_header)
text_file.write(engine_configs)
text_file.write(tree_engine_mid)
5 changes: 4 additions & 1 deletion Source/Tech Tree/Parts Browser/tree_parts_cfg_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import part_data
import os
from string import Template

output_dir = os.getenv('PB_OUTPUT_DIR', "../../../GameData/RP-0/Tree/")

tree_parts_header = """
//*********************************************************************************************
// PARTS TECH TREE PLACEMENT
@@ -34,7 +37,7 @@ def generate_parts_tree(parts):
if part['name'] is not None and len(part['name']) > 0:
if part['mod'] != 'Engine_Config' and not part['orphan']:
part_configs += generate_part_config(part)
text_file = open("../../../GameData/RP-0/Tree/TREE-Parts.cfg", "w", newline='\n')
text_file = open(output_dir + "TREE-Parts.cfg", "w", newline='\n')
text_file.write(tree_parts_header)
text_file.write(part_configs)
text_file.close()

0 comments on commit 9abbda5

Please sign in to comment.