174 lines
4.8 KiB
Python
174 lines
4.8 KiB
Python
"""
|
|
EU-Utility Premium
|
|
==================
|
|
|
|
Enterprise-grade modular overlay system for Entropia Universe.
|
|
|
|
This package provides the premium/enterprise layer with:
|
|
- Advanced plugin system with sandboxing
|
|
- Redux-inspired state management
|
|
- High-performance event bus
|
|
- Widget system for dashboard
|
|
- Entropia Universe game integration
|
|
|
|
Quick Start:
|
|
from premium import EUUtilityApp
|
|
|
|
app = EUUtilityApp()
|
|
app.run()
|
|
|
|
Modules:
|
|
plugins - Plugin management system
|
|
core - Core infrastructure (state, events)
|
|
widgets - Dashboard widget system
|
|
eu_integration - Entropia Universe integration
|
|
"""
|
|
|
|
__version__ = "3.0.0"
|
|
__author__ = "EU-Utility Team"
|
|
|
|
# Core exports
|
|
from premium.core.state.store import StateStore, ActionBase, create_store, get_store
|
|
from premium.core.event_bus import EventBus, Event, EventPriority
|
|
from premium.plugins.api import (
|
|
PluginAPI, PluginManifest, PluginContext, PluginInstance,
|
|
PluginState, PermissionLevel,
|
|
PluginError, PluginLoadError, PluginInitError
|
|
)
|
|
from premium.plugins.manager import PluginManager
|
|
|
|
# Widget system
|
|
from premium.widgets.base import Widget, WidgetConfig
|
|
from premium.widgets.dashboard_widget import DashboardWidget
|
|
|
|
# EU Integration
|
|
from premium.eu_integration.game_client import GameClient
|
|
from premium.eu_integration.log_parser import LogParser
|
|
from premium.eu_integration.events import GameEvent, LootEvent, SkillEvent
|
|
|
|
|
|
class EUUtilityApp:
|
|
"""Main application class for EU-Utility Premium.
|
|
|
|
This is the high-level API for the entire premium system.
|
|
|
|
Example:
|
|
app = EUUtilityApp()
|
|
app.initialize()
|
|
app.run()
|
|
"""
|
|
|
|
def __init__(self, config_path=None):
|
|
self.config_path = config_path
|
|
self.plugin_manager = None
|
|
self.state_store = None
|
|
self.event_bus = None
|
|
self.game_client = None
|
|
self.dashboard = None
|
|
self._initialized = False
|
|
|
|
def initialize(self):
|
|
"""Initialize all subsystems."""
|
|
from pathlib import Path
|
|
|
|
# Create event bus
|
|
self.event_bus = EventBus()
|
|
|
|
# Create state store
|
|
self.state_store = StateStore(
|
|
reducer=self._root_reducer,
|
|
initial_state=self._get_initial_state()
|
|
)
|
|
|
|
# Create plugin manager
|
|
plugin_dirs = [
|
|
Path(__file__).parent.parent / "plugins" / "builtin",
|
|
Path(__file__).parent.parent / "plugins" / "user",
|
|
]
|
|
data_dir = Path.home() / ".eu-utility" / "data"
|
|
|
|
self.plugin_manager = PluginManager(
|
|
plugin_dirs=plugin_dirs,
|
|
data_dir=data_dir,
|
|
event_bus=self.event_bus,
|
|
state_store=self.state_store
|
|
)
|
|
|
|
# Create game client
|
|
self.game_client = GameClient(event_bus=self.event_bus)
|
|
|
|
self._initialized = True
|
|
|
|
def run(self):
|
|
"""Run the application."""
|
|
if not self._initialized:
|
|
self.initialize()
|
|
|
|
# Discover and load plugins
|
|
self.plugin_manager.discover_all()
|
|
self.plugin_manager.load_all(auto_activate=True)
|
|
|
|
# Start game client
|
|
self.game_client.start()
|
|
|
|
# Run main loop
|
|
try:
|
|
self._main_loop()
|
|
except KeyboardInterrupt:
|
|
self.shutdown()
|
|
|
|
def shutdown(self):
|
|
"""Shutdown the application gracefully."""
|
|
if self.plugin_manager:
|
|
self.plugin_manager.shutdown()
|
|
if self.game_client:
|
|
self.game_client.stop()
|
|
|
|
def _root_reducer(self, state, action):
|
|
"""Root state reducer."""
|
|
# Default reducer - just returns state
|
|
# Plugins can register their own reducers
|
|
return state or {}
|
|
|
|
def _get_initial_state(self):
|
|
"""Get initial application state."""
|
|
return {
|
|
'app': {
|
|
'version': __version__,
|
|
'initialized': False,
|
|
'game_connected': False,
|
|
},
|
|
'player': {
|
|
'name': None,
|
|
'skills': {},
|
|
'loot': [],
|
|
},
|
|
'plugins': {},
|
|
}
|
|
|
|
def _main_loop(self):
|
|
"""Main application loop."""
|
|
import time
|
|
while True:
|
|
time.sleep(0.1)
|
|
|
|
|
|
__all__ = [
|
|
# Version
|
|
'__version__',
|
|
# Core classes
|
|
'EUUtilityApp',
|
|
# State management
|
|
'StateStore', 'ActionBase', 'create_store', 'get_store',
|
|
# Event system
|
|
'EventBus', 'Event', 'EventPriority',
|
|
# Plugin system
|
|
'PluginManager', 'PluginAPI', 'PluginManifest', 'PluginContext',
|
|
'PluginInstance', 'PluginState', 'PermissionLevel',
|
|
'PluginError', 'PluginLoadError', 'PluginInitError',
|
|
# Widgets
|
|
'Widget', 'WidgetConfig', 'Dashboard',
|
|
# EU Integration
|
|
'GameClient', 'LogParser', 'GameEvent', 'LootEvent', 'SkillEvent',
|
|
]
|