Address review comments.
This commit is contained in:
parent
8575b83212
commit
cdcf535894
6 changed files with 27 additions and 100 deletions
|
@ -2742,6 +2742,7 @@
|
||||||
<addaction name="actionNew_Tileset"/>
|
<addaction name="actionNew_Tileset"/>
|
||||||
<addaction name="actionTileset_Editor"/>
|
<addaction name="actionTileset_Editor"/>
|
||||||
<addaction name="actionRegion_Map_Editor"/>
|
<addaction name="actionRegion_Map_Editor"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="actionImport_Map_from_Advance_Map_1_92"/>
|
<addaction name="actionImport_Map_from_Advance_Map_1_92"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuHelp">
|
<widget class="QMenu" name="menuHelp">
|
||||||
|
|
|
@ -35,6 +35,7 @@ private:
|
||||||
Project *project;
|
Project *project;
|
||||||
void setDefaultValues(int, QString);
|
void setDefaultValues(int, QString);
|
||||||
void setDefaultValuesImportMap(MapLayout *);
|
void setDefaultValuesImportMap(MapLayout *);
|
||||||
|
void setDefaultValuesProjectConfig(bool, MapLayout*);
|
||||||
bool checkNewMapDimensions();
|
bool checkNewMapDimensions();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
MapParser::MapParser()
|
MapParser::MapParser()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MapLayout *MapParser::parse(QString filepath, bool *error, Project *project)
|
MapLayout *MapParser::parse(QString filepath, bool *error, Project *project)
|
||||||
|
@ -48,23 +47,6 @@ MapLayout *MapParser::parse(QString filepath, bool *error, Project *project)
|
||||||
(static_cast<unsigned char>(in.at(14)) << 16) |
|
(static_cast<unsigned char>(in.at(14)) << 16) |
|
||||||
(static_cast<unsigned char>(in.at(15)) << 24);
|
(static_cast<unsigned char>(in.at(15)) << 24);
|
||||||
|
|
||||||
/*int maxMetatiles = primaryTileset ? Project::getNumMetatilesPrimary() : Project::getNumMetatilesTotal() - Project::getNumMetatilesPrimary();
|
|
||||||
int numMetatiles = static_cast<unsigned char>(in.at(0)) |
|
|
||||||
(static_cast<unsigned char>(in.at(1)) << 8) |
|
|
||||||
(static_cast<unsigned char>(in.at(2)) << 16) |
|
|
||||||
(static_cast<unsigned char>(in.at(3)) << 24);
|
|
||||||
if (numMetatiles > maxMetatiles) {
|
|
||||||
*error = true;
|
|
||||||
logError(QString(".bvd file contains data for %1 metatiles, but the maximum number of metatiles is %2.").arg(numMetatiles).arg(maxMetatiles));
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (numMetatiles < 1) {
|
|
||||||
*error = true;
|
|
||||||
logError(QString(".bvd file contains no data for metatiles."));
|
|
||||||
return nullptr;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
int numMetatiles = mapWidth * mapHeight;
|
int numMetatiles = mapWidth * mapHeight;
|
||||||
int expectedFileSize = 20 + (numBorderTiles * 2) + (numMetatiles * 2);
|
int expectedFileSize = 20 + (numBorderTiles * 2) + (numMetatiles * 2);
|
||||||
if (in.length() != expectedFileSize) {
|
if (in.length() != expectedFileSize) {
|
||||||
|
@ -82,7 +64,7 @@ MapLayout *MapParser::parse(QString filepath, bool *error, Project *project)
|
||||||
Blockdata *border = nullptr;
|
Blockdata *border = nullptr;
|
||||||
if (numBorderTiles != 0) {
|
if (numBorderTiles != 0) {
|
||||||
border = new Blockdata();
|
border = new Blockdata();
|
||||||
for (int i = 20; (i + 1) < 20 + (numBorderTiles * 2); i += 2) {
|
for (int i = 20; (i + 1) < mapDataOffset; i += 2) {
|
||||||
uint16_t word = static_cast<uint16_t>((in[i] & 0xff) + ((in[i + 1] & 0xff) << 8));
|
uint16_t word = static_cast<uint16_t>((in[i] & 0xff) + ((in[i + 1] & 0xff) << 8));
|
||||||
border->addBlock(word);
|
border->addBlock(word);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2368,22 +2368,6 @@ void MainWindow::importMapFromAdvanceMap1_92()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This is crude because it makes a history entry for every newly-imported metatile.
|
|
||||||
// Revisit this when tiles and num metatiles are added to tileset editory history.
|
|
||||||
/* int metatileIdBase = primary ? 0 : Project::getNumMetatilesPrimary();
|
|
||||||
for (int i = 0; i < metatiles->length(); i++) {
|
|
||||||
if (i >= tileset->metatiles->length()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Metatile *prevMetatile = tileset->metatiles->at(i)->copy();
|
|
||||||
MetatileHistoryItem *commit = new MetatileHistoryItem(static_cast<uint16_t>(metatileIdBase + i), prevMetatile, metatiles->at(i)->copy());
|
|
||||||
metatileHistory.push(commit);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//tileset->metatiles = metatiles;
|
|
||||||
//this->refresh();
|
|
||||||
//this->hasUnsavedChanges = true;
|
|
||||||
openNewMapPopupWindowImportMap(mapLayout);
|
openNewMapPopupWindowImportMap(mapLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1912,8 +1912,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool
|
||||||
mapGroups->insert(mapName, groupNum);
|
mapGroups->insert(mapName, groupNum);
|
||||||
groupedMapNames[groupNum].append(mapName);
|
groupedMapNames[groupNum].append(mapName);
|
||||||
|
|
||||||
Map *map = new Map;
|
Map *map = newMap;
|
||||||
map = newMap;
|
|
||||||
|
|
||||||
map->isPersistedToFile = false;
|
map->isPersistedToFile = false;
|
||||||
map->setName(mapName);
|
map->setName(mapName);
|
||||||
|
@ -1923,11 +1922,7 @@ Map* Project::addNewMapToGroup(QString mapName, int groupNum, Map *newMap, bool
|
||||||
if (!existingLayout) {
|
if (!existingLayout) {
|
||||||
mapLayouts.insert(map->layoutId, map->layout);
|
mapLayouts.insert(map->layoutId, map->layout);
|
||||||
mapLayoutsTable.append(map->layoutId);
|
mapLayoutsTable.append(map->layoutId);
|
||||||
if (importedMap) {
|
if (!importedMap) {
|
||||||
map->layout->lastCommitMapBlocks.blocks = new Blockdata;
|
|
||||||
map->layout->lastCommitMapBlocks.blocks->copyFrom(map->layout->blockdata);
|
|
||||||
map->layout->lastCommitMapBlocks.dimensions = QSize(map->getWidth(), map->getHeight());
|
|
||||||
} else {
|
|
||||||
setNewMapBlockdata(map);
|
setNewMapBlockdata(map);
|
||||||
}
|
}
|
||||||
if (map->layout->border == nullptr) {
|
if (map->layout->border == nullptr) {
|
||||||
|
|
|
@ -124,51 +124,7 @@ void NewMapPopup::setDefaultValues(int groupNum, QString mapSec) {
|
||||||
|
|
||||||
ui->frame_NewMap_Options->setEnabled(true);
|
ui->frame_NewMap_Options->setEnabled(true);
|
||||||
|
|
||||||
switch (projectConfig.getBaseGameVersion())
|
setDefaultValuesProjectConfig(false, NULL);
|
||||||
{
|
|
||||||
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()) {
|
|
||||||
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 {
|
|
||||||
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::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
void NewMapPopup::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
||||||
|
@ -192,6 +148,18 @@ void NewMapPopup::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
||||||
|
|
||||||
ui->frame_NewMap_Options->setEnabled(true);
|
ui->frame_NewMap_Options->setEnabled(true);
|
||||||
|
|
||||||
|
setDefaultValuesProjectConfig(true, mapLayout);
|
||||||
|
|
||||||
|
map = new Map();
|
||||||
|
map->layout = new MapLayout();
|
||||||
|
map->layout->blockdata = mapLayout->blockdata->copy();
|
||||||
|
|
||||||
|
if (mapLayout->border != nullptr) {
|
||||||
|
map->layout->border = mapLayout->border->copy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NewMapPopup::setDefaultValuesProjectConfig(bool importedMap, MapLayout *mapLayout) {
|
||||||
switch (projectConfig.getBaseGameVersion())
|
switch (projectConfig.getBaseGameVersion())
|
||||||
{
|
{
|
||||||
case BaseGameVersion::pokeruby:
|
case BaseGameVersion::pokeruby:
|
||||||
|
@ -220,15 +188,19 @@ void NewMapPopup::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (projectConfig.getUseCustomBorderSize()) {
|
if (projectConfig.getUseCustomBorderSize()) {
|
||||||
ui->spinBox_NewMap_BorderWidth->setValue(mapLayout->border_width.toInt(nullptr, 0));
|
if (importedMap) {
|
||||||
ui->spinBox_NewMap_BorderHeight->setValue(mapLayout->border_height.toInt(nullptr, 0));
|
ui->spinBox_NewMap_BorderWidth->setValue(mapLayout->border_width.toInt(nullptr, 0));
|
||||||
|
ui->spinBox_NewMap_BorderHeight->setValue(mapLayout->border_height.toInt(nullptr, 0));
|
||||||
|
}
|
||||||
ui->spinBox_NewMap_BorderWidth->setVisible(true);
|
ui->spinBox_NewMap_BorderWidth->setVisible(true);
|
||||||
ui->spinBox_NewMap_BorderHeight->setVisible(true);
|
ui->spinBox_NewMap_BorderHeight->setVisible(true);
|
||||||
ui->label_NewMap_BorderWidth->setVisible(true);
|
ui->label_NewMap_BorderWidth->setVisible(true);
|
||||||
ui->label_NewMap_BorderHeight->setVisible(true);
|
ui->label_NewMap_BorderHeight->setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
ui->spinBox_NewMap_BorderWidth->setValue(DEFAULT_BORDER_WIDTH);
|
if (importedMap) {
|
||||||
ui->spinBox_NewMap_BorderHeight->setValue(DEFAULT_BORDER_HEIGHT);
|
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_BorderWidth->setVisible(false);
|
||||||
ui->spinBox_NewMap_BorderHeight->setVisible(false);
|
ui->spinBox_NewMap_BorderHeight->setVisible(false);
|
||||||
ui->label_NewMap_BorderWidth->setVisible(false);
|
ui->label_NewMap_BorderWidth->setVisible(false);
|
||||||
|
@ -241,14 +213,6 @@ void NewMapPopup::setDefaultValuesImportMap(MapLayout *mapLayout) {
|
||||||
ui->spinBox_NewMap_Floor_Number->setVisible(false);
|
ui->spinBox_NewMap_Floor_Number->setVisible(false);
|
||||||
ui->label_NewMap_Floor_Number->setVisible(false);
|
ui->label_NewMap_Floor_Number->setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
map = new Map();
|
|
||||||
map->layout = new MapLayout();
|
|
||||||
map->layout->blockdata = mapLayout->blockdata->copy();
|
|
||||||
|
|
||||||
if (mapLayout->border != nullptr) {
|
|
||||||
map->layout->border = mapLayout->border->copy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
void NewMapPopup::on_lineEdit_NewMap_Name_textChanged(const QString &text) {
|
||||||
|
@ -288,7 +252,7 @@ void NewMapPopup::on_pushButton_NewMap_Accept_clicked() {
|
||||||
|
|
||||||
if (this->existingLayout) {
|
if (this->existingLayout) {
|
||||||
layout = this->project->mapLayouts.value(this->layoutId);
|
layout = this->project->mapLayouts.value(this->layoutId);
|
||||||
newMap->needsLayoutDir = false;
|
newMap->needsLayoutDir = false;
|
||||||
} else {
|
} else {
|
||||||
layout = new MapLayout;
|
layout = new MapLayout;
|
||||||
layout->id = MapLayout::layoutConstantFromName(newMapName);
|
layout->id = MapLayout::layoutConstantFromName(newMapName);
|
||||||
|
|
Loading…
Reference in a new issue