Add camera shake
This commit is contained in:
+19
-19
@@ -1,9 +1,9 @@
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
import os
|
||||
|
||||
parser = argparse.ArgumentParser(description="Item CSV to .h defines")
|
||||
parser.add_argument("--csv", required=True, help="Path to item CSV file")
|
||||
parser = argparse.ArgumentParser(description="Item JSON to .h defines")
|
||||
parser.add_argument("--json", required=True, help="Path to item JSON file")
|
||||
parser.add_argument("--output", required=True, help="Path to output .h file")
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -13,26 +13,26 @@ def type_enum(name):
|
||||
def id_enum(name):
|
||||
return "ITEM_ID_" + name.upper()
|
||||
|
||||
# Load CSV
|
||||
# Load JSON
|
||||
item_ids = []
|
||||
item_types = []
|
||||
rows = {}
|
||||
|
||||
with open(args.csv, newline="", encoding="utf-8") as f:
|
||||
reader = csv.DictReader(f)
|
||||
if (
|
||||
"id" not in reader.fieldnames or
|
||||
"type" not in reader.fieldnames or
|
||||
"name" not in reader.fieldnames
|
||||
):
|
||||
raise ValueError("CSV must have 'id', 'type', and 'name' columns")
|
||||
for row in reader:
|
||||
item_id, item_type = row["id"], row["type"]
|
||||
if item_id not in item_ids:
|
||||
item_ids.append(item_id)
|
||||
if item_type not in item_types:
|
||||
item_types.append(item_type)
|
||||
rows[item_id] = row
|
||||
with open(args.json, encoding="utf-8") as f:
|
||||
entries = json.load(f)
|
||||
|
||||
if not all(
|
||||
"id" in row and "type" in row and "name" in row for row in entries
|
||||
):
|
||||
raise ValueError("Each item must have 'id', 'type', and 'name' fields")
|
||||
|
||||
for row in entries:
|
||||
item_id, item_type = row["id"], row["type"]
|
||||
if item_id not in item_ids:
|
||||
item_ids.append(item_id)
|
||||
if item_type not in item_types:
|
||||
item_types.append(item_type)
|
||||
rows[item_id] = row
|
||||
|
||||
# Assign enum values: types and IDs each start from 1 with NULL = 0.
|
||||
type_values = {}
|
||||
|
||||
Reference in New Issue
Block a user