sys_usbd: Allow 'Moving' figure to same slot on Dimensions Toypad (#15850)

This commit is contained in:
Joshua de Reeper 2024-07-29 16:50:20 +01:00 committed by GitHub
parent 02aac2c52e
commit 12fbff22b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 16 deletions

View file

@ -403,7 +403,20 @@ bool dimensions_toypad::remove_figure(u8 pad, u8 index, bool save)
bool dimensions_toypad::move_figure(u8 pad, u8 index, u8 old_pad, u8 old_index) bool dimensions_toypad::move_figure(u8 pad, u8 index, u8 old_pad, u8 old_index)
{ {
// When moving figures between spaces on the portal, remove any figure from the space they are moving to, if (old_index == index)
{
// Don't bother removing and loading again, just send response to the game
const dimensions_figure& figure = get_figure_by_index(old_index);
std::array<u8, 32> figure_remove_response = {0x56, 0x0b, pad, 0x00, figure.index, 0x01};
figure_remove_response[13] = generate_checksum(figure_remove_response, 13);
std::array<u8, 32> figure_add_response = {0x56, 0x0b, pad, 0x00, figure.index, 0x00};
figure_add_response[13] = generate_checksum(figure_add_response, 13);
m_figure_added_removed_responses.push(std::move(figure_remove_response));
m_figure_added_removed_responses.push(std::move(figure_add_response));
return true;
}
// When moving figures between spaces on the toypad, remove any figure from the space they are moving to,
// then remove them from their current space, then load them to the space they are moving to // then remove them from their current space, then load them to the space they are moving to
remove_figure(pad, index, true); remove_figure(pad, index, true);

View file

@ -543,9 +543,11 @@ void minifig_move_dialog::add_minifig_position(QGridLayout* grid_panel, u8 index
{ {
vbox_panel->addWidget(new QLabel(tr("None"))); vbox_panel->addWidget(new QLabel(tr("None")));
} }
if (old_index != index)
{
auto* btn_move = new QPushButton(tr("Move Here"), this); auto* btn_move = new QPushButton(tr("Move Here"), this);
if (old_index == index)
{
btn_move->setText(tr("Pick up and Place"));
}
vbox_panel->addWidget(btn_move); vbox_panel->addWidget(btn_move);
connect(btn_move, &QAbstractButton::clicked, this, [this, index] connect(btn_move, &QAbstractButton::clicked, this, [this, index]
{ {
@ -555,7 +557,6 @@ void minifig_move_dialog::add_minifig_position(QGridLayout* grid_panel, u8 index
3; 3;
accept(); accept();
}); });
}
grid_panel->addLayout(vbox_panel, row, column); grid_panel->addLayout(vbox_panel, row, column);
} }
@ -726,12 +727,15 @@ void dimensions_dialog::move_figure(u8 pad, u8 index)
if (move_dlg.exec() == Accepted) if (move_dlg.exec() == Accepted)
{ {
g_dimensionstoypad.move_figure(move_dlg.get_new_pad(), move_dlg.get_new_index(), pad, index); g_dimensionstoypad.move_figure(move_dlg.get_new_pad(), move_dlg.get_new_index(), pad, index);
if (index != move_dlg.get_new_index())
{
figure_slots[move_dlg.get_new_index()] = figure_slots[index]; figure_slots[move_dlg.get_new_index()] = figure_slots[index];
m_edit_figures[move_dlg.get_new_index()]->setText(m_edit_figures[index]->text()); m_edit_figures[move_dlg.get_new_index()]->setText(m_edit_figures[index]->text());
figure_slots[index] = std::nullopt; figure_slots[index] = std::nullopt;
m_edit_figures[index]->setText(tr("None")); m_edit_figures[index]->setText(tr("None"));
} }
} }
}
void dimensions_dialog::load_figure_path(u8 pad, u8 index, const QString& path) void dimensions_dialog::load_figure_path(u8 pad, u8 index, const QString& path)
{ {