Skip to content

Commit

Permalink
added jump buttons for pack/map
Browse files Browse the repository at this point in the history
  • Loading branch information
michael02022 committed Jan 24, 2025
1 parent 555807f commit 7adfeaf
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/update_ui_files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "s|import resources_rc|from .rc_resources import *|g" src/ui/ui_mainwindow.py
else
sed -i "s/import resources_rc/from .rc_resources import */g" src/ui/ui_mainwindow.py
fi
fi
52 changes: 52 additions & 0 deletions src/ui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ def __init__(self, app, parent=None):

self.ui.btnAutoname.clicked.connect(self.onAutoname)

# Jump Buttons
self.ui.pbnMapJumpUp.clicked.connect(self.onMapJumpUp)
self.ui.pbnMapJumpDown.clicked.connect(self.onMapJumpDown)

# Velocity Mapper
self.ui.pbnVelAdd.clicked.connect(self.onVelMapAdd)
self.ui.pbnVelDel.clicked.connect(self.onVelMapDel)
Expand Down Expand Up @@ -782,6 +786,54 @@ def onItemMap(self):
self.map_objects[idx].change_value("tuned_checkbox", False)
self.ui.chkTunedVersion.setEnabled(False)

def onMapJumpDown(self):
if self.ui.listMap.count() != 0:
idx = self.ui.listMap.currentRow()
pk_idx = self.ui.cbxPack.currentIndex()
mp_idx = self.ui.cbxMap.currentIndex()

current_ls = self.map_ls[mp_idx].split(os.sep)[:-1]

for i in range(len(self.map_ls) - mp_idx):
if self.map_ls[mp_idx + i].split(os.sep)[:-1] != current_ls:
self.ui.cbxMap.setCurrentIndex(mp_idx + i)
self.map_objects[idx].set_map(list(self.current_pack_dict)[pk_idx], self.map_ls[mp_idx + i])

self.ui.listMap.clear(); self.ui.listMap.addItems(get_map_names(self.map_objects))
self.ui.listMap.setCurrentRow(idx)
# the most horrible line of code I have ever wrote
if Path(f"""{self.settings.value("mainfolderpath")}/MappingPool/{str(pathlib.Path(f"{self.map_objects[idx].pack}/{self.map_objects[idx].map}").parent).replace(os.sep, '/')}/{pathlib.Path(self.map_objects[idx].map).stem} --TN.sfz""").is_file():
self.map_objects[idx].change_value("tuned_checkbox", True)
self.ui.chkTunedVersion.setEnabled(True)
else:
self.map_objects[idx].change_value("tuned_checkbox", False)
self.ui.chkTunedVersion.setEnabled(False)
break

def onMapJumpUp(self):
if self.ui.listMap.count() != 0:
idx = self.ui.listMap.currentRow()
pk_idx = self.ui.cbxPack.currentIndex()
mp_idx = self.ui.cbxMap.currentIndex()

current_ls = self.map_ls[mp_idx].split(os.sep)[:-1]

for i in range(mp_idx):
if self.map_ls[mp_idx - i].split(os.sep)[:-1] != current_ls:
self.ui.cbxMap.setCurrentIndex(mp_idx - i)
self.map_objects[idx].set_map(list(self.current_pack_dict)[pk_idx], self.map_ls[mp_idx - i])

self.ui.listMap.clear(); self.ui.listMap.addItems(get_map_names(self.map_objects))
self.ui.listMap.setCurrentRow(idx)
# the most horrible line of code I have ever wrote
if Path(f"""{self.settings.value("mainfolderpath")}/MappingPool/{str(pathlib.Path(f"{self.map_objects[idx].pack}/{self.map_objects[idx].map}").parent).replace(os.sep, '/')}/{pathlib.Path(self.map_objects[idx].map).stem} --TN.sfz""").is_file():
self.map_objects[idx].change_value("tuned_checkbox", True)
self.ui.chkTunedVersion.setEnabled(True)
else:
self.map_objects[idx].change_value("tuned_checkbox", False)
self.ui.chkTunedVersion.setEnabled(False)
break

def onAutoname(self):
idx = self.ui.listMap.currentRow()
self.ui.txtPreset.setText(self.map_objects[idx].get_name_b())
Expand Down
22 changes: 21 additions & 1 deletion src/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>1467</width>
<height>1163</height>
<height>1203</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -11053,6 +11053,26 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
</item>
<item row="5" column="1">
<widget class="QPushButton" name="pbnMapJumpDown">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>v</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QPushButton" name="pbnMapJumpUp">
<property name="text">
<string>^</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menuBar">
Expand Down

0 comments on commit 7adfeaf

Please sign in to comment.