Support bg_hidden_item_event

This commit is contained in:
Marcus Huderle 2018-02-12 13:29:45 -08:00
parent 22722f09c7
commit c3d0769967
3 changed files with 25 additions and 32 deletions

View file

@ -39,10 +39,6 @@ public:
values.insert(key, value);
}
bool is_hidden_item() {
return getInt("type") >= 5;
}
QMap<QString, QString> values;
QPixmap pixmap;
};

View file

@ -511,6 +511,8 @@ void MainWindow::updateSelectedObjects() {
field_labels["item"] = "Item";
field_labels["item_unknown5"] = "Unknown 5";
field_labels["item_unknown6"] = "Unknown 6";
field_labels["weather"] = "Weather";
field_labels["flag"] = "Flag";
QStringList fields;
@ -556,11 +558,9 @@ void MainWindow::updateSelectedObjects() {
fields << "type";
fields << "script_label";
}
else if (event_type == "hidden item") {
fields << "type";
else if (event_type == "event_hidden_item") {
fields << "item";
fields << "item_unknown5";
fields << "item_unknown6";
fields << "flag";
}
for (QString key : fields) {

View file

@ -667,7 +667,7 @@ void Project::loadObjectPixmaps(QList<Event*> objects) {
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
} else if (event_type == "trap" || event_type == "trap_weather") {
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
} else if (event_type == "sign" || event_type == "hidden item") {
} else if (event_type == "sign" || event_type == "event_hidden_item") {
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
}
@ -768,7 +768,7 @@ void Project::saveMapEvents(Map *map) {
text += "\n";
}
if (map->events["sign"].length() + map->events["hidden item"].length() > 0) {
if (map->events["sign"].length() + map->events["event_hidden_item"].length() > 0) {
text += QString("%1::\n").arg(map->bg_events_label);
for (Event *sign : map->events["sign"]) {
text += QString("\tbg_event %1").arg(sign->get("x"));
@ -779,15 +779,12 @@ void Project::saveMapEvents(Map *map) {
text += QString(", %1").arg(sign->get("script_label"));
text += "\n";
}
for (Event *item : map->events["hidden item"]) {
text += QString("\tbg_event %1").arg(item->get("x"));
for (Event *item : map->events["event_hidden_item"]) {
text += QString("\tbg_hidden_item_event %1").arg(item->get("x"));
text += QString(", %1").arg(item->get("y"));
text += QString(", %1").arg(item->get("elevation"));
text += QString(", %1").arg(item->get("type"));
text += QString(", 0");
text += QString(", %1").arg(item->get("item"));
text += QString(", %1").arg(item->get("item_unknown5"));
text += QString(", %1").arg(item->get("item_unknown6"));
text += QString(", %1").arg(item->get("flag"));
text += "\n";
}
text += "\n";
@ -924,7 +921,7 @@ void Project::readMapEvents(Map *map) {
}
QList<QStringList> *bgs = getLabelMacros(parse(text), map->bg_events_label);
map->events["hidden item"].clear();
map->events["event_hidden_item"].clear();
map->events["sign"].clear();
for (QStringList command : *bgs) {
if (command.value(0) == "bg_event") {
@ -936,23 +933,23 @@ void Project::readMapEvents(Map *map) {
bg->put("elevation", command.value(i++));
bg->put("type", command.value(i++));
i++;
if (bg->is_hidden_item()) {
bg->put("item", command.value(i++));
bg->put("item_unknown5", command.value(i++));
bg->put("item_unknown6", command.value(i++));
bg->put("event_type", "hidden item");
map->events["hidden item"].append(bg);
} else {
bg->put("script_label", command.value(i++));
//sign_unknown7
bg->put("event_type", "sign");
map->events["sign"].append(bg);
}
bg->put("script_label", command.value(i++));
//sign_unknown7
bg->put("event_type", "sign");
map->events["sign"].append(bg);
} else if (command.value(0) == "bg_hidden_item_event") {
Event *bg = new Event;
bg->put("map_name", map->name);
int i = 1;
bg->put("x", command.value(i++));
bg->put("y", command.value(i++));
bg->put("elevation", command.value(i++));
bg->put("item", command.value(i++));
bg->put("flag", command.value(i++));
bg->put("event_type", "event_hidden_item");
map->events["event_hidden_item"].append(bg);
}
}
}
QStringList Project::readCArray(QString text, QString label) {