-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI_Scoresaber_File.py
More file actions
112 lines (93 loc) · 3.06 KB
/
GUI_Scoresaber_File.py
File metadata and controls
112 lines (93 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import argparse
from decode_file import decompress, deserialize
from write_to_csv import write_to_csv
from tkinter import *
from tkinter import ttk
from tkinter import filedialog
import os
import pandas as pd
import numpy as np
gui = Tk()
gui.title("Process the DataFile")
file = None
folder = None
def getFolderPath():
global file
global filepath
file = filedialog.askopenfilename()
if file:
filepath = os.path.abspath(file)
Label(gui, text=str(filepath), font=('Aerial 11')).grid(row=1, column=2)
if complete:
complete.config(text="")
def getFolderPath3():
global folder
global filepath3
folder = filedialog.askdirectory()
if folder:
filepath3 = os.path.abspath(folder)
Label(gui, text=str(filepath3), font=('Aerial 11')).grid(row=2, column=2)
if complete:
complete.config(text="")
def onFolderConfirmed():
global file
global folder
if file is None:
strvarError.set("No Note File Selected")
if folder is None:
strvarError.set("No Output Folder Selected")
else:
doSomethingWithFolder()
def doSomethingWithFolder():
global file
global folder
global parser
global folder_name
global folder2
folder_name=os.path.splitext(filepath)[0]
parser = argparse.ArgumentParser(
description='Decompress & decode a ScoreSaber replay file'
)
parser.add_argument(
'-i',
'--input',
help='path to the file to parse',
default=filepath
)
parser.add_argument(
'-o',
'--output',
help='path to the output folder',
default=os.path.join(filepath3,"/",folder_name)
)
args = parser.parse_args()
write_to_csv(deserialize(decompress(args.input)), args.output)
folder2=os.path.join(filepath3,"/",folder_name)
df1=pd.read_csv(f'{folder2}/Position.csv')
df2=pd.read_csv(f'{folder2}/Notes.csv')
mergedRes2 = pd.merge(df1, df2,how='right', on ='Time')
mergedRes2.to_csv(f'{folder2}/Notes.csv')
# Remove the second row (considering the first row as headers, so technically this is the first data row)
df1.drop(df1.index[0], inplace=True)
# Remove none unique rows for time
df1.drop_duplicates(subset=['Time'], inplace=True)
df1.to_csv(f'{folder2}/Position.csv')
complete.config(text=f"Complete!!! 😎")
##Notes Row
btnFind = ttk.Button(gui, text="Select Replay File", command=getFolderPath)
btnFind.grid(row=1, column=1)
Label(gui, text="Replay File Path", font=('Aerial 11')).grid(row=1, column=2)
##Output Folder
ttk.Button(gui, text="Select Output Folder",command=getFolderPath3).grid(row=2,column=1)
Label(gui, text="Output File Path", font=('Aerial 11')).grid(row=2, column=2)
##Start Button
btnConfirm = ttk.Button(gui, text="Start", command=onFolderConfirmed)
btnConfirm.grid(row=3, column=2)
strvarError = StringVar()
## ERROR VALUE
lblError = Label(gui, textvar=strvarError)
lblError.grid(row=3, column=1)
## COMPLETE VALUE
complete=Label(gui, text="", font=('Aerial 11'))
complete.grid(row=3, column=1)
gui.mainloop()