mirror of
https://github.com/norohind/EDMC_SpanshRouter.git
synced 2025-04-19 18:47:36 +03:00
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
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 'spansh_router'
|
|
|
|
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"] == spansh_router.next_stop:
|
|
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)
|