Skip to content

Commit

Permalink
Add support for multiple save entries
Browse files Browse the repository at this point in the history
  • Loading branch information
rrooij committed Apr 2, 2018
1 parent f9cc672 commit 5667773
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 31 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ There is also a nice .deb file available on the [Releases](https://github.com/rr
Check out the [Releases](https://github.com/rrooij/sd3save_editor/releases) page. It will contain a Windows
binary.

# Limitations

Only the first save entry is editable.

# Warning

Backup your save before messing with it!
Expand Down
20 changes: 18 additions & 2 deletions sd3save_editor/gui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def initFileOpenEvents(self):

def setTableData(self):
self.ui.storageTableWidget.blockSignals(True)
items = save.read_all_storage_items_amount(self.saveData)
items = save.read_all_storage_items_amount(self.saveData, self.saveIndex)
self.ui.storageTableWidget.setRowCount(len(items))
for idx, item in enumerate(items):
itemNameWidget = QTableWidgetItem(item[0])
Expand All @@ -117,6 +117,20 @@ def initChangeNameInput(self):
self.ui.c2NameLineEdit.setMaxLength(6)
self.ui.c3NameLineEdit.setMaxLength(6)

def initSaveEntryComboBox(self):
self.ui.saveIndexComboBox.clear()
for x in range(0, 3):
if self.saveData[x]:
self.ui.saveIndexComboBox.addItem("Save entry {}".format(x + 1), x)

self.ui.saveIndexComboBox.activated.connect(self.saveEntryChanged)

def saveEntryChanged(self, index):
saveIndex = self.ui.saveIndexComboBox.itemData(index)
self.saveIndex = saveIndex
self.initData()
self.setTableData()

def initComboBox(self):
self.ui.locationComboBox.addItems(game_data.parse_locations_json())
self.ui.tracksComboBox.addItems(game_data.parse_tracks_json())
Expand All @@ -133,7 +147,8 @@ def saveFormValues(self):
try:
self.saveGuiData()
save.write_storage_item_amounts(self.saveData,
self.editedStorageItems)
self.editedStorageItems,
self.saveIndex)
save.write_save(self.filename, self.saveData)
QMessageBox.information(self, "Succesfully saved",
"Succesfully saved")
Expand All @@ -157,5 +172,6 @@ def openFileDialog(self):
self.initData()
self.setTableData()
self.initSaveEvent()
self.initSaveEntryComboBox()
except Exception as ex:
QMessageBox.warning(self, "Can't open Seiken3 save", str(ex))
38 changes: 26 additions & 12 deletions sd3save_editor/gui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="3" column="0">
<widget class="QTabWidget" name="tabsOverview">
<property name="currentIndex">
<number>0</number>
Expand All @@ -25,53 +25,53 @@
<string>General</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<item row="1" column="0">
<layout class="QFormLayout" name="formLayout">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="locationLabel">
<property name="text">
<string>Location</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="locationComboBox"/>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="labelLuc">
<property name="text">
<string>Luc</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QSpinBox" name="spinBoxLuc">
<property name="maximum">
<number>677215</number>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Playing track</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QComboBox" name="tracksComboBox"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Playing time</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QSpinBox" name="secondsSpinBox">
<property name="suffix">
<string> seconds</string>
Expand Down Expand Up @@ -354,7 +354,7 @@
</widget>
</widget>
</item>
<item row="1" column="0" alignment="Qt::AlignRight">
<item row="4" column="0" alignment="Qt::AlignRight">
<widget class="QPushButton" name="saveButton">
<property name="enabled">
<bool>false</bool>
Expand All @@ -364,6 +364,20 @@
</property>
</widget>
</item>
<item row="1" column="0">
<layout class="QFormLayout" name="formLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="saveEntryLabel">
<property name="text">
<string>Save Entry</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="saveIndexComboBox"/>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
Expand All @@ -372,7 +386,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>19</height>
<height>20</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down
36 changes: 23 additions & 13 deletions sd3save_editor/gui/mainwindow_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Form implementation generated from reading ui file 'mainwindow.ui'
#
# Created by: PyQt5 UI code generator 5.8.2
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!

Expand All @@ -27,31 +27,31 @@ def setupUi(self, MainWindow):
self.formLayout.setObjectName("formLayout")
self.locationLabel = QtWidgets.QLabel(self.tab)
self.locationLabel.setObjectName("locationLabel")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.locationLabel)
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.locationLabel)
self.locationComboBox = QtWidgets.QComboBox(self.tab)
self.locationComboBox.setObjectName("locationComboBox")
self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.locationComboBox)
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.locationComboBox)
self.labelLuc = QtWidgets.QLabel(self.tab)
self.labelLuc.setObjectName("labelLuc")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.labelLuc)
self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.labelLuc)
self.spinBoxLuc = QtWidgets.QSpinBox(self.tab)
self.spinBoxLuc.setMaximum(677215)
self.spinBoxLuc.setObjectName("spinBoxLuc")
self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.spinBoxLuc)
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.spinBoxLuc)
self.label = QtWidgets.QLabel(self.tab)
self.label.setObjectName("label")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.label)
self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label)
self.tracksComboBox = QtWidgets.QComboBox(self.tab)
self.tracksComboBox.setObjectName("tracksComboBox")
self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.tracksComboBox)
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.tracksComboBox)
self.label_2 = QtWidgets.QLabel(self.tab)
self.label_2.setObjectName("label_2")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.label_2)
self.formLayout.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.label_2)
self.secondsSpinBox = QtWidgets.QSpinBox(self.tab)
self.secondsSpinBox.setMaximum(2147483647)
self.secondsSpinBox.setObjectName("secondsSpinBox")
self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.secondsSpinBox)
self.gridLayout_2.addLayout(self.formLayout, 0, 0, 1, 1)
self.formLayout.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.secondsSpinBox)
self.gridLayout_2.addLayout(self.formLayout, 1, 0, 1, 1)
self.tabsOverview.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
Expand Down Expand Up @@ -198,14 +198,23 @@ def setupUi(self, MainWindow):
self.storageTableWidget.horizontalHeader().setStretchLastSection(True)
self.gridLayout_6.addWidget(self.storageTableWidget, 0, 0, 1, 1)
self.tabsOverview.addTab(self.tab_5, "")
self.gridLayout.addWidget(self.tabsOverview, 0, 0, 1, 1)
self.gridLayout.addWidget(self.tabsOverview, 3, 0, 1, 1)
self.saveButton = QtWidgets.QPushButton(self.centralwidget)
self.saveButton.setEnabled(False)
self.saveButton.setObjectName("saveButton")
self.gridLayout.addWidget(self.saveButton, 1, 0, 1, 1, QtCore.Qt.AlignRight)
self.gridLayout.addWidget(self.saveButton, 4, 0, 1, 1, QtCore.Qt.AlignRight)
self.formLayout_2 = QtWidgets.QFormLayout()
self.formLayout_2.setObjectName("formLayout_2")
self.saveEntryLabel = QtWidgets.QLabel(self.centralwidget)
self.saveEntryLabel.setObjectName("saveEntryLabel")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.saveEntryLabel)
self.saveIndexComboBox = QtWidgets.QComboBox(self.centralwidget)
self.saveIndexComboBox.setObjectName("saveIndexComboBox")
self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.saveIndexComboBox)
self.gridLayout.addLayout(self.formLayout_2, 1, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtWidgets.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 19))
self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 20))
self.menubar.setObjectName("menubar")
self.menuFile = QtWidgets.QMenu(self.menubar)
self.menuFile.setObjectName("menuFile")
Expand Down Expand Up @@ -259,6 +268,7 @@ def retranslateUi(self, MainWindow):
item.setText(_translate("MainWindow", "Amount"))
self.tabsOverview.setTabText(self.tabsOverview.indexOf(self.tab_5), _translate("MainWindow", "Item Storage"))
self.saveButton.setText(_translate("MainWindow", "Save"))
self.saveEntryLabel.setText(_translate("MainWindow", "Save Entry"))
self.menuFile.setTitle(_translate("MainWindow", "File"))
self.actionOpen.setText(_translate("MainWindow", "Open"))
self.actionOpen.setShortcut(_translate("MainWindow", "Ctrl+O"))
Expand Down

0 comments on commit 5667773

Please sign in to comment.