diff --git a/include/AME/Entities/Npc.hpp b/include/AME/Entities/Npc.hpp index be8e7cb..7622882 100644 --- a/include/AME/Entities/Npc.hpp +++ b/include/AME/Entities/Npc.hpp @@ -66,7 +66,7 @@ namespace ame UInt8 moveRadiusX; ///< Walking radius, vertical UInt8 moveRadiusY; ///< Walking radius, horizontal UInt8 filler_2; ///< Second filler byte - UInt8 property; ///< Npc property (trainer = 1) + UInt8 isTrainer; ///< If npc is trainer = 1 UInt8 filler_3; ///< Third filler byte UInt16 viewRadius; ///< View radius for trainers UInt32 ptrScript; ///< Offset of the script diff --git a/include/AME/Forms/MainWindow.h b/include/AME/Forms/MainWindow.h index d5c272c..ef31f98 100644 --- a/include/AME/Forms/MainWindow.h +++ b/include/AME/Forms/MainWindow.h @@ -175,7 +175,6 @@ namespace ame // Slots // /////////////////////////////////////////////////////////// - void showCorrectSignType(Sign *sign); bool loadROM(const QString &file); bool loadMapChangeTreeView(Map *map); bool loadMapChangeTreeView(int bank, int map); @@ -192,34 +191,63 @@ namespace ame void setScriptEditorButtonsEnabled(bool enabled); void on_action_Open_ROM_triggered(); - void on_sldWildGrassChance_valueChanged(int value); - void on_sldWildWaterChance_valueChanged(int value); - void on_sldWildFishingChance_valueChanged(int value); - void on_sldWildOtherChance_valueChanged(int value); - void on_cmbEntityTypeSelector_currentIndexChanged(int index); - void on_spnEntityScroller_valueChanged(int arg1); - void on_cmbSignType_currentIndexChanged(int index); - void on_warp_number_valueChanged(int value); - void on_warp_map_valueChanged(int value); - void on_warp_bank_valueChanged(int value); - void checkWarp(); - void on_tabWidget_currentChanged(int index); + void on_actionClearRecentFiles_triggered(); + void on_treeView_activated(const QModelIndex &index); void on_lineEdit_textChanged(const QString &arg1); - void on_actionClearRecentFiles_triggered(); + void on_tabWidget_currentChanged(int index); void on_tabWidget_2_currentChanged(int index); + void on_action_Connection_Editor_triggered(); void on_action_Settings_triggered(); void on_action_Tileset_Editor_triggered(); - void on_btnWarpToDest_clicked(); + void on_btnShowSprites_toggled(bool checked); + void on_btnMapGrid_toggled(bool checked); + void on_btnEntitiesGrid_toggled(bool checked); + + void on_cmbEntityTypeSelector_currentIndexChanged(int index); + void on_spnEntityScroller_valueChanged(int arg1); + + void on_npc_sprite_valueChanged(int value); + void on_npc_pos_x_valueChanged(int value); + void on_npc_pos_y_valueChanged(int value); + void on_spnNPCHeight_valueChanged(int value); + void on_spnNPCIdleAnim_valueChanged(int value); + void on_npc_mov_x_valueChanged(int value); + void on_npc_mov_y_valueChanged(int value); + void on_npc_trainer_toggled(bool checked); + void on_npc_view_rad_valueChanged(int value); + void on_npc_script_valueChanged(int value); + void on_npc_flag_valueChanged(int value); void on_btnNPCOpenScript_clicked(); + + void checkWarp(); + void on_warp_pos_x_valueChanged(int value); + void on_warp_pos_y_valueChanged(int value); + void on_spnWarpHeight_valueChanged(int value); + void on_warp_number_valueChanged(int value); + void on_warp_map_valueChanged(int value); + void on_warp_bank_valueChanged(int value); + void on_btnWarpToDest_clicked(); + + void on_trigger_pos_x_valueChanged(int value); + void on_trigger_pos_y_valueChanged(int value); void on_btnTriggerOpenScript_clicked(); + + void showCorrectSignType(Sign *sign); + void on_sign_pos_x_valueChanged(int value); + void on_sign_pos_y_valueChanged(int value); + void on_spnSignHeight_valueChanged(int value); + void on_cmbSignType_currentIndexChanged(int index); void on_btnSignOpenScript_clicked(); - void on_btnShowSprites_toggled(bool checked); - void on_btnMapGrid_toggled(bool checked); + void on_sldWildGrassChance_valueChanged(int value); + void on_sldWildWaterChance_valueChanged(int value); + void on_sldWildFishingChance_valueChanged(int value); + void on_sldWildOtherChance_valueChanged(int value); - void on_btnEntitiesGrid_toggled(bool checked); + void on_header_mapname_valueChanged(int value); + void on_cmbHeaderMapName_currentIndexChanged(int index); private: diff --git a/include/AME/Widgets/Rendering/AMEEntityView.h b/include/AME/Widgets/Rendering/AMEEntityView.h index cd2813b..f2e7772 100644 --- a/include/AME/Widgets/Rendering/AMEEntityView.h +++ b/include/AME/Widgets/Rendering/AMEEntityView.h @@ -50,10 +50,9 @@ namespace ame /////////////////////////////////////////////////////////// struct CurrentEntity { - QPoint absPos; + QPoint position; EntityType type = ET_Invalid; void *entity = NULL; - int index = 0; }; @@ -111,10 +110,18 @@ namespace ame void setCurrentEntity(CurrentEntity entity); /////////////////////////////////////////////////////////// - /// \brief Retrieves the currently selected entity. + /// \brief Sets a new x position for the highlighting of the + /// currently selected entity. /// /////////////////////////////////////////////////////////// - const CurrentEntity ¤tEntity() const; + void setCurrentEntityPosX(int x); + + /////////////////////////////////////////////////////////// + /// \brief Sets a new y position for the highlighting of the + /// currently selected entity. + /// + /////////////////////////////////////////////////////////// + void setCurrentEntityPosY(int y); /////////////////////////////////////////////////////////// /// \brief Sets the visibility of the grid from the UI. diff --git a/resources/UI/MainWindow.ui b/resources/UI/MainWindow.ui index c11bcfb..8ac4e1f 100644 --- a/resources/UI/MainWindow.ui +++ b/resources/UI/MainWindow.ui @@ -2433,36 +2433,13 @@ - + 0 0 - - - Courier New - - - - QAbstractSpinBox::NoButtons - - - 0x - - - 255 - - - 16 - - - true - - - 1 - diff --git a/src/Entities/EntityRawData.cpp b/src/Entities/EntityRawData.cpp index c0ec84d..b945fde 100644 --- a/src/Entities/EntityRawData.cpp +++ b/src/Entities/EntityRawData.cpp @@ -63,7 +63,7 @@ namespace ame ba.push_back((Int8) behaviour); ba.push_back((Int8) ((moveRadiusY << 4) | moveRadiusX)); ba.push_back((Int8) filler_2); - ba.push_back((Int8) property); + ba.push_back((Int8) isTrainer); ba.push_back((Int8) filler_3); ba.append((Int8 *) &viewRadius, 2); ptrScript += 0x08000000; diff --git a/src/Entities/EventTable.cpp b/src/Entities/EventTable.cpp index cf5aff6..a65ffe4 100644 --- a/src/Entities/EventTable.cpp +++ b/src/Entities/EventTable.cpp @@ -218,8 +218,8 @@ namespace ame tempRadius = rom.readByte(); npc->moveRadiusX = tempRadius & 15; npc->moveRadiusY = tempRadius >> 4; - npc->filler_2 = rom.readByte(); // either property is a hword or this isn't a filler - npc->property = rom.readByte(); + npc->filler_2 = rom.readByte(); + npc->isTrainer = rom.readByte(); npc->filler_3 = rom.readByte(); npc->viewRadius = rom.readHWord(); npc->ptrScript = rom.readPointer(); diff --git a/src/Forms/MainWindow.cpp b/src/Forms/MainWindow.cpp index b0039ce..89e37b3 100644 --- a/src/Forms/MainWindow.cpp +++ b/src/Forms/MainWindow.cpp @@ -405,6 +405,7 @@ namespace ame ui->cmbHeaderMapName->setModel(mapNameModel); + ui->npc_sprite->setMaximum(CONFIG(OverworldCount) - 1); ui->header_mapname->setRange(CONFIG(MapNameTotal) - CONFIG(MapNameCount), CONFIG(MapNameTotal) - 1); // Updates the treeview @@ -1166,7 +1167,7 @@ namespace ame // Populates the header tab setupHeader(currentMap); - //ui->cmbEntityTypeSelector->setCurrentIndex(0); + //workaround to reload current entity on_cmbEntityTypeSelector_currentIndexChanged(ui->cmbEntityTypeSelector->currentIndex()); if (name != NULL) @@ -1331,49 +1332,38 @@ namespace ame /////////////////////////////////////////////////////////// void MainWindow::on_cmbEntityTypeSelector_currentIndexChanged(int index) { + ui->spnEntityScroller->setMinimum(0); if (index == 0) { - ui->spnEntityScroller->setMinimum(0); ui->spnEntityScroller->setMaximum(m_CurrentMap->entities().npcs().size()-1); ui->stckEntityEditor->setEnabled(m_CurrentMap->entities().npcs().size() > 0); if (m_CurrentMap->entities().npcs().size() > 0) on_spnEntityScroller_valueChanged(m_CurrentNPC); - else - ui->glEntityEditor->setCurrentEntity(CurrentEntity()); } else if (index == 1) { - ui->spnEntityScroller->setMinimum(0); ui->spnEntityScroller->setMaximum(m_CurrentMap->entities().warps().size()-1); ui->stckEntityEditor->setEnabled(m_CurrentMap->entities().warps().size() > 0); if (m_CurrentMap->entities().warps().size() > 0) on_spnEntityScroller_valueChanged(m_CurrentWarp); - else - ui->glEntityEditor->setCurrentEntity(CurrentEntity()); } else if (index == 2) { - ui->spnEntityScroller->setMinimum(0); ui->spnEntityScroller->setMaximum(m_CurrentMap->entities().triggers().size()-1); ui->stckEntityEditor->setEnabled(m_CurrentMap->entities().triggers().size() > 0); if (m_CurrentMap->entities().triggers().size() > 0) on_spnEntityScroller_valueChanged(m_CurrentTrigger); - else - ui->glEntityEditor->setCurrentEntity(CurrentEntity()); } else { - ui->spnEntityScroller->setMinimum(0); ui->spnEntityScroller->setMaximum(m_CurrentMap->entities().signs().size()-1); ui->stckEntityEditor->setEnabled(m_CurrentMap->entities().signs().size() > 0); if (m_CurrentMap->entities().signs().size() > 0) on_spnEntityScroller_valueChanged(m_CurrentSign); - else - ui->glEntityEditor->setCurrentEntity(CurrentEntity()); } } @@ -1381,7 +1371,7 @@ namespace ame // Function type: Slot // Contributors: Pokedude, Nekaida // Last edit by: Nekaida - // Date of edit: 3/27/2017 + // Date of edit: 5/11/2017 // ///////////////////////////////////////////////////////// void MainWindow::on_spnEntityScroller_valueChanged(int arg1) @@ -1389,8 +1379,6 @@ namespace ame if (arg1 < 0) return; - - QPoint startPos = ui->glMapEditor->mainPos(); if (ui->cmbEntityTypeSelector->currentIndex() == 0 && m_CurrentMap->entities().npcs().size() > 0) { if (arg1 >= m_CurrentMap->entities().npcs().size()) @@ -1410,18 +1398,17 @@ namespace ame ui->npc_mov_x->setValue(eventN->moveRadiusX); ui->npc_mov_y->setValue(eventN->moveRadiusY); ui->npc_view_rad->setValue(eventN->viewRadius); - ui->npc_trainer->setValue(eventN->property); + ui->npc_trainer->setChecked(eventN->isTrainer); ui->npc_script->setValue(eventN->ptrScript); ui->npc_flag->setValue(eventN->flag); ui->npc_raw_data->setData(eventN->rawData()); ui->spnEntityScroller->setValue(m_CurrentNPC); - startPos += QPoint(eventN->positionX*16, eventN->positionY*16); CurrentEntity entity; - entity.absPos = startPos; + entity.position.setX(eventN->positionX * 16); + entity.position.setY(eventN->positionY * 16); entity.type = ET_Npc; entity.entity = eventN; - entity.index = m_CurrentNPC; ui->glEntityEditor->setCurrentEntity(entity); } else if (ui->cmbEntityTypeSelector->currentIndex() == 1 && m_CurrentMap->entities().warps().size() > 0) @@ -1441,15 +1428,14 @@ namespace ame ui->spnWarpHeight->setValue(eventW->level); ui->warp_raw_data->setData(eventW->rawData()); ui->spnEntityScroller->setValue(m_CurrentWarp); - startPos += QPoint(eventW->positionX*16, eventW->positionY*16); checkWarp(); CurrentEntity entity; - entity.absPos = startPos; + entity.position.setX(eventW->positionX * 16); + entity.position.setY(eventW->positionY * 16); entity.type = ET_Warp; entity.entity = eventW; - entity.index = m_CurrentWarp; ui->glEntityEditor->setCurrentEntity(entity); } else if (ui->cmbEntityTypeSelector->currentIndex() == 2 && m_CurrentMap->entities().triggers().size() > 0) @@ -1469,13 +1455,12 @@ namespace ame ui->spnTriggerHeight->setValue(eventT->level); ui->trigger_raw_data->setData(eventT->rawData()); ui->spnEntityScroller->setValue(m_CurrentTrigger); - startPos += QPoint(eventT->positionX*16, eventT->positionY*16); CurrentEntity entity; - entity.absPos = startPos; + entity.position.setX(eventT->positionX * 16); + entity.position.setY(eventT->positionY * 16); entity.type = ET_Trigger; entity.entity = eventT; - entity.index = m_CurrentTrigger; ui->glEntityEditor->setCurrentEntity(entity); } else if (m_CurrentMap->entities().signs().size() > 0) @@ -1494,13 +1479,12 @@ namespace ame ui->spnSignHeight->setValue(eventS->level); ui->spnSignType->setValue(static_cast(eventS->type)); ui->spnEntityScroller->setValue(m_CurrentSign); - startPos += QPoint(eventS->positionX*16, eventS->positionY*16); CurrentEntity entity; - entity.absPos = startPos; + entity.position.setX(eventS->positionX * 16); + entity.position.setY(eventS->positionY * 16); entity.type = ET_Sign; entity.entity = eventS; - entity.index = m_CurrentSign; ui->glEntityEditor->setCurrentEntity(entity); showCorrectSignType(eventS); @@ -1517,6 +1501,7 @@ namespace ame void MainWindow::on_cmbSignType_currentIndexChanged(int index) { Q_UNUSED(index); + m_CurrentMap->entities().signs()[m_CurrentSign]->type = static_cast(index); Sign *eventS = m_CurrentMap->entities().signs()[ui->spnEntityScroller->value()]; showCorrectSignType(eventS); } @@ -1525,7 +1510,7 @@ namespace ame // Function type: Slot // Contributors: Pokedude, Nekaida // Last edit by: Nekaida - // Date of edit: 3/27/2017 + // Date of edit: 5/11/2017 // /////////////////////////////////////////////////////////// void MainWindow::entity_mouseClick(QMouseEvent *event) @@ -1553,33 +1538,10 @@ namespace ame } if (eventN != NULL) { - // Load NPC properties + m_CurrentNPC = indexN; ui->stckEntityEditor->setCurrentWidget(ui->pageNPCs); - ui->npc_group_raw->setTitle(tr("Raw Data @ 0x") + QString::number(eventN->offset, 16).toUpper()); - ui->npc_num->setValue(eventN->npcID); - ui->npc_sprite->setValue(eventN->imageID); - ui->npc_pos_x->setValue(eventN->positionX); - ui->npc_pos_y->setValue(eventN->positionY); - ui->spnNPCHeight->setValue(eventN->level); - ui->npc_replacement->setValue(eventN->replacement); - ui->spnNPCIdleAnim->setValue(eventN->behaviour); - ui->npc_mov_x->setValue(eventN->moveRadiusX); - ui->npc_mov_y->setValue(eventN->moveRadiusY); - ui->npc_view_rad->setValue(eventN->viewRadius); - ui->npc_trainer->setValue(eventN->property); - ui->npc_script->setValue(eventN->ptrScript); - ui->npc_flag->setValue(eventN->flag); - ui->npc_raw_data->setData(eventN->rawData()); + ui->cmbEntityTypeSelector->setCurrentIndex(0); ui->spnEntityScroller->setValue(indexN); - - CurrentEntity entity; - entity.absPos.setX((event->pos().x()/16)*16); - entity.absPos.setY((event->pos().y()/16)*16); - entity.type = ET_Npc; - entity.entity = eventN; - entity.index = indexN; - ui->glEntityEditor->setCurrentEntity(entity); - return; } @@ -1596,28 +1558,10 @@ namespace ame } if (eventW != NULL) { - // Load warp properties + m_CurrentWarp = indexW; ui->stckEntityEditor->setCurrentWidget(ui->pageWarps); - ui->warp_group_raw->setTitle(tr("Raw Data @ 0x") + QString::number(eventW->offset, 16).toUpper()); - ui->warp_pos_x->setValue(eventW->positionX); - ui->warp_pos_y->setValue(eventW->positionY); - ui->warp_number->setValue(eventW->warp); - ui->warp_map->setValue(eventW->map); - ui->warp_bank->setValue(eventW->bank); - ui->spnWarpHeight->setValue(eventW->level); - ui->warp_raw_data->setData(eventW->rawData()); + ui->cmbEntityTypeSelector->setCurrentIndex(1); ui->spnEntityScroller->setValue(indexW); - - checkWarp(); - - CurrentEntity entity; - entity.absPos.setX((event->pos().x()/16)*16); - entity.absPos.setY((event->pos().y()/16)*16); - entity.type = ET_Warp; - entity.entity = eventW; - entity.index = indexW; - ui->glEntityEditor->setCurrentEntity(entity); - return; } @@ -1634,26 +1578,10 @@ namespace ame } if (eventT != NULL) { - // Load trigger properties + m_CurrentTrigger = indexT; ui->stckEntityEditor->setCurrentWidget(ui->pageTriggers); - ui->trigger_group_raw->setTitle(tr("Raw Data @ 0x") + QString::number(eventT->offset, 16).toUpper()); - ui->trigger_pos_x->setValue(eventT->positionX); - ui->trigger_pos_y->setValue(eventT->positionY); - ui->trigger_var->setValue(eventT->variable); - ui->trigger_value->setValue(eventT->value); - ui->trigger_script->setValue(eventT->ptrScript); - ui->spnTriggerHeight->setValue(eventT->level); - ui->trigger_raw_data->setData(eventT->rawData()); + ui->cmbEntityTypeSelector->setCurrentIndex(2); ui->spnEntityScroller->setValue(indexT); - - CurrentEntity entity; - entity.absPos.setX((event->pos().x()/16)*16); - entity.absPos.setY((event->pos().y()/16)*16); - entity.type = ET_Trigger; - entity.entity = eventT; - entity.index = indexT; - ui->glEntityEditor->setCurrentEntity(entity); - return; } @@ -1670,27 +1598,10 @@ namespace ame } if (eventS != NULL) { - // Load sign properties + m_CurrentSign = indexS; ui->stckEntityEditor->setCurrentWidget(ui->pageSigns); - ui->sign_group_raw->setTitle(tr("Raw Data @ 0x") + QString::number(eventS->offset, 16).toUpper()); - ui->sign_pos_x->setValue(eventS->positionX); - ui->sign_pos_y->setValue(eventS->positionY); - ui->sign_script->setValue(eventS->ptrScript); - ui->sign_raw_data->setData(eventS->rawData()); - ui->spnSignHeight->setValue(eventS->level); - ui->spnSignType->setValue(static_cast(eventS->type)); + ui->cmbEntityTypeSelector->setCurrentIndex(3); ui->spnEntityScroller->setValue(indexS); - - CurrentEntity entity; - entity.absPos.setX((event->pos().x()/16)*16); - entity.absPos.setY((event->pos().y()/16)*16); - entity.type = ET_Sign; - entity.entity = eventS; - entity.index = indexS; - ui->glEntityEditor->setCurrentEntity(entity); - - showCorrectSignType(eventS); - return; } } @@ -1745,8 +1656,7 @@ namespace ame } if (eventW != NULL) { - m_CurrentWarp = ui->warp_number->value(); - loadMapChangeTreeView(ui->warp_bank->value(), ui->warp_map->value()); + on_btnWarpToDest_clicked(); return; } @@ -1822,6 +1732,74 @@ namespace ame } } + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 4/2/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_header_mapname_valueChanged(int value) + { + ui->cmbHeaderMapName->setCurrentIndex(value - (CONFIG(MapNameTotal) - CONFIG(MapNameCount))); + // prevent crash for fr/bg caused by non-zero minimum value + if (ui->tabWidget->isEnabled()) + m_CurrentMap->m_NameIndex = value; + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 4/2/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_cmbHeaderMapName_currentIndexChanged(int index) + { + ui->header_mapname->setValue(index + CONFIG(MapNameTotal) - CONFIG(MapNameCount)); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_warp_pos_x_valueChanged(int value) + { + m_CurrentMap->entities().warps()[m_CurrentWarp]->positionX = value; + ui->glEntityEditor->setCurrentEntityPosX(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_warp_pos_y_valueChanged(int value) + { + m_CurrentMap->entities().warps()[m_CurrentWarp]->positionY = value; + ui->glEntityEditor->setCurrentEntityPosY(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/15/2017 + // + /////////////////////////////////////////////////////////// + + void MainWindow::on_spnWarpHeight_valueChanged(int value) + { + m_CurrentMap->entities().warps()[m_CurrentWarp]->level = value; + } + /////////////////////////////////////////////////////////// // Function type: Slot // Contributors: Nekaida @@ -1831,6 +1809,7 @@ namespace ame /////////////////////////////////////////////////////////// void MainWindow::on_warp_number_valueChanged(int value) { + m_CurrentMap->entities().warps()[m_CurrentWarp]->warp = value; checkWarp(); } @@ -1843,6 +1822,7 @@ namespace ame /////////////////////////////////////////////////////////// void MainWindow::on_warp_map_valueChanged(int value) { + m_CurrentMap->entities().warps()[m_CurrentWarp]->map = value; checkWarp(); } @@ -1855,6 +1835,7 @@ namespace ame /////////////////////////////////////////////////////////// void MainWindow::on_warp_bank_valueChanged(int value) { + m_CurrentMap->entities().warps()[m_CurrentWarp]->bank = value; checkWarp(); } @@ -1878,6 +1859,75 @@ namespace ame ui->btnWarpToDest->setEnabled(false); } + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_trigger_pos_x_valueChanged(int value) + { + m_CurrentMap->entities().triggers()[m_CurrentTrigger]->positionX = value; + ui->glEntityEditor->setCurrentEntityPosX(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_trigger_pos_y_valueChanged(int value) + { + m_CurrentMap->entities().triggers()[m_CurrentTrigger]->positionY = value; + ui->glEntityEditor->setCurrentEntityPosY(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_sign_pos_x_valueChanged(int value) + { + m_CurrentMap->entities().signs()[m_CurrentSign]->positionX = value; + ui->glEntityEditor->setCurrentEntityPosX(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_sign_pos_y_valueChanged(int value) + { + m_CurrentMap->entities().signs()[m_CurrentSign]->positionY = value; + ui->glEntityEditor->setCurrentEntityPosY(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/15/2017 + // + /////////////////////////////////////////////////////////// + + void MainWindow::on_spnSignHeight_valueChanged(int value) + { + m_CurrentMap->entities().signs()[m_CurrentSign]->level = value; + } + /////////////////////////////////////////////////////////// // Function type: Event // Contributors: Pokedude, Diegoisawesome @@ -2069,8 +2119,148 @@ namespace ame /////////////////////////////////////////////////////////// void MainWindow::on_btnWarpToDest_clicked() { - m_CurrentWarp = ui->warp_number->value(); + int warpTo = ui->warp_number->value(); loadMapChangeTreeView(ui->warp_bank->value(), ui->warp_map->value()); + ui->spnEntityScroller->setValue(warpTo); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_sprite_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->imageID = value; + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_pos_x_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->positionX = value; + ui->glEntityEditor->setCurrentEntityPosX(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_pos_y_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->positionY = value; + ui->glEntityEditor->setCurrentEntityPosY(value * 16); + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_spnNPCHeight_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->level = value; + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_spnNPCIdleAnim_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->behaviour = value; + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_mov_x_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->moveRadiusX = value; + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_mov_y_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->moveRadiusY = value; + ui->glEntityEditor->update(); + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_trainer_toggled(bool checked) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->isTrainer = checked; + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_view_rad_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->viewRadius = value; + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_script_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->ptrScript = value; + } + + /////////////////////////////////////////////////////////// + // Function type: Slot + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void MainWindow::on_npc_flag_valueChanged(int value) + { + m_CurrentMap->entities().npcs()[m_CurrentNPC]->flag = value; } /////////////////////////////////////////////////////////// diff --git a/src/Widgets/Rendering/AMEEntityView.cpp b/src/Widgets/Rendering/AMEEntityView.cpp index 8e3e648..fdc6a18 100644 --- a/src/Widgets/Rendering/AMEEntityView.cpp +++ b/src/Widgets/Rendering/AMEEntityView.cpp @@ -226,8 +226,8 @@ namespace ame // Draws the selection square if (m_Selection.entity) { - Int32 pX = m_Selection.absPos.x(); - Int32 pY = m_Selection.absPos.y(); + Int32 pX = mpos.x() + m_Selection.position.x(); + Int32 pY = mpos.y() + m_Selection.position.y(); painter.setPen(QColor(255, 0, 0)); painter.drawRect(pX, pY, 15, 15); } @@ -288,15 +288,27 @@ namespace ame } /////////////////////////////////////////////////////////// - // Function type: Getter - // Contributors: Pokedude - // Last edit by: Pokedude - // Date of edit: 1/7/2016 + // Function type: Setter + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 + // + /////////////////////////////////////////////////////////// + void AMEEntityView::setCurrentEntityPosX(int x) + { + m_Selection.position.setX(x); + } + + /////////////////////////////////////////////////////////// + // Function type: Setter + // Contributors: Nekaida + // Last edit by: Nekaida + // Date of edit: 5/11/2017 // /////////////////////////////////////////////////////////// - const CurrentEntity &AMEEntityView::currentEntity() const + void AMEEntityView::setCurrentEntityPosY(int y) { - return m_Selection; + m_Selection.position.setY(y); } ///////////////////////////////////////////////////////////