Skip to content

Commit

Permalink
Limit all lines to 100 or less characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Numerlor committed Jul 15, 2019
1 parent ba66a4a commit 2ce46b9
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 60 deletions.
73 changes: 48 additions & 25 deletions MainWindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,14 @@ def licenses_pop(self):
w.setup()

def update_jumps(self, index):
total_jumps = sum(int(self.MainTable.item(i, 3).text()) for i in range(self.MainTable.rowCount()))
total_jumps = sum(
int(self.MainTable.item(i, 3).text()) for i in range(self.MainTable.rowCount()))
if total_jumps != 0:
remaining_jumps = sum(
int(self.MainTable.item(i, 3).text()) for i in range(index, self.MainTable.rowCount()))
self.MainTable.horizontalHeaderItem(3).setText(f"Jumps {remaining_jumps}/{total_jumps}")
int(self.MainTable.item(i, 3).text()) for i in
range(index, self.MainTable.rowCount()))
self.MainTable.horizontalHeaderItem(3).setText(
f"Jumps {remaining_jumps}/{total_jumps}")
self.MainTable.resizeColumnToContents(3)
else:
self.MainTable.horizontalHeaderItem(3).setText("Jumps")
Expand Down Expand Up @@ -357,9 +360,13 @@ def write_default_settings(self):
self.resize(800, 600)
self.move(300, 300)
self.settings.setValue("paths/journal",
f"{os.environ['userprofile']}/Saved Games/Frontier Developments/Elite Dangerous/")
self.jpath = f"{os.environ['userprofile']}/Saved Games/Frontier Developments/Elite Dangerous/"
self.settings.setValue("paths/ahk", os.environ['PROGRAMW6432'] + "\\AutoHotkey\\AutoHotkey.exe")
(f"{os.environ['userprofile']}/Saved Games/"
f"Frontier Developments/Elite Dangerous/"))
self.jpath = (f"{os.environ['userprofile']}/Saved Games/"
f"Frontier Developments/Elite Dangerous/")
self.settings.setValue("paths/ahk",
(f"{os.environ['PROGRAMW6432']}/"
f"AutoHotkey/AutoHotkey.exe"))
self.settings.setValue("save_on_quit", True)
self.settings.setValue("paths/csv", "")
self.settings.setValue("window/size", QtCore.QSize(800, 600))
Expand All @@ -375,7 +382,8 @@ def write_default_settings(self):
"send, {Numpad7}\n"
"; wait for map to open\n"
"sleep, 850\n"
";navigate to second map tab and focus on search field\n"
";navigate to second map tab "
"and focus on search field\n"
"send, e\n"
"send, {Space}\n"
"ClipOld := ClipboardAll\n"
Expand All @@ -394,10 +402,12 @@ def write_ahk_path(self):
try:
open(self.settings.value("paths/ahk")).close()
except FileNotFoundError:
ahk_path = QtWidgets.QFileDialog.getOpenFileName(filter="AutoHotKey (AutoHotKey*.exe)",
caption="Select AutoHotkey's executable "
"if you wish to use it, cancel for copy mode",
directory="C:/")
ahk_path = QtWidgets.QFileDialog.getOpenFileName(
filter="AutoHotKey (AutoHotKey*.exe)",
caption="Select AutoHotkey's executable "
"if you wish to use it, cancel for copy mode",
directory="C:/")

if len(ahk_path[0]) == 0:
self.settings.setValue("copy_mode", True)
self.settings.setValue("paths/AHK", "")
Expand Down Expand Up @@ -470,7 +480,8 @@ def setupUi(self):
self.path_button.setMaximumWidth(95)
if len(self.cpath) > 0:
self.cs_submit.setEnabled(True)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred,
QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHeightForWidth(self.cs_comb.sizePolicy().hasHeightForWidth())
self.cs_comb.setSizePolicy(sizePolicy)
self.cs_comb.setMaximumWidth(95)
Expand All @@ -481,14 +492,16 @@ def setupUi(self):
self.path_button.pressed.connect(self.change_path)

self.horizontalLayout.addWidget(self.path_button, alignment=QtCore.Qt.AlignLeft)
spacerItem = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
spacerItem = QtWidgets.QSpacerItem(30, 20, QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.gridLayout_2.addLayout(self.horizontalLayout, 2, 0, 1, 1)
self.horizontalLayout_2.addWidget(self.cs_comb, alignment=QtCore.Qt.AlignLeft)
self.horizontalLayout_2.addWidget(self.cs_submit, alignment=QtCore.Qt.AlignRight)
self.gridLayout_2.addLayout(self.horizontalLayout_2, 4, 0, 1, 1)
self.gridLayout_2.addWidget(self.path_label, 1, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum,
QtWidgets.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem1, 3, 0, 1, 1)

# Spansh
Expand Down Expand Up @@ -517,7 +530,8 @@ def setupUi(self):
self.gridLayout_4.addWidget(self.range, 2, 0, 1, 1)
self.gridLayout_4.addWidget(self.source, 0, 0, 1, 1)
self.gridLayout_4.addWidget(self.nearest, 5, 1, 1, 1)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum,
QtWidgets.QSizePolicy.Expanding)
self.gridLayout_4.addItem(spacerItem2, 6, 0, 1, 1)
self.gridLayout_4.addWidget(self.eff_spinbox, 5, 0, 1, 1)
self.gridLayout_4.addWidget(self.sp_submit, 7, 1, 1, 1)
Expand Down Expand Up @@ -566,7 +580,8 @@ def button_on_filled_fields(self):

def change_path(self):
file_dialog = QtWidgets.QFileDialog()
fpath = file_dialog.getOpenFileName(filter="csv (*.csv)", directory=self.cpath[:self.cpath.rfind("/")])
fpath = file_dialog.getOpenFileName(filter="csv (*.csv)",
directory=self.cpath[:self.cpath.rfind("/")])
if len(fpath[0]) > 0:
self.cpath = fpath[0]
self.path_label.setText("Current path: " + fpath[0])
Expand All @@ -579,8 +594,9 @@ def change_path(self):

def get_journals(self):
try:
self.journals = sorted([self.jpath + file for file in os.listdir(self.jpath) if file.endswith(".log")],
key=os.path.getctime, reverse=True)
self.journals = sorted(
[self.jpath + file for file in os.listdir(self.jpath) if file.endswith(".log")],
key=os.path.getctime, reverse=True)
except FileNotFoundError:
d = popups.QuitDialog(self, "Journal folder not detected")
d.setupUi()
Expand All @@ -606,8 +622,10 @@ def update_source(self, index):
with open(self.journals[index], encoding='utf-8') as f:
lines = [json.loads(line) for line in f]
try:
self.source.setText(next(lines[i]['StarSystem'] for i in range(len(lines) - 1, -1, -1)
if lines[i]['event'] == "FSDJump" or lines[i]['event'] == "Location"))
self.source.setText(next(lines[i]['StarSystem'] for i
in range(len(lines) - 1, -1, -1)
if lines[i]['event'] == "FSDJump"
or lines[i]['event'] == "Location"))
except StopIteration:
self.source.clear()

Expand All @@ -616,7 +634,8 @@ def current_range(self, index):
lines = [json.loads(line) for line in f]
try:
self.ran_spinbox.setValue(next(round(float(lines[i]['MaxJumpRange']), 2)
for i in range(len(lines) - 1, -1, -1) if lines[i]['event'] == "Loadout"))
for i in range(len(lines) - 1, -1, -1)
if lines[i]['event'] == "Loadout"))
except StopIteration:
self.ran_spinbox.setValue(50)

Expand All @@ -629,8 +648,10 @@ def check_dropped_files(self):
self.cs_submit_act(files[0])

def sp_submit_act(self):
self.plotter = workers.SpanshPlot(self.eff_spinbox.value(), self.ran_spinbox.value(),
self.source.text(), self.destination.text(), self)
self.plotter = workers.SpanshPlot(self.eff_spinbox.value(),
self.ran_spinbox.value(),
self.source.text(),
self.destination.text(), self)
self.plotter.status_signal.connect(self.change_status)
self.plotter.finished_signal.connect(self.sp_finish_act)
self.plotter.start()
Expand Down Expand Up @@ -688,10 +709,12 @@ def last_submit_act(self):
self.last_submit.setEnabled(True)
else:
if last_route[0] == len(last_route[1]):
self.data_signal.emit(self.journals[self.last_comb.currentIndex()], last_route[1], 1)
self.data_signal.emit(self.journals[self.last_comb.currentIndex()],
last_route[1], 1)
self.close()
else:
self.data_signal.emit(self.journals[self.last_comb.currentIndex()], last_route[1], last_route[0])
self.data_signal.emit(self.journals[self.last_comb.currentIndex()],
last_route[1], last_route[0])
self.close()

def show_nearest(self):
Expand Down
76 changes: 50 additions & 26 deletions popups.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@


class Nearest(QtWidgets.QDialog):
closed_signal = QtCore.pyqtSignal() # signal sent when window is closed
destination_signal = QtCore.pyqtSignal(str) # signal containing destination to input into destination line edit
# signal sent when window is closed
closed_signal = QtCore.pyqtSignal()
# signal containing destination to input into destination line edit
destination_signal = QtCore.pyqtSignal(str)

# lightly modified auto generated
def __init__(self, parent):
Expand Down Expand Up @@ -46,7 +48,8 @@ def setupUi(self):
self.resize(207, 191)
self.main_layout.setContentsMargins(2, 2, 20, 2)
self.main_layout.setSpacing(2)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy = QtWidgets.QSizePolicy(
QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.main_layout_frame.sizePolicy().hasHeightForWidth())
Expand Down Expand Up @@ -116,15 +119,19 @@ def setupUi(self):
self.show()

def ena_button(self):
if len(self.x_edit.text()) != 0 and len(self.y_edit.text()) != 0 and len(self.z_edit.text()) != 0:
if (len(self.x_edit.text()) != 0
and len(self.y_edit.text()) != 0
and len(self.z_edit.text()) != 0):
self.get_button.setEnabled(True)
else:
self.get_button.setEnabled(False)

def get_nearest(self):
self.nearest_worker = workers.NearestRequest("https://spansh.co.uk/api/nearest",
f"x={self.x_edit.text()}&y={self.y_edit.text()}"
f"&z={self.z_edit.text()}", self)
f"x={self.x_edit.text()}"
f"&y={self.y_edit.text()}"
f"&z={self.z_edit.text()}"
, self)
self.nearest_worker.finished_signal.connect(self.nearest_finished)
self.nearest_worker.status_signal.connect(self.change_status)
self.nearest_worker.start()
Expand Down Expand Up @@ -164,7 +171,7 @@ class GameShutPop(QtWidgets.QDialog):
close_signal = QtCore.pyqtSignal()

def __init__(self, parent, settings, route, index):
super(QtWidgets.QDialog, self).__init__(parent)
super(GameShutPop, self).__init__(parent)
self.verticalLayout = QtWidgets.QVBoxLayout(self)
self.label = QtWidgets.QLabel(self)
self.horizontalLayout = QtWidgets.QHBoxLayout()
Expand All @@ -188,7 +195,9 @@ def setupUi(self):

self.jour_ver.addWidget(self.pushButton, alignment=QtCore.Qt.AlignLeft)
self.jour_ver.addWidget(self.comboBox, alignment=QtCore.Qt.AlignCenter)
self.jour_ver.addSpacerItem(QtWidgets.QSpacerItem(1, 1, QtWidgets.QSizePolicy.MinimumExpanding))
self.jour_ver.addSpacerItem(QtWidgets.QSpacerItem(
1, 1,
QtWidgets.QSizePolicy.MinimumExpanding))

self.save_quit_lay.addWidget(self.save_button, alignment=QtCore.Qt.AlignRight)
self.save_quit_lay.addWidget(self.pushButton_2, alignment=QtCore.Qt.AlignRight)
Expand All @@ -197,9 +206,11 @@ def setupUi(self):
self.horizontalLayout.addLayout(self.save_quit_lay)

self.verticalLayout.addWidget(self.label, alignment=QtCore.Qt.AlignCenter)
self.verticalLayout.addSpacerItem(QtWidgets.QSpacerItem(1, 1
, QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.MinimumExpanding))
self.verticalLayout.addSpacerItem(QtWidgets.QSpacerItem(
1, 1,
QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.MinimumExpanding))

self.verticalLayout.setContentsMargins(6, 20, 6, 6)
self.verticalLayout.addLayout(self.horizontalLayout)

Expand All @@ -225,10 +236,14 @@ def save_route(self):

def populate_combo(self):
self.comboBox.addItems(["Last journal", "Second to last",
"Third to last"][:len([file for file in listdir(self.jpath) if file.endswith(".log")])])
"Third to last"][:len([file for file
in listdir(self.jpath)
if file.endswith(".log")])])

def load_journal(self):
journals = sorted([self.jpath + file for file in listdir(self.jpath) if file.endswith(".log")],
journals = sorted([self.jpath + file for file
in listdir(self.jpath)
if file.endswith(".log")],
key=getctime, reverse=True)
self.worker_signal.emit(journals[self.comboBox.currentIndex()], self.route, self.index)
self.hide()
Expand Down Expand Up @@ -273,7 +288,8 @@ def setupUi(self):
self.bold_check.setText("Bold")
self.pushButton.setText("Save settings")
self.main_bind_edit.setToolTip(
"Bind to trigger the script, # for win key, ! for alt, ^ for control, + for shift")
"Bind to trigger the script, # for win key, "
"! for alt, ^ for control, + for shift")
self.save_on_quit.setText("Save route on window close")
self.copy_check.setText("Copy mode")
self.ahk_button.setText("AHK Path")
Expand Down Expand Up @@ -307,17 +323,20 @@ def setupUi(self):
self.show()

def ahk_dialog(self):
ahk_path = QtWidgets.QFileDialog.getOpenFileName(filter="AutoHotKey (AutoHotKey*.exe)",
caption="Select AutoHotkey's executable",
directory="C:/")
ahk_path = QtWidgets.QFileDialog.getOpenFileName(
filter="AutoHotKey (AutoHotKey*.exe)",
caption="Select AutoHotkey's executable",
directory="C:/")

if len(ahk_path[0]) != 0:
self.settings.setValue("paths/AHK", ahk_path[0])
self.copy_check.setDisabled(False)
self.settings.sync()

def save_settings(self):
values = [self.main_bind_edit.text(), self.script_edit.toPlainText(), self.dark_check.isChecked(),
self.font_combo.currentFont(), self.font_size_combo.value(), self.bold_check.isChecked(),
values = [self.main_bind_edit.text(), self.script_edit.toPlainText(),
self.dark_check.isChecked(), self.font_combo.currentFont(),
self.font_size_combo.value(), self.bold_check.isChecked(),
self.save_on_quit.isChecked(), self.copy_check.isChecked()]

if "|SYSTEMDATA|" not in values[1]:
Expand Down Expand Up @@ -380,14 +399,18 @@ def setup(self):
self.setLayout(self.main_layout)
self.main_layout.setContentsMargins(7, 20, 7, 10)
self.main_layout.addWidget(self.label, alignment=QtCore.Qt.AlignCenter)
self.main_layout.addSpacerItem(QtWidgets.QSpacerItem(1, 1
, QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.MinimumExpanding))
self.main_layout.addSpacerItem(QtWidgets.QSpacerItem(
1, 1,
QtWidgets.QSizePolicy.Fixed,
QtWidgets.QSizePolicy.MinimumExpanding))

self.main_layout.addLayout(self.button_layout)
self.button_layout.addWidget(self.new_route_button)
self.button_layout.addSpacerItem(QtWidgets.QSpacerItem(1, 1
, QtWidgets.QSizePolicy.MinimumExpanding,
QtWidgets.QSizePolicy.Fixed))
self.button_layout.addSpacerItem(QtWidgets.QSpacerItem(
1, 1,
QtWidgets.QSizePolicy.MinimumExpanding,
QtWidgets.QSizePolicy.Fixed))

self.button_layout.addWidget(self.quit_button)

self.quit_button.pressed.connect(sys.exit)
Expand Down Expand Up @@ -420,7 +443,8 @@ def setup(self):
self.text.setText("Auto Neutron Copyright (C) 2019 Numerlor\n"
"This program comes with ABSOLUTELY NO WARRANTY.\n"
"This is free software, and you are welcome to redistribute it")
self.text.append('under certain conditions; <a href="https://www.gnu.org/licenses/">click here</a> for details')
self.text.append('under certain conditions; <a href="https://www'
'.gnu.org/licenses/">click here</a> for details')
self.main_layout.addWidget(self.text)
self.text.setOpenExternalLinks(True)
self.setLayout(self.main_layout)
Expand Down
Loading

0 comments on commit 2ce46b9

Please sign in to comment.