Skip to content

Commit

Permalink
Merge branch 'STOCD:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraust authored Sep 2, 2024
2 parents ceedbeb + 21c70cf commit 6febad2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 17 deletions.
16 changes: 10 additions & 6 deletions OSCRUI/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
from PySide6.QtWidgets import QSpacerItem, QTabWidget, QTableView
from PySide6.QtWidgets import QVBoxLayout, QHBoxLayout, QGridLayout
from PySide6.QtCore import QSize, QSettings, QTimer
from PySide6.QtGui import QFontDatabase, QIntValidator
from PySide6.QtGui import QFontDatabase, QIntValidator, QKeySequence, QShortcut

from .headers import init_header_trans, get_table_headers, get_tree_headers, get_heal_tree_headers, get_live_table_headers
from .headers import (
init_header_trans, get_table_headers, get_tree_headers, get_heal_tree_headers,
get_live_table_headers)
from .translation import init_translation

from .leagueconnector import OSCRClient
Expand All @@ -30,9 +32,10 @@ class OSCRUI():
set_parser_opacity_setting, set_graph_resolution_setting, set_sto_logpath_setting,
set_ui_scale_setting, switch_analysis_tab, switch_main_tab, switch_map_tab,
switch_overview_tab)
from .datafunctions import analyze_log_callback, copy_analysis_callback
from .datafunctions import copy_summary_callback, init_parser, update_shown_columns_dmg
from .datafunctions import update_shown_columns_heal
from .datafunctions import (
analyze_log_callback, copy_analysis_callback, copy_analysis_table_callback,
copy_summary_callback, init_parser, update_shown_columns_dmg,
update_shown_columns_heal)
from .displayer import create_legend_item
from .iofunctions import browse_path
from .style import get_style_class, create_style_sheet, theme_font, get_style
Expand All @@ -59,7 +62,6 @@ class OSCRUI():

league_api: OSCRClient


def __init__(self, theme, args, path, config, versions) -> None:
"""
Creates new Instance of OSCR.
Expand Down Expand Up @@ -87,6 +89,8 @@ def __init__(self, theme, args, path, config, versions) -> None:

reset_temp_folder(self.config['templog_folder_path'])
self.app, self.window = self.create_main_window()
self.copy_shortcut = QShortcut(
QKeySequence.StandardKey.Copy, self.window, self.copy_analysis_table_callback)
self.init_parser()
self.cache_assets()
self.setup_main_layout()
Expand Down
11 changes: 10 additions & 1 deletion OSCRUI/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from PySide6.QtWidgets import QFileDialog, QLineEdit

from OSCR import LIVE_TABLE_HEADER, OSCR, split_log_by_combat, split_log_by_lines
from OSCR import (
LIVE_TABLE_HEADER, OSCR, repair_logfile as oscr_repair_logfile, split_log_by_combat,
split_log_by_lines)

from .iofunctions import browse_path
from .textedit import format_path
Expand Down Expand Up @@ -307,3 +309,10 @@ def trim_logfile(self):
else:
temp_parser.analyze_log_file()
temp_parser.export_combat(0, log_path)


def repair_logfile(self):
"""
"""
log_path = os.path.abspath(self.entry.text())
oscr_repair_logfile(log_path, self.config['templog_folder_path'])
44 changes: 39 additions & 5 deletions OSCRUI/datafunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def init_parser(self):
# self.parser2 = OSCR()


def analyze_log_callback(self, translate, combat_id=None, path=None, parser_num: int = 1, hidden_path=False):
def analyze_log_callback(
self, translate, combat_id=None, path=None, parser_num: int = 1, hidden_path=False):
"""
Wrapper function for retrieving and showing data. Callback of "Analyse" and "Refresh" button.
Expand All @@ -51,7 +52,7 @@ def analyze_log_callback(self, translate, combat_id=None, path=None, parser_num:
return
if parser_num == 1:
parser: OSCR = self.parser1
elif parser_num == 2:
elif parser_num == 2:
parser: OSCR = self.parser2
else:
return
Expand All @@ -63,7 +64,8 @@ def analyze_log_callback(self, translate, combat_id=None, path=None, parser_num:
if combat_id is None:
if not path or not os.path.isfile(path):
show_warning(
self, self._('Invalid Logfile'), self._('The Logfile you are trying to open does not exist.'))
self, self._('Invalid Logfile'),
self._('The Logfile you are trying to open does not exist.'))
return
if not hidden_path and path != self.settings.value('log_path'):
self.settings.setValue('log_path', path)
Expand Down Expand Up @@ -218,7 +220,8 @@ def populate_analysis(self, root_items: tuple):
heal_out_table = self.widgets.analysis_table_hout
heal_out_model = HealTreeModel(
heal_out_item, self.theme_font('tree_table_header'), self.theme_font('tree_table'),
self.theme_font('', self.theme['tree_table']['::item']['font']), get_heal_tree_headers())
self.theme_font('', self.theme['tree_table']['::item']['font']),
get_heal_tree_headers())
heal_out_table.setModel(heal_out_model)
heal_out_root_index = damage_in_model.createIndex(0, 0, heal_out_model._root)
heal_out_table.expand(heal_out_model.index(0, 0, heal_out_root_index))
Expand All @@ -228,7 +231,8 @@ def populate_analysis(self, root_items: tuple):
heal_in_table = self.widgets.analysis_table_hin
heal_in_model = HealTreeModel(
heal_in_item, self.theme_font('tree_table_header'), self.theme_font('tree_table'),
self.theme_font('', self.theme['tree_table']['::item']['font']), get_heal_tree_headers())
self.theme_font('', self.theme['tree_table']['::item']['font']),
get_heal_tree_headers())
heal_in_table.setModel(heal_in_model)
heal_in_root_index = damage_in_model.createIndex(0, 0, heal_in_model._root)
heal_in_table.expand(heal_in_model.index(0, 0, heal_in_root_index))
Expand Down Expand Up @@ -283,6 +287,36 @@ def resize_tree_table(tree):
tree.header().resizeSection(col, width)


def copy_analysis_table_callback(self):
"""
Copies the current selection of analysis table as tab-delimited table
"""
print('Table COPY')
if self.widgets.main_tabber.currentIndex() != 1:
return
current_tab = self.widgets.analysis_tabber.currentIndex()
current_table = self.widgets.analysis_table[current_tab]
if current_tab <= 1:
format_function = format_damage_tree_data
else:
format_function = format_heal_tree_data
selection: list = current_table.selectedIndexes()
if selection:
selection.sort(key=lambda index: (index.row(), index.column()))
output = list()
last_row = -1
for cell_index in selection:
col = cell_index.column()
if cell_index.row() != last_row:
output.append(list())
output[-1].append(cell_index.internalPointer().get_data(col))
last_row = cell_index.row()
print(output)
output_text = '\n'.join(map(lambda row: '\t'.join(map(str, row)), output))
print(output_text)
self.app.clipboard().setText(output_text)


def copy_analysis_callback(self):
"""
Callback for copy button on analysis tab
Expand Down
19 changes: 15 additions & 4 deletions OSCRUI/subwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from OSCR import LiveParser

from .callbacks import (
auto_split_callback, combat_split_callback, copy_live_data_callback, trim_logfile)
auto_split_callback, combat_split_callback, copy_live_data_callback, trim_logfile,
repair_logfile)
from .displayer import create_live_graph, update_live_display, update_live_graph, update_live_table
from .datamodels import LiveParserTableModel
from .headers import get_live_table_headers
Expand Down Expand Up @@ -134,9 +135,9 @@ def split_dialog(self, translate):
trim_button.clicked.connect(lambda: trim_logfile(self))
grid_layout.addWidget(trim_button, 1, 2, alignment=ARIGHT | ABOTTOM)
grid_layout.setRowMinimumHeight(2, item_spacing)
seperator_8 = create_frame(self, content_frame, 'hr', size_policy=SMINMIN)
seperator_8.setFixedHeight(self.theme['hr']['height'])
grid_layout.addWidget(seperator_8, 3, 0, 1, 3)
seperator_3 = create_frame(self, content_frame, 'hr', size_policy=SMINMIN)
seperator_3.setFixedHeight(self.theme['hr']['height'])
grid_layout.addWidget(seperator_3, 3, 0, 1, 3)
grid_layout.setRowMinimumHeight(4, item_spacing)

auto_split_heading = create_label(self, self._('Split Log Automatically:'), 'label_heading')
Expand Down Expand Up @@ -202,6 +203,16 @@ def split_dialog(self, translate):
lambda le=lower_range_entry, ue=upper_range_entry:
combat_split_callback(self, current_logpath, le.text(), ue.text()))
grid_layout.addWidget(range_split_button, 11, 2, alignment=ARIGHT | ABOTTOM)
grid_layout.setRowMinimumHeight(12, item_spacing)
seperator_13 = create_frame(self, content_frame, 'hr', size_policy=SMINMIN)
seperator_13.setFixedHeight(self.theme['hr']['height'])
grid_layout.addWidget(seperator_13, 13, 0, 1, 3)
grid_layout.setRowMinimumHeight(14, item_spacing)
repair_log_heading = create_label(self, 'Repair Logfile', 'label_heading')
grid_layout.addWidget(repair_log_heading, 15, 0, alignment=ALEFT)
repair_log_button = create_button(self, 'Repair')
repair_log_button.clicked.connect(lambda: repair_logfile(self))
grid_layout.addWidget(repair_log_button, 16, 2, alignment=ARIGHT | ABOTTOM)

content_frame.setLayout(vertical_layout)

Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Launcher():

version = '2024.08b030'
version = '2024.08b210'
__version__ = '0.2'

# holds the style of the app
Expand Down

0 comments on commit 6febad2

Please sign in to comment.