예제 #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_From.AccessLevel < AccessLevel.Administrator)
            {
                return;
            }

            if (m_Response == null)
            {
                int index = info.ButtonID - 1;

                if (index == 0)
                {
                    PredefinedResponse resp = new PredefinedResponse("", "");

                    ArrayList list = PredefinedResponse.List;
                    list.Add(resp);

                    m_From.SendGump(new PredefGump(m_From, resp));
                }
                else
                {
                    --index;

                    int type = index % 3;
                    index /= 3;

                    ArrayList list = PredefinedResponse.List;

                    if (index >= 0 && index < list.Count)
                    {
                        PredefinedResponse resp = (PredefinedResponse)list[index];

                        switch (type)
                        {
                        case 0:     // edit
                        {
                            m_From.SendGump(new PredefGump(m_From, resp));
                            break;
                        }

                        case 1:     // move up
                        {
                            if (index > 0)
                            {
                                list.RemoveAt(index);
                                list.Insert(index - 1, resp);

                                PredefinedResponse.Save();
                                m_From.SendGump(new PredefGump(m_From, null));
                            }

                            break;
                        }

                        case 2:     // move down
                        {
                            if (index < (list.Count - 1))
                            {
                                list.RemoveAt(index);
                                list.Insert(index + 1, resp);

                                PredefinedResponse.Save();
                                m_From.SendGump(new PredefGump(m_From, null));
                            }

                            break;
                        }
                        }
                    }
                }
            }
            else
            {
                ArrayList list = PredefinedResponse.List;

                switch (info.ButtonID)
                {
                case 1:
                {
                    list.Remove(m_Response);

                    PredefinedResponse.Save();
                    m_From.SendGump(new PredefGump(m_From, null));
                    break;
                }

                case 2:
                {
                    TextRelay te = info.GetTextEntry(0);

                    if (te != null)
                    {
                        m_Response.Title = te.Text;
                    }

                    PredefinedResponse.Save();
                    m_From.SendGump(new PredefGump(m_From, m_Response));

                    break;
                }

                case 3:
                {
                    TextRelay te = info.GetTextEntry(1);

                    if (te != null)
                    {
                        m_Response.Message = te.Text;
                    }

                    PredefinedResponse.Save();
                    m_From.SendGump(new PredefGump(m_From, m_Response));

                    break;
                }
                }
            }
        }