Skip to content

Commit

Permalink
Provide populated comboboxes and tooltips for (mostly) everything
Browse files Browse the repository at this point in the history
  • Loading branch information
huderlem committed Jul 14, 2018
1 parent 74c2766 commit fba2ade
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 263 deletions.
6 changes: 3 additions & 3 deletions event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ Event* Event::createNewObjectEvent()
Event *event = new Event;
event->put("event_group_type", "object_event_group");
event->put("event_type", EventType::Object);
event->put("sprite", "EVENT_OBJ_GFX_BOY_1");
event->put("sprite", "MOVEMENT_TYPE_LOOK_AROUND");
event->put("movement_type", "1");
event->put("radius_x", 0);
event->put("radius_y", 0);
event->put("script_label", "NULL");
event->put("event_flag", "0");
event->put("replacement", "0");
event->put("trainer_see_type", "0");
event->put("is_trainer", "FALSE");
event->put("sight_radius_tree_id", 0);
return event;
}
Expand Down Expand Up @@ -130,7 +130,7 @@ QString Event::buildObjectEventMacro(int item_index)
text += QString(", %1").arg(this->get("movement_type"));
text += QString(", %1").arg(radius_x);
text += QString(", %1").arg(radius_y);
text += QString(", %1").arg(this->get("trainer_see_type"));
text += QString(", %1").arg(this->get("is_trainer"));
text += QString(", %1").arg(this->get("sight_radius_tree_id"));
text += QString(", %1").arg(this->get("script_label"));
text += QString(", %1").arg(this->get("event_flag"));
Expand Down
79 changes: 65 additions & 14 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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");
Expand All @@ -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;
}
}

Expand All @@ -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) {
Expand All @@ -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();
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ private slots:

void on_checkBox_smartPaths_stateChanged(int selected);

void on_checkBox_Visibility_clicked(bool checked);

private:
Ui::MainWindow *ui;
QStandardItemModel *mapListModel;
Expand Down
Loading

0 comments on commit fba2ade

Please sign in to comment.