Port changes from Custom Attributes redesign

This commit is contained in:
GriffinR
2024-10-10 21:14:03 -04:00
parent 09694891f3
commit fe38e42591
19 changed files with 823 additions and 367 deletions

View File

@@ -7,7 +7,7 @@
#include "eventframes.h"
#include "bordermetatilespixmapitem.h"
#include "currentselectedmetatilespixmapitem.h"
#include "customattributestable.h"
#include "customattributesframe.h"
#include "scripting.h"
#include "adjustingstackedwidget.h"
#include "draggablepixmapitem.h"
@@ -1033,16 +1033,7 @@ void MainWindow::displayMapProperties() {
ui->comboBox_PrimaryTileset->setCurrentText(editor->map->layout()->tileset_primary_label);
ui->comboBox_SecondaryTileset->setCurrentText(editor->map->layout()->tileset_secondary_label);
// Custom fields table.
/* // TODO: Re-enable
ui->tableWidget_CustomHeaderFields->blockSignals(true);
ui->tableWidget_CustomHeaderFields->setRowCount(0);
for (auto it = map->customHeaders.begin(); it != map->customHeaders.end(); it++)
CustomAttributesTable::addAttribute(ui->tableWidget_CustomHeaderFields, it.key(), it.value());
ui->tableWidget_CustomHeaderFields->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
ui->tableWidget_CustomHeaderFields->blockSignals(false);
*/
ui->mapCustomAttributesFrame->table()->setAttributes(editor->map->customAttributes());
}
void MainWindow::on_comboBox_LayoutSelector_currentTextChanged(const QString &text) {
@@ -1119,6 +1110,8 @@ bool MainWindow::setProjectUI() {
this->layoutListProxyModel->setSourceModel(this->layoutTreeModel);
ui->layoutList->setModel(layoutListProxyModel);
ui->mapCustomAttributesFrame->table()->setRestrictedKeys(project->topLevelMapFields);
return true;
}
@@ -2867,27 +2860,6 @@ void MainWindow::reloadScriptEngine() {
Scripting::cb_MapOpened(editor->map->name()); // TODO: API should have equivalent for layout
}
void MainWindow::on_pushButton_AddCustomHeaderField_clicked()
{
bool ok;
QJsonValue value = CustomAttributesTable::pickType(this, &ok);
if (ok){
CustomAttributesTable::addAttribute(this->ui->tableWidget_CustomHeaderFields, "", value, true);
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
}
}
void MainWindow::on_pushButton_DeleteCustomHeaderField_clicked()
{
if (CustomAttributesTable::deleteSelectedAttributes(this->ui->tableWidget_CustomHeaderFields))
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
}
void MainWindow::on_tableWidget_CustomHeaderFields_cellChanged(int, int)
{
this->editor->updateCustomMapHeaderValues(this->ui->tableWidget_CustomHeaderFields);
}
void MainWindow::on_horizontalSlider_MetatileZoom_valueChanged(int value) {
porymapConfig.metatilesZoom = value;
double scale = pow(3.0, static_cast<double>(value - 30) / 30.0);