82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
import pygame
|
|
import sys
|
|
import tkinter as tk
|
|
from tkinter import filedialog
|
|
from editor_core import EditorState
|
|
from ui import UI
|
|
|
|
def main():
|
|
# Initialize Tkinter for file dialog
|
|
try:
|
|
root = tk.Tk()
|
|
root.withdraw()
|
|
# Ensure dialog comes to front
|
|
root.attributes('-topmost', True)
|
|
|
|
print("Please select an OGG file to start editing...")
|
|
file_path = filedialog.askopenfilename(
|
|
title="Select Audio File",
|
|
filetypes=[("Audio Files", "*.ogg"), ("TJA Files", "*.tja"), ("All Files", "*.*")]
|
|
)
|
|
root.destroy()
|
|
except KeyboardInterrupt:
|
|
print("\nOperation cancelled by user.")
|
|
return
|
|
except Exception as e:
|
|
print(f"Error opening file dialog: {e}")
|
|
return
|
|
|
|
if not file_path:
|
|
print("No file selected. Exiting.")
|
|
return
|
|
|
|
# Initialize Pygame
|
|
pygame.init()
|
|
pygame.mixer.init()
|
|
|
|
SCREEN_WIDTH = 1024
|
|
SCREEN_HEIGHT = 600
|
|
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
|
pygame.display.set_caption("Taiko Editor (Python)")
|
|
|
|
clock = pygame.time.Clock()
|
|
|
|
# Initialize Editor
|
|
editor = EditorState()
|
|
editor.load_file(file_path)
|
|
|
|
ui = UI(editor, SCREEN_WIDTH, SCREEN_HEIGHT)
|
|
|
|
running = True
|
|
while running:
|
|
dt = clock.tick(60) # ms since last frame
|
|
|
|
# Event Handling
|
|
for event in pygame.event.get():
|
|
if event.type == pygame.QUIT:
|
|
running = False
|
|
elif event.type == pygame.KEYDOWN:
|
|
if event.key == pygame.K_SPACE:
|
|
editor.toggle_play()
|
|
elif event.key == pygame.K_s and (pygame.key.get_mods() & pygame.KMOD_CTRL):
|
|
editor.save()
|
|
print("Saved!")
|
|
elif event.key == pygame.K_DELETE:
|
|
editor.remove_selected()
|
|
|
|
ui.handle_event(event)
|
|
|
|
# Update
|
|
editor.update(dt)
|
|
|
|
# Draw
|
|
ui.draw(screen)
|
|
|
|
pygame.display.flip()
|
|
|
|
pygame.quit()
|
|
sys.exit()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|