-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Part Browser Changes: Added 'Add Part' button for new parts, tech req…
…uired is now autofilled. Tech required autofilled based on a mapping file of of year and category fields. Standardized the line endings on generated files. (to LF only) Updated the year field on the NK-9 (2009) to match its tech year.
- v3.19.0.0
- v3.18.0.0
- v3.17.0.0
- v3.16.0.0
- v3.15.0.0
- v3.14.0.0
- v3.13.0.0
- v3.12.0.0
- v3.11.0.0
- v3.10.0.0
- v3.9.0.0
- v3.8.0.0
- v3.7.0.0
- v3.6.1.0
- v3.6.0.0
- v3.5.0.0
- v3.4.0.0
- v3.3.0.1
- v3.3.0.0
- v3.2.1.0
- v3.2.0.1
- v3.2.0.0
- v3.1.1.2
- v3.1.1.1
- v3.1.1.0
- v3.0.0.2
- v3.0.0.1
- v3.0.0.0
- v2.13.0.0
- v2.12.0.0
- v2.11.0.1
- v2.11.0.0
- v2.10.0.0
- v2.9.1.1
- v2.9.1.0
- v2.9.0.1
- v2.9.0.0
- v2.8.1.0
- v2.8.0.0
- v2.7.1.0
- v2.7.0.0
- v2.6.4.0
- v2.6.3.0
- v2.6.2.0
- v2.6.1.1
- v2.6.0.0
- v2.5.0.0
- v2.4.2.0
- v2.4.1.0
- v2.4.0.0
- v2.3.0.0
- v2.2.0.0
- v2.1.0.0
- v2.0.2.0
- v2.0.1.0
- v2.0.0.0
- v1.13.2.2
- v1.13.2.1
- v1.13.2.0
- v1.13.1.0
- v1.13.0.0
- v1.12.19.0
- v1.12.18.0
- v1.12.17.0
- v1.12.16.0
- v1.12.15.0
- v1.12.14.0
- v1.12.13.0
- v1.12.12.0
- v1.12.11.0
- v1.12.10.0
- v1.12.9.0
- v1.12.8.0
- v1.12.7.0
- v1.12.6.0
- v1.12.5.0
- v1.12.4.0
- v1.12.3.0
- v1.12.2.0
- v1.12.1.0
- v1.12.0.0
- v1.11.11.0
- v1.11.10.0
- v1.11.9.0
- v1.11.8.0
- v1.11.7.0
- v1.11.6.0
- v1.11.5.0
- v1.11.4.0
- v1.11.3.0
- v1.11.2.0
- v1.11.1.0
- v1.11.0.0
- v1.10.7.0
- v1.10.6.1
- v1.10.6.0
- v1.10.5.0
- v1.10.4.0
- v1.10.3.0
- v1.10.2.0
- v1.10.0.1
- v1.10.0.0
- v1.9.1
- v1.9.0
- v1.8.1
- v1.8
- v1.7
- v1.6
- v1.5
- v1.4.1
- v1.3
- v1.2.1
- v1.2
- v1.1.1
- v1.1
- 3.1.0.0
- 3.0.1.0
- 1.4
1 parent
f80ac23
commit f28c610
Showing
12 changed files
with
2,382 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,963 changes: 1,963 additions & 0 deletions
1,963
Source/Tech Tree/Parts Browser/mappings/TechRequiredMappings.csv
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import csv | ||
import json | ||
import sys | ||
from os import listdir | ||
from os.path import isfile, join | ||
|
||
class TechMapping: | ||
tech_map = {} | ||
unique_years = set() | ||
|
||
def get_tech_by_category_and_year(self, category, year): | ||
print(f'Getting tech for category: {category} and {year}') | ||
if category in self.tech_map: | ||
if year in self.tech_map[category]: | ||
return self.tech_map[category][year] | ||
return "not found" | ||
|
||
def __init__(self): | ||
"""Load the parts from the json files.""" | ||
self.load_tech_mapping() | ||
print(f'Initialized the Tech mappings.') | ||
|
||
column_index = {} | ||
|
||
def load_tech_mapping(self): | ||
with open('mappings/TechRequiredMappings.csv') as csv_file: | ||
csv_reader = csv.reader(csv_file, delimiter=',') | ||
line_count = 0 | ||
for row in csv_reader: | ||
if line_count == 0: | ||
print(f'Column names are {", ".join(row)}') | ||
# store a map of column name to index for pulling into the part object | ||
for entry in enumerate(row): | ||
self.column_index[entry[1]] = entry[0] | ||
line_count += 1 | ||
else: | ||
line_count += 1 | ||
self.create_mapping(row) | ||
print(f'Loaded {line_count-1} tech mappings.') | ||
|
||
# This method creates the mappings given a row from the TechMapping CSV file. | ||
def create_mapping(self,row): | ||
category = self.get_value(row, "Category").upper() | ||
year = self.get_value(row, "Year") | ||
tech_required = self.get_value(row, "Tech") | ||
self.unique_years.add(year) | ||
|
||
if category in self.tech_map: | ||
if year in self.tech_map[category]: | ||
print("Error, duplicate tech mapping row: " + category + " - " + year) | ||
self.tech_map[category][year] = tech_required | ||
else: | ||
self.tech_map[category] = {year: tech_required} | ||
|
||
|
||
# protects against missing keys causing exceptions in original import | ||
def get_value(self,row,column_name): | ||
if column_name in self.column_index: | ||
return row[self.column_index[column_name]] | ||
else: | ||
return None | ||
|
||
def validate_current(self, parts): | ||
for part in parts: | ||
name = part['name'] | ||
tech_required = part['technology'] | ||
category = part['category'] | ||
year = part['year'] | ||
expected_tech = self.tech_map[category][year] | ||
if tech_required != expected_tech: | ||
print(f"Tech mismatch for {name} - {category} - {year} expected: {expected_tech} actual: {tech_required}") | ||
|
||
|
||
|
||
|
247 changes: 179 additions & 68 deletions
247
Source/Tech Tree/Parts Browser/templates/browser/dashboard.html
Large diffs are not rendered by default.
Oops, something went wrong.
152 changes: 76 additions & 76 deletions
152
Source/Tech Tree/Parts Browser/tree_engine_cfg_generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,76 @@ | ||
import part_data | ||
from string import Template | ||
|
||
tree_engine_header = """ | ||
//********************************************************************************************* | ||
// ENGINE_CONFIG TECH TREE PLACEMENT | ||
// This places the Engine_Config parts and creates the upgrade icons for the tree | ||
// | ||
// DO NOT EDIT THIS FILE DIRECTLY!!! | ||
// This file is generated using the RP-0 Parts Browser | ||
// | ||
//********************************************************************************************* | ||
@PART[*]:HAS[@MODULE[ModuleEngineConfigs]]:BEFORE[RealismOverhaulEnginesPost] | ||
{ | ||
@MODULE[ModuleEngineConfigs],* | ||
{ | ||
""" | ||
|
||
tree_engine_mid = """ | ||
} | ||
} | ||
""" | ||
|
||
module_engine_config_template = Template(""" | ||
@CONFIG[${name}] | ||
{ | ||
%techRequired = ${technology} | ||
%cost = ${cost}${optional_attributes} | ||
} | ||
""") | ||
|
||
part_upgrade_config_template = Template(""" | ||
PARTUPGRADE | ||
{ | ||
name = RFUpgrade_${name} | ||
partIcon = RO-H1-RS27 // FIXME Once we get dedicated model | ||
techRequired = ${technology} | ||
entryCost = 0 | ||
cost = 0 | ||
title = ${engine_config} Engine Upgrade: ${name} Config | ||
basicInfo = Engine Performance Upgrade | ||
manufacturer = Engine Upgrade | ||
deleteme = 1 | ||
description = The ${engine_config} Engine now supports the ${name} configuration for increased performance. Unlock it in the VAB/SPH through the engine configs interface.\\n\\n${description} | ||
} | ||
""") | ||
|
||
def generate_engine_tree(parts): | ||
engine_configs = "" | ||
part_upgrades = "" | ||
for part in parts: | ||
if "Engine_Config" == part["mod"] and not part['orphan']: | ||
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("output/TREE-Engines.cfg", "w") | ||
text_file.write(tree_engine_header) | ||
text_file.write(engine_configs) | ||
text_file.write(tree_engine_mid) | ||
text_file.write(part_upgrades) | ||
text_file.close() | ||
|
||
def generate_engine_config(part): | ||
optional_attributes = "" | ||
if 'description' in part and len(part['description']) > 0: | ||
optional_attributes += """ | ||
%description = """ + part['description'] | ||
if 'upgrade' in part and part['upgrade'] is True: | ||
optional_attributes += """ | ||
*@PARTUPGRADE[RFUpgrade_""" + part['name'] + """]/deleteme -= 1""" | ||
return module_engine_config_template.substitute(name=part['name'], technology=part['technology'], cost=part['cost'], optional_attributes=optional_attributes) | ||
|
||
def generate_part_upgrade_config(part): | ||
return part_upgrade_config_template.substitute(name=part['name'], technology=part['technology'], engine_config=part['engine_config'], description=part['description']) | ||
|
||
import part_data | ||
from string import Template | ||
|
||
tree_engine_header = """ | ||
//********************************************************************************************* | ||
// ENGINE_CONFIG TECH TREE PLACEMENT | ||
// This places the Engine_Config parts and creates the upgrade icons for the tree | ||
// | ||
// DO NOT EDIT THIS FILE DIRECTLY!!! | ||
// This file is generated using the RP-0 Parts Browser | ||
// | ||
//********************************************************************************************* | ||
@PART[*]:HAS[@MODULE[ModuleEngineConfigs]]:BEFORE[RealismOverhaulEnginesPost] | ||
{ | ||
@MODULE[ModuleEngineConfigs],* | ||
{ | ||
""" | ||
|
||
tree_engine_mid = """ | ||
} | ||
} | ||
""" | ||
|
||
module_engine_config_template = Template(""" | ||
@CONFIG[${name}] | ||
{ | ||
%techRequired = ${technology} | ||
%cost = ${cost}${optional_attributes} | ||
} | ||
""") | ||
|
||
part_upgrade_config_template = Template(""" | ||
PARTUPGRADE | ||
{ | ||
name = RFUpgrade_${name} | ||
partIcon = RO-H1-RS27 // FIXME Once we get dedicated model | ||
techRequired = ${technology} | ||
entryCost = 0 | ||
cost = 0 | ||
title = ${engine_config} Engine Upgrade: ${name} Config | ||
basicInfo = Engine Performance Upgrade | ||
manufacturer = Engine Upgrade | ||
deleteme = 1 | ||
description = The ${engine_config} Engine now supports the ${name} configuration for increased performance. Unlock it in the VAB/SPH through the engine configs interface.\\n\\n${description} | ||
} | ||
""") | ||
|
||
def generate_engine_tree(parts): | ||
engine_configs = "" | ||
part_upgrades = "" | ||
for part in parts: | ||
if "Engine_Config" == part["mod"] and not part['orphan']: | ||
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("output/TREE-Engines.cfg", "w", newline='\n') | ||
text_file.write(tree_engine_header) | ||
text_file.write(engine_configs) | ||
text_file.write(tree_engine_mid) | ||
text_file.write(part_upgrades) | ||
text_file.close() | ||
|
||
def generate_engine_config(part): | ||
optional_attributes = "" | ||
if 'description' in part and len(part['description']) > 0: | ||
optional_attributes += """ | ||
%description = """ + part['description'] | ||
if 'upgrade' in part and part['upgrade'] is True: | ||
optional_attributes += """ | ||
*@PARTUPGRADE[RFUpgrade_""" + part['name'] + """]/deleteme -= 1""" | ||
return module_engine_config_template.substitute(name=part['name'], technology=part['technology'], cost=part['cost'], optional_attributes=optional_attributes) | ||
|
||
def generate_part_upgrade_config(part): | ||
return part_upgrade_config_template.substitute(name=part['name'], technology=part['technology'], engine_config=part['engine_config'], description=part['description']) | ||
|
92 changes: 46 additions & 46 deletions
92
Source/Tech Tree/Parts Browser/tree_parts_cfg_generator.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
import part_data | ||
from string import Template | ||
|
||
tree_parts_header = """ | ||
//********************************************************************************************* | ||
// PARTS TECH TREE PLACEMENT | ||
// This places all parts in the tech tree | ||
// | ||
// DO NOT EDIT THIS FILE DIRECTLY!!! | ||
// This file is generated from the RP-0 Parts Browser | ||
// | ||
//********************************************************************************************* | ||
""" | ||
|
||
module_part_config_template = Template(""" | ||
@PART[${name}]:FOR[xxxRP0] | ||
{ | ||
%TechRequired = ${technology} | ||
%cost = ${cost} | ||
%entryCost = ${entry_cost} | ||
RP0conf = ${rp0_conf} | ||
@description ^=:$$: <b><color=green>From ${mod} mod</color></b>${module_tags} | ||
}""") | ||
module_tag_template = Template(""" | ||
MODULE | ||
{ name = ModuleTag${module_tag} }""") | ||
|
||
def generate_parts_tree(parts): | ||
part_configs = "" | ||
for part in 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("output/TREE-Parts.cfg", "w") | ||
text_file.write(tree_parts_header) | ||
text_file.write(part_configs) | ||
text_file.close() | ||
|
||
def generate_part_config(part): | ||
module_tags = '' | ||
for module_tag in part['module_tags']: | ||
module_tags += module_tag_template.substitute(module_tag=module_tag) | ||
if len(module_tags) > 0: | ||
module_tags = "\n" + module_tags + "\n" | ||
return module_part_config_template.substitute(name=part['name'], mod=part['mod'], technology=part['technology'], cost=part['cost'], entry_cost=part['entry_cost'], rp0_conf=str(part['rp0_conf']).lower(), module_tags=module_tags) | ||
|
||
import part_data | ||
from string import Template | ||
|
||
tree_parts_header = """ | ||
//********************************************************************************************* | ||
// PARTS TECH TREE PLACEMENT | ||
// This places all parts in the tech tree | ||
// | ||
// DO NOT EDIT THIS FILE DIRECTLY!!! | ||
// This file is generated from the RP-0 Parts Browser | ||
// | ||
//********************************************************************************************* | ||
""" | ||
|
||
module_part_config_template = Template(""" | ||
@PART[${name}]:FOR[xxxRP0] | ||
{ | ||
%TechRequired = ${technology} | ||
%cost = ${cost} | ||
%entryCost = ${entry_cost} | ||
RP0conf = ${rp0_conf} | ||
@description ^=:$$: <b><color=green>From ${mod} mod</color></b>${module_tags} | ||
}""") | ||
module_tag_template = Template(""" | ||
MODULE | ||
{ name = ModuleTag${module_tag} }""") | ||
|
||
def generate_parts_tree(parts): | ||
part_configs = "" | ||
for part in 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("output/TREE-Parts.cfg", "w", newline='\n') | ||
text_file.write(tree_parts_header) | ||
text_file.write(part_configs) | ||
text_file.close() | ||
|
||
def generate_part_config(part): | ||
module_tags = '' | ||
for module_tag in part['module_tags']: | ||
module_tags += module_tag_template.substitute(module_tag=module_tag) | ||
if len(module_tags) > 0: | ||
module_tags = "\n" + module_tags + "\n" | ||
return module_part_config_template.substitute(name=part['name'], mod=part['mod'], technology=part['technology'], cost=part['cost'], entry_cost=part['entry_cost'], rp0_conf=str(part['rp0_conf']).lower(), module_tags=module_tags) | ||