Merge branch 'master' into random-00
This commit is contained in:
commit
772ca7c957
17 changed files with 111 additions and 53 deletions
|
@ -14,9 +14,12 @@ The **"Breaking Changes"** listed below are changes that have been made in the d
|
|||
|
||||
### Changed
|
||||
- Collapse the map list by default.
|
||||
- Collision view now has a transparency slider to help make it easier to view the underlying metatiles.
|
||||
|
||||
### Fixed
|
||||
- Fix bug where smart paths could bes auto-enabled, despite the checkbox being disabled.
|
||||
- Fix crash that could occur when changing the palette id in the tileset palette editor.
|
||||
- Fix crash that could occur when shrinking the number of metatiles in a tileset.
|
||||
|
||||
## [1.1.0] - 2018-12-27
|
||||
### Breaking Changes
|
||||
|
|
|
@ -369,7 +369,7 @@
|
|||
<item>
|
||||
<widget class="QToolButton" name="toolButton_Shift">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Map Shift</p><p><span style=" font-weight:600;">Click and drag</span> on the map to shift the positions all metatiles at once. This is useful after resizing a map.</p></body></html></string>
|
||||
<string><html><head/><body><p>Map Shift</p><p><span style=" font-weight:600;">Click and drag</span> on the map to shift the positions of all metatiles at once. This is useful after resizing a map.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Shift</string>
|
||||
|
@ -1112,7 +1112,7 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QGraphicsView" name="graphicsView_Collision">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
|
@ -1128,20 +1128,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer name="horizontalSpacer_18">
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_19">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -1154,19 +1154,42 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer_18">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSlider" name="horizontalSlider_CollisionTransparency">
|
||||
<property name="minimum">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Transparency</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
|
|
@ -32,17 +32,20 @@ public:
|
|||
this->recentMap = "";
|
||||
this->mapSortOrder = MapSortOrder::Group;
|
||||
this->prettyCursors = true;
|
||||
this->collisionOpacity = 50;
|
||||
}
|
||||
void setRecentProject(QString project);
|
||||
void setRecentMap(QString map);
|
||||
void setMapSortOrder(MapSortOrder order);
|
||||
void setPrettyCursors(bool enabled);
|
||||
void setGeometry(QByteArray, QByteArray, QByteArray, QByteArray, QByteArray);
|
||||
void setCollisionOpacity(int opacity);
|
||||
QString getRecentProject();
|
||||
QString getRecentMap();
|
||||
MapSortOrder getMapSortOrder();
|
||||
bool getPrettyCursors();
|
||||
QMap<QString, QByteArray> getGeometry();
|
||||
int getCollisionOpacity();
|
||||
protected:
|
||||
QString getConfigFilepath();
|
||||
void parseConfigKeyValue(QString key, QString value);
|
||||
|
@ -60,6 +63,7 @@ private:
|
|||
QByteArray mapSplitterState;
|
||||
QByteArray eventsSlpitterState;
|
||||
QByteArray mainSplitterState;
|
||||
int collisionOpacity;
|
||||
};
|
||||
|
||||
extern PorymapConfig porymapConfig;
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
int getWidth();
|
||||
int getHeight();
|
||||
QPixmap render(bool ignoreCache);
|
||||
QPixmap renderCollision(bool ignoreCache);
|
||||
QPixmap renderCollision(qreal opacity, bool ignoreCache);
|
||||
bool blockChanged(int, Blockdata*);
|
||||
void cacheBlockdata();
|
||||
void cacheCollision();
|
||||
|
|
|
@ -114,6 +114,7 @@ public:
|
|||
|
||||
int scale_exp = 0;
|
||||
double scale_base = sqrt(2); // adjust scale factor with this
|
||||
qreal collisionOpacity = 0.5;
|
||||
|
||||
void objectsView_onMousePress(QMouseEvent *event);
|
||||
void objectsView_onMouseMove(QMouseEvent *event);
|
||||
|
|
|
@ -57,7 +57,6 @@ private slots:
|
|||
void on_action_Exit_triggered();
|
||||
void on_comboBox_Song_activated(const QString &arg1);
|
||||
void on_comboBox_Location_activated(const QString &arg1);
|
||||
void on_comboBox_Visibility_activated(const QString &arg1);
|
||||
void on_comboBox_Weather_activated(const QString &arg1);
|
||||
void on_comboBox_Type_activated(const QString &arg1);
|
||||
void on_comboBox_BattleScene_activated(const QString &arg1);
|
||||
|
@ -150,6 +149,8 @@ private slots:
|
|||
|
||||
void selectedEventIndexChanged(int index);
|
||||
|
||||
void on_horizontalSlider_CollisionTransparency_valueChanged(int value);
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
TilesetEditor *tilesetEditor = nullptr;
|
||||
|
|
|
@ -10,17 +10,19 @@
|
|||
class CollisionPixmapItem : public MapPixmapItem {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CollisionPixmapItem(Map *map, MovementPermissionsSelector *movementPermissionsSelector, MetatileSelector *metatileSelector, Settings *settings)
|
||||
CollisionPixmapItem(Map *map, MovementPermissionsSelector *movementPermissionsSelector, MetatileSelector *metatileSelector, Settings *settings, qreal *opacity)
|
||||
: MapPixmapItem(map, metatileSelector, settings){
|
||||
this->movementPermissionsSelector = movementPermissionsSelector;
|
||||
this->opacity = opacity;
|
||||
}
|
||||
MovementPermissionsSelector *movementPermissionsSelector;
|
||||
qreal *opacity;
|
||||
void updateMovementPermissionSelection(QGraphicsSceneMouseEvent *event);
|
||||
virtual void paint(QGraphicsSceneMouseEvent*);
|
||||
virtual void floodFill(QGraphicsSceneMouseEvent*);
|
||||
virtual void magicFill(QGraphicsSceneMouseEvent*);
|
||||
virtual void pick(QGraphicsSceneMouseEvent*);
|
||||
virtual void draw(bool ignoreCache = false);
|
||||
void draw(bool ignoreCache = false);
|
||||
|
||||
signals:
|
||||
void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *);
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
explicit PaletteEditor(Project*, Tileset*, Tileset*, QWidget *parent = nullptr);
|
||||
~PaletteEditor();
|
||||
void setPaletteId(int);
|
||||
void setTilesets(Tileset*, Tileset*);
|
||||
|
||||
private:
|
||||
Ui::PaletteEditor *ui;
|
||||
|
|
|
@ -48,7 +48,6 @@ private slots:
|
|||
void onSelectedTilesChanged();
|
||||
void onMetatileLayerTileChanged(int, int);
|
||||
void onMetatileLayerSelectionChanged(QPoint, int, int);
|
||||
void onPaletteEditorClosed();
|
||||
void onPaletteEditorChangedPaletteColor();
|
||||
void onPaletteEditorChangedPalette(int);
|
||||
|
||||
|
|
|
@ -129,6 +129,13 @@ void PorymapConfig::parseConfigKeyValue(QString key, QString value) {
|
|||
this->eventsSlpitterState = bytesFromString(value);
|
||||
} else if (key == "main_splitter_state") {
|
||||
this->mainSplitterState = bytesFromString(value);
|
||||
} else if (key == "collision_opacity") {
|
||||
bool ok;
|
||||
this->collisionOpacity = qMax(0, qMin(100, value.toInt(&ok)));
|
||||
if (!ok) {
|
||||
logWarn(QString("Invalid config value for collision_opacity: '%1'. Must be an integer.").arg(value));
|
||||
this->collisionOpacity = 50;
|
||||
}
|
||||
} else {
|
||||
logWarn(QString("Invalid config key found in config file %1: '%2'").arg(this->getConfigFilepath()).arg(key));
|
||||
}
|
||||
|
@ -145,6 +152,7 @@ QMap<QString, QString> PorymapConfig::getKeyValueMap() {
|
|||
map.insert("map_splitter_state", stringFromByteArray(this->mapSplitterState));
|
||||
map.insert("events_splitter_state", stringFromByteArray(this->eventsSlpitterState));
|
||||
map.insert("main_splitter_state", stringFromByteArray(this->mainSplitterState));
|
||||
map.insert("collision_opacity", QString("%1").arg(this->collisionOpacity));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
@ -195,6 +203,11 @@ void PorymapConfig::setGeometry(QByteArray windowGeometry_, QByteArray windowSta
|
|||
this->save();
|
||||
}
|
||||
|
||||
void PorymapConfig::setCollisionOpacity(int opacity) {
|
||||
this->collisionOpacity = opacity;
|
||||
// don't auto-save here because this can be called very frequently.
|
||||
}
|
||||
|
||||
QString PorymapConfig::getRecentProject() {
|
||||
return this->recentProject;
|
||||
}
|
||||
|
@ -223,6 +236,10 @@ QMap<QString, QByteArray> PorymapConfig::getGeometry() {
|
|||
return geometry;
|
||||
}
|
||||
|
||||
int PorymapConfig::getCollisionOpacity() {
|
||||
return this->collisionOpacity;
|
||||
}
|
||||
|
||||
const QMap<BaseGameVersion, QString> baseGameVersionMap = {
|
||||
{BaseGameVersion::pokeruby, "pokeruby"},
|
||||
{BaseGameVersion::pokeemerald, "pokeemerald"},
|
||||
|
|
|
@ -110,7 +110,7 @@ void Map::cacheCollision() {
|
|||
}
|
||||
}
|
||||
|
||||
QPixmap Map::renderCollision(bool ignoreCache) {
|
||||
QPixmap Map::renderCollision(qreal opacity, bool ignoreCache) {
|
||||
bool changed_any = false;
|
||||
int width_ = getWidth();
|
||||
int height_ = getHeight();
|
||||
|
@ -141,7 +141,7 @@ QPixmap Map::renderCollision(bool ignoreCache) {
|
|||
painter.setOpacity(1);
|
||||
painter.drawImage(metatile_origin, metatile_image);
|
||||
painter.save();
|
||||
painter.setOpacity(0.55);
|
||||
painter.setOpacity(opacity);
|
||||
painter.drawImage(metatile_origin, collision_metatile_image);
|
||||
painter.restore();
|
||||
}
|
||||
|
|
|
@ -575,7 +575,7 @@ void Editor::displayMapMovementPermissions() {
|
|||
scene->removeItem(collision_item);
|
||||
delete collision_item;
|
||||
}
|
||||
collision_item = new CollisionPixmapItem(map, this->movement_permissions_selector_item, this->metatile_selector_item, this->settings);
|
||||
collision_item = new CollisionPixmapItem(map, this->movement_permissions_selector_item, this->metatile_selector_item, this->settings, &this->collisionOpacity);
|
||||
connect(collision_item, SIGNAL(mouseEvent(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)),
|
||||
this, SLOT(mouseEvent_collision(QGraphicsSceneMouseEvent*,CollisionPixmapItem*)));
|
||||
connect(collision_item, SIGNAL(hoveredMapMovementPermissionChanged(int, int)),
|
||||
|
|
|
@ -205,6 +205,10 @@ void MainWindow::loadUserSettings() {
|
|||
ui->actionBetter_Cursors->setChecked(porymapConfig.getPrettyCursors());
|
||||
this->editor->settings->betterCursors = porymapConfig.getPrettyCursors();
|
||||
mapSortOrder = porymapConfig.getMapSortOrder();
|
||||
ui->horizontalSlider_CollisionTransparency->blockSignals(true);
|
||||
this->editor->collisionOpacity = static_cast<qreal>(porymapConfig.getCollisionOpacity()) / 100;
|
||||
ui->horizontalSlider_CollisionTransparency->setValue(porymapConfig.getCollisionOpacity());
|
||||
ui->horizontalSlider_CollisionTransparency->blockSignals(false);
|
||||
}
|
||||
|
||||
void MainWindow::restoreWindowState() {
|
||||
|
@ -493,13 +497,6 @@ void MainWindow::on_comboBox_Location_activated(const QString &location)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_Visibility_activated(const QString &requiresFlash)
|
||||
{
|
||||
if (editor && editor->map) {
|
||||
editor->map->requiresFlash = requiresFlash;
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_comboBox_Weather_activated(const QString &weather)
|
||||
{
|
||||
if (editor && editor->map) {
|
||||
|
@ -1569,6 +1566,12 @@ void MainWindow::selectedEventIndexChanged(int index)
|
|||
editor->selectMapEvent(selectedEvent);
|
||||
}
|
||||
|
||||
void MainWindow::on_horizontalSlider_CollisionTransparency_valueChanged(int value) {
|
||||
this->editor->collisionOpacity = static_cast<qreal>(value) / 100;
|
||||
porymapConfig.setCollisionOpacity(value);
|
||||
this->editor->collision_item->draw(true);
|
||||
}
|
||||
|
||||
void MainWindow::on_toolButton_deleteObject_clicked()
|
||||
{
|
||||
if (editor && editor->selected_events) {
|
||||
|
@ -1848,6 +1851,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
|||
this->ui->splitter_events->saveState(),
|
||||
this->ui->splitter_main->saveState()
|
||||
);
|
||||
porymapConfig.save();
|
||||
|
||||
QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ void CollisionPixmapItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
|||
|
||||
void CollisionPixmapItem::draw(bool ignoreCache) {
|
||||
if (map) {
|
||||
setPixmap(map->renderCollision(ignoreCache));
|
||||
setPixmap(map->renderCollision(*this->opacity, ignoreCache));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -260,22 +260,25 @@ void MapPixmapItem::magicFill(QGraphicsSceneMouseEvent *event) {
|
|||
int initialX = static_cast<int>(pos.x()) / 16;
|
||||
int initialY = static_cast<int>(pos.y()) / 16;
|
||||
Block *block = map->getBlock(initialX, initialY);
|
||||
QList<uint16_t> *selectedMetatiles = this->metatileSelector->getSelectedMetatiles();
|
||||
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
|
||||
uint16_t tile = block->tile;
|
||||
|
||||
for (int y = 0; y < map->getHeight(); y++) {
|
||||
for (int x = 0; x < map->getWidth(); x++) {
|
||||
block = map->getBlock(x, y);
|
||||
if (block && block->tile == tile) {
|
||||
int xDiff = x - initialX;
|
||||
int yDiff = y - initialY;
|
||||
int i = xDiff % selectionDimensions.x();
|
||||
int j = yDiff % selectionDimensions.y();
|
||||
if (i < 0) i = selectionDimensions.x() + i;
|
||||
if (j < 0) j = selectionDimensions.y() + j;
|
||||
block->tile = selectedMetatiles->at(j * selectionDimensions.x() + i);
|
||||
map->_setBlock(x, y, *block);
|
||||
if (block) {
|
||||
QList<uint16_t> *selectedMetatiles = this->metatileSelector->getSelectedMetatiles();
|
||||
QPoint selectionDimensions = this->metatileSelector->getSelectionDimensions();
|
||||
uint16_t tile = block->tile;
|
||||
|
||||
for (int y = 0; y < map->getHeight(); y++) {
|
||||
for (int x = 0; x < map->getWidth(); x++) {
|
||||
block = map->getBlock(x, y);
|
||||
if (block && block->tile == tile) {
|
||||
int xDiff = x - initialX;
|
||||
int yDiff = y - initialY;
|
||||
int i = xDiff % selectionDimensions.x();
|
||||
int j = yDiff % selectionDimensions.y();
|
||||
if (i < 0) i = selectionDimensions.x() + i;
|
||||
if (j < 0) j = selectionDimensions.y() + j;
|
||||
block->tile = selectedMetatiles->at(j * selectionDimensions.x() + i);
|
||||
map->_setBlock(x, y, *block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -188,6 +188,13 @@ void PaletteEditor::setPaletteId(int paletteId) {
|
|||
this->ui->spinBox_PaletteId->blockSignals(false);
|
||||
}
|
||||
|
||||
void PaletteEditor::setTilesets(Tileset *primaryTileset, Tileset *secondaryTileset) {
|
||||
this->primaryTileset = primaryTileset;
|
||||
this->secondaryTileset = secondaryTileset;
|
||||
this->refreshColorSliders();
|
||||
this->refreshColors();
|
||||
}
|
||||
|
||||
void PaletteEditor::setColor(int colorIndex) {
|
||||
int paletteNum = this->ui->spinBox_PaletteId->value();
|
||||
int red = this->sliders[colorIndex][0]->value() * 8;
|
||||
|
|
|
@ -79,9 +79,9 @@ void TilesetEditor::setTilesets(QString primaryTilesetLabel, QString secondaryTi
|
|||
|
||||
void TilesetEditor::refresh() {
|
||||
this->metatileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||
this->metatileSelector->select(this->metatileSelector->getSelectedMetatile());
|
||||
this->tileSelector->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||
this->metatileLayersItem->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||
this->metatileSelector->select(this->metatileSelector->getSelectedMetatile());
|
||||
this->drawSelectedTiles();
|
||||
|
||||
this->ui->graphicsView_Tiles->setSceneRect(0, 0, this->tileSelector->pixmap().width() + 2, this->tileSelector->pixmap().height() + 2);
|
||||
|
@ -313,6 +313,7 @@ void TilesetEditor::on_actionSave_Tileset_triggered()
|
|||
{
|
||||
this->project->saveTilesets(this->primaryTileset, this->secondaryTileset);
|
||||
emit this->tilesetsSaved(this->primaryTileset->name, this->secondaryTileset->name);
|
||||
this->paletteEditor->setTilesets(this->primaryTileset, this->secondaryTileset);
|
||||
this->ui->statusbar->showMessage(QString("Saved primary and secondary Tilesets!"), 5000);
|
||||
this->hasUnsavedChanges = false;
|
||||
}
|
||||
|
@ -483,18 +484,10 @@ void TilesetEditor::on_actionChange_Metatiles_Count_triggered()
|
|||
}
|
||||
}
|
||||
|
||||
void TilesetEditor::onPaletteEditorClosed() {
|
||||
if (this->paletteEditor) {
|
||||
delete this->paletteEditor;
|
||||
this->paletteEditor = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void TilesetEditor::on_actionChange_Palettes_triggered()
|
||||
{
|
||||
if (!this->paletteEditor) {
|
||||
this->paletteEditor = new PaletteEditor(this->project, this->primaryTileset, this->secondaryTileset, this);
|
||||
connect(this->paletteEditor, SIGNAL(closed()), this, SLOT(onPaletteEditorClosed()));
|
||||
connect(this->paletteEditor, SIGNAL(changedPaletteColor()), this, SLOT(onPaletteEditorChangedPaletteColor()));
|
||||
connect(this->paletteEditor, SIGNAL(changedPalette(int)), this, SLOT(onPaletteEditorChangedPalette(int)));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue