mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
fix jposcroll
This commit is contained in:
45
libs/tja.py
45
libs/tja.py
@@ -53,6 +53,8 @@ class TimelineObject:
|
|||||||
|
|
||||||
judge_pos_x: float = field(init=False)
|
judge_pos_x: float = field(init=False)
|
||||||
judge_pos_y: float = field(init=False)
|
judge_pos_y: float = field(init=False)
|
||||||
|
delta_x: float = field(init=False)
|
||||||
|
delta_y: float = field(init=False)
|
||||||
border_color: ray.Color = field(init=False)
|
border_color: ray.Color = field(init=False)
|
||||||
cam_h_offset: float = field(init=False)
|
cam_h_offset: float = field(init=False)
|
||||||
cam_v_offset: float = field(init=False)
|
cam_v_offset: float = field(init=False)
|
||||||
@@ -729,8 +731,6 @@ class TJAParser:
|
|||||||
sudden_moving = 0
|
sudden_moving = 0
|
||||||
judge_pos_x = 0
|
judge_pos_x = 0
|
||||||
judge_pos_y = 0
|
judge_pos_y = 0
|
||||||
judge_target_x = 0
|
|
||||||
judge_target_y = 0
|
|
||||||
border_color = ray.BLACK
|
border_color = ray.BLACK
|
||||||
cam_h_offset = 0
|
cam_h_offset = 0
|
||||||
cam_v_offset = 0
|
cam_v_offset = 0
|
||||||
@@ -1183,7 +1183,7 @@ class TJAParser:
|
|||||||
if len(parts) >= 4:
|
if len(parts) >= 4:
|
||||||
duration_ms = float(parts[1]) * 1000
|
duration_ms = float(parts[1]) * 1000
|
||||||
distance_str = parts[2]
|
distance_str = parts[2]
|
||||||
direction = int(parts[3]) # 0 = normal, 1 = reverse
|
direction = int(parts[3])
|
||||||
delta_x = 0
|
delta_x = 0
|
||||||
delta_y = 0
|
delta_y = 0
|
||||||
if 'i' in distance_str:
|
if 'i' in distance_str:
|
||||||
@@ -1196,27 +1196,32 @@ class TJAParser:
|
|||||||
distance = float(distance_str)
|
distance = float(distance_str)
|
||||||
delta_x = distance
|
delta_x = distance
|
||||||
delta_y = 0
|
delta_y = 0
|
||||||
|
|
||||||
if direction == 0:
|
if direction == 0:
|
||||||
delta_x = -delta_x
|
delta_x = -delta_x
|
||||||
delta_y = -delta_y
|
delta_y = -delta_y
|
||||||
|
|
||||||
judge_target_x = judge_pos_x + delta_x
|
for obj in reversed(curr_timeline):
|
||||||
judge_target_y = judge_pos_y + delta_y
|
if hasattr(obj, 'delta_x') and hasattr(obj, 'delta_y'):
|
||||||
interpolation_interval_ms = 8
|
if obj.hit_ms > self.current_ms:
|
||||||
num_steps = int(duration_ms / interpolation_interval_ms)
|
available_time = self.current_ms - obj.load_ms
|
||||||
for step in range(num_steps + 1):
|
total_duration = obj.hit_ms - obj.load_ms
|
||||||
t = step / max(num_steps, 1)
|
ratio = min(1.0, available_time / total_duration) if total_duration > 0 else 1.0
|
||||||
interpolated_ms = self.current_ms + (step * interpolation_interval_ms)
|
obj.delta_x *= ratio
|
||||||
interp_x = judge_pos_x + (delta_x * t)
|
obj.delta_y *= ratio
|
||||||
interp_y = judge_pos_y + (delta_y * t)
|
obj.hit_ms = self.current_ms
|
||||||
jpos_timeline = TimelineObject()
|
break
|
||||||
jpos_timeline.hit_ms = interpolated_ms
|
|
||||||
jpos_timeline.judge_pos_x = interp_x
|
jpos_scroll = TimelineObject()
|
||||||
jpos_timeline.judge_pos_y = interp_y
|
jpos_scroll.load_ms = self.current_ms
|
||||||
bisect.insort(curr_timeline, jpos_timeline, key=lambda x: x.hit_ms)
|
jpos_scroll.hit_ms = self.current_ms + duration_ms
|
||||||
judge_pos_x = judge_target_x
|
jpos_scroll.judge_pos_x = judge_pos_x
|
||||||
judge_pos_y = judge_target_y
|
jpos_scroll.judge_pos_y = judge_pos_y
|
||||||
|
jpos_scroll.delta_x = delta_x
|
||||||
|
jpos_scroll.delta_y = delta_y
|
||||||
|
curr_timeline.append(jpos_scroll)
|
||||||
|
|
||||||
|
judge_pos_x += delta_x
|
||||||
|
judge_pos_y += delta_y
|
||||||
continue
|
continue
|
||||||
elif '#NMSCROLL' in part:
|
elif '#NMSCROLL' in part:
|
||||||
scroll_type = ScrollType.NMSCROLL
|
scroll_type = ScrollType.NMSCROLL
|
||||||
|
|||||||
@@ -532,14 +532,32 @@ class Player:
|
|||||||
self.timeline_index += 1
|
self.timeline_index += 1
|
||||||
|
|
||||||
def get_judge_position(self, current_ms: float):
|
def get_judge_position(self, current_ms: float):
|
||||||
"""Get the current judgment circle position based on bar data"""
|
"""Get the current judgment circle position based on bar data with on-demand interpolation"""
|
||||||
if not self.timeline or self.timeline_index >= len(self.timeline):
|
if not self.timeline or self.timeline_index >= len(self.timeline):
|
||||||
return
|
return
|
||||||
|
|
||||||
timeline_object = self.timeline[self.timeline_index]
|
timeline_object = self.timeline[self.timeline_index]
|
||||||
if hasattr(timeline_object, 'judge_pos_x') and timeline_object.hit_ms <= current_ms:
|
|
||||||
self.judge_x = timeline_object.judge_pos_x * tex.screen_scale
|
if hasattr(timeline_object, 'delta_x'):
|
||||||
self.judge_y = timeline_object.judge_pos_y * tex.screen_scale
|
if timeline_object.load_ms <= current_ms <= timeline_object.hit_ms:
|
||||||
self.timeline_index += 1
|
duration = timeline_object.hit_ms - timeline_object.load_ms
|
||||||
|
if duration > 0:
|
||||||
|
t = (current_ms - timeline_object.load_ms) / duration
|
||||||
|
t = max(0.0, min(1.0, t))
|
||||||
|
|
||||||
|
self.judge_x = (timeline_object.judge_pos_x + (timeline_object.delta_x * t)) * tex.screen_scale
|
||||||
|
self.judge_y = (timeline_object.judge_pos_y + (timeline_object.delta_y * t)) * tex.screen_scale
|
||||||
|
else:
|
||||||
|
self.judge_x = (timeline_object.judge_pos_x + timeline_object.delta_x) * tex.screen_scale
|
||||||
|
self.judge_y = (timeline_object.judge_pos_y + timeline_object.delta_y) * tex.screen_scale
|
||||||
|
|
||||||
|
if current_ms > timeline_object.hit_ms:
|
||||||
|
self.timeline_index += 1
|
||||||
|
if self.timeline_index < len(self.timeline):
|
||||||
|
next_timeline_object = self.timeline[self.timeline_index]
|
||||||
|
if hasattr(next_timeline_object, 'delta_x'):
|
||||||
|
next_timeline_object.judge_pos_x = self.judge_x / tex.screen_scale
|
||||||
|
next_timeline_object.judge_pos_y = self.judge_y / tex.screen_scale
|
||||||
|
|
||||||
def handle_scroll_type_commands(self, current_ms: float):
|
def handle_scroll_type_commands(self, current_ms: float):
|
||||||
if not self.timeline or self.timeline_index >= len(self.timeline):
|
if not self.timeline or self.timeline_index >= len(self.timeline):
|
||||||
|
|||||||
Reference in New Issue
Block a user