Skip to content
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

Added event support (except for storyboards) #69

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion slider/beatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class Event:
def start_time(self):
return self._start_time if self._start_time != 0 else None

@classmethod
def strip_quotes_from_filename(cls, filename):
return filename[1:-1]

@classmethod
def parse(cls, data):
event_type, start_time_or_layer, *event_params = data.split(',')
Expand Down Expand Up @@ -95,6 +99,7 @@ def event_type(self):
def parse(cls, start_time, event_params):
try:
filename, x_offset, y_offset = event_params
filename = cls.strip_quotes_from_filename(filename)
except ValueError:
raise ValueError(
f'Missing param for Background, received {event_params}')
Expand All @@ -109,7 +114,7 @@ def parse(cls, start_time, event_params):
return cls(filename, x_offset, y_offset)

def __init__(self, filename, x_offset, y_offset):
self._start_time = None
self._start_time = timedelta(milliseconds=0)
self.filename = filename
self.x_offset = x_offset
self.y_offset = y_offset
Expand Down Expand Up @@ -146,6 +151,7 @@ def event_type(self):
def parse(cls, start_time, event_params):
try:
filename, x_offset, y_offset = event_params
filename = cls.strip_quotes_from_filename(filename)
kszlim marked this conversation as resolved.
Show resolved Hide resolved
except ValueError:
raise ValueError(
f'Missing param for video, received {event_params}')
Expand Down
8 changes: 8 additions & 0 deletions slider/tests/test_beatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,11 @@ def test_hp(beatmap):

def test_od(beatmap):
assert beatmap.od() == 9


def test_background(beatmap):
background = beatmap.background
assert background.filename == 'miiro_no_scenario.png'
assert background.x_offset == 0
assert background.y_offset == 0
assert background.start_time == timedelta(milliseconds=0)