mirror of
https://github.com/norohind/EDMC_SpanshRouter.git
synced 2025-06-13 13:52:15 +03:00
Save the version to skip
This commit is contained in:
parent
2d4cc88073
commit
602df9123b
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
offset
|
offset
|
||||||
|
savestate
|
||||||
|
@ -25,6 +25,8 @@ class SpanshUpdater():
|
|||||||
self.update_popup = UpdatePopup(self)
|
self.update_popup = UpdatePopup(self)
|
||||||
self.update_popup.withdraw()
|
self.update_popup.withdraw()
|
||||||
self.update_available = False
|
self.update_available = False
|
||||||
|
self.skip_update = tk.BooleanVar(False)
|
||||||
|
self.savestate_filepath = os.path.join(plugin_dir, 'savestate')
|
||||||
|
|
||||||
def download_zip(self):
|
def download_zip(self):
|
||||||
url = 'https://github.com/CMDR-Kiel42/EDMC_SpanshRouter/releases/download/v' + self.latest_version + '/' + self.zip_name
|
url = 'https://github.com/CMDR-Kiel42/EDMC_SpanshRouter/releases/download/v' + self.latest_version + '/' + self.zip_name
|
||||||
@ -118,6 +120,18 @@ class SpanshUpdater():
|
|||||||
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
||||||
sys.stderr.write(''.join('!! ' + line for line in lines))
|
sys.stderr.write(''.join('!! ' + line for line in lines))
|
||||||
|
|
||||||
|
def save_skip_update(self):
|
||||||
|
file_content = {}
|
||||||
|
try:
|
||||||
|
with open(self.savestate_filepath, 'r') as savestate_fh:
|
||||||
|
file_content = json.loads(savestate_fh)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
file_content["SkipUpdate"] = self.latest_version
|
||||||
|
with open(self.savestate_filepath, 'w') as savestate_fh:
|
||||||
|
savestate_fh.write(json.dumps(file_content))
|
||||||
|
|
||||||
|
|
||||||
class UpdatePopup(tk.Toplevel):
|
class UpdatePopup(tk.Toplevel):
|
||||||
def __init__(self, sp_updater):
|
def __init__(self, sp_updater):
|
||||||
@ -129,8 +143,10 @@ class UpdatePopup(tk.Toplevel):
|
|||||||
self.geometry("%dx%d+%d+%d" % (width, height, x, y))
|
self.geometry("%dx%d+%d+%d" % (width, height, x, y))
|
||||||
self.attributes("-topmost", True)
|
self.attributes("-topmost", True)
|
||||||
self.title("SpanshRouter - Update available")
|
self.title("SpanshRouter - Update available")
|
||||||
|
self.protocol("WM_DELETE_WINDOW", self.click_cancel)
|
||||||
self.text_field = ScrolledText.ScrolledText(self, wrap="word", height=10)
|
self.text_field = ScrolledText.ScrolledText(self, wrap="word", height=10)
|
||||||
self.text_field.tag_configure("title", font=tkfont.Font(weight="bold", size=14), justify=tk.CENTER)
|
self.text_field.tag_configure("title", font=tkfont.Font(weight="bold", size=14), justify=tk.CENTER)
|
||||||
|
self.skip_install_var = tk.BooleanVar()
|
||||||
|
|
||||||
for line in sp_updater.changelogs.splitlines():
|
for line in sp_updater.changelogs.splitlines():
|
||||||
if line.startswith("## "):
|
if line.startswith("## "):
|
||||||
@ -139,7 +155,7 @@ class UpdatePopup(tk.Toplevel):
|
|||||||
else:
|
else:
|
||||||
self.text_field.insert(tk.END, line + "\n")
|
self.text_field.insert(tk.END, line + "\n")
|
||||||
|
|
||||||
self.skip_install_checkbox = tk.Checkbutton(self, text="Do not warn me about this version anymore")
|
self.skip_install_checkbox = tk.Checkbutton(self, text="Do not warn me about this version anymore", variable=self.skip_install_var, selectcolor="black")
|
||||||
self.install_button = tk.Button(self, text="Install", command=self.click_install)
|
self.install_button = tk.Button(self, text="Install", command=self.click_install)
|
||||||
self.cancel_button = tk.Button(self, text="Cancel", command=self.click_cancel)
|
self.cancel_button = tk.Button(self, text="Cancel", command=self.click_cancel)
|
||||||
|
|
||||||
@ -156,4 +172,5 @@ class UpdatePopup(tk.Toplevel):
|
|||||||
|
|
||||||
def click_cancel(self):
|
def click_cancel(self):
|
||||||
self.sp_updater.update_available = False
|
self.sp_updater.update_available = False
|
||||||
|
self.sp_updater.skip_update = self.skip_install_var
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
2
load.py
2
load.py
@ -22,6 +22,8 @@ def plugin_stop():
|
|||||||
|
|
||||||
if sp_updater.update_available:
|
if sp_updater.update_available:
|
||||||
sp_updater.install()
|
sp_updater.install()
|
||||||
|
elif sp_updater.skip_update.get():
|
||||||
|
sp_updater.save_skip_update()
|
||||||
|
|
||||||
def journal_entry(cmdr, is_beta, system, station, entry, state):
|
def journal_entry(cmdr, is_beta, system, station, entry, state):
|
||||||
global spansh_router
|
global spansh_router
|
||||||
|
Loading…
x
Reference in New Issue
Block a user