forked from CMDR-Kiel42/EDMC_SpanshRouter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
load.py
50 lines (41 loc) · 1.82 KB
/
load.py
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
import sys
from SpanshRouter.SpanshRouter import SpanshRouter
import tkinter.messagebox as confirmDialog
spansh_router = None
def plugin_start3(plugin_dir):
return plugin_start(plugin_dir)
def plugin_start(plugin_dir):
global spansh_router
spansh_router = SpanshRouter(plugin_dir)
spansh_router.check_for_update()
return 'SpanshRouter'
def plugin_stop():
global spansh_router
spansh_router.save_route()
if spansh_router.update_available:
spansh_router.install_update()
def journal_entry(cmdr, is_beta, system, station, entry, state):
global spansh_router
if ( entry['event'] in ['FSDJump', 'Location', 'SupercruiseEntry', 'SupercruiseExit']
and entry["StarSystem"].lower() == spansh_router.next_stop.lower()):
spansh_router.update_route()
spansh_router.set_source_ac(entry["StarSystem"])
elif entry['event'] == 'FSSDiscoveryScan' and entry['SystemName'] == spansh_router.next_stop:
spansh_router.update_route()
def ask_for_update():
global spansh_router
if spansh_router.update_available:
update_txt = "New Spansh Router update available!\n"
update_txt += "If you choose to install it, you will have to restart EDMC for it to take effect.\n\n"
update_txt += spansh_router.spansh_updater.changelogs
update_txt += "\n\nInstall?"
install_update = confirmDialog.askyesno("SpanshRouter", update_txt)
if install_update:
confirmDialog.showinfo("SpanshRouter", "The update will be installed as soon as you quit EDMC.")
else:
spansh_router.update_available = False
def plugin_app(parent):
global spansh_router
spansh_router.init_gui(parent)
spansh_router.open_last_route()
parent.master.after_idle(ask_for_update)