Merge remote-tracking branch 'origin/master' into scripting
This commit is contained in:
commit
e0afb24002
7 changed files with 65 additions and 28 deletions
|
@ -677,7 +677,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStackedWidget" name="stackedWidget_MapEvents">
|
||||
<widget class="AdjustingStackedWidget" name="stackedWidget_MapEvents">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
|
@ -3036,6 +3036,11 @@
|
|||
<extends>QComboBox</extends>
|
||||
<header>noscrollcombobox.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>AdjustingStackedWidget</class>
|
||||
<extends>QStackedWidget</extends>
|
||||
<header>adjustingstackedwidget.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>GraphicsView</class>
|
||||
<extends>QGraphicsView</extends>
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
QList<QStringList> groupedMapNames;
|
||||
QStringList *mapNames = nullptr;
|
||||
QMap<QString, QVariant> miscConstants;
|
||||
QList<HealLocation> flyableMaps;
|
||||
QList<HealLocation> healLocations;
|
||||
QMap<QString, QString>* mapConstantsToMapNames;
|
||||
QMap<QString, QString>* mapNamesToMapConstants;
|
||||
QList<QString> mapLayoutsTable;
|
||||
|
|
25
include/ui/adjustingstackedwidget.h
Normal file
25
include/ui/adjustingstackedwidget.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef ADJUSTINGSTACKEDWIDGET_H
|
||||
#define ADJUSTINGSTACKEDWIDGET_H
|
||||
|
||||
#include <QStackedWidget>
|
||||
|
||||
|
||||
|
||||
class AdjustingStackedWidget : public QStackedWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AdjustingStackedWidget(QWidget *parent = nullptr) : QStackedWidget(parent) {}
|
||||
|
||||
// override this to allow the stacked widget's current page to dictate size
|
||||
virtual void setCurrentIndex(int index) {
|
||||
QStackedWidget::setCurrentIndex(index);
|
||||
for (int i = 0; i < this->count(); ++i) {
|
||||
this->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
}
|
||||
this->widget(index)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // ADJUSTINGSTACKEDWIDGET_H
|
|
@ -122,6 +122,7 @@ HEADERS += include/core/block.h \
|
|||
include/ui/noscrollcombobox.h \
|
||||
include/ui/noscrollspinbox.h \
|
||||
include/ui/montabwidget.h \
|
||||
include/ui/adjustingstackedwidget.h \
|
||||
include/ui/paletteeditor.h \
|
||||
include/ui/selectablepixmapitem.h \
|
||||
include/ui/tileseteditor.h \
|
||||
|
|
|
@ -1067,10 +1067,14 @@ void Editor::mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item
|
|||
} else {
|
||||
// Left-clicking while in paint mode will add a new event of the
|
||||
// type of the first currently selected events.
|
||||
DraggablePixmapItem * newEvent = addNewEvent(this->selected_events->first()->event->get("event_type"));
|
||||
if (newEvent) {
|
||||
newEvent->move(x, y);
|
||||
selectMapEvent(newEvent, false);
|
||||
// Disallow adding heal locations, deleting them is not possible yet
|
||||
QString eventType = this->selected_events->first()->event->get("event_type");
|
||||
if (eventType != "event_heal_location") {
|
||||
DraggablePixmapItem * newEvent = addNewEvent(eventType);
|
||||
if (newEvent) {
|
||||
newEvent->move(x, y);
|
||||
selectMapEvent(newEvent, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (map_edit_mode == "select") {
|
||||
|
@ -1868,8 +1872,8 @@ DraggablePixmapItem* Editor::addNewEvent(QString event_type) {
|
|||
event->put("map_name", map->name);
|
||||
if (event_type == "event_heal_location") {
|
||||
HealLocation hl = HealLocation::fromEvent(event);
|
||||
project->flyableMaps.append(hl);
|
||||
event->put("index", project->flyableMaps.length());
|
||||
project->healLocations.append(hl);
|
||||
event->put("index", project->healLocations.length());
|
||||
}
|
||||
map->addEvent(event);
|
||||
project->loadEventPixmaps(map->getAllEvents());
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "currentselectedmetatilespixmapitem.h"
|
||||
#include "customattributestable.h"
|
||||
#include "scripting.h"
|
||||
#include "adjustingstackedwidget.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QDirIterator>
|
||||
|
|
|
@ -341,7 +341,7 @@ bool Project::loadMapData(Map* map) {
|
|||
}
|
||||
|
||||
map->events["heal_event_group"].clear();
|
||||
for (auto it = flyableMaps.begin(); it != flyableMaps.end(); it++) {
|
||||
for (auto it = healLocations.begin(); it != healLocations.end(); it++) {
|
||||
|
||||
HealLocation loc = *it;
|
||||
|
||||
|
@ -917,33 +917,34 @@ void Project::saveHealLocationStruct(Map *map) {
|
|||
QString constants_text = QString("#ifndef GUARD_CONSTANTS_HEAL_LOCATIONS_H\n");
|
||||
constants_text += QString("#define GUARD_CONSTANTS_HEAL_LOCATIONS_H\n\n");
|
||||
|
||||
QMap<QString, int> flyableMapsDupes;
|
||||
QSet<QString> flyableMapsUnique;
|
||||
QMap<QString, int> healLocationsDupes;
|
||||
QSet<QString> healLocationsUnique;
|
||||
|
||||
// set flyableMapsDupes and flyableMapsUnique
|
||||
for (auto it = flyableMaps.begin(); it != flyableMaps.end(); it++) {
|
||||
// set healLocationsDupes and healLocationsUnique
|
||||
for (auto it = healLocations.begin(); it != healLocations.end(); it++) {
|
||||
HealLocation loc = *it;
|
||||
QString xname = loc.idName;
|
||||
if (flyableMapsUnique.contains(xname)) {
|
||||
flyableMapsDupes[xname] = 1;
|
||||
if (healLocationsUnique.contains(xname)) {
|
||||
healLocationsDupes[xname] = 1;
|
||||
}
|
||||
flyableMapsUnique.insert(xname);
|
||||
healLocationsUnique.insert(xname);
|
||||
}
|
||||
|
||||
// set new location in flyableMapsList
|
||||
// set new location in healLocations list
|
||||
if (map->events["heal_event_group"].length() > 0) {
|
||||
for (Event *healEvent : map->events["heal_event_group"]) {
|
||||
HealLocation hl = HealLocation::fromEvent(healEvent);
|
||||
flyableMaps[hl.index - 1] = hl;
|
||||
healLocations[hl.index - 1] = hl;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 1;
|
||||
for (auto map_in : flyableMaps) {
|
||||
for (auto map_in : healLocations) {
|
||||
// add numbered suffix for duplicate constants
|
||||
if (flyableMapsDupes.keys().contains(map_in.idName)) {
|
||||
map_in.idName += QString("_%1").arg(flyableMapsDupes[map_in.idName]);
|
||||
flyableMapsDupes[map_in.idName]++;
|
||||
if (healLocationsDupes.keys().contains(map_in.idName)) {
|
||||
QString duplicateName = map_in.idName;
|
||||
map_in.idName += QString("_%1").arg(healLocationsDupes[duplicateName]);
|
||||
healLocationsDupes[duplicateName]++;
|
||||
}
|
||||
|
||||
// Save first array (heal location coords), only data array in RSE
|
||||
|
@ -973,7 +974,7 @@ void Project::saveHealLocationStruct(Map *map) {
|
|||
data_text += QString("};\n\n%1%2u16 sWhiteoutRespawnHealCenterMapIdxs[][2] =\n{\n")
|
||||
.arg(dataQualifiers.value("heal_locations").isStatic ? "static " : "")
|
||||
.arg(dataQualifiers.value("heal_locations").isConst ? "const " : "");
|
||||
for (auto map_in : flyableMaps) {
|
||||
for (auto map_in : healLocations) {
|
||||
data_text += QString(" [%1%2 - 1] = {MAP_GROUP(%3), MAP_NUM(%3)},\n")
|
||||
.arg(constantPrefix)
|
||||
.arg(map_in.idName)
|
||||
|
@ -984,7 +985,7 @@ void Project::saveHealLocationStruct(Map *map) {
|
|||
data_text += QString("};\n\n%1%2u8 sWhiteoutRespawnHealerNpcIds[] =\n{\n")
|
||||
.arg(dataQualifiers.value("heal_locations").isStatic ? "static " : "")
|
||||
.arg(dataQualifiers.value("heal_locations").isConst ? "const " : "");
|
||||
for (auto map_in : flyableMaps) {
|
||||
for (auto map_in : healLocations) {
|
||||
data_text += QString(" [%1%2 - 1] = %3,\n")
|
||||
.arg(constantPrefix)
|
||||
.arg(map_in.idName)
|
||||
|
@ -2120,7 +2121,7 @@ bool Project::readRegionMapSections() {
|
|||
|
||||
bool Project::readHealLocations() {
|
||||
dataQualifiers.clear();
|
||||
flyableMaps.clear();
|
||||
healLocations.clear();
|
||||
QString filename = "src/data/heal_locations.h";
|
||||
fileWatcher.addPath(root + "/" + filename);
|
||||
QString text = parser.readTextFile(root + "/" + filename);
|
||||
|
@ -2147,7 +2148,7 @@ bool Project::readHealLocations() {
|
|||
unsigned x = spawn.captured("x").toUShort();
|
||||
unsigned y = spawn.captured("y").toUShort();
|
||||
unsigned npc = respawnNPC.captured("npc").toUShort();
|
||||
flyableMaps.append(HealLocation(idName, mapName, i, x, y, respawnMapName, npc));
|
||||
healLocations.append(HealLocation(idName, mapName, i, x, y, respawnMapName, npc));
|
||||
}
|
||||
} else {
|
||||
dataQualifiers.insert("heal_locations", getDataQualifiers(text, "sHealLocations"));
|
||||
|
@ -2160,7 +2161,7 @@ bool Project::readHealLocations() {
|
|||
QString mapName = match.captured("map");
|
||||
unsigned x = match.captured("x").toUShort();
|
||||
unsigned y = match.captured("y").toUShort();
|
||||
flyableMaps.append(HealLocation(idName, mapName, i, x, y));
|
||||
healLocations.append(HealLocation(idName, mapName, i, x, y));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -2497,7 +2498,7 @@ void Project::saveMapHealEvents(Map *map) {
|
|||
if (map->events["heal_event_group"].length() > 0) {
|
||||
for (Event *healEvent : map->events["heal_event_group"]) {
|
||||
HealLocation hl = HealLocation::fromEvent(healEvent);
|
||||
flyableMaps[hl.index - 1] = hl;
|
||||
healLocations[hl.index - 1] = hl;
|
||||
}
|
||||
}
|
||||
saveHealLocationStruct(map);
|
||||
|
|
Loading…
Reference in a new issue