From 7072c001afeaf7c0ac94536218147ac0a30742f0 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Thu, 7 May 2020 20:13:56 -0500 Subject: [PATCH] Implement api for checkboxes --- include/mainwindow.h | 6 ++++++ src/mainwindow.cpp | 24 ++++++++++++++++++++++++ test_script.js | 5 ++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index bd7f4408..bb85e62a 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -89,6 +89,12 @@ public: Q_INVOKABLE QString getSecondaryTileset(); Q_INVOKABLE void setPrimaryTileset(QString tileset); Q_INVOKABLE void setSecondaryTileset(QString tileset); + Q_INVOKABLE void setGridVisibility(bool visible); + Q_INVOKABLE bool getGridVisibility(); + Q_INVOKABLE void setBorderVisibility(bool visible); + Q_INVOKABLE bool getBorderVisibility(); + Q_INVOKABLE void setSmartPathsEnabled(bool visible); + Q_INVOKABLE bool getSmartPathsEnabled(); Q_INVOKABLE void registerAction(QString functionName, QString actionName); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 27e29645..310fe8b1 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2961,6 +2961,30 @@ void MainWindow::setSecondaryTileset(QString tileset) { this->on_comboBox_SecondaryTileset_currentTextChanged(tileset); } +void MainWindow::setGridVisibility(bool visible) { + this->ui->checkBox_ToggleGrid->setChecked(visible); +} + +bool MainWindow::getGridVisibility() { + return this->ui->checkBox_ToggleGrid->isChecked(); +} + +void MainWindow::setBorderVisibility(bool visible) { + this->editor->toggleBorderVisibility(visible); +} + +bool MainWindow::getBorderVisibility() { + return this->ui->checkBox_ToggleBorder->isChecked(); +} + +void MainWindow::setSmartPathsEnabled(bool visible) { + this->ui->checkBox_smartPaths->setChecked(visible); +} + +bool MainWindow::getSmartPathsEnabled() { + return this->ui->checkBox_smartPaths->isChecked(); +} + void MainWindow::registerAction(QString functionName, QString actionName) { if (!this->ui || !this->ui->menuTools) return; diff --git a/test_script.js b/test_script.js index c807898a..31965ce5 100644 --- a/test_script.js +++ b/test_script.js @@ -11,6 +11,8 @@ function applyTint(palette, tint) { } } +let visible = true; + function applyTintToPalettes(tint) { try { // const primaryPalettes = map.getPrimaryTilesetPalettes() @@ -23,7 +25,8 @@ function applyTintToPalettes(tint) { // map.setPrimaryTilesetPalettesPreview(primaryPalettes) // map.setSecondaryTilesetPalettesPreview(secondaryPalettes) - map.setSecondaryTileset("gTileset_Rustboro") + console.log(map.setSmartPathsEnabled(visible)) + visible = !visible } catch(err) { console.log(err) }