-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Directional Vehicle Parts for mounted tools, seats, windshields, rams, and doors #40437
Merged
I-am-Erk
merged 20 commits into
CleverRaven:master
from
mrkybe:directional_vehicle_parts
Jul 5, 2020
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ccfcf29
Merge remote-tracking branch 'upstream/master'
mrkybe 4413fe1
Merge remote-tracking branch 'upstream/master'
mrkybe 439e304
Merge remote-tracking branch 'upstream/master'
mrkybe c6a12e3
Merge branch 'master' into upstream/master
mrkybe 6704a4f
Merge remote-tracking branch 'upstream/master'
mrkybe d2ca094
Script to convert vehicle parts into directional versions
mrkybe 8d3170c
New rams, break out doors into own file
mrkybe c62eaca
Breakout doors into own file, update script
mrkybe 85614a0
Fix script logic
mrkybe ef65acd
Fix the logic again, add door variants
mrkybe 37110a4
Breakout windshields
mrkybe d0dad09
Windshield variants
mrkybe 51e4892
Ram variants
mrkybe 3fe3c50
Breakout vehicle mounted tools
mrkybe 12f65b2
Directional vehicle tools
mrkybe df53fd4
Breakout seats
mrkybe 3d5dc48
Make seats directional
mrkybe 1ea74fc
Only apply to vehicle parts
mrkybe cbe1388
Keep default symbols for default parts
mrkybe e1eb106
Merge branch 'master' into directional_vehicle_parts
I-am-Erk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import argparse | ||
import json | ||
import os | ||
import subprocess | ||
|
||
default_path = "data/json/vehicleparts/rams.json" | ||
default_output = "data/json/vehicleparts/rams2.json" | ||
ids_created_output = "data/json/vehicleparts/new_ids.txt" | ||
|
||
ids_to_create_directional_parts_for = [] | ||
list_of_created_ids = [] | ||
|
||
variants = { | ||
"nw" : "y", | ||
"vertical" : "j", | ||
"ne" : "u", | ||
"sw" : "b", | ||
"vertical_2" : "H", | ||
"se" : "n", | ||
"cover" : "^", | ||
"horizontal" : "h", | ||
"horizontal_2" : "=", | ||
"cross" : "c", | ||
"box" : "#" | ||
} | ||
|
||
def gen_new(path): | ||
with open(path, "r") as json_file: | ||
json_data = json.load(json_file) | ||
for jo in json_data: | ||
if "id" in jo: | ||
jo["abstract"] = jo["id"] | ||
jo.pop("id") | ||
ids_to_create_directional_parts_for.append(jo["abstract"]) | ||
|
||
for key, value in variants.items(): | ||
for ram in ids_to_create_directional_parts_for: | ||
new_ram_id = ram + "_" + key | ||
new_ram_data = { | ||
"id": new_ram_id, | ||
"copy-from": ram, | ||
"symbol": value, | ||
"type": "vehicle_part" | ||
} | ||
json_data.append(new_ram_data) | ||
list_of_created_ids.append(new_ram_id) | ||
return json_data | ||
|
||
path = os.path.join(os.getcwd(), default_path) | ||
output_path = os.path.join(os.getcwd(), default_output) | ||
result = gen_new(path) | ||
print(*ids_to_create_directional_parts_for, sep = "\n") | ||
|
||
with open(output_path, "w") as jf: | ||
json.dump(result, jf, ensure_ascii=False, sort_keys=True) | ||
subprocess.Popen(['D:/Cataclysm-DDA/tools/format/json_formatter.exe', output_path], shell=True) | ||
|
||
with open(ids_created_output, "w") as jf: | ||
for id in list_of_created_ids: | ||
jf.write(id + "\n") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only going to work on windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script I based this off, this https://github.com/CleverRaven/Cataclysm-DDA/blob/master/tools/json_tools/pocket_mags.py and it wasn't working for me on Windows. I don't actually expect anyone to be running this script, as I'm committing the transformed JSON along side it. It's more for documentation purposes.