Merge pull request #12771 from deReeperJosh/moreinfinityslots

IOS/USB Add 2 more Spaces for Disney Infinity figures
This commit is contained in:
Admiral H. Curtiss
2024-06-22 20:03:26 +02:00
committed by GitHub
7 changed files with 74 additions and 40 deletions

View File

@ -628,6 +628,11 @@ InfinityBase::LoadFigure(const std::array<u8, INFINITY_NUM_BLOCKS * INFINITY_BLO
order_added = figure.order_added;
position = DeriveFigurePosition(position);
if (position == 0)
{
ERROR_LOG_FMT(IOS_USB, "Invalid Position for Infinity Figure");
return "Unknown Figure";
}
std::array<u8, 32> figure_change_response = {0xab, 0x04, position, 0x09, order_added, 0x00};
figure_change_response[6] = GenerateChecksum(figure_change_response, 6);
@ -649,9 +654,14 @@ void InfinityBase::RemoveFigure(u8 position)
if (figure.present)
{
figure.present = false;
position = DeriveFigurePosition(position);
if (position == 0)
{
ERROR_LOG_FMT(IOS_USB, "Invalid Position for Infinity Figure");
return;
}
figure.present = false;
std::array<u8, 32> figure_change_response = {0xab, 0x04, position, 0x09, figure.order_added,
0x01};
@ -744,14 +754,28 @@ std::string InfinityBase::FindFigure(u32 number) const
u8 InfinityBase::DeriveFigurePosition(u8 position)
{
// In the added/removed response, position needs to be 1 for the hexagon, 2 for Player 1 and
// Player 1's abilities, and 3 for Player 2 and Player 2's abilities. Abilities are in positions
// > 2 in the UI (3/5 for player 1, 4/6 for player 2) so decrement the position until < 2.
// Player 1's abilities, and 3 for Player 2 and Player 2's abilities. In the UI, positions 0, 1
// and 2 represent the hexagon slot, 3, 4 and 5 represent Player 1's slot and 6, 7 and 8 represent
// Player 2's slot.
while (position > 2)
position -= 2;
switch (position)
{
case 0:
case 1:
case 2:
return 1;
case 3:
case 4:
case 5:
return 2;
case 6:
case 7:
case 8:
return 3;
position++;
return position;
default:
return 0;
}
}
InfinityFigure& InfinityBase::GetFigureByOrder(u8 order_added)

View File

@ -89,7 +89,7 @@ public:
protected:
std::mutex m_infinity_mutex;
std::array<InfinityFigure, 7> m_figures;
std::array<InfinityFigure, 9> m_figures;
private:
InfinityFigure& GetFigureByOrder(u8 order_added);

View File

@ -79,17 +79,21 @@ void InfinityBaseWindow::CreateMainWindow()
AddFigureSlot(vbox_group, tr("Play Set/Power Disc"), 0);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player One"), 1);
AddFigureSlot(vbox_group, tr("Power Disc Two"), 1);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player One Ability One"), 3);
AddFigureSlot(vbox_group, tr("Power Disc Three"), 2);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player One"), 3);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player One Ability One"), 4);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player One Ability Two"), 5);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player Two"), 2);
AddFigureSlot(vbox_group, tr("Player Two"), 6);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player Two Ability One"), 4);
AddFigureSlot(vbox_group, tr("Player Two Ability One"), 7);
add_line(vbox_group);
AddFigureSlot(vbox_group, tr("Player Two Ability Two"), 6);
AddFigureSlot(vbox_group, tr("Player Two Ability Two"), 8);
m_group_figures->setLayout(vbox_group);
scroll_area->setWidget(m_group_figures);
@ -203,8 +207,9 @@ CreateFigureDialog::CreateFigureDialog(QWidget* parent, u8 slot) : QDialog(paren
// Only display entry if it is a piece appropriate for the slot
if ((slot == 0 &&
((figure > 0x1E8480 && figure < 0x2DC6BF) || (figure > 0x3D0900 && figure < 0x4C4B3F))) ||
((slot == 1 || slot == 2) && figure < 0x1E847F) ||
((slot == 3 || slot == 4 || slot == 5 || slot == 6) &&
((slot == 1 || slot == 2) && (figure > 0x3D0900 && figure < 0x4C4B3F)) ||
((slot == 3 || slot == 6) && figure < 0x1E847F) ||
((slot == 4 || slot == 5 || slot == 7 || slot == 8) &&
(figure > 0x2DC6C0 && figure < 0x3D08FF)))
{
const auto figure_name = QString::fromStdString(entry.first);

View File

@ -28,7 +28,7 @@ public:
~InfinityBaseWindow() override;
protected:
std::array<QLineEdit*, 7> m_edit_figures;
std::array<QLineEdit*, 9> m_edit_figures;
private:
void CreateMainWindow();