|
@@ -1152,17 +1152,17 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
|
1152
|
1152
|
continue;
|
1153
|
1153
|
}
|
1154
|
1154
|
QString event_type = object->get("event_type");
|
1155
|
|
- if (event_type == "object") {
|
|
1155
|
+ if (event_type == EventType::Object) {
|
1156
|
1156
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(0, 0, 16, 16);
|
1157
|
|
- } else if (event_type == "warp") {
|
|
1157
|
+ } else if (event_type == EventType::Warp) {
|
1158
|
1158
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(16, 0, 16, 16);
|
1159
|
|
- } else if (event_type == "trap" || event_type == "trap_weather") {
|
|
1159
|
+ } else if (event_type == EventType::CoordScript || event_type == EventType::CoordWeather) {
|
1160
|
1160
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(32, 0, 16, 16);
|
1161
|
|
- } else if (event_type == "sign" || event_type == "event_hidden_item" || event_type == "event_secret_base") {
|
|
1161
|
+ } else if (event_type == EventType::Sign || event_type == EventType::HiddenItem || event_type == EventType::SecretBase) {
|
1162
|
1162
|
object->pixmap = QPixmap(":/images/Entities_16x16.png").copy(48, 0, 16, 16);
|
1163
|
1163
|
}
|
1164
|
1164
|
|
1165
|
|
- if (event_type == "object") {
|
|
1165
|
+ if (event_type == EventType::Object) {
|
1166
|
1166
|
int sprite_id = constants.value(object->get("sprite"));
|
1167
|
1167
|
|
1168
|
1168
|
QString info_label = pointers.value(sprite_id).replace("&", "");
|
|
@@ -1178,117 +1178,74 @@ void Project::loadEventPixmaps(QList<Event*> objects) {
|
1178
|
1178
|
object->pixmap = pixmap;
|
1179
|
1179
|
}
|
1180
|
1180
|
}
|
1181
|
|
-
|
1182
|
1181
|
}
|
1183
|
1182
|
}
|
1184
|
|
-
|
1185
|
1183
|
}
|
1186
|
1184
|
|
1187
|
1185
|
void Project::saveMapEvents(Map *map) {
|
1188
|
1186
|
QString path = root + QString("/data/maps/%1/events.inc").arg(map->name);
|
1189
|
1187
|
QString text = "";
|
1190
|
|
-
|
1191
|
|
- if (map->events["object"].length() > 0) {
|
1192
|
|
- text += QString("%1::\n").arg(map->object_events_label);
|
1193
|
|
- for (int i = 0; i < map->events["object"].length(); i++) {
|
1194
|
|
- Event *object_event = map->events["object"].value(i);
|
1195
|
|
- int radius_x = object_event->getInt("radius_x");
|
1196
|
|
- int radius_y = object_event->getInt("radius_y");
|
1197
|
|
- uint16_t x = object_event->getInt("x");
|
1198
|
|
- uint16_t y = object_event->getInt("y");
|
1199
|
|
-
|
1200
|
|
- text += QString("\tobject_event %1").arg(i + 1);
|
1201
|
|
- text += QString(", %1").arg(object_event->get("sprite"));
|
1202
|
|
- text += QString(", %1").arg(object_event->get("replacement"));
|
1203
|
|
- text += QString(", %1").arg(x);
|
1204
|
|
- text += QString(", %1").arg(y);
|
1205
|
|
- text += QString(", %1").arg(object_event->get("elevation"));
|
1206
|
|
- text += QString(", %1").arg(object_event->get("behavior"));
|
1207
|
|
- text += QString(", %1").arg(radius_x);
|
1208
|
|
- text += QString(", %1").arg(radius_y);
|
1209
|
|
- text += QString(", %1").arg(object_event->get("property"));
|
1210
|
|
- text += QString(", %1").arg(object_event->get("sight_radius"));
|
1211
|
|
- text += QString(", %1").arg(object_event->get("script_label"));
|
1212
|
|
- text += QString(", %1").arg(object_event->get("event_flag"));
|
1213
|
|
- text += "\n";
|
|
1188
|
+ QString objectEventsLabel = "0x0";
|
|
1189
|
+ QString warpEventsLabel = "0x0";
|
|
1190
|
+ QString coordEventsLabel = "0x0";
|
|
1191
|
+ QString bgEventsLabel = "0x0";
|
|
1192
|
+
|
|
1193
|
+ if (map->events["object_event_group"].length() > 0) {
|
|
1194
|
+ objectEventsLabel = Map::objectEventsLabelFromName(map->name);
|
|
1195
|
+ text += QString("%1::\n").arg(objectEventsLabel);
|
|
1196
|
+ for (int i = 0; i < map->events["object_event_group"].length(); i++) {
|
|
1197
|
+ Event *object_event = map->events["object_event_group"].value(i);
|
|
1198
|
+ text += object_event->buildObjectEventMacro(i);
|
1214
|
1199
|
}
|
1215
|
1200
|
text += "\n";
|
1216
|
1201
|
}
|
1217
|
1202
|
|
1218
|
|
- if (map->events["warp"].length() > 0) {
|
1219
|
|
- text += QString("%1::\n").arg(map->warps_label);
|
1220
|
|
- for (Event *warp : map->events["warp"]) {
|
1221
|
|
- text += QString("\twarp_def %1").arg(warp->get("x"));
|
1222
|
|
- text += QString(", %1").arg(warp->get("y"));
|
1223
|
|
- text += QString(", %1").arg(warp->get("elevation"));
|
1224
|
|
- text += QString(", %1").arg(warp->get("destination_warp"));
|
1225
|
|
- text += QString(", %1").arg(mapNamesToMapConstants->value(warp->get("destination_map_name")));
|
1226
|
|
- text += "\n";
|
|
1203
|
+ if (map->events["warp_event_group"].length() > 0) {
|
|
1204
|
+ warpEventsLabel = Map::warpEventsLabelFromName(map->name);
|
|
1205
|
+ text += QString("%1::\n").arg(warpEventsLabel);
|
|
1206
|
+ for (Event *warp : map->events["warp_event_group"]) {
|
|
1207
|
+ text += warp->buildWarpEventMacro(mapNamesToMapConstants);
|
1227
|
1208
|
}
|
1228
|
1209
|
text += "\n";
|
1229
|
1210
|
}
|
1230
|
1211
|
|
1231
|
|
- if (map->events["trap"].length() + map->events["trap_weather"].length() > 0) {
|
1232
|
|
- text += QString("%1::\n").arg(map->coord_events_label);
|
1233
|
|
- for (Event *coords : map->events["trap"]) {
|
1234
|
|
- text += QString("\tcoord_event %1").arg(coords->get("x"));
|
1235
|
|
- text += QString(", %1").arg(coords->get("y"));
|
1236
|
|
- text += QString(", %1").arg(coords->get("elevation"));
|
1237
|
|
- text += QString(", 0");
|
1238
|
|
- text += QString(", %1").arg(coords->get("script_var"));
|
1239
|
|
- text += QString(", %1").arg(coords->get("script_var_value"));
|
1240
|
|
- text += QString(", 0");
|
1241
|
|
- text += QString(", %1").arg(coords->get("script_label"));
|
1242
|
|
- text += "\n";
|
1243
|
|
- }
|
1244
|
|
- for (Event *coords : map->events["trap_weather"]) {
|
1245
|
|
- text += QString("\tcoord_weather_event %1").arg(coords->get("x"));
|
1246
|
|
- text += QString(", %1").arg(coords->get("y"));
|
1247
|
|
- text += QString(", %1").arg(coords->get("elevation"));
|
1248
|
|
- text += QString(", %1").arg(coords->get("weather"));
|
1249
|
|
- text += "\n";
|
|
1212
|
+ if (map->events["coord_event_group"].length() > 0) {
|
|
1213
|
+ coordEventsLabel = Map::coordEventsLabelFromName(map->name);
|
|
1214
|
+ text += QString("%1::\n").arg(coordEventsLabel);
|
|
1215
|
+ for (Event *event : map->events["coord_event_group"]) {
|
|
1216
|
+ QString event_type = event->get("event_type");
|
|
1217
|
+ if (event_type == EventType::CoordScript) {
|
|
1218
|
+ text += event->buildCoordScriptEventMacro();
|
|
1219
|
+ } else if (event_type == EventType::CoordWeather) {
|
|
1220
|
+ text += event->buildCoordWeatherEventMacro();
|
|
1221
|
+ }
|
1250
|
1222
|
}
|
1251
|
1223
|
text += "\n";
|
1252
|
1224
|
}
|
1253
|
1225
|
|
1254
|
|
- if (map->events["sign"].length() +
|
1255
|
|
- map->events["event_hidden_item"].length() +
|
1256
|
|
- map->events["event_secret_base"].length() > 0)
|
|
1226
|
+ if (map->events["bg_event_group"].length() > 0)
|
1257
|
1227
|
{
|
1258
|
|
- text += QString("%1::\n").arg(map->bg_events_label);
|
1259
|
|
- for (Event *sign : map->events["sign"]) {
|
1260
|
|
- text += QString("\tbg_event %1").arg(sign->get("x"));
|
1261
|
|
- text += QString(", %1").arg(sign->get("y"));
|
1262
|
|
- text += QString(", %1").arg(sign->get("elevation"));
|
1263
|
|
- text += QString(", %1").arg(sign->get("type"));
|
1264
|
|
- text += QString(", 0");
|
1265
|
|
- text += QString(", %1").arg(sign->get("script_label"));
|
1266
|
|
- text += "\n";
|
1267
|
|
- }
|
1268
|
|
- for (Event *item : map->events["event_hidden_item"]) {
|
1269
|
|
- text += QString("\tbg_hidden_item_event %1").arg(item->get("x"));
|
1270
|
|
- text += QString(", %1").arg(item->get("y"));
|
1271
|
|
- text += QString(", %1").arg(item->get("elevation"));
|
1272
|
|
- text += QString(", %1").arg(item->get("item"));
|
1273
|
|
- text += QString(", %1").arg(item->get("flag"));
|
1274
|
|
- text += "\n";
|
1275
|
|
- }
|
1276
|
|
- for (Event *item : map->events["event_secret_base"]) {
|
1277
|
|
- text += QString("\tbg_secret_base_event %1").arg(item->get("x"));
|
1278
|
|
- text += QString(", %1").arg(item->get("y"));
|
1279
|
|
- text += QString(", %1").arg(item->get("elevation"));
|
1280
|
|
- text += QString(", %1").arg(item->get("secret_base_map"));
|
1281
|
|
- text += "\n";
|
|
1228
|
+ bgEventsLabel = Map::bgEventsLabelFromName(map->name);
|
|
1229
|
+ text += QString("%1::\n").arg(bgEventsLabel);
|
|
1230
|
+ for (Event *event : map->events["bg_event_group"]) {
|
|
1231
|
+ QString event_type = event->get("event_type");
|
|
1232
|
+ if (event_type == EventType::Sign) {
|
|
1233
|
+ text += event->buildSignEventMacro();
|
|
1234
|
+ } else if (event_type == EventType::HiddenItem) {
|
|
1235
|
+ text += event->buildHiddenItemEventMacro();
|
|
1236
|
+ } else if (event_type == EventType::SecretBase) {
|
|
1237
|
+ text += event->buildSecretBaseEventMacro();
|
|
1238
|
+ }
|
1282
|
1239
|
}
|
1283
|
1240
|
text += "\n";
|
1284
|
1241
|
}
|
1285
|
1242
|
|
1286
|
1243
|
text += QString("%1::\n").arg(map->events_label);
|
1287
|
1244
|
text += QString("\tmap_events %1, %2, %3, %4\n")
|
1288
|
|
- .arg(map->object_events_label)
|
1289
|
|
- .arg(map->warps_label)
|
1290
|
|
- .arg(map->coord_events_label)
|
1291
|
|
- .arg(map->bg_events_label);
|
|
1245
|
+ .arg(objectEventsLabel)
|
|
1246
|
+ .arg(warpEventsLabel)
|
|
1247
|
+ .arg(coordEventsLabel)
|
|
1248
|
+ .arg(bgEventsLabel);
|
1292
|
1249
|
|
1293
|
1250
|
saveTextFile(path, text);
|
1294
|
1251
|
}
|
|
@@ -1306,13 +1263,13 @@ void Project::readMapEvents(Map *map) {
|
1306
|
1263
|
}
|
1307
|
1264
|
|
1308
|
1265
|
QStringList *labels = getLabelValues(parseAsm(text), map->events_label);
|
1309
|
|
- map->object_events_label = labels->value(0);
|
1310
|
|
- map->warps_label = labels->value(1);
|
1311
|
|
- map->coord_events_label = labels->value(2);
|
1312
|
|
- map->bg_events_label = labels->value(3);
|
|
1266
|
+ QString objectEventsLabel = labels->value(0);
|
|
1267
|
+ QString warpEventsLabel = labels->value(1);
|
|
1268
|
+ QString coordEventsLabel = labels->value(2);
|
|
1269
|
+ QString bgEventsLabel = labels->value(3);
|
1313
|
1270
|
|
1314
|
|
- QList<QStringList> *object_events = getLabelMacros(parseAsm(text), map->object_events_label);
|
1315
|
|
- map->events["object"].clear();
|
|
1271
|
+ QList<QStringList> *object_events = getLabelMacros(parseAsm(text), objectEventsLabel);
|
|
1272
|
+ map->events["object_event_group"].clear();
|
1316
|
1273
|
for (QStringList command : *object_events) {
|
1317
|
1274
|
if (command.value(0) == "object_event") {
|
1318
|
1275
|
Event *object = new Event;
|
|
@@ -1326,18 +1283,18 @@ void Project::readMapEvents(Map *map) {
|
1326
|
1283
|
object->put("behavior", command.value(i++));
|
1327
|
1284
|
object->put("radius_x", command.value(i++).toInt(nullptr, 0));
|
1328
|
1285
|
object->put("radius_y", command.value(i++).toInt(nullptr, 0));
|
1329
|
|
- object->put("property", command.value(i++));
|
1330
|
|
- object->put("sight_radius", command.value(i++));
|
|
1286
|
+ object->put("trainer_see_type", command.value(i++));
|
|
1287
|
+ object->put("sight_radius_tree_id", command.value(i++));
|
1331
|
1288
|
object->put("script_label", command.value(i++));
|
1332
|
1289
|
object->put("event_flag", command.value(i++));
|
1333
|
|
-
|
1334
|
|
- object->put("event_type", "object");
|
1335
|
|
- map->events["object"].append(object);
|
|
1290
|
+ object->put("event_group_type", "object_event_group");
|
|
1291
|
+ object->put("event_type", EventType::Object);
|
|
1292
|
+ map->events["object_event_group"].append(object);
|
1336
|
1293
|
}
|
1337
|
1294
|
}
|
1338
|
1295
|
|
1339
|
|
- QList<QStringList> *warps = getLabelMacros(parseAsm(text), map->warps_label);
|
1340
|
|
- map->events["warp"].clear();
|
|
1296
|
+ QList<QStringList> *warps = getLabelMacros(parseAsm(text), warpEventsLabel);
|
|
1297
|
+ map->events["warp_event_group"].clear();
|
1341
|
1298
|
for (QStringList command : *warps) {
|
1342
|
1299
|
if (command.value(0) == "warp_def") {
|
1343
|
1300
|
Event *warp = new Event;
|
|
@@ -1352,17 +1309,17 @@ void Project::readMapEvents(Map *map) {
|
1352
|
1309
|
QString mapConstant = command.value(i++);
|
1353
|
1310
|
if (mapConstantsToMapNames->contains(mapConstant)) {
|
1354
|
1311
|
warp->put("destination_map_name", mapConstantsToMapNames->value(mapConstant));
|
1355
|
|
- warp->put("event_type", "warp");
|
1356
|
|
- map->events["warp"].append(warp);
|
|
1312
|
+ warp->put("event_group_type", "warp_event_group");
|
|
1313
|
+ warp->put("event_type", EventType::Warp);
|
|
1314
|
+ map->events["warp_event_group"].append(warp);
|
1357
|
1315
|
} else {
|
1358
|
1316
|
qDebug() << QString("Destination map constant '%1' is invalid for warp").arg(mapConstant);
|
1359
|
1317
|
}
|
1360
|
1318
|
}
|
1361
|
1319
|
}
|
1362
|
1320
|
|
1363
|
|
- QList<QStringList> *coords = getLabelMacros(parseAsm(text), map->coord_events_label);
|
1364
|
|
- map->events["trap"].clear();
|
1365
|
|
- map->events["trap_weather"].clear();
|
|
1321
|
+ QList<QStringList> *coords = getLabelMacros(parseAsm(text), coordEventsLabel);
|
|
1322
|
+ map->events["coord_event_group"].clear();
|
1366
|
1323
|
for (QStringList command : *coords) {
|
1367
|
1324
|
if (command.value(0) == "coord_event") {
|
1368
|
1325
|
Event *coord = new Event;
|
|
@@ -1383,8 +1340,9 @@ void Project::readMapEvents(Map *map) {
|
1383
|
1340
|
//coord_unknown3
|
1384
|
1341
|
//coord_unknown4
|
1385
|
1342
|
|
1386
|
|
- coord->put("event_type", "trap");
|
1387
|
|
- map->events["trap"].append(coord);
|
|
1343
|
+ coord->put("event_group_type", "coord_event_group");
|
|
1344
|
+ coord->put("event_type", EventType::CoordScript);
|
|
1345
|
+ map->events["coord_event_group"].append(coord);
|
1388
|
1346
|
} else if (command.value(0) == "coord_weather_event") {
|
1389
|
1347
|
Event *coord = new Event;
|
1390
|
1348
|
coord->put("map_name", map->name);
|
|
@@ -1393,15 +1351,14 @@ void Project::readMapEvents(Map *map) {
|
1393
|
1351
|
coord->put("y", command.value(i++));
|
1394
|
1352
|
coord->put("elevation", command.value(i++));
|
1395
|
1353
|
coord->put("weather", command.value(i++));
|
1396
|
|
- coord->put("event_type", "trap_weather");
|
1397
|
|
- map->events["trap_weather"].append(coord);
|
|
1354
|
+ coord->put("event_group_type", "coord_event_group");
|
|
1355
|
+ coord->put("event_type", EventType::CoordWeather);
|
|
1356
|
+ map->events["coord_event_group"].append(coord);
|
1398
|
1357
|
}
|
1399
|
1358
|
}
|
1400
|
1359
|
|
1401
|
|
- QList<QStringList> *bgs = getLabelMacros(parseAsm(text), map->bg_events_label);
|
1402
|
|
- map->events["sign"].clear();
|
1403
|
|
- map->events["event_hidden_item"].clear();
|
1404
|
|
- map->events["event_secret_base"].clear();
|
|
1360
|
+ QList<QStringList> *bgs = getLabelMacros(parseAsm(text), bgEventsLabel);
|
|
1361
|
+ map->events["bg_event_group"].clear();
|
1405
|
1362
|
for (QStringList command : *bgs) {
|
1406
|
1363
|
if (command.value(0) == "bg_event") {
|
1407
|
1364
|
Event *bg = new Event;
|
|
@@ -1410,12 +1367,13 @@ void Project::readMapEvents(Map *map) {
|
1410
|
1367
|
bg->put("x", command.value(i++));
|
1411
|
1368
|
bg->put("y", command.value(i++));
|
1412
|
1369
|
bg->put("elevation", command.value(i++));
|
1413
|
|
- bg->put("type", command.value(i++));
|
|
1370
|
+ bg->put("player_facing_direction", command.value(i++));
|
1414
|
1371
|
i++;
|
1415
|
1372
|
bg->put("script_label", command.value(i++));
|
1416
|
1373
|
//sign_unknown7
|
1417
|
|
- bg->put("event_type", "sign");
|
1418
|
|
- map->events["sign"].append(bg);
|
|
1374
|
+ bg->put("event_group_type", "bg_event_group");
|
|
1375
|
+ bg->put("event_type", EventType::Sign);
|
|
1376
|
+ map->events["bg_event_group"].append(bg);
|
1419
|
1377
|
} else if (command.value(0) == "bg_hidden_item_event") {
|
1420
|
1378
|
Event *bg = new Event;
|
1421
|
1379
|
bg->put("map_name", map->name);
|
|
@@ -1425,8 +1383,9 @@ void Project::readMapEvents(Map *map) {
|
1425
|
1383
|
bg->put("elevation", command.value(i++));
|
1426
|
1384
|
bg->put("item", command.value(i++));
|
1427
|
1385
|
bg->put("flag", command.value(i++));
|
1428
|
|
- bg->put("event_type", "event_hidden_item");
|
1429
|
|
- map->events["event_hidden_item"].append(bg);
|
|
1386
|
+ bg->put("event_group_type", "bg_event_group");
|
|
1387
|
+ bg->put("event_type", EventType::HiddenItem);
|
|
1388
|
+ map->events["bg_event_group"].append(bg);
|
1430
|
1389
|
} else if (command.value(0) == "bg_secret_base_event") {
|
1431
|
1390
|
Event *bg = new Event;
|
1432
|
1391
|
bg->put("map_name", map->name);
|
|
@@ -1435,24 +1394,18 @@ void Project::readMapEvents(Map *map) {
|
1435
|
1394
|
bg->put("y", command.value(i++));
|
1436
|
1395
|
bg->put("elevation", command.value(i++));
|
1437
|
1396
|
bg->put("secret_base_map", command.value(i++));
|
1438
|
|
- bg->put("event_type", "event_secret_base");
|
1439
|
|
- map->events["event_secret_base"].append(bg);
|
|
1397
|
+ bg->put("event_group_type", "bg_event_group");
|
|
1398
|
+ bg->put("event_type", EventType::SecretBase);
|
|
1399
|
+ map->events["bg_event_group"].append(bg);
|
1440
|
1400
|
}
|
1441
|
1401
|
}
|
1442
|
1402
|
}
|
1443
|
1403
|
|
1444
|
1404
|
void Project::setNewMapEvents(Map *map) {
|
1445
|
|
- map->object_events_label = "0x0";
|
1446
|
|
- map->warps_label = "0x0";
|
1447
|
|
- map->coord_events_label = "0x0";
|
1448
|
|
- map->bg_events_label = "0x0";
|
1449
|
|
- map->events["object"].clear();
|
1450
|
|
- map->events["warp"].clear();
|
1451
|
|
- map->events["trap"].clear();
|
1452
|
|
- map->events["trap_weather"].clear();
|
1453
|
|
- map->events["sign"].clear();
|
1454
|
|
- map->events["event_hidden_item"].clear();
|
1455
|
|
- map->events["event_secret_base"].clear();
|
|
1405
|
+ map->events["object_event_group"].clear();
|
|
1406
|
+ map->events["warp_event_group"].clear();
|
|
1407
|
+ map->events["coord_event_group"].clear();
|
|
1408
|
+ map->events["bg_event_group"].clear();
|
1456
|
1409
|
}
|
1457
|
1410
|
|
1458
|
1411
|
QStringList Project::readCArray(QString text, QString label) {
|