Ejemplo n.º 1
0
    def _parse_difficulty(self):
        d_end = self.data.find('\n\n')
        separator = _separators['Difficulty']

        for line in self.data[:d_end].splitlines():
            key, val = line.split(separator, 1)

            # all diff params should be float
            if not utils._isdecimal(val, _float=True):
                continue

            if key == 'HPDrainRate':
                self.diff_hp = float(val)
            elif key == 'CircleSize':
                self.diff_cs = float(val)
            elif key == 'OverallDifficulty':
                self.diff_od = float(val)
            elif key == 'ApproachRate':
                self.diff_ar = float(val)
            elif key == 'SliderMultiplier':
                self.slider_multiplier = float(val)
            elif key == 'SliderTickRate':
                self.slider_tick_rate = float(val)
            else:
                raise Exception(f'Invalid [Difficulty] key {key}')

        self._offset += d_end
Ejemplo n.º 2
0
    def _parse_editor(self):
        e_end = self.data.find('\n\n')
        separator = _separators['Editor']

        for line in self.data[:e_end].splitlines():
            key, val = line.split(separator, 1)

            if key == 'Bookmarks':
                bookmarks_str = val.split(',')
                if not all(x.isdecimal() for x in bookmarks_str):
                    continue

                self.bookmarks = [int(x) for x in bookmarks_str]
            elif key == 'DistanceSpacing':
                if not utils._isdecimal(val, _float=True):
                    continue

                self.distance_spacing = float(val)
            elif key == 'BeatDivisor':
                if not utils._isdecimal(val, _float=True):
                    continue

                self.beat_divisor = float(val)
            elif key == 'GridSize':
                if not val.isdecimal():
                    continue

                self.grid_size = int(val)
            elif key == 'TimelineZoom':
                if not utils._isdecimal(val, _float=True):
                    continue

                self.timeline_zoom = float(val)
            else:
                raise Exception(f'Invalid [Editor] key {key}')

        self._offset += e_end
Ejemplo n.º 3
0
    def _parse_general(self):
        g_end = self.data.find('\n\n')
        separator = _separators['General']

        for line in self.data[:g_end].splitlines():
            key, val = line.split(separator, 1)

            # how should i clean this.. lol

            if key == 'AudioFilename':
                self.audio_filename = val
            elif key == 'AudioLeadIn':
                if not val.isdecimal():
                    continue

                self.audio_leadin = int(val)
            # deprecated
            #elif key == 'AudioHash':
            #    self.audio_hash = val
            elif key == 'PreviewTime':
                if not val.isdecimal():
                    continue

                self.preview_time = int(val)
            elif key == 'Countdown':
                if not val.isdecimal():
                    continue

                self.countdown = int(val)
            elif key == 'SampleSet':
                if val not in ('Normal', 'Soft', 'Drum'):
                    continue

                self.sample_set = {
                    'Normal': SampleSet.NORMAL,
                    'Soft': SampleSet.SOFT,
                    'Drum': SampleSet.DRUM
                }[val]
            elif key == 'StackLeniency':
                if not utils._isdecimal(val, _float=True):
                    continue

                self.stack_leniency = float(val)
            elif key == 'Mode':
                if not val.isdecimal():
                    continue

                self.mode = int(val)
            elif key == 'LetterboxInBreaks':
                self.letterbox_in_breaks = val == '1'
            # deprecated
            #elif key == 'StoryFireInFront':
            #    self.story_fire_in_front = val == '1'
            elif key == 'UseSkinSprites':
                self.use_skin_sprites = val == '1'
            # deprecated
            #elif key == 'AlwaysShowPlayfield':
            #    self.always_show_playfield = val == '1'
            elif key == 'OverlayPosition':
                if val not in ('NoChange', 'Below', 'Above'):
                    continue

                self.overlay_position = {
                    'NoChange': OverlayPosition.No_Change,
                    'Below': OverlayPosition.Below,
                    'Above': OverlayPosition.Above
                }[val]
            elif key == 'SkinPreference':
                self.skin_preference = val
            elif key == 'EpilepsyWarning':
                self.epilepsy_warning = val == '1'
            elif key == 'CountdownOffset':
                if not val.isdecimal():
                    continue

                self.countdown_offset = int(val)
            elif key == 'SpecialStyle':
                self.special_style = val == '1'
            elif key == 'WidescreenStoryboard':
                self.widescreen_storyboard = val == '1'
            elif key == 'SamplesMatchPlaybackRate':
                self.samples_match_playback_rate = val == '1'
            else:
                raise Exception(f'Invalid [General] key {key}')

        self._offset += g_end