Skip to content

Commit

Permalink
Update for compatibility with latest EDMC
Browse files Browse the repository at this point in the history
- Replaced ship_map with ship_name_map

- Replaced config.get with config.get_str

- Added a text indicator to tell you to refuel when following an exact route in neutron navigator.
  • Loading branch information
WaferMouse committed May 13, 2021
1 parent c5336bf commit 50e6a20
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 36 deletions.
6 changes: 3 additions & 3 deletions chat_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def __init__(self, parent, *args, **options):
"""
Create a TK widget for the EDMC main window
"""
self.theme = config.getint('theme')
self.fg = config.get('dark_text') if self.theme else 'black'
self.hl = config.get('dark_highlight') if self.theme else 'blue'
self.theme = config.get_int('theme')
self.fg = config.get_str('dark_text') if self.theme else 'black'
self.hl = config.get_str('dark_highlight') if self.theme else 'blue'
self.bg = 'grey4' if self.theme else None
self.status = tk.Text(self, bg = self.bg)
self.chatcopy = tk.Button(self, text = "Copy", command = self.copy_button3)
Expand Down
16 changes: 10 additions & 6 deletions fleet_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

from os import path

from companion import ship_map
from edmc_data import ship_name_map

ship_map = ship_name_map.copy()

#from companion import ship_map

from special_frames import *

Expand Down Expand Up @@ -68,10 +72,10 @@ def update_ship(self, ship_data, cmdr):
self.system_link.set_system(self.sysname)
self.station_link.set_station(self.sysname, self.stationname, self.market_id)
edID = FLAT_SHIPS[self.ship_data['name'].lower()]['edID']
if config.get('L3_shipyard_provider') == 'Inara':
if config.get_str('L3_shipyard_provider') == 'Inara':
self.ship_url = ship_data["shipInaraURL"]
else:
self.ship_url = "https://www.edsm.net/en/user/fleet/id/{}/cmdr/{}/ship/sId/{}/sType/{}".format(config.get('EDSM_id'), urllib.parse.quote_plus(self.cmdr), self.ship_data['id'], edID)
self.ship_url = "https://www.edsm.net/en/user/fleet/id/{}/cmdr/{}/ship/sId/{}/sType/{}".format(config.get_str('EDSM_id'), urllib.parse.quote_plus(self.cmdr), self.ship_data['id'], edID)
# https://inara.cz/cmdr-fleet/
self.ship_link.configure(url = self.ship_url, text = self.ship_lbl_txt)
#self.station_link.configure(url = self.station_url, text = self.stationname)
Expand Down Expand Up @@ -103,9 +107,9 @@ class FleetMonitor(WaferModule):

def __init__(self, parent, *args, **options):
WaferModule.__init__(self, parent, *args, **options)
self.theme = config.getint('theme')
self.fg = config.get('dark_text') if self.theme else 'black'
self.hl = config.get('dark_highlight') if self.theme else 'blue'
self.theme = config.get_int('theme')
self.fg = config.get_str('dark_text') if self.theme else 'black'
self.hl = config.get_str('dark_highlight') if self.theme else 'blue'
self.bg = 'grey4' if self.theme else None
self.ships = {}
self.bigjsonships = {}
Expand Down
9 changes: 3 additions & 6 deletions fsd_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import pickle
import sys

theme = config.getint('theme')
fg = config.get('dark_text') if theme else 'black'
hl = config.get('dark_highlight') if theme else 'blue'
theme = config.get_int('theme')
fg = config.get_str('dark_text') if theme else 'black'
hl = config.get_str('dark_highlight') if theme else 'blue'
bg = 'grey4' if theme else None

# https://www.edsm.net/api-v1/system?systemName=Shinrarta%20Dezhra&showCoordinates=1&showInformation=1&showPermit=1&showPrimaryStar=1
Expand All @@ -39,9 +39,6 @@
this.edsm_session = None
this.edsm_data = None

with open(join(config.respath, 'systems.p'), 'rb') as h:
this.system_ids = pickle.load(h)

def test_stuff():
o = 'Shinrarta Dezhra'
# disassembled = urlparse(o)
Expand Down
22 changes: 11 additions & 11 deletions load.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,19 @@ def plugin_start3(plugin_dir):
Load this plugin into EDMC
"""
try:
config.get('L3_shipyard_provider')
config.get_str('L3_shipyard_provider')
except:
config.set('L3_shipyard_provider','EDSM')
try:
config.get('L3_system_provider')
config.get_str('L3_system_provider')
except:
config.set('L3_system_provider','none')
try:
config.get('L3_station_provider')
config.get_str('L3_station_provider')
except:
config.set('L3_station_provider','none')
try:
config.get('EDSM_id')
config.get_str('EDSM_id')
except:
config.set('EDSM_id', '')
print("L3-37 started")
Expand All @@ -105,9 +105,9 @@ def plugin_app(parent):
]
plugin_app.wafer_modules = {}
plugin_app.frame = FakeNotebook(parent, text = 'L3-37')
plugin_app.theme = config.getint('theme')
plugin_app.fg = config.get('dark_text') if plugin_app.theme else 'black'
plugin_app.hl = config.get('dark_highlight') if plugin_app.theme else 'blue'
plugin_app.theme = config.get_int('theme')
plugin_app.fg = config.get_str('dark_text') if plugin_app.theme else 'black'
plugin_app.hl = config.get_str('dark_highlight') if plugin_app.theme else 'blue'
plugin_app.bg = 'grey4' if plugin_app.theme else None
for module in plugin_app.wafer_module_classes:
plugin_app.wafer_modules[module[0]] = module[1](plugin_app.frame, highlightbackground=plugin_app.fg, highlightcolor=plugin_app.fg, highlightthickness = 1)#, relief = tk.SUNKEN, borderwidth = 1)
Expand Down Expand Up @@ -135,7 +135,7 @@ def plugin_prefs(parent, cmdr, is_beta):
row = row + 1
b.grid_configure(pady = 2)
try:
this.system_provider_select.set(config.get('L3_system_provider'))
this.system_provider_select.set(config.get_str('L3_system_provider'))
except:
this.system_provider_select.set("none")
system_frame.grid(sticky = "nsew")
Expand All @@ -146,7 +146,7 @@ def plugin_prefs(parent, cmdr, is_beta):
row = row + 1
this.station_provider_select = tk.StringVar()
try:
this.station_provider_select.set(config.get('L3_station_provider'))
this.station_provider_select.set(config.get_str('L3_station_provider'))
except:
this.station_provider_select.set("none")
for mode in service_providers:
Expand All @@ -161,7 +161,7 @@ def plugin_prefs(parent, cmdr, is_beta):
shipyard_provider_label.grid(column = 2, row = 0, pady = 2)
this.shipyard_provider_select = tk.StringVar()
try:
this.shipyard_provider_select.set(config.get('L3_shipyard_provider'))
this.shipyard_provider_select.set(config.get_str('L3_shipyard_provider'))
except:
this.shipyard_provider_select.set("EDSM")
modes = ['EDSM','Inara']
Expand All @@ -177,7 +177,7 @@ def plugin_prefs(parent, cmdr, is_beta):
this.EDSM_id_entry.grid(column = 3, row = 2)
try:
this.EDSM_id_entry.delete(0, tk.END)
this.EDSM_id_entry.insert(0, config.get('EDSM_id'))
this.EDSM_id_entry.insert(0, config.get_str('EDSM_id'))
except:
pass
shipyard_frame.grid(column = 1, row = 1, sticky = "nsew")
Expand Down
6 changes: 3 additions & 3 deletions mats_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ class MatsHelper(WaferModule):
def __init__(self, parent, *args, **options):
WaferModule.__init__(self, parent, *args, **options)
self.parent = parent
self.theme = config.getint('theme')
self.fg = config.get('dark_text') if self.theme else 'black'
self.hl = config.get('dark_highlight') if self.theme else 'blue'
self.theme = config.get_int('theme')
self.fg = config.get_str('dark_text') if self.theme else 'black'
self.hl = config.get_str('dark_highlight') if self.theme else 'blue'
self.bg = 'grey4' if self.theme else None
for cat in materials:
for i in materials[cat]:
Expand Down
11 changes: 8 additions & 3 deletions neutron_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
with open(path.join(plugin_path,'flat_ships.json')) as json_data:
FLAT_SHIPS = json.load(json_data)

theme = config.getint('theme')
theme_fg = config.get('dark_text') if theme else 'black'
theme_hl = config.get('dark_highlight') if theme else 'blue'
theme = config.get_int('theme')
theme_fg = config.get_str('dark_text') if theme else 'black'
theme_hl = config.get_str('dark_highlight') if theme else 'blue'
theme_bg = 'grey4' if theme else None

def getclipboard():
Expand Down Expand Up @@ -361,6 +361,10 @@ def process_route(self):
is_neutron = i['neutron_star']
self.dyn_widgets.append(SystemFrame(self.details_scroll.interior, name, is_neutron = is_neutron))
self.dyn_widgets[-1].grid(row = widget_row*4, column = 1, sticky = 'nsew', rowspan = 2)
try:
must_refuel = i['must_refuel']
except:
must_refuel = False
try:
if is_exact:
jumps = 1
Expand All @@ -370,6 +374,7 @@ def process_route(self):
jump_text = '1 neutron jump{}.'.format(['', ' and {} other{}'.format(str(jumps - 1),['', 's'][jumps != 2])][jumps > 1])
else:
jump_text = '{} jump{}.'.format(jumps, ['', 's'][jumps != 1])
jump_text = '{}{}'.format(['', 'REFUEL -> '][must_refuel], jump_text)
self.jump_widgets.append(tk.Label(self.details_scroll.interior, text = jump_text, anchor = tk.E))
if theme:
self.jump_widgets[-1].config(bg = theme_bg, fg = theme_fg)
Expand Down
8 changes: 4 additions & 4 deletions web_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

def get_system_url(system_name, provider = None):
if not provider:
provider = config.get('L3_system_provider')
provider = config.get_str('L3_system_provider')
if provider == 'none':
provider = config.get('system_provider')
provider = config.get_str('system_provider')
if provider == 'eddb':
return('https://eddb.io/system/name/' + urllib.parse.quote_plus(system_name))
elif provider == 'Inara':
Expand All @@ -18,9 +18,9 @@ def get_nearest_url(system_name):

def get_station_url(system_name, station_name, provider = None, market_id = None):
if not provider:
provider = config.get('L3_station_provider')
provider = config.get_str('L3_station_provider')
if provider == 'none':
provider = config.get('station_provider')
provider = config.get_str('station_provider')
if provider == 'eddb':
if market_id:
return('https://eddb.io/station/market-id/' + urllib.parse.quote_plus(str(market_id)))
Expand Down

0 comments on commit 50e6a20

Please sign in to comment.