...
 
Commits (1)
......@@ -24,7 +24,7 @@ for c in chars:
continue
current_data = load_char(char_path, c, current)
path_diff = output_path+"diffs/%s_%s_%s.bin" % (c, previous, current)
if previous_data is not None and not os.path.exists(path_diff):
if previous_data is not None:# and not os.path.exists(path_diff):
diff = DeepDiff(previous_data, current_data, exclude_paths=["root['version']"])
diff = transform_diff(clean_diff(diff, previous_data, current_data))
if len(diff):
......
......@@ -76,7 +76,7 @@ def transform_autocancel(data):
unk["Unknown4"] = data["Unknown4"]
if type(data["Condition"]) == int and data["Condition"] & 0x8000:
res["Condition"] = data["Condition"] & 0x7FFF
res["ActivateStates"] = read_flags(data["Unknown2"], ["A", "B", "C", "D", "E", "F"])
res["ActivateStates"] = read_flags(data["Unknown2"], ["A", "B", "C", "D", "E", "F", "G", "H"])
else:
res["Script"] = "Self" if data["MoveIndex"] < 0 else data["MoveIndex"]
if data["Unknown2"] == 2:
......
......@@ -2,38 +2,49 @@ from collections import defaultdict
import numpy as np
from model_transform.util import read_flags
def parse_position_flag(flag):
hi_end = flag >> 15
low_end = flag & 0xFFF
unknown = "Unknown (%x)" % flag
suffix = ""
if flag[1] != (0, 0):
suffix = " ("
if flag[1][0]:
suffix += "only in " + ", ".join(read_flags(flag[1][0], ["A", "B", "C", "D", "E", "F", "G", "H"]))
if flag[1][1]:
suffix += "not in " + ", ".join(read_flags(flag[1][1], ["A", "B", "C", "D", "E", "F", "G", "H"]))
suffix += ")"
hi_end = flag[0] >> 15
low_end = flag[0] & 0xFFF
unknown = "Unknown (%x)" % flag[0]
unknown += suffix
if hi_end & 8:
# Relative
if low_end != 0:
return unknown
if hi_end & 1:
return "RelativeX"
return "RelativeX" + suffix
if hi_end & 2:
return "RelativeY"
return "RelativeY" + suffix
return unknown
if low_end == 0:
# Shift
if hi_end & 1:
return "ShiftX"
return "ShiftX" + suffix
if hi_end & 2:
return "ShiftY"
return "ShiftY" + suffix
return unknown
if low_end & 4:
# Shift
if hi_end & 1:
return "BoxShiftX"
return "BoxShiftX" + suffix
if hi_end & 2:
return "BoxShiftY"
return "BoxShiftY" + suffix
return unknown
if low_end & 8:
# Shift
if hi_end & 2:
return "GroundLevel"
return "GroundLevel" + suffix
return unknown
return unknown
......@@ -44,7 +55,8 @@ def transform_positions(positions, max_frames):
if "Flag" not in data:
continue
flag = data["Flag"]
line = lines[flag]
states = data.get("BACVERint1", 0), data.get("BACVERint2", 0)
line = lines[flag, states]
value = data["Movement"]
np.nan_to_num(line[data["TickStart"]:data["TickEnd"]], copy=False)
line[data["TickStart"]:data["TickEnd"]] += value
......
......@@ -5,10 +5,10 @@ def transform_time_element(data):
}
flag1 = data.get("BACVERint1", 0)
if flag1:
res["ActiveOnStates"] = read_flags(flag1, ["A", "B", "C", "D", "E", "F"])
res["ActiveOnStates"] = read_flags(flag1, ["A", "B", "C", "D", "E", "F", "G", "H"])
flag2 = data.get("BACVERint2", 0)
if flag2:
res["InactiveOnStates"] = read_flags(flag2, ["A", "B", "C", "D", "E", "F"])
res["InactiveOnStates"] = read_flags(flag2, ["A", "B", "C", "D", "E", "F", "G", "H"])
flag3 = data.get("BACVERint3", 0)
if flag3:
res["TickFlag3"] = flag3
......
......@@ -136,7 +136,7 @@ function selectFromSparkline(ev) {
var sparkConfig = {
type: 'line',
height: 60,
height: 50,
width: Math.min(totalTicks * 4, 300),
chartRangeMin: 0,
tooltipOffsetX: -100,
......@@ -161,7 +161,7 @@ var altSparkConfig = {
}
};
for (var p in positions) {
var $el = $("#sparkline-"+(p.toLowerCase()).replace(" ", "_").replace("(", "").replace(")", ""));
var $el = $("#sparkline-"+(p.toLowerCase()).replace(/ /g, "_").replace("(", "").replace(")", ""));
var max = null;
var min = 0;
for (var i = 0, l = positions[p].length ; i < l ; i++) {
......@@ -183,6 +183,7 @@ for (var p in positions) {
sparkConfig.chartRangeMin = min;
altSparkConfig.chartRangeMin = min;
$el.sparkline(positions[p], sparkConfig);
console.log(positions[p], sparkConfig);
if (oldPositions && oldPositions[p]) {
if (oldPositions[p].length === 0) {
oldPositions[p] = positions[p];
......@@ -225,7 +226,7 @@ $('.sparklines').bind("mousedown", function() {
if (sparklineDrag) selectFromSparkline(ev);
});
if (states.length) {
if (typeof(states) !== "undefined" && states.length) {
var stateBox = "<h4>States</h4> ";
for (var i = 0; i < states.length; i++) {
stateBox += "<label>" + states[i] + " <input type='checkbox' class='activate-state' id='activate-state-" + states[i] + "'></label> ";
......
......@@ -42,6 +42,8 @@ class Timeline:
for d in self.instances:
start = d["TickStart"]
end = d["TickEnd"]
if "ActiveOnStates" in d:
continue
if start < self.min:
self.min = start
if end > self.max:
......@@ -74,14 +76,34 @@ def shift_to_js(script, shift_type):
res += [None for _ in range(len(res), script["TotalTicks"])]
return res
def add_position_entries(p1, p2):
if p1 is None:
return p2
if p2 is None:
return p1
res = list(p1)
for i, p in enumerate(p2):
if res[i] is None:
res[i] = p
elif p is not None:
res[i] += p
return res
def simulate_positions(script):
positions = {k: shift_to_js(script, k) for k in script.get("Positions", {}).keys()}
ticks = script["TotalTicks"]
shift_x = positions.get("ShiftX")
shift_y = positions.get("ShiftY")
ground_level = positions.get("GroundLevel")
for item, p in positions.items():
if item.startswith("ShiftX") and "not" in item:
shift_x = add_position_entries(p, shift_x)
if item.startswith("ShiftY") and "not" in item:
shift_y = add_position_entries(p, shift_y)
if item.startswith("GroundLevel") and "not" in item:
ground_level = add_position_entries(p, ground_level)
forces = script.get("Forces")
ticks = script["TotalTicks"]
timeline = Timeline(None, forces)
pos = Position(0, 0)
result_x = []
......
......@@ -193,10 +193,10 @@ with ZipFile("result/dump.zip", "w", compression=ZIP_DEFLATED) as zf:
# print(version)
# write_version(basepath, version_map, "SKR", "000")
for char, versions in sorted(version_map.items()):
# if char not in {"LAR", "ABG", "FLK", "ZGF"}:
# if char not in {"SGT"}:
# continue
for version, version_content in sorted(versions.items()):
if version_content[0] != "3.051":
continue
# if version_content[0] != "3.060":
# continue
print(char, version, version_content)
write_version(basepath, version_map, char, version, zf)