CarrierJump missing workaround refactor

This commit is contained in:
norohind 2022-09-18 01:56:25 +03:00
parent 9e79815fba
commit e47ba96e71
Signed by: norohind
GPG Key ID: 01C3BECC26FB59E1

14
load.py
View File

@ -3,7 +3,6 @@ import functools
import json import json
import logging import logging
import os import os
import sys
import threading import threading
import tkinter as tk import tkinter as tk
from tkinter import ttk from tkinter import ttk
@ -32,7 +31,6 @@ class This:
For holding global variables For holding global variables
""" """
music_flag_1: bool = False
webhooks_overrided_name: tk.StringVar webhooks_overrided_name: tk.StringVar
webhooks_urls: list[tk.StringVar] webhooks_urls: list[tk.StringVar]
@ -290,19 +288,23 @@ def journal_entry_decorator(func: callable) -> callable:
The decorator aimed to solve problem with missing CarrierJump event. The decorator aimed to solve problem with missing CarrierJump event.
""" """
music_flag_1 = False
@functools.wraps(func) @functools.wraps(func)
def decorated(cmdr, is_beta, system, station, entry, state): def decorated(cmdr, is_beta, system, station, entry, state):
nonlocal music_flag_1
event: str = entry['event'] event: str = entry['event']
if event == 'Music' and entry.get('MusicTrack') == 'NoInGameMusic': if event == 'Music' and entry.get('MusicTrack') == 'NoInGameMusic':
this.music_flag_1 = True music_flag_1 = True
elif event == 'Location' and this.music_flag_1: elif event == 'Location' and music_flag_1:
entry['event'] = 'CarrierJump' entry['event'] = 'CarrierJump'
this.music_flag_1 = False music_flag_1 = False
logger.info(f'Generating synthetic CarrierJump') logger.info(f'Generating synthetic CarrierJump')
elif event.lower() == 'shutdown' or event in ('Location', 'LoadGame', 'CarrierJump'): elif event.lower() == 'shutdown' or event in ('Location', 'LoadGame', 'CarrierJump'):
this.music_flag_1 = False music_flag_1 = False
return func(cmdr, is_beta, system, station, entry, state) return func(cmdr, is_beta, system, station, entry, state)