-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflash_manager.py
More file actions
70 lines (58 loc) · 2.56 KB
/
flash_manager.py
File metadata and controls
70 lines (58 loc) · 2.56 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
#!/usr/bin/env python3
import os
import platform
import subprocess
from tkinter import messagebox, Toplevel
from base_manager import BaseManager
class FlashManager(BaseManager):
def __init__(self, config_manager, download_manager=None, status_callback=None):
super().__init__(status_callback)
self.config_manager = config_manager
self.download_manager = download_manager
def is_download_in_progress(self):
"""Check if a download is currently in progress"""
if self.download_manager:
return self.download_manager.is_download_in_progress()
return False
def check_flash_player(self, parent=None):
"""Check if Flash Player is installed and download if needed"""
flash_path = self.config_manager.get_flash_player_path()
# Check if Flash Player exists
if not flash_path or not os.path.exists(flash_path):
result = self.show_dialog(parent, "Flash Player", "Flash Player is not installed. Do you want to download it now?")
if result:
return self.download_flash_player(parent)
else:
return None
return flash_path
def download_flash_player(self, parent=None):
"""Download Flash Player using DownloadManager"""
if self.download_manager:
return self.download_manager.download_flash_player(parent)
else:
self.show_dialog(parent, "Error", "Download manager not available", dialog_type="error")
return None
def launch_game(self, game_path, parent=None):
"""Launch a game with Flash Player"""
try:
flash_path = self.check_flash_player(parent)
if not flash_path:
return False
system = platform.system()
cmd = None
if system == "Windows":
cmd = [flash_path, game_path]
elif system == "Darwin": # macOS
cmd = ["open", "-a", flash_path, game_path]
elif system == "Linux":
cmd = [flash_path, game_path]
else:
self.show_dialog(parent, "Error", "Unsupported operating system", dialog_type="error")
return False
if cmd:
subprocess.Popen(cmd)
return True
return False
except Exception as e:
self.show_dialog(parent, "Error", f"Failed to launch game: {str(e)}", dialog_type="error")
return False