Skip to content

Commit

Permalink
Add more module sort options (#73)
Browse files Browse the repository at this point in the history
* add more module sort options

* Add test results

* Update README.md status badges.

* use Mod_VO_ID over Mod_Entry_Area

* Add test results

* Update README.md status badges.

* refactor module id/name lookups

* Add test results

* Update README.md status badges.

* set `use_hardcoded` default to False

since it now works fine.

* Add test results

* Update README.md status badges.

* borrow from b18

* Add test results

* Update README.md status badges.

* fixes/improvements/cleanup

* Add test results

* Update README.md status badges.

* remaining fixes

what a mess

* oops - return the name if found (faster)

* Add test results

* Update README.md status badges.

---------

Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
th3w1zard1 and actions-user authored Mar 20, 2024
1 parent ad4a226 commit 7fc2fa8
Show file tree
Hide file tree
Showing 77 changed files with 27,327 additions and 26,375 deletions.
3 changes: 2 additions & 1 deletion Libraries/PyKotor/src/pykotor/common/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ def from_stream(
if not stream.seekable():
msg = "Stream must be seekable"
raise ValueError(msg)

if isinstance(stream, io.RawIOBase):
return cls(io.BufferedReader(stream), offset, size)
try:
mmap_stream = mmap.mmap(stream.fileno(), length=0, access=mmap.ACCESS_READ)
except (ValueError, OSError): # ValueError means mmap cannot map to empty files
Expand Down
366 changes: 273 additions & 93 deletions Libraries/PyKotor/src/pykotor/extract/installation.py

Large diffs are not rendered by default.

48 changes: 20 additions & 28 deletions README.md

Large diffs are not rendered by default.

30,200 changes: 15,100 additions & 15,100 deletions Tools/HolocronToolset/src/resources_rc.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,10 @@ def installations(self) -> dict[str, InstallationConfig]:
"ncsDecompilerPath",
"",
)
moduleSortOption = Settings.addSetting(
"moduleSortOption",
1,
)
# endregion

# region Bools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setupValues(self):
self.ui.useBetaChannel.setChecked(self.settings.useBetaChannel)
self.ui.saveRimCheck.setChecked(not self.settings.disableRIMSaving)
self.ui.mergeRimCheck.setChecked(self.settings.joinRIMsTogether)
self.ui.useModuleFilenamesCheck.setChecked(self.settings.useModuleFilenames)
self.ui.moduleSortOptionComboBox.setCurrentIndex(self.settings.moduleSortOption)
self.ui.greyRimCheck.setChecked(self.settings.greyRIMText)
self.ui.showPreviewUTCCheck.setChecked(self.settings.showPreviewUTC)
self.ui.showPreviewUTPCheck.setChecked(self.settings.showPreviewUTP)
Expand All @@ -39,7 +39,7 @@ def save(self):
self.settings.useBetaChannel = not self.ui.useBetaChannel.isChecked()
self.settings.disableRIMSaving = not self.ui.saveRimCheck.isChecked()
self.settings.joinRIMsTogether = self.ui.mergeRimCheck.isChecked()
self.settings.useModuleFilenames = self.ui.useModuleFilenamesCheck.isChecked()
self.settings.moduleSortOption = self.ui.moduleSortOptionComboBox.currentIndex()
self.settings.greyRIMText = self.ui.greyRimCheck.isChecked()
self.settings.showPreviewUTC = self.ui.showPreviewUTCCheck.isChecked()
self.settings.showPreviewUTP = self.ui.showPreviewUTPCheck.isChecked()
Expand Down
20 changes: 14 additions & 6 deletions Tools/HolocronToolset/src/toolset/gui/windows/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,14 +729,22 @@ def _getModulesList(self, *, reload: bool = True) -> list[QStandardItem]:
self.active.load_modules()

areaNames: dict[str, str] = self.active.module_names()
def sortAlgo(moduleFileName: str) -> str:
lowerModuleFileName = moduleFileName.lower()
if "stunt" in lowerModuleFileName: # keep the least used stunt modules at the bottom.
sortStr = "zzzzz"
elif self.settings.moduleSortOption == 0: #"Sort by filename":
sortStr = ""
elif self.settings.moduleSortOption == 1: #"Sort by humanized area name":
sortStr = areaNames.get(moduleFileName).lower()
else: # alternate mod id that attempts to match to filename.
sortStr = self.active.module_id(moduleFileName, use_hardcoded=False, use_alternate=True)
sortStr += f"_{lowerModuleFileName}".lower()
return sortStr

sortedKeys: list[str] = sorted(
areaNames,
key=lambda moduleFileName:
(
moduleFileName.lower()
if self.settings.useModuleFilenames
else areaNames.get(moduleFileName).lower()
)
key=sortAlgo
)

modules: list[QStandardItem] = []
Expand Down
14 changes: 10 additions & 4 deletions Tools/HolocronToolset/src/toolset/uic/widgets/settings/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ def setupUi(self, Form):
self.mergeRimCheck = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.mergeRimCheck.setObjectName("mergeRimCheck")
self.verticalLayout.addWidget(self.mergeRimCheck)
self.useModuleFilenamesCheck = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.useModuleFilenamesCheck.setObjectName("useModuleFilenamesCheck")
self.verticalLayout.addWidget(self.useModuleFilenamesCheck)
self.moduleSortOptionComboBox = QtWidgets.QComboBox(self.scrollAreaWidgetContents)
self.moduleSortOptionComboBox.setEditable(False)
self.moduleSortOptionComboBox.setObjectName("moduleSortOptionComboBox")
self.moduleSortOptionComboBox.addItem("")
self.moduleSortOptionComboBox.addItem("")
self.moduleSortOptionComboBox.addItem("")
self.verticalLayout.addWidget(self.moduleSortOptionComboBox)
self.greyRimCheck = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.greyRimCheck.setObjectName("greyRimCheck")
self.verticalLayout.addWidget(self.greyRimCheck)
Expand Down Expand Up @@ -122,7 +126,9 @@ def retranslateUi(self, Form):
self.useBetaChannel.setText(_translate("Form", "Check for beta updates and take me to their download link when they\'re available."))
self.alsoCheckReleaseVersion.setText(_translate("Form", "Also check release version if it is newer than beta version."))
self.mergeRimCheck.setText(_translate("Form", "Merge RIM files in the Modules tab of the Main Window."))
self.useModuleFilenamesCheck.setText(_translate("Form", "Sort by filename rather than area name in the Modules tab."))
self.moduleSortOptionComboBox.setItemText(0, _translate("Form", "Sort by filename"))
self.moduleSortOptionComboBox.setItemText(1, _translate("Form", "Sort by humanized area name"))
self.moduleSortOptionComboBox.setItemText(2, _translate("Form", "Sort by area name"))
self.greyRimCheck.setText(_translate("Form", "Set RIM files to have grey text in the Modules tab of the Main Window."))
self.showPreviewUTCCheck.setText(_translate("Form", "Show 3D Preview in UTC Editor"))
self.showPreviewUTPCheck.setText(_translate("Form", "Show 3D Preview in UTP Editor"))
Expand Down
23 changes: 19 additions & 4 deletions Tools/HolocronToolset/src/ui/widgets/settings/misc.ui
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,25 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="useModuleFilenamesCheck">
<property name="text">
<string>Sort by filename rather than area name in the Modules tab.</string>
</property>
<widget class="QComboBox" name="moduleSortOptionComboBox">
<property name="editable">
<bool>false</bool>
</property>
<item>
<property name="text">
<string>Sort by filename</string>
</property>
</item>
<item>
<property name="text">
<string>Sort by humanized area name</string>
</property>
</item>
<item>
<property name="text">
<string>Sort by area name</string>
</property>
</item>
</widget>
</item>
<item>
Expand Down
Loading

0 comments on commit 7fc2fa8

Please sign in to comment.