update ui so that map and events tabs share widgets

- use a programmatically created QTabBar to switch between pages of stacked widget
- use stacked widget to display selected objects and metatiles frames
- remove unique map events tab

this gives access to the toolbuttons while editing events (not functional yet)
This commit is contained in:
garak
2019-11-01 21:19:39 -04:00
committed by garakmon
parent c0674d9676
commit fa42beac1d
5 changed files with 2179 additions and 2362 deletions

View File

@@ -79,6 +79,15 @@ void MainWindow::initExtraShortcuts() {
}
void MainWindow::initCustomUI() {
// Set up the tab bar
ui->mainTabBar->addTab("Map"); // add the icon
ui->mainTabBar->setTabIcon(0, QIcon(QStringLiteral(":/icons/map.ico")));
ui->mainTabBar->addTab("Events");
ui->mainTabBar->addTab("Header");
ui->mainTabBar->addTab("Connections");
ui->mainTabBar->addTab("Wild Pokemon"); // add the icon
ui->mainTabBar->setTabIcon(4, QIcon(QStringLiteral(":/icons/tall_grass.ico")));
// Right-clicking on items in the map list tree view brings up a context menu.
ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)),
@@ -152,11 +161,14 @@ void MainWindow::initMapSortOrder() {
void MainWindow::setProjectSpecificUIVisibility()
{
ui->tabWidget->setTabEnabled(4, projectConfig.getEncounterJsonActive());
ui->actionUse_Encounter_Json->setChecked(projectConfig.getEncounterJsonActive());
ui->actionUse_Poryscript->setChecked(projectConfig.getUsePoryScript());
if (!projectConfig.getEncounterJsonActive()) {
ui->mainTabBar->removeTab(4);
ui->mainStackedWidget->removeWidget(ui->mainStackedWidget->widget(4));
}
switch (projectConfig.getBaseGameVersion())
{
case BaseGameVersion::pokeruby:
@@ -264,7 +276,6 @@ void MainWindow::restoreWindowState() {
this->restoreGeometry(geometry.value("window_geometry"));
this->restoreState(geometry.value("window_state"));
this->ui->splitter_map->restoreState(geometry.value("map_splitter_state"));
this->ui->splitter_events->restoreState(geometry.value("events_splitter_state"));
this->ui->splitter_main->restoreState(geometry.value("main_splitter_state"));
}
@@ -444,7 +455,7 @@ void MainWindow::redrawMapScene()
if (!editor->displayMap())
return;
on_tabWidget_currentChanged(ui->tabWidget->currentIndex());
on_mainTabBar_tabBarClicked(ui->mainStackedWidget->currentIndex());
double base = editor->scale_base;
double exp = editor->scale_exp;
@@ -455,11 +466,7 @@ void MainWindow::redrawMapScene()
ui->graphicsView_Map->setScene(editor->scene);
ui->graphicsView_Map->setSceneRect(editor->scene->sceneRect());
ui->graphicsView_Map->setFixedSize(width, height);
ui->graphicsView_Objects_Map->setScene(editor->scene);
ui->graphicsView_Objects_Map->setSceneRect(editor->scene->sceneRect());
ui->graphicsView_Objects_Map->setFixedSize(width, height);
ui->graphicsView_Objects_Map->editor = editor;
ui->graphicsView_Map->editor = editor;
ui->graphicsView_Connections->setScene(editor->scene);
ui->graphicsView_Connections->setSceneRect(editor->scene->sceneRect());
@@ -1203,11 +1210,16 @@ void MainWindow::on_action_Exit_triggered()
QApplication::quit();
}
void MainWindow::on_tabWidget_currentChanged(int index)
void MainWindow::on_mainTabBar_tabBarClicked(int index)
{
int tabIndexToStackIndex[5] = {0, 0, 1, 2, 3};
ui->mainStackedWidget->setCurrentIndex(tabIndexToStackIndex[index]);
if (index == 0) {
ui->stackedWidget_MapEvents->setCurrentIndex(0);
on_tabWidget_2_currentChanged(ui->tabWidget_2->currentIndex());
} else if (index == 1) {
ui->stackedWidget_MapEvents->setCurrentIndex(1);
editor->setEditingObjects();
} else if (index == 3) {
editor->setEditingConnections();
@@ -1318,13 +1330,11 @@ void MainWindow::scaleMapView(int s) {
double sfactor = pow(base,s);
ui->graphicsView_Map->scale(sfactor,sfactor);
ui->graphicsView_Objects_Map->scale(sfactor,sfactor);
ui->graphicsView_Connections->scale(sfactor,sfactor);
int width = static_cast<int>(ceil((editor->scene->width()) * pow(base,exp))) + 2;
int height = static_cast<int>(ceil((editor->scene->height()) * pow(base,exp))) + 2;
ui->graphicsView_Map->setFixedSize(width, height);
ui->graphicsView_Objects_Map->setFixedSize(width, height);
ui->graphicsView_Connections->setFixedSize(width, height);
}
}
@@ -2512,7 +2522,6 @@ void MainWindow::closeEvent(QCloseEvent *event) {
this->saveGeometry(),
this->saveState(),
this->ui->splitter_map->saveState(),
this->ui->splitter_events->saveState(),
this->ui->splitter_main->saveState()
);
porymapConfig.save();