mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 19:50:12 +01:00
Added osu parser, not fully implemented. Very much hardcoded to only play p names
This commit is contained in:
2623
PNames.osu
Normal file
2623
PNames.osu
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1 +1,2 @@
|
|||||||
61506649d1a0f78c7759ffd83b010e58ab0e167bdeb06b11584933d7a7409f35|Dogbite|t+pazolite
|
74ee9547980a5a16d7de54004b8422fd1655e079d51cfe7fa554787604ecb654|TRIPLE HELIX|Yonokid
|
||||||
|
61506649d1a0f78c7759ffd83b010e58ab0e167bdeb06b11584933d7a7409f35|Dogbite|t+pazolite
|
||||||
|
|||||||
38
config.toml
38
config.toml
@@ -12,38 +12,38 @@ practice_mode_bar_delay = 1
|
|||||||
score_method = "shinuchi"
|
score_method = "shinuchi"
|
||||||
|
|
||||||
[nameplate_1p]
|
[nameplate_1p]
|
||||||
name = 'どんちゃん'
|
name = "どんちゃん"
|
||||||
title = 'ドンだーデビュー!'
|
title = "ドンだーデビュー!"
|
||||||
title_bg = 0
|
title_bg = 0
|
||||||
dan = -1
|
dan = -1
|
||||||
gold = false
|
gold = false
|
||||||
rainbow = false
|
rainbow = false
|
||||||
|
|
||||||
[nameplate_2p]
|
[nameplate_2p]
|
||||||
name = 'かつちゃん'
|
name = "かつちゃん"
|
||||||
title = 'ドンだーデビュー!'
|
title = "ドンだーデビュー!"
|
||||||
title_bg = 1
|
title_bg = 1
|
||||||
dan = -1
|
dan = -1
|
||||||
gold = false
|
gold = false
|
||||||
rainbow = false
|
rainbow = false
|
||||||
|
|
||||||
[paths]
|
[paths]
|
||||||
tja_path = ['Songs']
|
tja_path = ["Songs"]
|
||||||
skin = 'PyTaikoGreen'
|
skin = "PyTaikoGreen"
|
||||||
|
|
||||||
[keys]
|
[keys]
|
||||||
exit_key = 'Q'
|
exit_key = "Q"
|
||||||
borderless_key = 'F10'
|
borderless_key = "f10"
|
||||||
fullscreen_key = 'F11'
|
fullscreen_key = "f11"
|
||||||
pause_key = "SPACE"
|
pause_key = "space"
|
||||||
back_key = 'ESCAPE'
|
back_key = "escape"
|
||||||
restart_key = 'F1'
|
restart_key = "f1"
|
||||||
|
|
||||||
[keys_1p]
|
[keys_1p]
|
||||||
left_kat = ['D']
|
left_kat = ["D"]
|
||||||
left_don = ['F']
|
left_don = ["F"]
|
||||||
right_don = ['J']
|
right_don = ["J"]
|
||||||
right_kat = ['K']
|
right_kat = ["K"]
|
||||||
|
|
||||||
[keys_2p]
|
[keys_2p]
|
||||||
left_kat = ["Z"]
|
left_kat = ["Z"]
|
||||||
@@ -58,17 +58,13 @@ right_don = [17]
|
|||||||
right_kat = [12]
|
right_kat = [12]
|
||||||
|
|
||||||
[audio]
|
[audio]
|
||||||
# device_type: 0 = default, this will be set on first launch to the recommended setting
|
|
||||||
# Windows users should generally pick 4 (WDM-KS) and Linux users should pick 0 (ALSA)
|
|
||||||
device_type = 0
|
device_type = 0
|
||||||
sample_rate = 44100
|
sample_rate = 44100
|
||||||
# buffer_size: Size in samples per audio buffer
|
|
||||||
# - 0 = let driver choose (may result in very small buffers with ASIO, typically 64)
|
|
||||||
buffer_size = 32
|
buffer_size = 32
|
||||||
|
|
||||||
[volume]
|
[volume]
|
||||||
sound = 1.0
|
sound = 1.0
|
||||||
music = 1.0
|
music = 0.0
|
||||||
voice = 1.0
|
voice = 1.0
|
||||||
hitsound = 1.0
|
hitsound = 1.0
|
||||||
attract_mode = 1.0
|
attract_mode = 1.0
|
||||||
|
|||||||
1
libs/osz.py
Symbolic link
1
libs/osz.py
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
../osz.py
|
||||||
79
osz.py
Normal file
79
osz.py
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import hashlib
|
||||||
|
import logging
|
||||||
|
import math
|
||||||
|
import random
|
||||||
|
from collections import deque
|
||||||
|
from dataclasses import dataclass, field, fields
|
||||||
|
from enum import IntEnum
|
||||||
|
from functools import lru_cache
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from libs.global_data import Modifiers
|
||||||
|
from libs.utils import strip_comments
|
||||||
|
from libs.tja import TimelineObject, Note, NoteType, Drumroll, Balloon, NoteList, CourseData, ParserState
|
||||||
|
|
||||||
|
osu_file = Path("./PNames.osu")
|
||||||
|
contents = osu_file.open(mode='r', encoding='utf-8').read()
|
||||||
|
|
||||||
|
import re
|
||||||
|
def read_osu_note_data(file_path, target_header="HitObjects"):
|
||||||
|
note_data = []
|
||||||
|
current_header = None
|
||||||
|
|
||||||
|
with file_path.open(mode='r', encoding='utf-8') as f:
|
||||||
|
|
||||||
|
for line in f:
|
||||||
|
line = line.rstrip("\n")
|
||||||
|
|
||||||
|
if re.match(r"\[\w*\]", line): # header pattern
|
||||||
|
current_header = line[1:-1]
|
||||||
|
|
||||||
|
if current_header == target_header:
|
||||||
|
if re.match(r"[-+]?\d*\.?\d+" , line):
|
||||||
|
string_array = re.findall(r"[-+]?\d*\.?\d+" , line) # search for floats
|
||||||
|
int_array = [int(num_str) for num_str in string_array]
|
||||||
|
note_data.append(int_array)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
|
||||||
|
return note_data
|
||||||
|
|
||||||
|
|
||||||
|
note_data = read_osu_note_data(osu_file)
|
||||||
|
|
||||||
|
def note_data_to_NoteList(note_data):
|
||||||
|
osu_NoteList = NoteList()
|
||||||
|
counter = 0
|
||||||
|
for line in note_data:
|
||||||
|
if line[3] == 1 and line[4] == 0: # DON
|
||||||
|
don = Note()
|
||||||
|
don.type = NoteType(1)
|
||||||
|
don.hit_ms = line[2]
|
||||||
|
don.bpm = 207
|
||||||
|
don.scroll_x = 1
|
||||||
|
don.scroll_y = 0
|
||||||
|
don.display = True
|
||||||
|
don.index = counter
|
||||||
|
counter = counter + 1
|
||||||
|
don.moji = 0
|
||||||
|
osu_NoteList.play_notes.append(don)
|
||||||
|
if line[3] == 1 and line[4] == 2: # KAT
|
||||||
|
kat = Note()
|
||||||
|
kat.type = NoteType(2)
|
||||||
|
kat.hit_ms = line[2]
|
||||||
|
kat.bpm = 207
|
||||||
|
kat.scroll_x = 1
|
||||||
|
kat.scroll_y = 0
|
||||||
|
kat.display = True
|
||||||
|
kat.index = counter
|
||||||
|
counter = counter + 1
|
||||||
|
kat.moji = 1
|
||||||
|
osu_NoteList.play_notes.append(kat)
|
||||||
|
osu_NoteList.draw_notes = osu_NoteList.play_notes.copy()
|
||||||
|
return osu_NoteList
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -50,6 +50,8 @@ from libs.utils import (
|
|||||||
)
|
)
|
||||||
from libs.video import VideoPlayer
|
from libs.video import VideoPlayer
|
||||||
|
|
||||||
|
from libs.osz import read_osu_note_data, note_data_to_NoteList
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class DrumType(IntEnum):
|
class DrumType(IntEnum):
|
||||||
@@ -414,9 +416,11 @@ class Player:
|
|||||||
unload_offset = travel_distance / sudden_pixels_per_ms
|
unload_offset = travel_distance / sudden_pixels_per_ms
|
||||||
note.unload_ms = note.hit_ms + unload_offset
|
note.unload_ms = note.hit_ms + unload_offset
|
||||||
|
|
||||||
|
###from libs.osz import read_osu_note_data, note_data_to_NoteList
|
||||||
def reset_chart(self):
|
def reset_chart(self):
|
||||||
notes, self.branch_m, self.branch_e, self.branch_n = self.tja.notes_to_position(self.difficulty)
|
#notes, self.branch_m, self.branch_e, self.branch_n = self.tja.notes_to_position(self.difficulty)
|
||||||
|
notes = note_data_to_NoteList(read_osu_note_data(Path("./PNames.osu")))
|
||||||
|
self.branch_m, self.branch_e, self.branch_n = [], [], []
|
||||||
self.play_notes, self.draw_note_list, self.draw_bar_list = deque(apply_modifiers(notes, self.modifiers)[0]), deque(apply_modifiers(notes, self.modifiers)[1]), deque(apply_modifiers(notes, self.modifiers)[2])
|
self.play_notes, self.draw_note_list, self.draw_bar_list = deque(apply_modifiers(notes, self.modifiers)[0]), deque(apply_modifiers(notes, self.modifiers)[1]), deque(apply_modifiers(notes, self.modifiers)[2])
|
||||||
|
|
||||||
self.don_notes = deque([note for note in self.play_notes if note.type in {NoteType.DON, NoteType.DON_L}])
|
self.don_notes = deque([note for note in self.play_notes if note.type in {NoteType.DON, NoteType.DON_L}])
|
||||||
|
|||||||
Reference in New Issue
Block a user