Provide populated comboboxes and tooltips for (mostly) everything

This commit is contained in:
Marcus Huderle
2018-07-13 20:33:49 -05:00
parent 74c2766c01
commit fba2ade2bb
8 changed files with 328 additions and 263 deletions

View File

@@ -244,7 +244,7 @@ void MainWindow::setRecentMap(QString map_name) {
void MainWindow::displayMapProperties() {
ui->comboBox_Song->clear();
ui->comboBox_Location->clear();
ui->comboBox_Visibility->clear();
ui->checkBox_Visibility->setChecked(false);
ui->comboBox_Weather->clear();
ui->comboBox_Type->clear();
ui->comboBox_BattleScene->clear();
@@ -263,7 +263,7 @@ void MainWindow::displayMapProperties() {
ui->comboBox_Song->addItems(songs);
ui->comboBox_Song->setCurrentText(map->song);
ui->comboBox_Location->addItems(project->getLocations());
ui->comboBox_Location->addItems(*project->regionMapSections);
ui->comboBox_Location->setCurrentText(map->location);
QMap<QString, QStringList> tilesets = project->getTilesets();
@@ -272,16 +272,15 @@ void MainWindow::displayMapProperties() {
ui->comboBox_SecondaryTileset->addItems(tilesets.value("secondary"));
ui->comboBox_SecondaryTileset->setCurrentText(map->layout->tileset_secondary_label);
ui->comboBox_Visibility->addItems(project->getVisibilities());
ui->comboBox_Visibility->setCurrentText(map->visibility);
ui->checkBox_Visibility->setChecked(map->requiresFlash.toInt() > 0 || map->requiresFlash == "TRUE");
ui->comboBox_Weather->addItems(project->getWeathers());
ui->comboBox_Weather->addItems(*project->weatherNames);
ui->comboBox_Weather->setCurrentText(map->weather);
ui->comboBox_Type->addItems(project->getMapTypes());
ui->comboBox_Type->addItems(*project->mapTypes);
ui->comboBox_Type->setCurrentText(map->type);
ui->comboBox_BattleScene->addItems(project->getBattleScenes());
ui->comboBox_BattleScene->addItems(*project->mapBattleScenes);
ui->comboBox_BattleScene->setCurrentText(map->battle_scene);
ui->checkBox_ShowLocation->setChecked(map->show_location.toInt() > 0 || map->show_location == "TRUE");
@@ -301,10 +300,10 @@ void MainWindow::on_comboBox_Location_activated(const QString &location)
}
}
void MainWindow::on_comboBox_Visibility_activated(const QString &visibility)
void MainWindow::on_comboBox_Visibility_activated(const QString &requiresFlash)
{
if (editor && editor->map) {
editor->map->visibility = visibility;
editor->map->requiresFlash = requiresFlash;
}
}
@@ -329,6 +328,17 @@ void MainWindow::on_comboBox_BattleScene_activated(const QString &battle_scene)
}
}
void MainWindow::on_checkBox_Visibility_clicked(bool checked)
{
if (editor && editor->map) {
if (checked) {
editor->map->requiresFlash = "TRUE";
} else {
editor->map->requiresFlash = "FALSE";
}
}
}
void MainWindow::on_checkBox_ShowLocation_clicked(bool checked)
{
if (editor && editor->map) {
@@ -344,10 +354,14 @@ void MainWindow::loadDataStructures() {
Project *project = editor->project;
project->readMapLayoutsTable();
project->readAllMapLayouts();
project->readRegionMapSections();
project->readItemNames();
project->readFlagNames();
project->readVarNames();
project->readMovementTypes();
project->readMapTypes();
project->readMapBattleScenes();
project->readWeatherNames();
project->readCoordEventWeatherNames();
project->readSecretBaseIds();
project->readBgEventFacingDirections();
@@ -642,11 +656,10 @@ void MainWindow::updateSelectedObjects() {
QMap<QString, QString> field_labels;
field_labels["script_label"] = "Script";
field_labels["event_flag"] = "Event Flag";
field_labels["replacement"] = "Replacement";
field_labels["movement_type"] = "Movement";
field_labels["radius_x"] = "Movement Radius X";
field_labels["radius_y"] = "Movement Radius Y";
field_labels["trainer_see_type"] = "Trainer See Type";
field_labels["is_trainer"] = "Trainer";
field_labels["sight_radius_tree_id"] = "Sight Radius / Berry Tree ID";
field_labels["destination_warp"] = "Destination Warp";
field_labels["destination_map_name"] = "Destination Map";
@@ -684,8 +697,7 @@ void MainWindow::updateSelectedObjects() {
fields << "radius_y";
fields << "script_label";
fields << "event_flag";
fields << "replacement";
fields << "trainer_see_type";
fields << "is_trainer";
fields << "sight_radius_tree_id";
}
else if (event_type == EventType::Warp) {
@@ -713,18 +725,38 @@ void MainWindow::updateSelectedObjects() {
}
for (QString key : fields) {
QString value = item->event->get(key);
QWidget *widget = new QWidget(frame);
QFormLayout *fl = new QFormLayout(widget);
fl->setContentsMargins(9, 0, 9, 0);
// is_trainer is the only non-combobox item.
if (key == "is_trainer") {
QCheckBox *checkbox = new QCheckBox(widget);
checkbox->setEnabled(true);
checkbox->setChecked(value.toInt() != 0 && value != "FALSE");
checkbox->setToolTip("Whether or not this object is trainer.");
fl->addRow(new QLabel(field_labels[key], widget), checkbox);
widget->setLayout(fl);
frame->layout()->addWidget(widget);
connect(checkbox, &QCheckBox::stateChanged, [=](int state) {
QString isTrainer = state == Qt::Checked ? "TRUE" : "FALSE";
item->event->put("is_trainer", isTrainer);
});
continue;
}
NoScrollComboBox *combo = new NoScrollComboBox(widget);
combo->setEditable(true);
QString value = item->event->get(key);
if (key == "destination_map_name") {
if (!editor->project->mapNames->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->mapNames);
combo->setToolTip("The destination map name of the warp.");
} else if (key == "destination_warp") {
combo->setToolTip("The warp id on the destination map.");
} else if (key == "item") {
if (!editor->project->itemNames->contains(value)) {
combo->addItem(value);
@@ -735,31 +767,50 @@ void MainWindow::updateSelectedObjects() {
combo->addItem(value);
}
combo->addItems(*editor->project->flagNames);
if (key == "flag")
combo->setToolTip("The flag which is set when the hidden item is picked up.");
else if (key == "event_flag")
combo->setToolTip("The flag which hides the object when set.");
} else if (key == "script_var") {
if (!editor->project->varNames->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->varNames);
combo->setToolTip("The variable by which the script is triggered. The script is triggered when this variable's value matches 'Var Value'.");
} else if (key == "script_var_value") {
combo->setToolTip("The variable's value which triggers the script.");
} else if (key == "movement_type") {
if (!editor->project->movementTypes->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->movementTypes);
combo->setToolTip("The object's natural movement behavior when the player is not interacting with it.");
} else if (key == "weather") {
if (!editor->project->coordEventWeatherNames->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->coordEventWeatherNames);
combo->setToolTip("The weather that starts when the player steps on this spot.");
} else if (key == "secret_base_id") {
if (!editor->project->secretBaseIds->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->secretBaseIds);
combo->setToolTip("The secret base id which is inside this secret base entrance. Secret base ids are meant to be unique to each and every secret base entrance.");
} else if (key == "player_facing_direction") {
if (!editor->project->bgEventFacingDirections->contains(value)) {
combo->addItem(value);
}
combo->addItems(*editor->project->bgEventFacingDirections);
combo->setToolTip("The direction which the player must be facing to be able to interact with this event.");
} else if (key == "radius_x") {
combo->setToolTip("The maximum number of metatiles this object is allowed to move left or right during its normal movement behavior actions.");
} else if (key == "radius_y") {
combo->setToolTip("The maximum number of metatiles this object is allowed to move up or down during its normal movement behavior actions.");
} else if (key == "script_label") {
combo->setToolTip("The script which is executed with this event.");
} else if (key == "sight_radius_tree_id") {
combo->setToolTip("The maximum sight range of a trainer, OR the unique id of the berry tree.");
} else {
combo->addItem(value);
}