2022-03-07 10:55:49 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace TJAPlayer3
|
|
|
|
|
{
|
|
|
|
|
internal class ModalQueue
|
|
|
|
|
{
|
|
|
|
|
public ModalQueue(Modal.EModalFormat mf)
|
|
|
|
|
{
|
2023-02-15 01:27:05 +01:00
|
|
|
|
_modalQueues = new Queue<Modal>[] { new Queue<Modal>(), new Queue<Modal>(), new Queue<Modal>(), new Queue<Modal>(), new Queue<Modal>() };
|
2022-03-07 10:55:49 +01:00
|
|
|
|
_modalFormat = mf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add two modals (one per player) at the same time
|
2023-02-15 01:27:05 +01:00
|
|
|
|
public void tAddModal(Modal mp1, Modal mp2, Modal mp3, Modal mp4, Modal mp5)
|
2022-03-07 10:55:49 +01:00
|
|
|
|
{
|
|
|
|
|
mp1.modalFormat = _modalFormat;
|
|
|
|
|
mp2.modalFormat = _modalFormat;
|
2023-02-15 01:27:05 +01:00
|
|
|
|
mp3.modalFormat = _modalFormat;
|
|
|
|
|
mp4.modalFormat = _modalFormat;
|
|
|
|
|
mp5.modalFormat = _modalFormat;
|
2022-03-07 10:55:49 +01:00
|
|
|
|
mp1.player = 0;
|
|
|
|
|
mp2.player = 1;
|
2023-02-15 01:27:05 +01:00
|
|
|
|
mp3.player = 2;
|
|
|
|
|
mp4.player = 3;
|
|
|
|
|
mp5.player = 4;
|
2022-03-07 10:55:49 +01:00
|
|
|
|
mp1.tSetupModal();
|
|
|
|
|
mp2.tSetupModal();
|
2023-02-15 01:27:05 +01:00
|
|
|
|
mp3.tSetupModal();
|
|
|
|
|
mp4.tSetupModal();
|
|
|
|
|
mp5.tSetupModal();
|
2022-03-07 10:55:49 +01:00
|
|
|
|
|
|
|
|
|
if (mp1 != null)
|
|
|
|
|
_modalQueues[0].Enqueue(mp1);
|
|
|
|
|
if (mp2 != null)
|
|
|
|
|
_modalQueues[1].Enqueue(mp2);
|
2023-02-15 01:27:05 +01:00
|
|
|
|
if (mp3 != null)
|
|
|
|
|
_modalQueues[2].Enqueue(mp3);
|
|
|
|
|
if (mp4 != null)
|
|
|
|
|
_modalQueues[3].Enqueue(mp4);
|
|
|
|
|
if (mp5 != null)
|
|
|
|
|
_modalQueues[4].Enqueue(mp5);
|
2022-03-07 10:55:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Add a single modal
|
|
|
|
|
public void tAddModal(Modal mp, int player)
|
|
|
|
|
{
|
|
|
|
|
mp.modalFormat = _modalFormat;
|
|
|
|
|
mp.player = player;
|
|
|
|
|
mp.tSetupModal();
|
|
|
|
|
|
|
|
|
|
if (mp != null && player >= 0 && player < TJAPlayer3.ConfigIni.nPlayerCount)
|
|
|
|
|
_modalQueues[player].Enqueue(mp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Modal tPopModal(int player)
|
|
|
|
|
{
|
|
|
|
|
if (!tIsQueueEmpty(player))
|
|
|
|
|
return _modalQueues[player].Dequeue();
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool tIsQueueEmpty(int player)
|
|
|
|
|
{
|
|
|
|
|
if (player < 0 || player >= TJAPlayer3.ConfigIni.nPlayerCount)
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return _modalQueues[player].Count < 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool tAreBothQueuesEmpty()
|
|
|
|
|
{
|
2023-02-15 01:27:05 +01:00
|
|
|
|
return tIsQueueEmpty(0) && tIsQueueEmpty(1) && tIsQueueEmpty(2) && tIsQueueEmpty(3) && tIsQueueEmpty(4);
|
2022-03-07 10:55:49 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Modal.EModalFormat _modalFormat;
|
|
|
|
|
private Queue<Modal>[] _modalQueues;
|
|
|
|
|
}
|
|
|
|
|
}
|