Remove version patch reordering. Remove the main class display from onesix edit mods.
This commit is contained in:
		| @@ -110,7 +110,6 @@ void OneSixModEditDialog::updateVersionControls() | ||||
| { | ||||
| 	ui->forgeBtn->setEnabled(true); | ||||
| 	ui->liteloaderBtn->setEnabled(true); | ||||
| 	ui->mainClassEdit->setText(m_version->mainClass); | ||||
| } | ||||
|  | ||||
| void OneSixModEditDialog::disableVersionControls() | ||||
| @@ -119,7 +118,6 @@ void OneSixModEditDialog::disableVersionControls() | ||||
| 	ui->liteloaderBtn->setEnabled(false); | ||||
| 	ui->reloadLibrariesBtn->setEnabled(false); | ||||
| 	ui->removeLibraryBtn->setEnabled(false); | ||||
| 	ui->mainClassEdit->setText(""); | ||||
| } | ||||
|  | ||||
| void OneSixModEditDialog::on_reloadLibrariesBtn_clicked() | ||||
| @@ -131,6 +129,7 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() | ||||
| { | ||||
| 	if (ui->libraryTreeView->currentIndex().isValid()) | ||||
| 	{ | ||||
| 		// FIXME: use actual model, not reloading. | ||||
| 		if (!m_version->remove(ui->libraryTreeView->currentIndex().row())) | ||||
| 		{ | ||||
| 			QMessageBox::critical(this, tr("Error"), tr("Couldn't remove file")); | ||||
| @@ -144,97 +143,31 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked() | ||||
|  | ||||
| void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked() | ||||
| { | ||||
| 	QDir(m_inst->instanceRoot()).remove("order.json"); | ||||
| 	m_inst->reloadVersion(); | ||||
| 	// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). | ||||
| } | ||||
|  | ||||
| void OneSixModEditDialog::on_moveLibraryUpBtn_clicked() | ||||
| { | ||||
|  | ||||
| 	QMap<QString, int> order = getExistingOrder(); | ||||
| 	if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty()) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
| 	const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row(); | ||||
| 	const QString ourId = m_version->versionFileId(ourRow); | ||||
| 	const int ourOrder = order[ourId]; | ||||
| 	if (ourId.isNull() || ourId.startsWith("org.multimc.")) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	QMap<int, QString> sortedOrder = invert(order); | ||||
|  | ||||
| 	QList<int> sortedOrders = sortedOrder.keys(); | ||||
| 	const int ourIndex = sortedOrders.indexOf(ourOrder); | ||||
| 	if (ourIndex <= 0) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
| 	const int ourNewOrder = sortedOrders.at(ourIndex - 1); | ||||
| 	order[ourId] = ourNewOrder; | ||||
| 	order[sortedOrder[sortedOrders[ourIndex - 1]]] = ourOrder; | ||||
|  | ||||
| 	// FIXME: why is GUI code doing this in particular? why isn't this part of a model? | ||||
| 	if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) | ||||
| 	{ | ||||
| 		QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_inst->reloadVersion(); | ||||
| 		ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow - 1), QItemSelectionModel::SelectCurrent); | ||||
| 	} | ||||
| 	// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). | ||||
| } | ||||
|  | ||||
| // FIXME: WHY IS THIS DUPLICATED? | ||||
| void OneSixModEditDialog::on_moveLibraryDownBtn_clicked() | ||||
| { | ||||
| 	QMap<QString, int> order = getExistingOrder(); | ||||
| 	if (order.size() < 2 || ui->libraryTreeView->selectionModel()->selectedIndexes().isEmpty()) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
| 	const int ourRow = ui->libraryTreeView->selectionModel()->selectedIndexes().first().row(); | ||||
| 	const QString ourId = m_version->versionFileId(ourRow); | ||||
| 	const int ourOrder = order[ourId]; | ||||
| 	if (ourId.isNull() || ourId.startsWith("org.multimc.")) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
|  | ||||
| 	QMap<int, QString> sortedOrder = invert(order); | ||||
|  | ||||
| 	QList<int> sortedOrders = sortedOrder.keys(); | ||||
| 	const int ourIndex = sortedOrders.indexOf(ourOrder); | ||||
| 	if ((ourIndex + 1) >= sortedOrders.size()) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
| 	const int ourNewOrder = sortedOrders.at(ourIndex + 1); | ||||
| 	order[ourId] = ourNewOrder; | ||||
| 	order[sortedOrder[sortedOrders[ourIndex + 1]]] = ourOrder; | ||||
|  | ||||
| 	// FIXME: why is GUI code doing this in particular? why isn't this part of a model? | ||||
| 	if (!OneSixVersionBuilder::writeOverrideOrders(order, m_inst)) | ||||
| 	{ | ||||
| 		QMessageBox::critical(this, tr("Error"), tr("Couldn't save the new order")); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		m_inst->reloadVersion(); | ||||
| 		ui->libraryTreeView->selectionModel()->select(m_version->index(ourRow + 1), QItemSelectionModel::SelectCurrent); | ||||
| 	} | ||||
| 	// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S). | ||||
| } | ||||
|  | ||||
| void OneSixModEditDialog::on_forgeBtn_clicked() | ||||
| { | ||||
| 	// FIXME: use actual model, not reloading. Move logic to model. | ||||
|  | ||||
| 	// FIXME: model::isCustom(); | ||||
| 	if (QDir(m_inst->instanceRoot()).exists("custom.json")) | ||||
| 	{ | ||||
| 		if (QMessageBox::question(this, tr("Revert?"), tr("This action will remove your custom.json. Continue?")) != QMessageBox::Yes) | ||||
| 		{ | ||||
| 			return; | ||||
| 		} | ||||
| 		// FIXME: model::revertToBase(); | ||||
| 		QDir(m_inst->instanceRoot()).remove("custom.json"); | ||||
| 		m_inst->reloadVersion(); | ||||
| 	} | ||||
| @@ -351,35 +284,6 @@ bool OneSixModEditDialog::resourcePackListFilter(QKeyEvent *keyEvent) | ||||
| 	return QDialog::eventFilter(ui->resPackTreeView, keyEvent); | ||||
| } | ||||
|  | ||||
| QMap<QString, int> OneSixModEditDialog::getExistingOrder() const | ||||
| { | ||||
|  | ||||
| 	QMap<QString, int> order; | ||||
| 	// default | ||||
| 	{ | ||||
| 		for (auto & file : m_version->versionFiles) | ||||
| 		{ | ||||
| 			if (file.id.startsWith("org.multimc.")) | ||||
| 			{ | ||||
| 				continue; | ||||
| 			} | ||||
| 			order.insert(file.id, file.order); | ||||
| 		} | ||||
| 	} | ||||
| 	// overriden | ||||
| 	{ | ||||
| 		QMap<QString, int> overridenOrder = OneSixVersionBuilder::readOverrideOrders(m_inst); | ||||
| 		for (auto id : order.keys()) | ||||
| 		{ | ||||
| 			if (overridenOrder.contains(id)) | ||||
| 			{ | ||||
| 				order[id] = overridenOrder[id]; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return order; | ||||
| } | ||||
|  | ||||
| bool OneSixModEditDialog::eventFilter(QObject *obj, QEvent *ev) | ||||
| { | ||||
| 	if (ev->type() != QEvent::KeyPress) | ||||
|   | ||||
| @@ -48,24 +48,6 @@ | ||||
|            </attribute> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <layout class="QHBoxLayout" name="horizontalLayout_7"> | ||||
|            <item> | ||||
|             <widget class="QLabel" name="label"> | ||||
|              <property name="text"> | ||||
|               <string>Main Class:</string> | ||||
|              </property> | ||||
|             </widget> | ||||
|            </item> | ||||
|            <item> | ||||
|             <widget class="QLineEdit" name="mainClassEdit"> | ||||
|              <property name="enabled"> | ||||
|               <bool>false</bool> | ||||
|              </property> | ||||
|             </widget> | ||||
|            </item> | ||||
|           </layout> | ||||
|          </item> | ||||
|         </layout> | ||||
|        </item> | ||||
|        <item> | ||||
| @@ -108,13 +90,6 @@ | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QPushButton" name="resetLibraryOrderBtn"> | ||||
|            <property name="text"> | ||||
|             <string>Reset order</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="Line" name="line_2"> | ||||
|            <property name="orientation"> | ||||
| @@ -124,6 +99,12 @@ | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QPushButton" name="moveLibraryUpBtn"> | ||||
|            <property name="enabled"> | ||||
|             <bool>false</bool> | ||||
|            </property> | ||||
|            <property name="toolTip"> | ||||
|             <string>This isn't implemented yet.</string> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>Move up</string> | ||||
|            </property> | ||||
| @@ -131,11 +112,30 @@ | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QPushButton" name="moveLibraryDownBtn"> | ||||
|            <property name="enabled"> | ||||
|             <bool>false</bool> | ||||
|            </property> | ||||
|            <property name="toolTip"> | ||||
|             <string>This isn't implemented yet.</string> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>Move down</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <widget class="QPushButton" name="resetLibraryOrderBtn"> | ||||
|            <property name="enabled"> | ||||
|             <bool>false</bool> | ||||
|            </property> | ||||
|            <property name="toolTip"> | ||||
|             <string>This isn't implemented yet.</string> | ||||
|            </property> | ||||
|            <property name="text"> | ||||
|             <string>Reset order</string> | ||||
|            </property> | ||||
|           </widget> | ||||
|          </item> | ||||
|          <item> | ||||
|           <spacer name="verticalSpacer_7"> | ||||
|            <property name="orientation"> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user