Ejemplo n.º 1
0
        private void DrawPhonePage(int startX, int unit, int width)
        {
            // background
            _batch.Draw(_phoneBackground, new Rectangle(
                            startX, 0,
                            (int)(_phoneBackground.Width * Border.SCALE),
                            (int)(_phoneBackground.Height * Border.SCALE)), Color.White);

            // reception
            // TODO: get reception from map file
            var hasReception = true;

            _batch.Draw(_reception, new Rectangle(
                            startX + width - unit * 3, unit,
                            (int)(16 * Border.SCALE),
                            (int)(16 * Border.SCALE)),
                        new Rectangle(hasReception ? 0 : 16, 0, 16, 16), Color.White);

            // contacts
            var visibleContacts = new Contact[CONTACTS_VISIBLE];
            var contacts        = Controller.ActivePlayer.Contacts;

            for (var i = 0; i < visibleContacts.Length; i++)
            {
                var index = i + _phoneScroll;
                if (contacts.Length > index)
                {
                    visibleContacts[i] = _phonebook.GetContact(contacts[index]);
                }
                else
                {
                    visibleContacts[i] = _emptyContact;
                }
            }
            var contactsText = string.Join(Environment.NewLine, visibleContacts.Select((c, i) =>
            {
                var selector = ">";
                if (_phoneOptionsBox.Visible || _deleteNumberOptionsBox.Visible)
                {
                    selector = "^>>";
                }
                return
                ((_phoneIndex == i ? selector : " ") +
                 c.name + ":" + Environment.NewLine +
                 "    " + c.title);
            }));

            _contactsFontRenderer.DrawText(_batch, contactsText,
                                           new Vector2(startX + unit, unit * 4),
                                           Color.Black, Border.SCALE);

            _phoneOptionsBox.Draw(_batch, TINTED_WHITE);
            _deleteNumberOptionsBox.Draw(_batch, TINTED_WHITE);
            _phoneTextbox.Draw(_batch, TINTED_WHITE);
        }