Merge pull request #482 from GriffinRichards/config-tilesets
Save new map settings, add default tileset config options
This commit is contained in:
commit
0e039e0769
15 changed files with 300 additions and 284 deletions
|
@ -19,13 +19,13 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
- Add Cut/Copy/Paste for metatiles in the Tileset Editor.
|
- Add Cut/Copy/Paste for metatiles in the Tileset Editor.
|
||||||
- Add button to copy the full metatile label to the clipboard in the Tileset Editor.
|
- Add button to copy the full metatile label to the clipboard in the Tileset Editor.
|
||||||
- Add ability to export an image of the primary or secondary tileset's metatiles.
|
- Add ability to export an image of the primary or secondary tileset's metatiles.
|
||||||
- Add option to not open the most recent project on launch.
|
- Add new config options for customizing how new maps are filled, setting default tilesets, and whether the most recent project should be opened on launch.
|
||||||
- Add options for customizing how new maps are filled
|
|
||||||
- Add color picker to palette editor for taking colors from the screen.
|
- Add color picker to palette editor for taking colors from the screen.
|
||||||
- Add new features to the scripting API, including the ability to display messages and user input windows, set the overlay's opacity, rotation, scale, and clipping, interact with map header properties and the map border, read tile pixel data, and more.
|
- Add new features to the scripting API, including the ability to display messages and user input windows, set the overlay's opacity, rotation, scale, and clipping, interact with map header properties and the map border, read tile pixel data, and more.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Overhauled the region map editor, adding support for tilemaps, and significant customization. Also now supports pokefirered.
|
- Overhauled the region map editor, adding support for tilemaps, and significant customization. Also now supports pokefirered.
|
||||||
|
- Previous settings will be remembered in the New Map Options window.
|
||||||
- The Custom Attributes table for map headers and events now supports types other than strings.
|
- The Custom Attributes table for map headers and events now supports types other than strings.
|
||||||
- If an object event is inanimate, it will always render using its first frame.
|
- If an object event is inanimate, it will always render using its first frame.
|
||||||
- Unused metatile attribute bits are preserved instead of being cleared.
|
- Unused metatile attribute bits are preserved instead of being cleared.
|
||||||
|
@ -63,6 +63,8 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
||||||
- Silence unnecessary error logging when parsing C defines Porymap doesn't use.
|
- Silence unnecessary error logging when parsing C defines Porymap doesn't use.
|
||||||
- Fix some windows like the Tileset Editor not raising to the front when reactivated.
|
- Fix some windows like the Tileset Editor not raising to the front when reactivated.
|
||||||
- Metatile behaviors with no constant will now display their value in the Tileset Editor.
|
- Metatile behaviors with no constant will now display their value in the Tileset Editor.
|
||||||
|
- Fix incorrect limits on Floor Number and Border Width/Height in the New Map Options window.
|
||||||
|
- Fix Border Width/Height being set to 0 when creating a new map from an existing layout.
|
||||||
|
|
||||||
## [4.5.0] - 2021-12-26
|
## [4.5.0] - 2021-12-26
|
||||||
### Added
|
### Added
|
||||||
|
|
|
@ -57,7 +57,7 @@ For example if you wanted to rename ``include/constants/items.h`` to ``headers/d
|
||||||
include/constants/metatile_labels.h, yes, yes, ``constants_metatile_labels``,
|
include/constants/metatile_labels.h, yes, yes, ``constants_metatile_labels``,
|
||||||
include/constants/metatile_behaviors.h, yes, no, ``constants_metatile_behaviors``,
|
include/constants/metatile_behaviors.h, yes, no, ``constants_metatile_behaviors``,
|
||||||
include/fieldmap.h, yes, no, ``constants_fieldmap``, reads tileset related constants
|
include/fieldmap.h, yes, no, ``constants_fieldmap``, reads tileset related constants
|
||||||
src/event_object_movement.c, yes, no, ``path_initial_facing_table``, reads ``gInitialMovementTypeFacingDirections``
|
src/event_object_movement.c, yes, no, ``initial_facing_table``, reads ``gInitialMovementTypeFacingDirections``
|
||||||
src/pokemon_icon.c, yes, no, ``path_pokemon_icon_table``, reads files in ``gMonIconTable``
|
src/pokemon_icon.c, yes, no, ``pokemon_icon_table``, reads files in ``gMonIconTable``
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ your project root as ``porymap.user.cfg``. You should add this file to your giti
|
||||||
``new_map_metatile``, 1, project, yes, The metatile id that will be used to fill new maps
|
``new_map_metatile``, 1, project, yes, The metatile id that will be used to fill new maps
|
||||||
``new_map_elevation``, 3, project, yes, The elevation that will be used to fill new maps
|
``new_map_elevation``, 3, project, yes, The elevation that will be used to fill new maps
|
||||||
``new_map_border_metatiles``, "``468,469,476,477`` or ``20,21,28,29``", project, yes, The list of metatile ids that will be used to fill the 2x2 border of new maps
|
``new_map_border_metatiles``, "``468,469,476,477`` or ``20,21,28,29``", project, yes, The list of metatile ids that will be used to fill the 2x2 border of new maps
|
||||||
|
``default_primary_tileset``, ``gTileset_General``, project, yes, The label of the default primary tileset
|
||||||
|
``default_secondary_tileset``, ``gTileset_Petalburg`` or ``gTileset_PalletTown``, project, yes, The label of the default secondary tileset
|
||||||
``custom_scripts``, , user, yes, A list of script files to load into the scripting engine
|
``custom_scripts``, , user, yes, A list of script files to load into the scripting engine
|
||||||
``prefabs_filepath``, ``<project_root>/prefabs.json``, project, yes, The filepath containing prefab JSON data
|
``prefabs_filepath``, ``<project_root>/prefabs.json``, project, yes, The filepath containing prefab JSON data
|
||||||
``prefabs_import_prompted``, 0, project, no, Keeps track of whether or not the project was prompted for importing default prefabs
|
``prefabs_import_prompted``, 0, project, no, Keeps track of whether or not the project was prompted for importing default prefabs
|
||||||
|
|
|
@ -217,7 +217,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="10" column="1">
|
<item row="10" column="1">
|
||||||
<widget class="NoScrollComboBox" name="comboBox_Song">
|
<widget class="NoScrollComboBox" name="comboBox_NewMap_Song">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p>The default background music for this map.</p></body></html></string>
|
<string><html><head/><body><p>The default background music for this map.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -183,8 +183,8 @@ enum ProjectFilePath {
|
||||||
constants_metatile_labels,
|
constants_metatile_labels,
|
||||||
constants_metatile_behaviors,
|
constants_metatile_behaviors,
|
||||||
constants_fieldmap,
|
constants_fieldmap,
|
||||||
path_initial_facing_table,
|
initial_facing_table,
|
||||||
path_pokemon_icon_table,
|
pokemon_icon_table,
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProjectConfig: public KeyValueConfigBase
|
class ProjectConfig: public KeyValueConfigBase
|
||||||
|
@ -209,6 +209,7 @@ public:
|
||||||
this->newMapMetatileId = 1;
|
this->newMapMetatileId = 1;
|
||||||
this->newMapElevation = 3;
|
this->newMapElevation = 3;
|
||||||
this->newMapBorderMetatileIds = DEFAULT_BORDER_RSE;
|
this->newMapBorderMetatileIds = DEFAULT_BORDER_RSE;
|
||||||
|
this->defaultPrimaryTileset = "gTileset_General";
|
||||||
this->prefabFilepath = QString();
|
this->prefabFilepath = QString();
|
||||||
this->prefabImportPrompted = false;
|
this->prefabImportPrompted = false;
|
||||||
this->tilesetsHaveCallback = true;
|
this->tilesetsHaveCallback = true;
|
||||||
|
@ -251,6 +252,8 @@ public:
|
||||||
int getNewMapElevation();
|
int getNewMapElevation();
|
||||||
void setNewMapBorderMetatileIds(QList<int> metatileIds);
|
void setNewMapBorderMetatileIds(QList<int> metatileIds);
|
||||||
QList<int> getNewMapBorderMetatileIds();
|
QList<int> getNewMapBorderMetatileIds();
|
||||||
|
QString getDefaultPrimaryTileset();
|
||||||
|
QString getDefaultSecondaryTileset();
|
||||||
void setFilePath(ProjectFilePath pathId, QString path);
|
void setFilePath(ProjectFilePath pathId, QString path);
|
||||||
QString getFilePath(ProjectFilePath pathId);
|
QString getFilePath(ProjectFilePath pathId);
|
||||||
void setPrefabFilepath(QString filepath);
|
void setPrefabFilepath(QString filepath);
|
||||||
|
@ -285,6 +288,8 @@ private:
|
||||||
int newMapMetatileId;
|
int newMapMetatileId;
|
||||||
int newMapElevation;
|
int newMapElevation;
|
||||||
QList<int> newMapBorderMetatileIds;
|
QList<int> newMapBorderMetatileIds;
|
||||||
|
QString defaultPrimaryTileset;
|
||||||
|
QString defaultSecondaryTileset;
|
||||||
QStringList readKeys;
|
QStringList readKeys;
|
||||||
QString prefabFilepath;
|
QString prefabFilepath;
|
||||||
bool prefabImportPrompted;
|
bool prefabImportPrompted;
|
||||||
|
|
|
@ -15,7 +15,7 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString name;
|
QString name;
|
||||||
QString is_secondary;
|
bool is_secondary;
|
||||||
QString tiles_label;
|
QString tiles_label;
|
||||||
QString palettes_label;
|
QString palettes_label;
|
||||||
QString metatiles_label;
|
QString metatiles_label;
|
||||||
|
|
|
@ -176,8 +176,7 @@ private slots:
|
||||||
void onMapNeedsRedrawing();
|
void onMapNeedsRedrawing();
|
||||||
void onTilesetsSaved(QString, QString);
|
void onTilesetsSaved(QString, QString);
|
||||||
void onWildMonDataChanged();
|
void onWildMonDataChanged();
|
||||||
void openNewMapPopupWindow(int, QVariant);
|
void openNewMapPopupWindow();
|
||||||
void openNewMapPopupWindowImportMap(MapLayout *);
|
|
||||||
void onNewMapCreated();
|
void onNewMapCreated();
|
||||||
void onMapCacheCleared();
|
void onMapCacheCleared();
|
||||||
void importMapFromAdvanceMap1_92();
|
void importMapFromAdvanceMap1_92();
|
||||||
|
@ -330,6 +329,7 @@ private:
|
||||||
bool isProgrammaticEventTabChange;
|
bool isProgrammaticEventTabChange;
|
||||||
bool projectHasUnsavedChanges;
|
bool projectHasUnsavedChanges;
|
||||||
bool projectOpenFailure = false;
|
bool projectOpenFailure = false;
|
||||||
|
bool openedNewMapDialog = false;
|
||||||
|
|
||||||
MapSortOrder mapSortOrder;
|
MapSortOrder mapSortOrder;
|
||||||
|
|
||||||
|
@ -389,6 +389,7 @@ private:
|
||||||
|
|
||||||
QObjectList shortcutableObjects() const;
|
QObjectList shortcutableObjects() const;
|
||||||
void addCustomHeaderValue(QString key, QJsonValue value, bool isNew = false);
|
void addCustomHeaderValue(QString key, QJsonValue value, bool isNew = false);
|
||||||
|
int insertTilesetLabel(QStringList * list, QString label);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MapListUserRoles {
|
enum MapListUserRoles {
|
||||||
|
|
|
@ -108,7 +108,8 @@ public:
|
||||||
QMap<QString, Tileset*> tilesetCache;
|
QMap<QString, Tileset*> tilesetCache;
|
||||||
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
|
Tileset* loadTileset(QString, Tileset *tileset = nullptr);
|
||||||
Tileset* getTileset(QString, bool forceLoad = false);
|
Tileset* getTileset(QString, bool forceLoad = false);
|
||||||
QMap<QString, QStringList> tilesetLabels;
|
QStringList primaryTilesetLabels;
|
||||||
|
QStringList secondaryTilesetLabels;
|
||||||
QStringList tilesetLabelsOrdered;
|
QStringList tilesetLabelsOrdered;
|
||||||
|
|
||||||
Blockdata readBlockdata(QString);
|
Blockdata readBlockdata(QString);
|
||||||
|
@ -170,8 +171,7 @@ public:
|
||||||
|
|
||||||
QString defaultSong;
|
QString defaultSong;
|
||||||
QStringList getVisibilities();
|
QStringList getVisibilities();
|
||||||
void insertTilesetLabel(QString label, bool isSecondary);
|
void appendTilesetLabel(QString label, QString isSecondaryStr);
|
||||||
void insertTilesetLabel(QString label, QString isSecondaryStr);
|
|
||||||
bool readTilesetLabels();
|
bool readTilesetLabels();
|
||||||
bool readTilesetProperties();
|
bool readTilesetProperties();
|
||||||
bool readMaxMapDataSize();
|
bool readMaxMapDataSize();
|
||||||
|
@ -210,6 +210,9 @@ public:
|
||||||
QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels);
|
QCompleter *getEventScriptLabelCompleter(QStringList additionalScriptLabels);
|
||||||
QStringList getGlobalScriptLabels();
|
QStringList getGlobalScriptLabels();
|
||||||
|
|
||||||
|
QString getDefaultPrimaryTilesetLabel();
|
||||||
|
QString getDefaultSecondaryTilesetLabel();
|
||||||
|
|
||||||
static int getNumTilesPrimary();
|
static int getNumTilesPrimary();
|
||||||
static int getNumTilesTotal();
|
static int getNumTilesTotal();
|
||||||
static int getNumMetatilesPrimary();
|
static int getNumMetatilesPrimary();
|
||||||
|
@ -229,7 +232,6 @@ private:
|
||||||
void updateMapLayout(Map*);
|
void updateMapLayout(Map*);
|
||||||
|
|
||||||
void setNewMapHeader(Map* map, int mapIndex);
|
void setNewMapHeader(Map* map, int mapIndex);
|
||||||
void setNewMapLayout(Map* map);
|
|
||||||
void setNewMapBlockdata(Map* map);
|
void setNewMapBlockdata(Map* map);
|
||||||
void setNewMapBorder(Map *map);
|
void setNewMapBorder(Map *map);
|
||||||
void setNewMapEvents(Map *map);
|
void setNewMapEvents(Map *map);
|
||||||
|
|
|
@ -22,10 +22,10 @@ public:
|
||||||
bool existingLayout;
|
bool existingLayout;
|
||||||
bool importedMap;
|
bool importedMap;
|
||||||
QString layoutId;
|
QString layoutId;
|
||||||
void init(int, int, QString, QString);
|
void init();
|
||||||
void initImportMap(MapLayout *);
|
void init(MapSortOrder type, QVariant data);
|
||||||
void useLayout(QString);
|
void init(MapLayout *);
|
||||||
void connectSignals();
|
static void setDefaultSettings(Project *project);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void applied();
|
void applied();
|
||||||
|
@ -33,11 +33,31 @@ signals:
|
||||||
private:
|
private:
|
||||||
Ui::NewMapPopup *ui;
|
Ui::NewMapPopup *ui;
|
||||||
Project *project;
|
Project *project;
|
||||||
void setDefaultValues(int, QString);
|
|
||||||
void setDefaultValuesImportMap(MapLayout *);
|
|
||||||
void setDefaultValuesProjectConfig(bool, MapLayout*);
|
|
||||||
bool checkNewMapDimensions();
|
bool checkNewMapDimensions();
|
||||||
bool checkNewMapGroup();
|
bool checkNewMapGroup();
|
||||||
|
void saveSettings();
|
||||||
|
void useLayout(QString layoutId);
|
||||||
|
void useLayoutSettings(MapLayout *mapLayout);
|
||||||
|
|
||||||
|
struct Settings {
|
||||||
|
QString group;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
int borderWidth;
|
||||||
|
int borderHeight;
|
||||||
|
QString primaryTilesetLabel;
|
||||||
|
QString secondaryTilesetLabel;
|
||||||
|
QString type;
|
||||||
|
QString location;
|
||||||
|
QString song;
|
||||||
|
bool canFlyTo;
|
||||||
|
bool showLocationName;
|
||||||
|
bool allowRunning;
|
||||||
|
bool allowBiking;
|
||||||
|
bool allowEscaping;
|
||||||
|
int floorNumber;
|
||||||
|
};
|
||||||
|
static struct Settings settings;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_NewMap_Accept_clicked();
|
void on_pushButton_NewMap_Accept_clicked();
|
||||||
|
|
|
@ -59,8 +59,8 @@ const QMap<ProjectFilePath, std::pair<QString, QString>> defaultPaths = {
|
||||||
{ProjectFilePath::constants_metatile_labels, { "constants_metatile_labels", "include/constants/metatile_labels.h"}},
|
{ProjectFilePath::constants_metatile_labels, { "constants_metatile_labels", "include/constants/metatile_labels.h"}},
|
||||||
{ProjectFilePath::constants_metatile_behaviors, { "constants_metatile_behaviors", "include/constants/metatile_behaviors.h"}},
|
{ProjectFilePath::constants_metatile_behaviors, { "constants_metatile_behaviors", "include/constants/metatile_behaviors.h"}},
|
||||||
{ProjectFilePath::constants_fieldmap, { "constants_fieldmap", "include/fieldmap.h"}},
|
{ProjectFilePath::constants_fieldmap, { "constants_fieldmap", "include/fieldmap.h"}},
|
||||||
{ProjectFilePath::path_pokemon_icon_table, { "path_pokemon_icon_table", "src/pokemon_icon.c"}},
|
{ProjectFilePath::pokemon_icon_table, { "pokemon_icon_table", "src/pokemon_icon.c"}},
|
||||||
{ProjectFilePath::path_initial_facing_table, { "path_initial_facing_table", "src/event_object_movement.c"}},
|
{ProjectFilePath::initial_facing_table, { "initial_facing_table", "src/event_object_movement.c"}},
|
||||||
};
|
};
|
||||||
|
|
||||||
ProjectFilePath reverseDefaultPaths(QString str) {
|
ProjectFilePath reverseDefaultPaths(QString str) {
|
||||||
|
@ -545,6 +545,10 @@ void ProjectConfig::parseConfigKeyValue(QString key, QString value) {
|
||||||
// Set any metatiles not provided to 0
|
// Set any metatiles not provided to 0
|
||||||
this->newMapBorderMetatileIds.append(0);
|
this->newMapBorderMetatileIds.append(0);
|
||||||
}
|
}
|
||||||
|
} else if (key == "default_primary_tileset") {
|
||||||
|
this->defaultPrimaryTileset = value;
|
||||||
|
} else if (key == "default_secondary_tileset") {
|
||||||
|
this->defaultSecondaryTileset = value;
|
||||||
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
#ifdef CONFIG_BACKWARDS_COMPATABILITY
|
||||||
} else if (key == "recent_map") {
|
} else if (key == "recent_map") {
|
||||||
userConfig.setRecentMap(value);
|
userConfig.setRecentMap(value);
|
||||||
|
@ -594,6 +598,7 @@ void ProjectConfig::setUnreadKeys() {
|
||||||
if (!readKeys.contains("enable_floor_number")) this->enableFloorNumber = isPokefirered;
|
if (!readKeys.contains("enable_floor_number")) this->enableFloorNumber = isPokefirered;
|
||||||
if (!readKeys.contains("create_map_text_file")) this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
|
if (!readKeys.contains("create_map_text_file")) this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
|
||||||
if (!readKeys.contains("new_map_border_metatiles")) this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
|
if (!readKeys.contains("new_map_border_metatiles")) this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
|
||||||
|
if (!readKeys.contains("default_secondary_tileset")) this->defaultSecondaryTileset = isPokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg";
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
|
@ -616,6 +621,8 @@ QMap<QString, QString> ProjectConfig::getKeyValueMap() {
|
||||||
for (auto metatile : this->newMapBorderMetatileIds)
|
for (auto metatile : this->newMapBorderMetatileIds)
|
||||||
metatiles << QString::number(metatile);
|
metatiles << QString::number(metatile);
|
||||||
map.insert("new_map_border_metatiles", metatiles.join(","));
|
map.insert("new_map_border_metatiles", metatiles.join(","));
|
||||||
|
map.insert("default_primary_tileset", this->defaultPrimaryTileset);
|
||||||
|
map.insert("default_secondary_tileset", this->defaultSecondaryTileset);
|
||||||
map.insert("prefabs_filepath", this->prefabFilepath);
|
map.insert("prefabs_filepath", this->prefabFilepath);
|
||||||
map.insert("prefabs_import_prompted", QString::number(this->prefabImportPrompted));
|
map.insert("prefabs_import_prompted", QString::number(this->prefabImportPrompted));
|
||||||
for (auto it = this->filePaths.constKeyValueBegin(); it != this->filePaths.constKeyValueEnd(); ++it) {
|
for (auto it = this->filePaths.constKeyValueBegin(); it != this->filePaths.constKeyValueEnd(); ++it) {
|
||||||
|
@ -652,17 +659,7 @@ void ProjectConfig::onNewConfigFileCreated() {
|
||||||
this->baseGameVersion = static_cast<BaseGameVersion>(baseGameVersionComboBox->currentData().toInt());
|
this->baseGameVersion = static_cast<BaseGameVersion>(baseGameVersionComboBox->currentData().toInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool isPokefirered = this->baseGameVersion == BaseGameVersion::pokefirered;
|
this->setUnreadKeys(); // Initialize version-specific options
|
||||||
this->useCustomBorderSize = isPokefirered;
|
|
||||||
this->enableEventWeatherTrigger = !isPokefirered;
|
|
||||||
this->enableEventSecretBase = !isPokefirered;
|
|
||||||
this->enableHiddenItemQuantity = isPokefirered;
|
|
||||||
this->enableHiddenItemRequiresItemfinder = isPokefirered;
|
|
||||||
this->enableHealLocationRespawnData = isPokefirered;
|
|
||||||
this->enableEventCloneObject = isPokefirered;
|
|
||||||
this->enableFloorNumber = isPokefirered;
|
|
||||||
this->createMapTextFile = (this->baseGameVersion != BaseGameVersion::pokeemerald);
|
|
||||||
this->newMapBorderMetatileIds = isPokefirered ? DEFAULT_BORDER_FRLG : DEFAULT_BORDER_RSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectConfig::setProjectDir(QString projectDir) {
|
void ProjectConfig::setProjectDir(QString projectDir) {
|
||||||
|
@ -835,6 +832,14 @@ QList<int> ProjectConfig::getNewMapBorderMetatileIds() {
|
||||||
return this->newMapBorderMetatileIds;
|
return this->newMapBorderMetatileIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ProjectConfig::getDefaultPrimaryTileset() {
|
||||||
|
return this->defaultPrimaryTileset;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProjectConfig::getDefaultSecondaryTileset() {
|
||||||
|
return this->defaultSecondaryTileset;
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectConfig::setPrefabFilepath(QString filepath) {
|
void ProjectConfig::setPrefabFilepath(QString filepath) {
|
||||||
this->prefabFilepath = filepath;
|
this->prefabFilepath = filepath;
|
||||||
this->save();
|
this->save();
|
||||||
|
|
|
@ -128,19 +128,20 @@ QList<QRgb> Tileset::getPalette(int paletteId, Tileset *primaryTileset, Tileset
|
||||||
|
|
||||||
bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm) {
|
bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm) {
|
||||||
QString headersFile = root + "/" + (usingAsm ? projectConfig.getFilePath(ProjectFilePath::tilesets_headers_asm)
|
QString headersFile = root + "/" + (usingAsm ? projectConfig.getFilePath(ProjectFilePath::tilesets_headers_asm)
|
||||||
: projectConfig.getFilePath(ProjectFilePath::tilesets_headers));
|
: projectConfig.getFilePath(ProjectFilePath::tilesets_headers));
|
||||||
QFile file(headersFile);
|
QFile file(headersFile);
|
||||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
if (!file.open(QIODevice::WriteOnly | QIODevice::Append)) {
|
||||||
logError(QString("Could not write to file \"%1\"").arg(headersFile));
|
logError(QString("Could not write to file \"%1\"").arg(headersFile));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
QString isSecondaryStr = this->is_secondary ? "TRUE" : "FALSE";
|
||||||
QString dataString = "\n";
|
QString dataString = "\n";
|
||||||
if (usingAsm) {
|
if (usingAsm) {
|
||||||
// Append to asm file
|
// Append to asm file
|
||||||
dataString.append("\t.align 2\n");
|
dataString.append("\t.align 2\n");
|
||||||
dataString.append(QString("%1::\n").arg(this->name));
|
dataString.append(QString("%1::\n").arg(this->name));
|
||||||
dataString.append("\t.byte TRUE @ is compressed\n");
|
dataString.append("\t.byte TRUE @ is compressed\n");
|
||||||
dataString.append(QString("\t.byte %1 @ is secondary\n").arg(this->is_secondary));
|
dataString.append(QString("\t.byte %1 @ is secondary\n").arg(isSecondaryStr));
|
||||||
dataString.append("\t.2byte 0 @ padding\n");
|
dataString.append("\t.2byte 0 @ padding\n");
|
||||||
dataString.append(QString("\t.4byte gTilesetTiles_%1\n").arg(friendlyName));
|
dataString.append(QString("\t.4byte gTilesetTiles_%1\n").arg(friendlyName));
|
||||||
dataString.append(QString("\t.4byte gTilesetPalettes_%1\n").arg(friendlyName));
|
dataString.append(QString("\t.4byte gTilesetPalettes_%1\n").arg(friendlyName));
|
||||||
|
@ -156,7 +157,7 @@ bool Tileset::appendToHeaders(QString root, QString friendlyName, bool usingAsm)
|
||||||
// Append to C file
|
// Append to C file
|
||||||
dataString.append(QString("const struct Tileset %1 =\n{\n").arg(this->name));
|
dataString.append(QString("const struct Tileset %1 =\n{\n").arg(this->name));
|
||||||
if (projectConfig.getTilesetsHaveIsCompressed()) dataString.append(" .isCompressed = TRUE,\n");
|
if (projectConfig.getTilesetsHaveIsCompressed()) dataString.append(" .isCompressed = TRUE,\n");
|
||||||
dataString.append(QString(" .isSecondary = %1,\n").arg(this->is_secondary));
|
dataString.append(QString(" .isSecondary = %1,\n").arg(isSecondaryStr));
|
||||||
dataString.append(QString(" .tiles = gTilesetTiles_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .tiles = gTilesetTiles_%1,\n").arg(friendlyName));
|
||||||
dataString.append(QString(" .palettes = gTilesetPalettes_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .palettes = gTilesetPalettes_%1,\n").arg(friendlyName));
|
||||||
dataString.append(QString(" .metatiles = gMetatiles_%1,\n").arg(friendlyName));
|
dataString.append(QString(" .metatiles = gMetatiles_%1,\n").arg(friendlyName));
|
||||||
|
@ -245,7 +246,7 @@ bool Tileset::appendToMetatiles(QString root, QString friendlyName, bool usingAs
|
||||||
// Example: for gTileset_DepartmentStore, returns "data/tilesets/secondary/department_store"
|
// Example: for gTileset_DepartmentStore, returns "data/tilesets/secondary/department_store"
|
||||||
QString Tileset::getExpectedDir()
|
QString Tileset::getExpectedDir()
|
||||||
{
|
{
|
||||||
return Tileset::getExpectedDir(this->name, ParseUtil::gameStringToBool(this->is_secondary));
|
return Tileset::getExpectedDir(this->name, this->is_secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Tileset::getExpectedDir(QString tilesetName, bool isSecondary)
|
QString Tileset::getExpectedDir(QString tilesetName, bool isSecondary)
|
||||||
|
|
|
@ -961,9 +961,9 @@ bool MainWindow::loadProjectCombos() {
|
||||||
ui->comboBox_Location->clear();
|
ui->comboBox_Location->clear();
|
||||||
ui->comboBox_Location->addItems(project->mapSectionValueToName.values());
|
ui->comboBox_Location->addItems(project->mapSectionValueToName.values());
|
||||||
ui->comboBox_PrimaryTileset->clear();
|
ui->comboBox_PrimaryTileset->clear();
|
||||||
ui->comboBox_PrimaryTileset->addItems(project->tilesetLabels.value("primary"));
|
ui->comboBox_PrimaryTileset->addItems(project->primaryTilesetLabels);
|
||||||
ui->comboBox_SecondaryTileset->clear();
|
ui->comboBox_SecondaryTileset->clear();
|
||||||
ui->comboBox_SecondaryTileset->addItems(project->tilesetLabels.value("secondary"));
|
ui->comboBox_SecondaryTileset->addItems(project->secondaryTilesetLabels);
|
||||||
ui->comboBox_Weather->clear();
|
ui->comboBox_Weather->clear();
|
||||||
ui->comboBox_Weather->addItems(project->weatherNames);
|
ui->comboBox_Weather->addItems(project->weatherNames);
|
||||||
ui->comboBox_BattleScene->clear();
|
ui->comboBox_BattleScene->clear();
|
||||||
|
@ -1141,20 +1141,20 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point)
|
||||||
|
|
||||||
void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction)
|
void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction)
|
||||||
{
|
{
|
||||||
int groupNum = triggeredAction->data().toInt();
|
openNewMapPopupWindow();
|
||||||
openNewMapPopupWindow(MapSortOrder::Group, groupNum);
|
this->newMapPrompt->init(MapSortOrder::Group, triggeredAction->data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAddNewMapToAreaClick(QAction* triggeredAction)
|
void MainWindow::onAddNewMapToAreaClick(QAction* triggeredAction)
|
||||||
{
|
{
|
||||||
QString secName = triggeredAction->data().toString();
|
openNewMapPopupWindow();
|
||||||
openNewMapPopupWindow(MapSortOrder::Area, secName);
|
this->newMapPrompt->init(MapSortOrder::Area, triggeredAction->data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onAddNewMapToLayoutClick(QAction* triggeredAction)
|
void MainWindow::onAddNewMapToLayoutClick(QAction* triggeredAction)
|
||||||
{
|
{
|
||||||
QString layoutId = triggeredAction->data().toString();
|
openNewMapPopupWindow();
|
||||||
openNewMapPopupWindow(MapSortOrder::Layout, layoutId);
|
this->newMapPrompt->init(MapSortOrder::Layout, triggeredAction->data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onNewMapCreated() {
|
void MainWindow::onNewMapCreated() {
|
||||||
|
@ -1191,7 +1191,11 @@ void MainWindow::onNewMapCreated() {
|
||||||
delete newMap;
|
delete newMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openNewMapPopupWindow(int type, QVariant data) {
|
void MainWindow::openNewMapPopupWindow() {
|
||||||
|
if (!openedNewMapDialog) {
|
||||||
|
NewMapPopup::setDefaultSettings(this->editor->project);
|
||||||
|
openedNewMapDialog = true;
|
||||||
|
}
|
||||||
if (!this->newMapPrompt) {
|
if (!this->newMapPrompt) {
|
||||||
this->newMapPrompt = new NewMapPopup(this, this->editor->project);
|
this->newMapPrompt = new NewMapPopup(this, this->editor->project);
|
||||||
}
|
}
|
||||||
|
@ -1201,42 +1205,22 @@ void MainWindow::openNewMapPopupWindow(int type, QVariant data) {
|
||||||
this->newMapPrompt->raise();
|
this->newMapPrompt->raise();
|
||||||
this->newMapPrompt->activateWindow();
|
this->newMapPrompt->activateWindow();
|
||||||
}
|
}
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case MapSortOrder::Group:
|
|
||||||
this->newMapPrompt->init(type, data.toInt(), QString(), QString());
|
|
||||||
break;
|
|
||||||
case MapSortOrder::Area:
|
|
||||||
this->newMapPrompt->init(type, 0, data.toString(), QString());
|
|
||||||
break;
|
|
||||||
case MapSortOrder::Layout:
|
|
||||||
this->newMapPrompt->init(type, 0, QString(), data.toString());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
connect(this->newMapPrompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
connect(this->newMapPrompt, &NewMapPopup::applied, this, &MainWindow::onNewMapCreated);
|
||||||
this->newMapPrompt->setAttribute(Qt::WA_DeleteOnClose);
|
this->newMapPrompt->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::openNewMapPopupWindowImportMap(MapLayout *mapLayout) {
|
void MainWindow::on_action_NewMap_triggered() {
|
||||||
if (!this->newMapPrompt) {
|
openNewMapPopupWindow();
|
||||||
this->newMapPrompt = new NewMapPopup(this, this->editor->project);
|
this->newMapPrompt->init();
|
||||||
}
|
|
||||||
if (!this->newMapPrompt->isVisible()) {
|
|
||||||
this->newMapPrompt->show();
|
|
||||||
} else {
|
|
||||||
this->newMapPrompt->raise();
|
|
||||||
this->newMapPrompt->activateWindow();
|
|
||||||
}
|
|
||||||
|
|
||||||
this->newMapPrompt->initImportMap(mapLayout);
|
|
||||||
|
|
||||||
connect(this->newMapPrompt, SIGNAL(applied()), this, SLOT(onNewMapCreated()));
|
|
||||||
connect(this->newMapPrompt, &QObject::destroyed, [=](QObject *) { this->newMapPrompt = nullptr; });
|
|
||||||
this->newMapPrompt->setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_action_NewMap_triggered() {
|
// Insert label for newly-created tileset into sorted list of existing labels
|
||||||
openNewMapPopupWindow(MapSortOrder::Group, 0);
|
int MainWindow::insertTilesetLabel(QStringList * list, QString label) {
|
||||||
|
int i = 0;
|
||||||
|
for (; i < list->length(); i++)
|
||||||
|
if (list->at(i) > label) break;
|
||||||
|
list->insert(i, label);
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionNew_Tileset_triggered() {
|
void MainWindow::on_actionNew_Tileset_triggered() {
|
||||||
|
@ -1266,8 +1250,7 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (editor->project->tilesetLabels.value("primary").contains(createTilesetDialog->fullSymbolName)
|
if (editor->project->tilesetLabelsOrdered.contains(createTilesetDialog->fullSymbolName)) {
|
||||||
|| editor->project->tilesetLabels.value("secondary").contains(createTilesetDialog->fullSymbolName)) {
|
|
||||||
logError(QString("Could not create tileset \"%1\", the symbol \"%2\" already exists.").arg(createTilesetDialog->friendlyName, createTilesetDialog->fullSymbolName));
|
logError(QString("Could not create tileset \"%1\", the symbol \"%2\" already exists.").arg(createTilesetDialog->friendlyName, createTilesetDialog->fullSymbolName));
|
||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
msgBox.setText("Failed to add new tileset.");
|
msgBox.setText("Failed to add new tileset.");
|
||||||
|
@ -1285,7 +1268,7 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
||||||
newSet.tilesImagePath = fullDirectoryPath + "/tiles.png";
|
newSet.tilesImagePath = fullDirectoryPath + "/tiles.png";
|
||||||
newSet.metatiles_path = fullDirectoryPath + "/metatiles.bin";
|
newSet.metatiles_path = fullDirectoryPath + "/metatiles.bin";
|
||||||
newSet.metatile_attrs_path = fullDirectoryPath + "/metatile_attributes.bin";
|
newSet.metatile_attrs_path = fullDirectoryPath + "/metatile_attributes.bin";
|
||||||
newSet.is_secondary = createTilesetDialog->isSecondary ? "TRUE" : "FALSE";
|
newSet.is_secondary = createTilesetDialog->isSecondary;
|
||||||
int numMetaTiles = createTilesetDialog->isSecondary ? (Project::getNumTilesTotal() - Project::getNumTilesPrimary()) : Project::getNumTilesPrimary();
|
int numMetaTiles = createTilesetDialog->isSecondary ? (Project::getNumTilesTotal() - Project::getNumTilesPrimary()) : Project::getNumTilesPrimary();
|
||||||
QImage tilesImage(":/images/blank_tileset.png");
|
QImage tilesImage(":/images/blank_tileset.png");
|
||||||
editor->project->loadTilesetTiles(&newSet, tilesImage);
|
editor->project->loadTilesetTiles(&newSet, tilesImage);
|
||||||
|
@ -1325,12 +1308,14 @@ void MainWindow::on_actionNew_Tileset_triggered() {
|
||||||
newSet.appendToGraphics(editor->project->root, createTilesetDialog->friendlyName, editor->project->usingAsmTilesets);
|
newSet.appendToGraphics(editor->project->root, createTilesetDialog->friendlyName, editor->project->usingAsmTilesets);
|
||||||
newSet.appendToMetatiles(editor->project->root, createTilesetDialog->friendlyName, editor->project->usingAsmTilesets);
|
newSet.appendToMetatiles(editor->project->root, createTilesetDialog->friendlyName, editor->project->usingAsmTilesets);
|
||||||
|
|
||||||
if(!createTilesetDialog->isSecondary) {
|
if (!createTilesetDialog->isSecondary) {
|
||||||
this->ui->comboBox_PrimaryTileset->addItem(createTilesetDialog->fullSymbolName);
|
int index = insertTilesetLabel(&editor->project->primaryTilesetLabels, createTilesetDialog->fullSymbolName);
|
||||||
|
this->ui->comboBox_PrimaryTileset->insertItem(index, createTilesetDialog->fullSymbolName);
|
||||||
} else {
|
} else {
|
||||||
this->ui->comboBox_SecondaryTileset->addItem(createTilesetDialog->fullSymbolName);
|
int index = insertTilesetLabel(&editor->project->secondaryTilesetLabels, createTilesetDialog->fullSymbolName);
|
||||||
|
this->ui->comboBox_SecondaryTileset->insertItem(index, createTilesetDialog->fullSymbolName);
|
||||||
}
|
}
|
||||||
editor->project->insertTilesetLabel(createTilesetDialog->fullSymbolName, createTilesetDialog->isSecondary);
|
insertTilesetLabel(&editor->project->tilesetLabelsOrdered, createTilesetDialog->fullSymbolName);
|
||||||
|
|
||||||
QMessageBox msgBox(this);
|
QMessageBox msgBox(this);
|
||||||
msgBox.setText("Successfully created tileset.");
|
msgBox.setText("Successfully created tileset.");
|
||||||
|
@ -2464,7 +2449,8 @@ void MainWindow::importMapFromAdvanceMap1_92()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
openNewMapPopupWindowImportMap(mapLayout);
|
openNewMapPopupWindow();
|
||||||
|
this->newMapPrompt->init(mapLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
|
void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
|
||||||
|
@ -2547,7 +2533,7 @@ void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName
|
||||||
|
|
||||||
void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &tilesetLabel)
|
void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &tilesetLabel)
|
||||||
{
|
{
|
||||||
if (editor->project->tilesetLabels["primary"].contains(tilesetLabel) && editor->map) {
|
if (editor->project->primaryTilesetLabels.contains(tilesetLabel) && editor->map) {
|
||||||
editor->updatePrimaryTileset(tilesetLabel);
|
editor->updatePrimaryTileset(tilesetLabel);
|
||||||
redrawMapScene();
|
redrawMapScene();
|
||||||
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
||||||
|
@ -2559,7 +2545,7 @@ void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &ti
|
||||||
|
|
||||||
void MainWindow::on_comboBox_SecondaryTileset_currentTextChanged(const QString &tilesetLabel)
|
void MainWindow::on_comboBox_SecondaryTileset_currentTextChanged(const QString &tilesetLabel)
|
||||||
{
|
{
|
||||||
if (editor->project->tilesetLabels["secondary"].contains(tilesetLabel) && editor->map) {
|
if (editor->project->secondaryTilesetLabels.contains(tilesetLabel) && editor->map) {
|
||||||
editor->updateSecondaryTileset(tilesetLabel);
|
editor->updateSecondaryTileset(tilesetLabel);
|
||||||
redrawMapScene();
|
redrawMapScene();
|
||||||
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
||||||
|
|
|
@ -591,26 +591,6 @@ void Project::ignoreWatchedFileTemporarily(QString filepath) {
|
||||||
modifiedFileTimestamps.insert(filepath, QDateTime::currentMSecsSinceEpoch() + 5000);
|
modifiedFileTimestamps.insert(filepath, QDateTime::currentMSecsSinceEpoch() + 5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::setNewMapLayout(Map* map) {
|
|
||||||
MapLayout *layout = new MapLayout();
|
|
||||||
layout->id = MapLayout::layoutConstantFromName(map->name);
|
|
||||||
layout->name = QString("%1_Layout").arg(map->name);
|
|
||||||
layout->width = getDefaultMapSize();
|
|
||||||
layout->height = getDefaultMapSize();
|
|
||||||
layout->border_width = DEFAULT_BORDER_WIDTH;
|
|
||||||
layout->border_height = DEFAULT_BORDER_HEIGHT;
|
|
||||||
layout->border_path = QString("%2%1/border.bin").arg(map->name).arg(projectConfig.getFilePath(ProjectFilePath::data_layouts_folders));
|
|
||||||
layout->blockdata_path = QString("%2%1/map.bin").arg(map->name).arg(projectConfig.getFilePath(ProjectFilePath::data_layouts_folders));
|
|
||||||
layout->tileset_primary_label = tilesetLabels["primary"].value(0, "gTileset_General");
|
|
||||||
layout->tileset_secondary_label = tilesetLabels["secondary"].value(0, projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg");
|
|
||||||
map->layout = layout;
|
|
||||||
map->layoutId = layout->id;
|
|
||||||
|
|
||||||
// Insert new entry into the global map layouts.
|
|
||||||
mapLayouts.insert(layout->id, layout);
|
|
||||||
mapLayoutsTable.append(layout->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Project::saveMapGroups() {
|
void Project::saveMapGroups() {
|
||||||
QString mapGroupsFilepath = QString("%1/%2").arg(root).arg(projectConfig.getFilePath(ProjectFilePath::json_map_groups));
|
QString mapGroupsFilepath = QString("%1/%2").arg(root).arg(projectConfig.getFilePath(ProjectFilePath::json_map_groups));
|
||||||
QFile mapGroupsFile(mapGroupsFilepath);
|
QFile mapGroupsFile(mapGroupsFilepath);
|
||||||
|
@ -1046,7 +1026,7 @@ void Project::saveTilesetPalettes(Tileset *tileset) {
|
||||||
bool Project::loadLayoutTilesets(MapLayout *layout) {
|
bool Project::loadLayoutTilesets(MapLayout *layout) {
|
||||||
layout->tileset_primary = getTileset(layout->tileset_primary_label);
|
layout->tileset_primary = getTileset(layout->tileset_primary_label);
|
||||||
if (!layout->tileset_primary) {
|
if (!layout->tileset_primary) {
|
||||||
QString defaultTileset = tilesetLabels["primary"].value(0, "gTileset_General");
|
QString defaultTileset = this->getDefaultPrimaryTilesetLabel();
|
||||||
logWarn(QString("Map layout %1 has invalid primary tileset '%2'. Using default '%3'").arg(layout->id).arg(layout->tileset_primary_label).arg(defaultTileset));
|
logWarn(QString("Map layout %1 has invalid primary tileset '%2'. Using default '%3'").arg(layout->id).arg(layout->tileset_primary_label).arg(defaultTileset));
|
||||||
layout->tileset_primary_label = defaultTileset;
|
layout->tileset_primary_label = defaultTileset;
|
||||||
layout->tileset_primary = getTileset(layout->tileset_primary_label);
|
layout->tileset_primary = getTileset(layout->tileset_primary_label);
|
||||||
|
@ -1058,7 +1038,7 @@ bool Project::loadLayoutTilesets(MapLayout *layout) {
|
||||||
|
|
||||||
layout->tileset_secondary = getTileset(layout->tileset_secondary_label);
|
layout->tileset_secondary = getTileset(layout->tileset_secondary_label);
|
||||||
if (!layout->tileset_secondary) {
|
if (!layout->tileset_secondary) {
|
||||||
QString defaultTileset = tilesetLabels["secondary"].value(0, projectConfig.getBaseGameVersion() == BaseGameVersion::pokefirered ? "gTileset_PalletTown" : "gTileset_Petalburg");
|
QString defaultTileset = this->getDefaultSecondaryTilesetLabel();
|
||||||
logWarn(QString("Map layout %1 has invalid secondary tileset '%2'. Using default '%3'").arg(layout->id).arg(layout->tileset_secondary_label).arg(defaultTileset));
|
logWarn(QString("Map layout %1 has invalid secondary tileset '%2'. Using default '%3'").arg(layout->id).arg(layout->tileset_secondary_label).arg(defaultTileset));
|
||||||
layout->tileset_secondary_label = defaultTileset;
|
layout->tileset_secondary_label = defaultTileset;
|
||||||
layout->tileset_secondary = getTileset(layout->tileset_secondary_label);
|
layout->tileset_secondary = getTileset(layout->tileset_secondary_label);
|
||||||
|
@ -1082,7 +1062,7 @@ Tileset* Project::loadTileset(QString label, Tileset *tileset) {
|
||||||
tileset = new Tileset;
|
tileset = new Tileset;
|
||||||
}
|
}
|
||||||
tileset->name = label;
|
tileset->name = label;
|
||||||
tileset->is_secondary = values.value(memberMap.key("isSecondary"));
|
tileset->is_secondary = ParseUtil::gameStringToBool(values.value(memberMap.key("isSecondary")));
|
||||||
tileset->tiles_label = values.value(memberMap.key("tiles"));
|
tileset->tiles_label = values.value(memberMap.key("tiles"));
|
||||||
tileset->palettes_label = values.value(memberMap.key("palettes"));
|
tileset->palettes_label = values.value(memberMap.key("palettes"));
|
||||||
tileset->metatiles_label = values.value(memberMap.key("metatiles"));
|
tileset->metatiles_label = values.value(memberMap.key("metatiles"));
|
||||||
|
@ -1098,7 +1078,7 @@ Tileset* Project::loadTileset(QString label, Tileset *tileset) {
|
||||||
}
|
}
|
||||||
const auto tilesetAttributes = structs[label];
|
const auto tilesetAttributes = structs[label];
|
||||||
tileset->name = label;
|
tileset->name = label;
|
||||||
tileset->is_secondary = tilesetAttributes.value("isSecondary");
|
tileset->is_secondary = ParseUtil::gameStringToBool(tilesetAttributes.value("isSecondary"));
|
||||||
tileset->tiles_label = tilesetAttributes.value("tiles");
|
tileset->tiles_label = tilesetAttributes.value("tiles");
|
||||||
tileset->palettes_label = tilesetAttributes.value("palettes");
|
tileset->palettes_label = tilesetAttributes.value("palettes");
|
||||||
tileset->metatiles_label = tilesetAttributes.value("metatiles");
|
tileset->metatiles_label = tilesetAttributes.value("metatiles");
|
||||||
|
@ -1588,7 +1568,8 @@ void Project::loadTilesetMetatileLabels(Tileset* tileset) {
|
||||||
for (QString labelName : labels.keys()) {
|
for (QString labelName : labels.keys()) {
|
||||||
int metatileId = labels[labelName];
|
int metatileId = labels[labelName];
|
||||||
// subtract Project::num_tiles_primary from secondary metatiles
|
// subtract Project::num_tiles_primary from secondary metatiles
|
||||||
Metatile *metatile = Tileset::getMetatile(metatileId - (ParseUtil::gameStringToBool(tileset->is_secondary) ? Project::num_tiles_primary : 0), tileset, nullptr);
|
int offset = tileset->is_secondary ? Project::num_tiles_primary : 0;
|
||||||
|
Metatile *metatile = Tileset::getMetatile(metatileId - offset, tileset, nullptr);
|
||||||
if (metatile) {
|
if (metatile) {
|
||||||
metatile->label = labelName.replace(tilesetPrefix, "");
|
metatile->label = labelName.replace(tilesetPrefix, "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -1850,28 +1831,43 @@ Project::DataQualifiers Project::getDataQualifiers(QString text, QString label)
|
||||||
return qualifiers;
|
return qualifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::insertTilesetLabel(QString label, bool isSecondary) {
|
QString Project::getDefaultPrimaryTilesetLabel() {
|
||||||
QString category = isSecondary ? "secondary" : "primary";
|
QString defaultLabel = projectConfig.getDefaultPrimaryTileset();
|
||||||
this->tilesetLabels[category].append(label);
|
if (!this->primaryTilesetLabels.contains(defaultLabel)) {
|
||||||
this->tilesetLabelsOrdered.append(label);
|
QString firstLabel = this->primaryTilesetLabels.first();
|
||||||
|
logWarn(QString("Unable to find default primary tileset '%1', using '%2' instead.").arg(defaultLabel).arg(firstLabel));
|
||||||
|
defaultLabel = firstLabel;
|
||||||
|
}
|
||||||
|
return defaultLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::insertTilesetLabel(QString label, QString isSecondaryStr) {
|
QString Project::getDefaultSecondaryTilesetLabel() {
|
||||||
|
QString defaultLabel = projectConfig.getDefaultSecondaryTileset();
|
||||||
|
if (!this->secondaryTilesetLabels.contains(defaultLabel)) {
|
||||||
|
QString firstLabel = this->secondaryTilesetLabels.first();
|
||||||
|
logWarn(QString("Unable to find default secondary tileset '%1', using '%2' instead.").arg(defaultLabel).arg(firstLabel));
|
||||||
|
defaultLabel = firstLabel;
|
||||||
|
}
|
||||||
|
return defaultLabel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::appendTilesetLabel(QString label, QString isSecondaryStr) {
|
||||||
bool ok;
|
bool ok;
|
||||||
bool isSecondary = ParseUtil::gameStringToBool(isSecondaryStr, &ok);
|
bool isSecondary = ParseUtil::gameStringToBool(isSecondaryStr, &ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
logError(QString("Unable to convert value '%1' of isSecondary to bool for tileset %2.").arg(isSecondaryStr).arg(label));
|
logError(QString("Unable to convert value '%1' of isSecondary to bool for tileset %2.").arg(isSecondaryStr).arg(label));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
insertTilesetLabel(label, isSecondary);
|
QStringList * list = isSecondary ? &this->secondaryTilesetLabels : &this->primaryTilesetLabels;
|
||||||
|
list->append(label);
|
||||||
|
this->tilesetLabelsOrdered.append(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readTilesetLabels() {
|
bool Project::readTilesetLabels() {
|
||||||
QStringList primaryTilesets;
|
QStringList primaryTilesets;
|
||||||
QStringList secondaryTilesets;
|
QStringList secondaryTilesets;
|
||||||
this->tilesetLabels.clear();
|
this->primaryTilesetLabels.clear();
|
||||||
this->tilesetLabels.insert("primary", primaryTilesets);
|
this->secondaryTilesetLabels.clear();
|
||||||
this->tilesetLabels.insert("secondary", secondaryTilesets);
|
|
||||||
this->tilesetLabelsOrdered.clear();
|
this->tilesetLabelsOrdered.clear();
|
||||||
|
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::tilesets_headers);
|
QString filename = projectConfig.getFilePath(ProjectFilePath::tilesets_headers);
|
||||||
|
@ -1889,8 +1885,11 @@ bool Project::readTilesetLabels() {
|
||||||
QRegularExpressionMatchIterator iter = re.globalMatch(text);
|
QRegularExpressionMatchIterator iter = re.globalMatch(text);
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
QRegularExpressionMatch match = iter.next();
|
QRegularExpressionMatch match = iter.next();
|
||||||
insertTilesetLabel(match.captured("label"), match.captured("isSecondary"));
|
appendTilesetLabel(match.captured("label"), match.captured("isSecondary"));
|
||||||
}
|
}
|
||||||
|
this->primaryTilesetLabels.sort();
|
||||||
|
this->secondaryTilesetLabels.sort();
|
||||||
|
this->tilesetLabelsOrdered.sort();
|
||||||
filename = asm_filename; // For error reporting further down
|
filename = asm_filename; // For error reporting further down
|
||||||
} else {
|
} else {
|
||||||
this->usingAsmTilesets = false;
|
this->usingAsmTilesets = false;
|
||||||
|
@ -1898,16 +1897,16 @@ bool Project::readTilesetLabels() {
|
||||||
QStringList labels = structs.keys();
|
QStringList labels = structs.keys();
|
||||||
// TODO: This is alphabetical, AdvanceMap import wants the vanilla order in tilesetLabelsOrdered
|
// TODO: This is alphabetical, AdvanceMap import wants the vanilla order in tilesetLabelsOrdered
|
||||||
for (const auto tilesetLabel : labels){
|
for (const auto tilesetLabel : labels){
|
||||||
insertTilesetLabel(tilesetLabel, structs[tilesetLabel].value("isSecondary"));
|
appendTilesetLabel(tilesetLabel, structs[tilesetLabel].value("isSecondary"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool success = true;
|
bool success = true;
|
||||||
if (this->tilesetLabels["secondary"].isEmpty()) {
|
if (this->secondaryTilesetLabels.isEmpty()) {
|
||||||
logError(QString("Failed to find any secondary tilesets in %1").arg(filename));
|
logError(QString("Failed to find any secondary tilesets in %1").arg(filename));
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
if (this->tilesetLabels["primary"].isEmpty()) {
|
if (this->primaryTilesetLabels.isEmpty()) {
|
||||||
logError(QString("Failed to find any primary tilesets in %1").arg(filename));
|
logError(QString("Failed to find any primary tilesets in %1").arg(filename));
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
@ -2164,7 +2163,7 @@ bool Project::readMovementTypes() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Project::readInitialFacingDirections() {
|
bool Project::readInitialFacingDirections() {
|
||||||
QString filename = projectConfig.getFilePath(ProjectFilePath::path_initial_facing_table);
|
QString filename = projectConfig.getFilePath(ProjectFilePath::initial_facing_table);
|
||||||
fileWatcher.addPath(root + "/" + filename);
|
fileWatcher.addPath(root + "/" + filename);
|
||||||
facingDirections = parser.readNamedIndexCArray(filename, "gInitialMovementTypeFacingDirections");
|
facingDirections = parser.readNamedIndexCArray(filename, "gInitialMovementTypeFacingDirections");
|
||||||
if (facingDirections.isEmpty()) {
|
if (facingDirections.isEmpty()) {
|
||||||
|
@ -2505,7 +2504,7 @@ bool Project::readEventGraphics() {
|
||||||
|
|
||||||
bool Project::readSpeciesIconPaths() {
|
bool Project::readSpeciesIconPaths() {
|
||||||
speciesToIconPath.clear();
|
speciesToIconPath.clear();
|
||||||
QString srcfilename = projectConfig.getFilePath(ProjectFilePath::path_pokemon_icon_table);
|
QString srcfilename = projectConfig.getFilePath(ProjectFilePath::pokemon_icon_table);
|
||||||
QString incfilename = projectConfig.getFilePath(ProjectFilePath::data_pokemon_gfx);
|
QString incfilename = projectConfig.getFilePath(ProjectFilePath::data_pokemon_gfx);
|
||||||
fileWatcher.addPath(root + "/" + srcfilename);
|
fileWatcher.addPath(root + "/" + srcfilename);
|
||||||
fileWatcher.addPath(root + "/" + incfilename);
|
fileWatcher.addPath(root + "/" + incfilename);
|
||||||
|
|
|
@ -226,13 +226,13 @@ QList<QString> ScriptUtility::getTilesetNames() {
|
||||||
QList<QString> ScriptUtility::getPrimaryTilesetNames() {
|
QList<QString> ScriptUtility::getPrimaryTilesetNames() {
|
||||||
if (!window || !window->editor || !window->editor->project)
|
if (!window || !window->editor || !window->editor->project)
|
||||||
return QList<QString>();
|
return QList<QString>();
|
||||||
return window->editor->project->tilesetLabels["primary"];
|
return window->editor->project->primaryTilesetLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> ScriptUtility::getSecondaryTilesetNames() {
|
QList<QString> ScriptUtility::getSecondaryTilesetNames() {
|
||||||
if (!window || !window->editor || !window->editor->project)
|
if (!window || !window->editor || !window->editor->project)
|
||||||
return QList<QString>();
|
return QList<QString>();
|
||||||
return window->editor->project->tilesetLabels["secondary"];
|
return window->editor->project->secondaryTilesetLabels;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QString> ScriptUtility::getMetatileBehaviorNames() {
|
QList<QString> ScriptUtility::getMetatileBehaviorNames() {
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
struct NewMapPopup::Settings NewMapPopup::settings = {};
|
||||||
|
|
||||||
NewMapPopup::NewMapPopup(QWidget *parent, Project *project) :
|
NewMapPopup::NewMapPopup(QWidget *parent, Project *project) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::NewMapPopup)
|
ui(new Ui::NewMapPopup)
|
||||||
|
@ -21,30 +23,104 @@ NewMapPopup::NewMapPopup(QWidget *parent, Project *project) :
|
||||||
|
|
||||||
NewMapPopup::~NewMapPopup()
|
NewMapPopup::~NewMapPopup()
|
||||||
{
|
{
|
||||||
|
saveSettings();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMapPopup::init(int type, int group, QString sec, QString layoutId) {
|
void NewMapPopup::init() {
|
||||||
switch (type)
|
// Populate combo boxes
|
||||||
{
|
ui->comboBox_NewMap_Primary_Tileset->addItems(project->primaryTilesetLabels);
|
||||||
case MapSortOrder::Group:
|
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->secondaryTilesetLabels);
|
||||||
setDefaultValues(group, QString());
|
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
||||||
break;
|
ui->comboBox_NewMap_Song->addItems(project->songNames);
|
||||||
case MapSortOrder::Area:
|
ui->comboBox_NewMap_Type->addItems(project->mapTypes);
|
||||||
setDefaultValues(group, sec);
|
ui->comboBox_NewMap_Location->addItems(project->mapSectionValueToName.values());
|
||||||
break;
|
|
||||||
case MapSortOrder::Layout:
|
// Set spin box limits
|
||||||
useLayout(layoutId);
|
ui->spinBox_NewMap_Width->setMinimum(1);
|
||||||
setDefaultValues(group, QString());
|
ui->spinBox_NewMap_Height->setMinimum(1);
|
||||||
break;
|
ui->spinBox_NewMap_Width->setMaximum(project->getMaxMapWidth());
|
||||||
}
|
ui->spinBox_NewMap_Height->setMaximum(project->getMaxMapHeight());
|
||||||
connectSignals();
|
ui->spinBox_NewMap_BorderWidth->setMinimum(1);
|
||||||
|
ui->spinBox_NewMap_BorderHeight->setMinimum(1);
|
||||||
|
ui->spinBox_NewMap_Floor_Number->setMinimum(-128);
|
||||||
|
ui->spinBox_NewMap_Floor_Number->setMaximum(127);
|
||||||
|
|
||||||
|
// Hide config specific ui elements
|
||||||
|
bool hasFlags = (projectConfig.getBaseGameVersion() != BaseGameVersion::pokeruby);
|
||||||
|
ui->checkBox_NewMap_Allow_Running->setVisible(hasFlags);
|
||||||
|
ui->checkBox_NewMap_Allow_Biking->setVisible(hasFlags);
|
||||||
|
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(hasFlags);
|
||||||
|
ui->label_NewMap_Allow_Running->setVisible(hasFlags);
|
||||||
|
ui->label_NewMap_Allow_Biking->setVisible(hasFlags);
|
||||||
|
ui->label_NewMap_Allow_Escape_Rope->setVisible(hasFlags);
|
||||||
|
|
||||||
|
bool hasCustomBorders = projectConfig.getUseCustomBorderSize();
|
||||||
|
ui->spinBox_NewMap_BorderWidth->setVisible(hasCustomBorders);
|
||||||
|
ui->spinBox_NewMap_BorderHeight->setVisible(hasCustomBorders);
|
||||||
|
ui->label_NewMap_BorderWidth->setVisible(hasCustomBorders);
|
||||||
|
ui->label_NewMap_BorderHeight->setVisible(hasCustomBorders);
|
||||||
|
|
||||||
|
bool hasFloorNumber = projectConfig.getFloorNumberEnabled();
|
||||||
|
ui->spinBox_NewMap_Floor_Number->setVisible(hasFloorNumber);
|
||||||
|
ui->label_NewMap_Floor_Number->setVisible(hasFloorNumber);
|
||||||
|
|
||||||
|
// Restore previous settings
|
||||||
|
ui->lineEdit_NewMap_Name->setText(project->getNewMapName());
|
||||||
|
ui->comboBox_NewMap_Group->setTextItem(settings.group);
|
||||||
|
ui->spinBox_NewMap_Width->setValue(settings.width);
|
||||||
|
ui->spinBox_NewMap_Height->setValue(settings.height);
|
||||||
|
ui->spinBox_NewMap_BorderWidth->setValue(settings.borderWidth);
|
||||||
|
ui->spinBox_NewMap_BorderHeight->setValue(settings.borderHeight);
|
||||||
|
ui->comboBox_NewMap_Primary_Tileset->setTextItem(settings.primaryTilesetLabel);
|
||||||
|
ui->comboBox_NewMap_Secondary_Tileset->setTextItem(settings.secondaryTilesetLabel);
|
||||||
|
ui->comboBox_NewMap_Type->setTextItem(settings.type);
|
||||||
|
ui->comboBox_NewMap_Location->setTextItem(settings.location);
|
||||||
|
ui->comboBox_NewMap_Song->setTextItem(settings.song);
|
||||||
|
ui->checkBox_NewMap_Flyable->setChecked(settings.canFlyTo);
|
||||||
|
ui->checkBox_NewMap_Show_Location->setChecked(settings.showLocationName);
|
||||||
|
ui->checkBox_NewMap_Allow_Running->setChecked(settings.allowRunning);
|
||||||
|
ui->checkBox_NewMap_Allow_Biking->setChecked(settings.allowBiking);
|
||||||
|
ui->checkBox_NewMap_Allow_Escape_Rope->setChecked(settings.allowEscaping);
|
||||||
|
ui->spinBox_NewMap_Floor_Number->setValue(settings.floorNumber);
|
||||||
|
|
||||||
|
// Connect signals
|
||||||
|
connect(ui->spinBox_NewMap_Width, QOverload<int>::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
|
||||||
|
connect(ui->spinBox_NewMap_Height, QOverload<int>::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
|
||||||
|
|
||||||
|
ui->frame_NewMap_Options->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMapPopup::initImportMap(MapLayout *mapLayout) {
|
// Creating new map by right-clicking in the map list
|
||||||
|
void NewMapPopup::init(MapSortOrder type, QVariant data) {
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case MapSortOrder::Group:
|
||||||
|
settings.group = project->groupNames.at(data.toInt());
|
||||||
|
break;
|
||||||
|
case MapSortOrder::Area:
|
||||||
|
settings.location = data.toString();
|
||||||
|
break;
|
||||||
|
case MapSortOrder::Layout:
|
||||||
|
useLayout(data.toString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Creating new map from AdvanceMap import
|
||||||
|
void NewMapPopup::init(MapLayout *mapLayout) {
|
||||||
this->importedMap = true;
|
this->importedMap = true;
|
||||||
setDefaultValuesImportMap(mapLayout);
|
useLayoutSettings(mapLayout);
|
||||||
connectSignals();
|
|
||||||
|
this->map = new Map();
|
||||||
|
this->map->layout = new MapLayout();
|
||||||
|
this->map->layout->blockdata = mapLayout->blockdata;
|
||||||
|
|
||||||
|
if (!mapLayout->border.isEmpty()) {
|
||||||
|
this->map->layout->border = mapLayout->border;
|
||||||
|
}
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewMapPopup::checkNewMapDimensions() {
|
bool NewMapPopup::checkNewMapDimensions() {
|
||||||
|
@ -53,7 +129,6 @@ bool NewMapPopup::checkNewMapDimensions() {
|
||||||
|
|
||||||
if (numMetatiles > maxMetatiles) {
|
if (numMetatiles > maxMetatiles) {
|
||||||
ui->frame_NewMap_Warning->setVisible(true);
|
ui->frame_NewMap_Warning->setVisible(true);
|
||||||
//ui->label_NewMap_WarningMessage->setText("WARNING: The specified map dimensions are too large.");
|
|
||||||
QString errorText = QString("Error: The specified width and height are too large.\n"
|
QString errorText = QString("Error: The specified width and height are too large.\n"
|
||||||
"The maximum map width and height is the following: (width + 15) * (height + 14) <= %1\n"
|
"The maximum map width and height is the following: (width + 15) * (height + 14) <= %1\n"
|
||||||
"The specified map width and height was: (%2 + 15) * (%3 + 14) = %4")
|
"The specified map width and height was: (%2 + 15) * (%3 + 14) = %4")
|
||||||
|
@ -89,148 +164,66 @@ bool NewMapPopup::checkNewMapGroup() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMapPopup::connectSignals() {
|
void NewMapPopup::setDefaultSettings(Project *project) {
|
||||||
ui->spinBox_NewMap_Width->setMinimum(1);
|
settings.group = project->groupNames.at(0);
|
||||||
ui->spinBox_NewMap_Height->setMinimum(1);
|
settings.width = project->getDefaultMapSize();
|
||||||
ui->spinBox_NewMap_Width->setMaximum(project->getMaxMapWidth());
|
settings.height = project->getDefaultMapSize();
|
||||||
ui->spinBox_NewMap_Height->setMaximum(project->getMaxMapHeight());
|
settings.borderWidth = DEFAULT_BORDER_WIDTH;
|
||||||
|
settings.borderHeight = DEFAULT_BORDER_HEIGHT;
|
||||||
|
settings.primaryTilesetLabel = project->getDefaultPrimaryTilesetLabel();
|
||||||
|
settings.secondaryTilesetLabel = project->getDefaultSecondaryTilesetLabel();
|
||||||
|
settings.type = project->mapTypes.at(0);
|
||||||
|
settings.location = project->mapSectionValueToName.values().at(0);
|
||||||
|
settings.song = project->songNames.at(0);
|
||||||
|
settings.canFlyTo = false;
|
||||||
|
settings.showLocationName = true;
|
||||||
|
settings.allowRunning = false;
|
||||||
|
settings.allowBiking = false;
|
||||||
|
settings.allowEscaping = false;
|
||||||
|
settings.floorNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//ui->icon_NewMap_WarningIcon->setPixmap();
|
void NewMapPopup::saveSettings() {
|
||||||
connect(ui->spinBox_NewMap_Width, QOverload<int>::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
|
settings.group = ui->comboBox_NewMap_Group->currentText();
|
||||||
connect(ui->spinBox_NewMap_Height, QOverload<int>::of(&QSpinBox::valueChanged), [=](int){checkNewMapDimensions();});
|
settings.width = ui->spinBox_NewMap_Width->value();
|
||||||
|
settings.height = ui->spinBox_NewMap_Height->value();
|
||||||
|
settings.borderWidth = ui->spinBox_NewMap_BorderWidth->value();
|
||||||
|
settings.borderHeight = ui->spinBox_NewMap_BorderHeight->value();
|
||||||
|
settings.primaryTilesetLabel = ui->comboBox_NewMap_Primary_Tileset->currentText();
|
||||||
|
settings.secondaryTilesetLabel = ui->comboBox_NewMap_Secondary_Tileset->currentText();
|
||||||
|
settings.type = ui->comboBox_NewMap_Type->currentText();
|
||||||
|
settings.location = ui->comboBox_NewMap_Location->currentText();
|
||||||
|
settings.song = ui->comboBox_NewMap_Song->currentText();
|
||||||
|
settings.canFlyTo = ui->checkBox_NewMap_Flyable->isChecked();
|
||||||
|
settings.showLocationName = ui->checkBox_NewMap_Show_Location->isChecked();
|
||||||
|
settings.allowRunning = ui->checkBox_NewMap_Allow_Running->isChecked();
|
||||||
|
settings.allowBiking = ui->checkBox_NewMap_Allow_Biking->isChecked();
|
||||||
|
settings.allowEscaping = ui->checkBox_NewMap_Allow_Escape_Rope->isChecked();
|
||||||
|
settings.floorNumber = ui->spinBox_NewMap_Floor_Number->value();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewMapPopup::useLayoutSettings(MapLayout *layout) {
|
||||||
|
if (!layout) return;
|
||||||
|
settings.width = layout->width;
|
||||||
|
settings.height = layout->height;
|
||||||
|
settings.borderWidth = layout->border_width;
|
||||||
|
settings.borderHeight = layout->border_height;
|
||||||
|
settings.primaryTilesetLabel = layout->tileset_primary_label;
|
||||||
|
settings.secondaryTilesetLabel = layout->tileset_secondary_label;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMapPopup::useLayout(QString layoutId) {
|
void NewMapPopup::useLayout(QString layoutId) {
|
||||||
this->existingLayout = true;
|
this->existingLayout = true;
|
||||||
this->layoutId = layoutId;
|
this->layoutId = layoutId;
|
||||||
}
|
useLayoutSettings(project->mapLayouts.value(this->layoutId));
|
||||||
|
|
||||||
void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
// Dimensions and tilesets can't be changed for new maps using an existing layout
|
||||||
ui->lineEdit_NewMap_Name->setText(project->getNewMapName());
|
ui->spinBox_NewMap_Width->setDisabled(true);
|
||||||
|
ui->spinBox_NewMap_Height->setDisabled(true);
|
||||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->tilesetLabels.value("primary"));
|
ui->spinBox_NewMap_BorderWidth->setDisabled(true);
|
||||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->tilesetLabels.value("secondary"));
|
ui->spinBox_NewMap_BorderHeight->setDisabled(true);
|
||||||
|
ui->comboBox_NewMap_Primary_Tileset->setDisabled(true);
|
||||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
ui->comboBox_NewMap_Secondary_Tileset->setDisabled(true);
|
||||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(groupNum));
|
|
||||||
|
|
||||||
ui->comboBox_Song->addItems(project->songNames);
|
|
||||||
|
|
||||||
if (existingLayout) {
|
|
||||||
ui->spinBox_NewMap_Width->setValue(project->mapLayouts.value(layoutId)->width);
|
|
||||||
ui->spinBox_NewMap_Height->setValue(project->mapLayouts.value(layoutId)->height);
|
|
||||||
ui->comboBox_NewMap_Primary_Tileset->setCurrentText(project->mapLayouts.value(layoutId)->tileset_primary_label);
|
|
||||||
ui->comboBox_NewMap_Secondary_Tileset->setCurrentText(project->mapLayouts.value(layoutId)->tileset_secondary_label);
|
|
||||||
ui->spinBox_NewMap_Width->setDisabled(true);
|
|
||||||
ui->spinBox_NewMap_Height->setDisabled(true);
|
|
||||||
ui->spinBox_NewMap_BorderWidth->setDisabled(true);
|
|
||||||
ui->spinBox_NewMap_BorderHeight->setDisabled(true);
|
|
||||||
ui->comboBox_NewMap_Primary_Tileset->setDisabled(true);
|
|
||||||
ui->comboBox_NewMap_Secondary_Tileset->setDisabled(true);
|
|
||||||
} else {
|
|
||||||
ui->spinBox_NewMap_Width->setValue(project->getDefaultMapSize());
|
|
||||||
ui->spinBox_NewMap_Height->setValue(project->getDefaultMapSize());
|
|
||||||
ui->spinBox_NewMap_BorderWidth->setValue(DEFAULT_BORDER_WIDTH);
|
|
||||||
ui->spinBox_NewMap_BorderHeight->setValue(DEFAULT_BORDER_HEIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->comboBox_NewMap_Type->addItems(project->mapTypes);
|
|
||||||
ui->comboBox_NewMap_Location->addItems(project->mapSectionValueToName.values());
|
|
||||||
if (!mapSec.isEmpty()) ui->comboBox_NewMap_Location->setCurrentText(mapSec);
|
|
||||||
ui->checkBox_NewMap_Show_Location->setChecked(true);
|
|
||||||
|
|
||||||
ui->frame_NewMap_Options->setEnabled(true);
|
|
||||||
|
|
||||||
setDefaultValuesProjectConfig(false, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewMapPopup::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
|
||||||
ui->lineEdit_NewMap_Name->setText(project->getNewMapName());
|
|
||||||
|
|
||||||
ui->comboBox_NewMap_Primary_Tileset->addItems(project->tilesetLabels.value("primary"));
|
|
||||||
ui->comboBox_NewMap_Secondary_Tileset->addItems(project->tilesetLabels.value("secondary"));
|
|
||||||
|
|
||||||
ui->comboBox_NewMap_Group->addItems(project->groupNames);
|
|
||||||
ui->comboBox_NewMap_Group->setCurrentText(project->groupNames.at(0));
|
|
||||||
|
|
||||||
ui->comboBox_Song->addItems(project->songNames);
|
|
||||||
|
|
||||||
ui->spinBox_NewMap_Width->setValue(mapLayout->width);
|
|
||||||
ui->spinBox_NewMap_Height->setValue(mapLayout->height);
|
|
||||||
ui->comboBox_NewMap_Primary_Tileset->setCurrentText(mapLayout->tileset_primary_label);
|
|
||||||
ui->comboBox_NewMap_Secondary_Tileset->setCurrentText(mapLayout->tileset_secondary_label);
|
|
||||||
|
|
||||||
ui->comboBox_NewMap_Type->addItems(project->mapTypes);
|
|
||||||
ui->comboBox_NewMap_Location->addItems(project->mapSectionValueToName.values());
|
|
||||||
ui->checkBox_NewMap_Show_Location->setChecked(true);
|
|
||||||
|
|
||||||
ui->frame_NewMap_Options->setEnabled(true);
|
|
||||||
|
|
||||||
setDefaultValuesProjectConfig(true, mapLayout);
|
|
||||||
|
|
||||||
map = new Map();
|
|
||||||
map->layout = new MapLayout();
|
|
||||||
map->layout->blockdata = mapLayout->blockdata;
|
|
||||||
|
|
||||||
if (!mapLayout->border.isEmpty()) {
|
|
||||||
map->layout->border = mapLayout->border;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NewMapPopup::setDefaultValuesProjectConfig(bool importedMap, MapLayout *mapLayout) {
|
|
||||||
switch (projectConfig.getBaseGameVersion())
|
|
||||||
{
|
|
||||||
case BaseGameVersion::pokeruby:
|
|
||||||
ui->checkBox_NewMap_Allow_Running->setVisible(false);
|
|
||||||
ui->checkBox_NewMap_Allow_Biking->setVisible(false);
|
|
||||||
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(false);
|
|
||||||
ui->label_NewMap_Allow_Running->setVisible(false);
|
|
||||||
ui->label_NewMap_Allow_Biking->setVisible(false);
|
|
||||||
ui->label_NewMap_Allow_Escape_Rope->setVisible(false);
|
|
||||||
break;
|
|
||||||
case BaseGameVersion::pokeemerald:
|
|
||||||
ui->checkBox_NewMap_Allow_Running->setVisible(true);
|
|
||||||
ui->checkBox_NewMap_Allow_Biking->setVisible(true);
|
|
||||||
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(true);
|
|
||||||
ui->label_NewMap_Allow_Running->setVisible(true);
|
|
||||||
ui->label_NewMap_Allow_Biking->setVisible(true);
|
|
||||||
ui->label_NewMap_Allow_Escape_Rope->setVisible(true);
|
|
||||||
break;
|
|
||||||
case BaseGameVersion::pokefirered:
|
|
||||||
ui->checkBox_NewMap_Allow_Running->setVisible(true);
|
|
||||||
ui->checkBox_NewMap_Allow_Biking->setVisible(true);
|
|
||||||
ui->checkBox_NewMap_Allow_Escape_Rope->setVisible(true);
|
|
||||||
ui->label_NewMap_Allow_Running->setVisible(true);
|
|
||||||
ui->label_NewMap_Allow_Biking->setVisible(true);
|
|
||||||
ui->label_NewMap_Allow_Escape_Rope->setVisible(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (projectConfig.getUseCustomBorderSize()) {
|
|
||||||
if (importedMap) {
|
|
||||||
ui->spinBox_NewMap_BorderWidth->setValue(mapLayout->border_width);
|
|
||||||
ui->spinBox_NewMap_BorderHeight->setValue(mapLayout->border_height);
|
|
||||||
}
|
|
||||||
ui->spinBox_NewMap_BorderWidth->setVisible(true);
|
|
||||||
ui->spinBox_NewMap_BorderHeight->setVisible(true);
|
|
||||||
ui->label_NewMap_BorderWidth->setVisible(true);
|
|
||||||
ui->label_NewMap_BorderHeight->setVisible(true);
|
|
||||||
} else {
|
|
||||||
if (importedMap) {
|
|
||||||
ui->spinBox_NewMap_BorderWidth->setValue(DEFAULT_BORDER_WIDTH);
|
|
||||||
ui->spinBox_NewMap_BorderHeight->setValue(DEFAULT_BORDER_HEIGHT);
|
|
||||||
}
|
|
||||||
ui->spinBox_NewMap_BorderWidth->setVisible(false);
|
|
||||||
ui->spinBox_NewMap_BorderHeight->setVisible(false);
|
|
||||||
ui->label_NewMap_BorderWidth->setVisible(false);
|
|
||||||
ui->label_NewMap_BorderHeight->setVisible(false);
|
|
||||||
}
|
|
||||||
if (projectConfig.getFloorNumberEnabled()) {
|
|
||||||
ui->spinBox_NewMap_Floor_Number->setVisible(true);
|
|
||||||
ui->label_NewMap_Floor_Number->setVisible(true);
|
|
||||||
} else {
|
|
||||||
ui->spinBox_NewMap_Floor_Number->setVisible(false);
|
|
||||||
ui->label_NewMap_Floor_Number->setVisible(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
||||||
|
@ -264,7 +257,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
newMap->name = newMapName;
|
newMap->name = newMapName;
|
||||||
newMap->type = this->ui->comboBox_NewMap_Type->currentText();
|
newMap->type = this->ui->comboBox_NewMap_Type->currentText();
|
||||||
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
|
newMap->location = this->ui->comboBox_NewMap_Location->currentText();
|
||||||
newMap->song = this->ui->comboBox_Song->currentText();
|
newMap->song = this->ui->comboBox_NewMap_Song->currentText();
|
||||||
newMap->requiresFlash = false;
|
newMap->requiresFlash = false;
|
||||||
newMap->weather = this->project->weatherNames.value(0, "WEATHER_NONE");
|
newMap->weather = this->project->weatherNames.value(0, "WEATHER_NONE");
|
||||||
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked();
|
newMap->show_location = this->ui->checkBox_NewMap_Show_Location->isChecked();
|
||||||
|
|
Loading…
Reference in a new issue