2020-08-25 18:53:35 -07:00
|
|
|
using Server.Network;
|
|
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
namespace Server.Menus.Questions;
|
|
|
|
|
|
|
|
|
|
public class QuestionMenu : IMenu
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
private static int m_NextSerial;
|
|
|
|
|
|
|
|
|
|
public QuestionMenu(string question, string[] answers)
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
Question = question?.Trim() ?? "";
|
|
|
|
|
Answers = answers;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
do
|
2020-08-25 18:53:35 -07:00
|
|
|
{
|
2022-10-10 21:47:08 -07:00
|
|
|
Serial = ++m_NextSerial;
|
|
|
|
|
Serial &= 0x7FFFFFFF;
|
|
|
|
|
} while (Serial == 0);
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public string Question { get; }
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public string[] Answers { get; }
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public int Serial { get; }
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public int EntryLength => Answers.Length;
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public virtual void OnCancel(NetState state)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public virtual void OnResponse(NetState state, int index)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-08-25 18:53:35 -07:00
|
|
|
|
2022-10-10 21:47:08 -07:00
|
|
|
public void SendTo(NetState state)
|
|
|
|
|
{
|
|
|
|
|
state.AddMenu(this);
|
|
|
|
|
state.SendDisplayQuestionMenu(this);
|
2020-08-25 18:53:35 -07:00
|
|
|
}
|
|
|
|
|
}
|