mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-05-30 07:09:39 +03:00
Rename plugin callback to dashboard_entry
This commit is contained in:
parent
a081b6b637
commit
75edff5fc3
@ -57,7 +57,7 @@ import prefs
|
||||
import plug
|
||||
from hotkey import hotkeymgr
|
||||
from monitor import monitor
|
||||
from status import status
|
||||
from dashboard import dashboard
|
||||
from theme import theme
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ class AppWindow:
|
||||
self.w.bind('<KP_Enter>', self.getandsend)
|
||||
self.w.bind_all('<<Invoke>>', self.getandsend) # Hotkey monitoring
|
||||
self.w.bind_all('<<JournalEvent>>', self.journal_event) # Journal monitoring
|
||||
self.w.bind_all('<<StatusEvent>>', self.status_event) # Cmdr Status monitoring
|
||||
self.w.bind_all('<<DashboardEvent>>', self.dashboard_event) # Dashboard monitoring
|
||||
self.w.bind_all('<<PluginError>>', self.plugin_error) # Statusbar
|
||||
self.w.bind_all('<<Quit>>', self.onexit) # Updater
|
||||
|
||||
@ -630,8 +630,8 @@ class AppWindow:
|
||||
hotkeymgr.play_bad()
|
||||
|
||||
if entry['event'] in ['StartUp', 'LoadGame'] and monitor.started:
|
||||
# Can start status monitoring
|
||||
if not status.start(self.w, monitor.started):
|
||||
# Can start dashboard monitoring
|
||||
if not dashboard.start(self.w, monitor.started):
|
||||
print "Can't start Status monitoring"
|
||||
|
||||
# Don't send to EDDN while on crew
|
||||
@ -686,11 +686,11 @@ class AppWindow:
|
||||
hotkeymgr.play_bad()
|
||||
|
||||
# Handle Status event
|
||||
def status_event(self, event):
|
||||
entry = status.status
|
||||
def dashboard_event(self, event):
|
||||
entry = dashboard.status
|
||||
if entry:
|
||||
# Currently we don't do anything with these events
|
||||
err = plug.notify_status(monitor.cmdr, monitor.is_beta, entry)
|
||||
err = plug.notify_dashboard_entry(monitor.cmdr, monitor.is_beta, entry)
|
||||
if err:
|
||||
self.status['text'] = err
|
||||
if not config.getint('hotkey_mute'):
|
||||
@ -797,7 +797,7 @@ class AppWindow:
|
||||
config.set('geometry', '+{1}+{2}'.format(*self.w.geometry().split('+')))
|
||||
self.w.withdraw() # Following items can take a few seconds, so hide the main window while they happen
|
||||
hotkeymgr.unregister()
|
||||
status.close()
|
||||
dashboard.close()
|
||||
monitor.close()
|
||||
plug.notify_stop()
|
||||
self.eddn.close()
|
||||
|
@ -128,12 +128,12 @@ def journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||
sys.stderr.write("Arrived at {}\n".format(entry['StarSystem']))
|
||||
```
|
||||
|
||||
### Player Status
|
||||
### Player Dashboard
|
||||
|
||||
This gets called periodically - typically about once a second - whith the players live status
|
||||
This gets called when something on the player's cockpit display changes - typically about once a second when in orbital flight
|
||||
|
||||
```python
|
||||
def status(cmdr, is_beta, entry):
|
||||
def dashboard_entry(cmdr, is_beta, entry):
|
||||
deployed = entry['Flags'] & 1<<6
|
||||
sys.stderr.write("Hardpoints {}\n", deployed and "deployed" or "stowed")
|
||||
```
|
||||
@ -154,7 +154,7 @@ The data is a dictionary and full of lots of wonderful stuff!
|
||||
|
||||
## Error messages
|
||||
|
||||
You can display an error in EDMC's status area by returning a string from your `journal_entry()`, `status()` or `cmdr_data()` function, or asynchronously (e.g. from a "worker" thread that is performing a long running operation) by calling `plug.show_error()`. Either method will cause the "bad" sound to be played (unless the user has muted sound).
|
||||
You can display an error in EDMC's status area by returning a string from your `journal_entry()`, `status_entry()` or `cmdr_data()` function, or asynchronously (e.g. from a "worker" thread that is performing a long running operation) by calling `plug.show_error()`. Either method will cause the "bad" sound to be played (unless the user has muted sound).
|
||||
|
||||
The status area is shared between EDMC itself and all other plugins, so your message won't be displayed for very long. Create a dedicated widget if you need to display routine status information.
|
||||
|
||||
|
@ -2,7 +2,7 @@ import json
|
||||
from calendar import timegm
|
||||
from operator import itemgetter
|
||||
from os import listdir, stat
|
||||
from os.path import getmtime, isdir, join
|
||||
from os.path import isdir, join
|
||||
from sys import platform
|
||||
import time
|
||||
|
||||
@ -26,7 +26,7 @@ else:
|
||||
|
||||
|
||||
# Status.json handler
|
||||
class Status(FileSystemEventHandler):
|
||||
class Dashboard(FileSystemEventHandler):
|
||||
|
||||
_POLL = 1 # Fallback polling interval
|
||||
|
||||
@ -55,7 +55,7 @@ class Status(FileSystemEventHandler):
|
||||
# File system events are unreliable/non-existent over network drives on Linux.
|
||||
# We can't easily tell whether a path points to a network drive, so assume
|
||||
# any non-standard logdir might be on a network drive and poll instead.
|
||||
polling = bool(config.get('statusdir')) and platform != 'win32'
|
||||
polling = bool(config.get('journaldir')) and platform != 'win32'
|
||||
if not polling and not self.observer:
|
||||
self.observer = Observer()
|
||||
self.observer.daemon = True
|
||||
@ -68,7 +68,7 @@ class Status(FileSystemEventHandler):
|
||||
self.observed = self.observer.schedule(self, self.currentdir)
|
||||
|
||||
if __debug__:
|
||||
print '%s status "%s"' % (polling and 'Polling' or 'Monitoring', self.currentdir)
|
||||
print '%s Dashboard "%s"' % (polling and 'Polling' or 'Monitoring', self.currentdir)
|
||||
|
||||
# Even if we're not intending to poll, poll at least once to process pre-existing
|
||||
# data and to check whether the watchdog thread has crashed due to events not
|
||||
@ -79,7 +79,7 @@ class Status(FileSystemEventHandler):
|
||||
|
||||
def stop(self):
|
||||
if __debug__:
|
||||
print 'Stopping monitoring Status'
|
||||
print 'Stopping monitoring Dashboard'
|
||||
self.currentdir = None
|
||||
if self.observed:
|
||||
self.observed = None
|
||||
@ -123,9 +123,9 @@ class Status(FileSystemEventHandler):
|
||||
# Status file is shared between beta and live. So filter out status not in this game session.
|
||||
if timegm(time.strptime(entry['timestamp'], '%Y-%m-%dT%H:%M:%SZ')) >= self.session_start and self.status != entry:
|
||||
self.status = entry
|
||||
self.root.event_generate('<<StatusEvent>>', when="tail")
|
||||
self.root.event_generate('<<DashboardEvent>>', when="tail")
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
|
||||
# singleton
|
||||
status = Status()
|
||||
dashboard = Dashboard()
|
4
plug.py
4
plug.py
@ -226,7 +226,7 @@ def notify_journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||
return error
|
||||
|
||||
|
||||
def notify_status(cmdr, is_beta, entry):
|
||||
def notify_dashboard_entry(cmdr, is_beta, entry):
|
||||
"""
|
||||
Send a status entry to each plugin.
|
||||
:param cmdr: The piloting Cmdr name
|
||||
@ -236,7 +236,7 @@ def notify_status(cmdr, is_beta, entry):
|
||||
"""
|
||||
error = None
|
||||
for plugin in PLUGINS:
|
||||
status = plugin._get_func('status')
|
||||
status = plugin._get_func('dashboard_entry')
|
||||
if status:
|
||||
try:
|
||||
# Pass a copy of the status entry in case the callee modifies it
|
||||
|
Loading…
x
Reference in New Issue
Block a user