"""
平台拖拽检测器

自动选择合适的平台特定拖拽检测器。
"""

from .base_detector import BaseDragDetector, DragDetectorFactory
from typing import List


class PlatformDragDetector:
    """平台拖拽检测器包装类"""
    
    def __init__(self, supported_formats: List[str] = None):
        """
        初始化平台拖拽检测器
        
        Args:
            supported_formats: 支持的文件格式列表
        """
        self.supported_formats = supported_formats or ['.gltf', '.glb', '.fbx', '.bam', '.egg', '.obj']
        self.detector = DragDetectorFactory.create_detector(self.supported_formats)
        self._is_monitoring = False
        
    def set_drop_callback(self, callback):
        """设置拖拽回调函数"""
        if self.detector:
            self.detector.set_drop_callback(callback)
            
    def start_monitoring(self):
        """开始监控"""
        if self.detector and not self._is_monitoring:
            self.detector.start_monitoring()
            self._is_monitoring = True
            
    def stop_monitoring(self):
        """停止监控"""
        if self.detector and self._is_monitoring:
            self.detector.stop_monitoring()
            self._is_monitoring = False
            
    def get_dropped_files(self):
        """获取拖拽的文件"""
        if self.detector:
            return self.detector.get_dropped_files()
        return []
        
    def is_supported(self) -> bool:
        """检查当前平台是否支持"""
        return self.detector.is_supported() if self.detector else False
        
    def add_dropped_file(self, file_path: str):
        """添加拖拽的文件路径"""
        if self.detector:
            self.detector.add_dropped_file(file_path)
    
    def get_platform_info(self) -> dict:
        """获取平台信息"""
        import platform
        return {
            'system': platform.system(),
            'release': platform.release(),
            'version': platform.version(),
            'detector_type': type(self.detector).__name__,
            'supported': self.is_supported()
        }