-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
477 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
.pylint_cache | ||
*.pyc | ||
**/__pycache__/* | ||
output | ||
output | ||
experiment* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Binary tool automation code |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
The code for art manager automation | ||
""" | ||
import logging | ||
import os | ||
|
||
from pywinauto.application import Application | ||
|
||
logger = logging.getLogger("tqma") | ||
|
||
|
||
class ArtManager: | ||
""" Represents art manager tool from official TQAE install path """ | ||
def __init__(self, installation_path, settings_path): | ||
logger.debug("Instantiating art manager object") | ||
self.path = os.path.join(installation_path, "ArtManager.exe") | ||
self.tools_ini = self.read_tools_ini(os.path.join(settings_path, "Tools.ini")) | ||
|
||
def read_tools_ini(self, tools_ini_path): | ||
""" Reads tools_ini and extracts some important settings related to work/build paths """ | ||
parsed_settings = {} | ||
logger.debug(f"Tools.ini path: {tools_ini_path}") | ||
with open(tools_ini_path, 'r', encoding='utf-8') as tools_ini: | ||
for line in tools_ini.readlines(): | ||
if "=" in line: | ||
parsed_settings[line.split("=")[0]] = line.strip().split("=")[1] | ||
logger.debug(f"Working dir: {parsed_settings['localdir']}") | ||
logger.debug(f"Build dir: {parsed_settings['builddir']}") | ||
logger.debug(f"Tools dir: {parsed_settings['toolsdir']}") | ||
|
||
return parsed_settings | ||
|
||
def run(self): | ||
""" Runs the ArtManager executable """ | ||
logger.debug("Starting art manager") | ||
app = Application(backend="win32").start(self.path) | ||
logger.debug(f"{app}") | ||
|
||
def build(self, output_mod_name): | ||
""" Builds the selected mod """ | ||
logger.debug(f"Building mod {output_mod_name}:)") | ||
self.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
""" DBR operations library """ | ||
|
||
def parse_dbr(dbr_file): | ||
""" Takes a file path as an input and parses it as a dbr. Returns dictionary with DBR data""" | ||
dbr_data = {} | ||
with open(dbr_file, 'r', encoding='utf-8') as dbr_contents: | ||
for line in dbr_contents.readlines(): | ||
dbr_data[line.split(',', 1)[0]] = line.split(',', 1)[1].strip() | ||
|
||
return dbr_data | ||
|
||
def write_dbr(dbr_data, output_file): | ||
""" Takes a dictionary with DBR data and writes it into an output file as a dbr """ | ||
contents = "" | ||
for key, value in dbr_data.items(): | ||
contents += key + "," + value + "\n" | ||
|
||
with open(output_file, 'w', encoding='utf-8') as dbr_contents: | ||
dbr_contents.write(contents) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
""" | ||
The code for all the windows that TQMA has | ||
""" | ||
import logging | ||
import os | ||
|
||
from PyQt6.QtWidgets import QWidget, QLabel, QPushButton, QHBoxLayout, QGroupBox, QGridLayout | ||
from PyQt6.QtCore import Qt | ||
|
||
from src.dbr_lib import parse_dbr | ||
|
||
|
||
logger = logging.getLogger("tqma") | ||
|
||
|
||
class ConflictResolutionWindow(QWidget): | ||
""" Settings window to configure build/working paths, mod paths etc. """ | ||
def __init__(self, overlaps): | ||
super().__init__() | ||
self.currently_processed_overlap = None | ||
self.currently_processed_key = None | ||
self.number_of_conflicts_left = 0 | ||
|
||
# The layout | ||
layout = QGridLayout(self) | ||
layout.setSpacing(15) | ||
self.setLayout(layout) | ||
|
||
# Make a duplicate list of objects because we will be popping them | ||
self.overlaps = overlaps.copy() | ||
for overlap in self.overlaps: | ||
if not overlap.conflicting_keys: | ||
self.overlaps.remove(overlap) | ||
|
||
# Count total number of conflicts | ||
for overlap in self.overlaps: | ||
self.number_of_conflicts_left += len(overlap.conflicting_keys) | ||
|
||
# Start the conflict resolution right from init | ||
self.resolve_next_overlap() | ||
|
||
def clear_layout(self, layout): | ||
""" Clears layout """ | ||
if layout is not None: | ||
while layout.count(): | ||
child = layout.takeAt(0) | ||
if child.widget() is not None: | ||
child.widget().deleteLater() | ||
elif child.layout() is not None: | ||
self.clear_layout(child.layout()) | ||
|
||
def process_resolution_choice(self, choice): | ||
""" This method is called when user presses the button for one of conflict value choices """ | ||
logger.debug(f"Resolution choice: {choice}") | ||
self.currently_processed_overlap.resolved[self.currently_processed_key] = choice | ||
self.clear_layout(self.layout()) | ||
self.number_of_conflicts_left -= 1 | ||
self.resolve_next_overlap() | ||
|
||
def resolve_next_overlap(self): | ||
""" | ||
Pops next overlap from overlaps and runs conflict resolution for it | ||
If there are no overlaps left the conflict resolution window is closed | ||
""" | ||
if not self.overlaps and not self.currently_processed_overlap.conflicting_keys: | ||
logger.debug("No overlaps or conflicting keys left to process, closing") | ||
self.close() | ||
return | ||
|
||
if not self.currently_processed_overlap or not self.currently_processed_overlap.conflicting_keys: | ||
self.currently_processed_overlap = self.overlaps.pop() | ||
|
||
self.currently_processed_key = self.currently_processed_overlap.conflicting_keys.pop() | ||
self.run_conflict_resolution(self.currently_processed_overlap, self.currently_processed_key) | ||
|
||
def run_conflict_resolution(self, overlap, conflicting_key): | ||
""" Takes a single overlap, generates widgets with choices for conflicting key(s) and stores user input """ | ||
group_box_x_position = 2 | ||
|
||
self.setWindowTitle(f"TQMA conflicts left: {self.number_of_conflicts_left}") | ||
logger.debug( | ||
f"Processing {overlap.dbr_relpath} {conflicting_key}, conflicts left: {self.number_of_conflicts_left}" | ||
) | ||
|
||
conflict_dbr_info_label = QLabel(f"Resolving conflict for dbr {overlap.dbr_relpath}", self) | ||
self.layout().addWidget(conflict_dbr_info_label, 0, 0, 2, 1, alignment=Qt.AlignmentFlag.AlignTop) | ||
conflict_key_info_label = QLabel(f"Conflicting key: {conflicting_key}", self) | ||
self.layout().addWidget(conflict_key_info_label, 1, 0, 2, 1, alignment=Qt.AlignmentFlag.AlignTop) | ||
|
||
for mod in overlap.mods: | ||
group_box = QGroupBox(self) | ||
group_box_layout = QHBoxLayout() | ||
group_box_layout.setSpacing(10) | ||
group_box.setLayout(group_box_layout) | ||
|
||
dbr_data = parse_dbr(os.path.join(mod.path, overlap.dbr_relpath)) | ||
# label with mod name | ||
mod_name_label = QLabel(f"Mod name: {mod.name}", self) | ||
group_box.layout().addWidget(mod_name_label) | ||
# button with attribute value | ||
value_button = QPushButton(f"{dbr_data[conflicting_key]}") | ||
value_button.clicked.connect( | ||
lambda checked, choice=dbr_data[conflicting_key]: self.process_resolution_choice(choice) | ||
) | ||
group_box.layout().addWidget(value_button) | ||
|
||
self.layout().addWidget(group_box, group_box_x_position, 0, 2, 1, alignment=Qt.AlignmentFlag.AlignTop) | ||
group_box_x_position += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.