Add map view tab to API
This commit is contained in:
parent
b39906c03f
commit
39cd1d335b
6 changed files with 55 additions and 21 deletions
|
@ -646,7 +646,7 @@
|
|||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget_2">
|
||||
<widget class="QTabWidget" name="mapViewTab">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
|
|
|
@ -170,8 +170,10 @@ public:
|
|||
Q_INVOKABLE int getNumMetatileLayers();
|
||||
Q_INVOKABLE int getBaseGameVersion();
|
||||
Q_INVOKABLE QList<QString> getCustomScripts();
|
||||
Q_INVOKABLE int getCurrentTab();
|
||||
Q_INVOKABLE void setCurrentTab(int index);
|
||||
Q_INVOKABLE int getMainTab();
|
||||
Q_INVOKABLE void setMainTab(int index);
|
||||
Q_INVOKABLE int getMapViewTab();
|
||||
Q_INVOKABLE void setMapViewTab(int index);
|
||||
|
||||
|
||||
private slots:
|
||||
|
@ -203,7 +205,6 @@ private slots:
|
|||
void on_action_NewMap_triggered();
|
||||
void on_actionNew_Tileset_triggered();
|
||||
void on_action_Save_triggered();
|
||||
void on_tabWidget_2_currentChanged(int index);
|
||||
void on_action_Exit_triggered();
|
||||
void on_comboBox_Song_currentTextChanged(const QString &arg1);
|
||||
void on_comboBox_Location_currentTextChanged(const QString &arg1);
|
||||
|
@ -221,6 +222,7 @@ private slots:
|
|||
void on_actionEdit_Shortcuts_triggered();
|
||||
|
||||
void on_mainTabBar_tabBarClicked(int index);
|
||||
void on_mapViewTab_tabBarClicked(int index);
|
||||
|
||||
void on_actionZoom_In_triggered();
|
||||
void on_actionZoom_Out_triggered();
|
||||
|
@ -394,7 +396,8 @@ private:
|
|||
QString getEventGroupFromTabWidget(QWidget *tab);
|
||||
void closeSupplementaryWindows();
|
||||
void setWindowDisabled(bool);
|
||||
void setMainTab(int);
|
||||
void setMainTabInternal(int);
|
||||
void setMapViewTabInternal(int);
|
||||
|
||||
void initTilesetEditor();
|
||||
bool initRegionMapEditor();
|
||||
|
|
|
@ -16,7 +16,8 @@ enum CallbackType {
|
|||
OnMapResized,
|
||||
OnMapShifted,
|
||||
OnTilesetUpdated,
|
||||
OnTabChanged,
|
||||
OnMainTabChanged,
|
||||
OnMapViewTabChanged,
|
||||
};
|
||||
|
||||
class Scripting
|
||||
|
@ -41,7 +42,8 @@ public:
|
|||
static void cb_MapResized(int oldWidth, int oldHeight, int newWidth, int newHeight);
|
||||
static void cb_MapShifted(int xDelta, int yDelta);
|
||||
static void cb_TilesetUpdated(QString tilesetName);
|
||||
static void cb_TabChanged(int oldTab, int newTab);
|
||||
static void cb_MainTabChanged(int oldTab, int newTab);
|
||||
static void cb_MapViewTabChanged(int oldTab, int newTab);
|
||||
static bool tryErrorJS(QJSValue js);
|
||||
|
||||
private:
|
||||
|
|
|
@ -676,7 +676,7 @@ void MainWindow::redrawMapScene()
|
|||
|
||||
void MainWindow::refreshMapScene()
|
||||
{
|
||||
setMainTab(ui->mainTabBar->currentIndex());
|
||||
setMainTabInternal(ui->mainTabBar->currentIndex());
|
||||
|
||||
ui->graphicsView_Map->setScene(editor->scene);
|
||||
ui->graphicsView_Map->setSceneRect(editor->scene->sceneRect());
|
||||
|
@ -1661,7 +1661,13 @@ void MainWindow::on_action_Save_triggered() {
|
|||
updateMapList();
|
||||
}
|
||||
|
||||
void MainWindow::on_tabWidget_2_currentChanged(int index)
|
||||
void MainWindow::on_mapViewTab_tabBarClicked(int index)
|
||||
{
|
||||
Scripting::cb_MapViewTabChanged(ui->mapViewTab->currentIndex(), index);
|
||||
setMapViewTabInternal(index);
|
||||
}
|
||||
|
||||
void MainWindow::setMapViewTabInternal(int index)
|
||||
{
|
||||
if (index == 0) {
|
||||
editor->setEditingMap();
|
||||
|
@ -1681,11 +1687,11 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
|
|||
{
|
||||
int oldIndex = ui->mainTabBar->currentIndex();
|
||||
if (index != oldIndex)
|
||||
Scripting::cb_TabChanged(oldIndex, index);
|
||||
setMainTab(index);
|
||||
Scripting::cb_MainTabChanged(oldIndex, index);
|
||||
setMainTabInternal(index);
|
||||
}
|
||||
|
||||
void MainWindow::setMainTab(int index)
|
||||
void MainWindow::setMainTabInternal(int index)
|
||||
{
|
||||
ui->mainTabBar->setCurrentIndex(index);
|
||||
|
||||
|
@ -1694,7 +1700,7 @@ void MainWindow::setMainTab(int index)
|
|||
|
||||
if (index == 0) {
|
||||
ui->stackedWidget_MapEvents->setCurrentIndex(0);
|
||||
on_tabWidget_2_currentChanged(ui->tabWidget_2->currentIndex());
|
||||
setMapViewTabInternal(ui->mapViewTab->currentIndex());
|
||||
clickToolButtonFromEditMode(editor->map_edit_mode);
|
||||
} else if (index == 1) {
|
||||
ui->stackedWidget_MapEvents->setCurrentIndex(1);
|
||||
|
@ -2542,7 +2548,7 @@ void MainWindow::on_toolButton_Paint_clicked()
|
|||
editor->settings->mapCursor = QCursor(QPixmap(":/icons/pencil_cursor.ico"), 10, 10);
|
||||
|
||||
// do not stop single tile mode when editing collision
|
||||
if (ui->tabWidget_2->currentIndex() == 0)
|
||||
if (ui->mapViewTab->currentIndex() == 0)
|
||||
editor->cursorMapTileRect->stopSingleTileMode();
|
||||
|
||||
ui->graphicsView_Map->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
||||
|
|
|
@ -990,14 +990,26 @@ QList<QString> MainWindow::getCustomScripts() {
|
|||
return projectConfig.getCustomScripts();
|
||||
}
|
||||
|
||||
int MainWindow::getCurrentTab() {
|
||||
int MainWindow::getMainTab() {
|
||||
if (!this->ui || !this->ui->mainTabBar)
|
||||
return -1;
|
||||
return this->ui->mainTabBar->currentIndex();
|
||||
}
|
||||
|
||||
void MainWindow::setCurrentTab(int index) {
|
||||
void MainWindow::setMainTab(int index) {
|
||||
if (!this->ui || !this->ui->mainTabBar || index < 0 || index >= this->ui->mainTabBar->count())
|
||||
return
|
||||
this->setMainTab(index);
|
||||
return;
|
||||
this->setMainTabInternal(index);
|
||||
}
|
||||
|
||||
int MainWindow::getMapViewTab() {
|
||||
if (this->getMainTab() != 0 || !this->ui->mapViewTab)
|
||||
return -1;
|
||||
return this->ui->mapViewTab->currentIndex();
|
||||
}
|
||||
|
||||
void MainWindow::setMapViewTab(int index) {
|
||||
if (this->getMainTab() != 0 || !this->ui->mapViewTab || index < 0 || index >= this->ui->mapViewTab->count())
|
||||
return;
|
||||
this->setMapViewTabInternal(index);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,8 @@ QMap<CallbackType, QString> callbackFunctions = {
|
|||
{OnMapResized, "onMapResized"},
|
||||
{OnMapShifted, "onMapShifted"},
|
||||
{OnTilesetUpdated, "onTilesetUpdated"},
|
||||
{OnTabChanged, "onTabChanged"},
|
||||
{OnMainTabChanged, "onMainTabChanged"},
|
||||
{OnMapViewTabChanged, "onMapViewTabChanged"},
|
||||
};
|
||||
|
||||
Scripting *instance = nullptr;
|
||||
|
@ -175,14 +176,24 @@ void Scripting::cb_TilesetUpdated(QString tilesetName) {
|
|||
instance->invokeCallback(OnTilesetUpdated, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_TabChanged(int oldTab, int newTab) {
|
||||
void Scripting::cb_MainTabChanged(int oldTab, int newTab) {
|
||||
if (!instance) return;
|
||||
|
||||
QJSValueList args {
|
||||
oldTab,
|
||||
newTab,
|
||||
};
|
||||
instance->invokeCallback(OnTabChanged, args);
|
||||
instance->invokeCallback(OnMainTabChanged, args);
|
||||
}
|
||||
|
||||
void Scripting::cb_MapViewTabChanged(int oldTab, int newTab) {
|
||||
if (!instance) return;
|
||||
|
||||
QJSValueList args {
|
||||
oldTab,
|
||||
newTab,
|
||||
};
|
||||
instance->invokeCallback(OnMapViewTabChanged, args);
|
||||
}
|
||||
|
||||
QJSValue Scripting::fromBlock(Block block) {
|
||||
|
|
Loading…
Reference in a new issue