Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Version 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
connerglover committed Mar 27, 2023
1 parent d57e011 commit a51e8d6
Showing 1 changed file with 24 additions and 50 deletions.
74 changes: 24 additions & 50 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,85 +28,69 @@ def format(time):
minutes = minutes - (hours * 60)
# Converts Integers to Strings
# Combines the time into a single string
if seconds == '0':
return f'0s {milliseconds}ms'
elif minutes == '0':
if len(seconds) == 1:
return f'0{str(seconds)}s {milliseconds}ms'
else:
return f'{str(seconds)}s {milliseconds}ms'
elif hours == '0':
return f'{str(minutes)}m {str(seconds)}s {milliseconds}ms'
else:
return f'{str(hours)}h {str(minutes)}m {str(seconds)}s {milliseconds}ms'
seconds = str(seconds).rjust(2, '0')
minutes = str(minutes).rjust(2, '0')
if len(hours) < 2:
hours = str(hours).rjust(2, '0')
return f'{str(hours)}h {str(minutes)}m {str(seconds)}s {milliseconds}ms'

# Calculates the loads
def loads(dbi_start, dbi_end, fps):
try: # Turns JSON into a Dictionary and Checks if it is Valid (Start)
dbis_dict = json_loads(dbi_start)
except:
sg.popup('Error (Start)', 'Debug Info is not valid.',
title='Error') # Error Message
sg.popup('Error (Start)', 'Debug Info is not valid.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
try: # Turns JSON into a Dictionary and Checks if it is Valid (End)
dbie_dict = json_loads(dbi_end)
except:
sg.popup('Error (End)', 'Debug Info is not valid.',
title='Error') # Error Message
sg.popup('Error (End)', 'Debug Info is not valid.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
try: # Gets the CMT from the Dictionary
cmt_end = dbie_dict['cmt']
cmt_start = dbis_dict['cmt']
except:
sg.popup('Error (CMT)', 'CMT is not Valid.',
title='Error') # Error Message
sg.popup('Error (CMT)', 'CMT is not Valid.',title='Error', icon=r'assets\pytime.ico') # Error Message
# Rounds the CMT to the nearest frame
cmt_start = ReTime.frame_round(d(cmt_start), fps)
cmt_end = ReTime.frame_round(d(cmt_end), fps)
# Calculates the Loads
loads = (d(cmt_end) - d(cmt_start))
if -abs(loads) == loads: # Checks if the Start is greater than the End
sg.popup('Error', 'The start is greater than the end.',
title='Error') # Error Message
sg.popup('Error', 'The start is greater than the end.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
# Rounds the Loads to the nearest frame just in case the rounding is off
loads = ReTime.frame_round(loads, fps)
sg.popup(f'Loads Added', title='Loads', font=(
'Helvetica', 16)) # Success Message
sg.popup(f'Loads Added', title='Loads', font=('Helvetica', 16), icon=r'assets\pytime.ico') # Success Message
return loads

# Calculates the Final Time
def final(dbi_start, dbi_end, loads, fps):
try: # Turns JSON into a Dictionary and Checks if it is Valid (Start)
dbis_dict = json_loads(dbi_start)
except:
sg.popup('Error (Start)', 'Debug Info is not valid.',
title='Error') # Error Message
sg.popup('Error (Start)', 'Debug Info is not valid.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
try: # Turns JSON into a Dictionary and Checks if it is Valid (End)
dbie_dict = json_loads(dbi_end)
except:
sg.popup('Error (End)', 'Debug Info is not valid.',
title='Error') # Error Message
sg.popup('Error (End)', 'Debug Info is not valid.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
try: # Gets the CMT from the Dictionary
cmt_end = dbie_dict['cmt']
cmt_start = dbis_dict['cmt']
except:
sg.popup('Error (CMT)', 'CMT is not Valid.',
title='Error') # Error Message
sg.popup('Error (CMT)', 'CMT is not Valid.',title='Error', icon=r'assets\pytime.ico') # Error Message
# Rounds the CMT to the nearest frame
cmt_start = ReTime.frame_round(d(cmt_start), fps)
cmt_end = ReTime.frame_round(d(cmt_end), fps)
# Calculates the Final Time
time_loads = (d(cmt_end) - d(cmt_start))
if -abs(time_loads) == time_loads: # Checks if the Start is greater than the End
sg.popup('Error', 'The start is greater than the end.',
title='Error') # Error Message
sg.popup('Error', 'The start is greater than the end.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
if loads > time_loads: # Checks if the Loads are greater than the Time
sg.popup('Error', 'The Loads is greater than the Time.',
title='Error') # Error Message
sg.popup('Error', 'The Loads is greater than the Time.',title='Error', icon=r'assets\pytime.ico') # Error Message
return
# Rounds Loads for the millionth time
loads = ReTime.frame_round(loads, fps)
Expand All @@ -115,20 +99,17 @@ def final(dbi_start, dbi_end, loads, fps):
no_loads = ReTime.format(time_no_loads)
with_loads = ReTime.format(time_loads)
if loads == 0:
final_confirm = sg.popup_yes_no(
f'Without Loads: {no_loads}', 'Would you like the Mod Note to be Copied to the Clipboard?',
title='Results')
final_confirm = sg.popup_yes_no(f'Without Loads: {no_loads}', 'Would you like the Mod Note to be Copied to the Clipboard?',title='Results', icon=r'assets\pytime.ico')
if final_confirm == 'Yes':
copy(
f'Mod Note: Retimed to {no_loads} at {fps} FPS using [PyTime](https://github.com/ConnerConnerConner/PyTime)')
elif final_confirm == 'No':
return
else:
final_confirm = sg.popup_yes_no(
f'Without Loads: {no_loads}, With Loads: {with_loads}', 'Mod Note Copied to Clipboard', title='Results')
# makes sure that the minutes are less than 60
final_confirm = sg.popup_yes_no(f'Without Loads: {no_loads}, With Loads: {with_loads}', 'Mod Note Copied to Clipboard', title='Results', icon=r'assets\pytime.ico')
if final_confirm == 'Yes':
copy(
f'Mod Note: Retimed to {no_loads} at {fps} FPS using [PyTime](https://github.com/ConnerConnerConner/PyTime)')
copy(f'Mod Note: Retimed to {no_loads} at {fps} FPS using [PyTime](https://github.com/ConnerConnerConner/PyTime)')
elif final_confirm == 'No':
return

Expand All @@ -142,17 +123,15 @@ def final(dbi_start, dbi_end, loads, fps):
[sg.Button('Paste', font=('Helvetica', 10), key='paste_dbie_loads'),sg.InputText(key='dbie_loads', font=('Helvetica', 14), pad=((5, 0), (0, 0)), size=(15, 1)),sg.Text(' Debug Info End (Loads)', font=('Helvetica', 14), justification='right')],
[sg.Button('Calculate', font=('Helvetica', 18)), sg.Button('Add Loads', font=('Helvetica', 18)), sg.Button('Remove All Loads', font=('Helvetica', 18))]
]
main_window = sg.Window('PyTime', main_layout, resizable=False,
element_justification='left', size=(516, 275), finalize=True)
main_window = sg.Window('PyTime', main_layout, resizable=False, element_justification='left', size=(516, 275), finalize=True, icon=r'assets\pytime.ico')

# Main Loop
while True:
event, values = main_window.read() # Reads the Window
if event == sg.WIN_CLOSED: # Checks if the Window is Closed
break
if event == 'Remove All Loads': # Checks if the Remove All Loads Button is Pressed
lr_confirm = sg.popup_yes_no('Are you sure you want to remove all loads?', title='Remove All Loads', font=(
'Helvetica', 16), icon=r'assets\PyTime.ico') # Confirmation Message
lr_confirm = sg.popup_yes_no('Are you sure you want to remove all loads?', title='Remove All Loads', font=('Helvetica', 16), icon=r'assets\pytime.ico') # Confirmation Message
if lr_confirm == 'Yes':
# Clears Loads Input Boxes
main_window['dbis_loads'].update('')
Expand Down Expand Up @@ -194,10 +173,10 @@ def final(dbi_start, dbi_end, loads, fps):
try: # Checks if the FPS is Valid
fps = d(fps)
except:
sg.popup('Error (FPS)', 'FPS is not an valid number.', title='Error')
sg.popup('Error (FPS)', 'FPS is not an valid number.', title='Error', icon=r'assets\pytime.ico')
continue
if fps == 0:
sg.popup('Error (FPS)', 'FPS cannot be 0.', title='Error')
sg.popup('Error (FPS)', 'FPS cannot be 0.', title='Error', icon=r'assets\pytime.ico')
continue
else:
if not 'loads' in globals(): # Check if the Loads Variables Exists
Expand All @@ -218,10 +197,5 @@ def final(dbi_start, dbi_end, loads, fps):
if event == 'paste_dbie_loads':
main_window['dbie_loads'].update(paste())

main_window.close() # Closes the Window once

# Credit to Rekto for Helping Me With Everything
# Credit to Slush0Puppy for Frane Rounding
# Credit to Me For Making This Shitf
# Credit to You For Using This Shit
main_window.close() # Closes the Window
# Made by Conner Speedrunning

0 comments on commit a51e8d6

Please sign in to comment.