public static void Show(PacketAPI apiHandle, bool isIgnoreList)
		{
			if (Instance != null)
				return;

			List<string> allLines = isIgnoreList ? InteractList.LoadAllIgnore() : InteractList.LoadAllFriend();

			string charName = World.Instance.MainPlayer.ActiveCharacter.Name;
			charName = char.ToUpper(charName[0]) + charName.Substring(1);
			string titleText = string.Format("{0}'s {2} [{1}]", charName, allLines.Count,
				World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));

			ScrollingListDialog dlg = new ScrollingListDialog
			{
				Title = titleText,
				Buttons = ScrollingListDialogButtons.AddCancel,
				ListItemType = ListDialogItem.ListItemStyle.Small
			};

			List<ListDialogItem> characters = allLines.Select(character => new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small) { Text = character }).ToList();
			characters.ForEach(character =>
			{
				character.OnLeftClick += (o, e) => EOGame.Instance.Hud.SetChatText("!" + character.Text + " ");
				character.OnRightClick += (o, e) =>
				{
					dlg.RemoveFromList(character);
					dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
						World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));
				};
			});
			dlg.SetItemList(characters);

			dlg.DialogClosing += (o, e) =>
			{
				if (e.Result == XNADialogResult.Cancel)
				{
					Instance = null;
					if (isIgnoreList)
						InteractList.WriteIgnoreList(dlg.NamesList);
					else
						InteractList.WriteFriendList(dlg.NamesList);
				}
				else if (e.Result == XNADialogResult.Add)
				{
					e.CancelClose = true;
					string prompt = World.GetString(isIgnoreList ? DATCONST2.DIALOG_WHO_TO_MAKE_IGNORE : DATCONST2.DIALOG_WHO_TO_MAKE_FRIEND);
					TextInputDialog dlgInput = new TextInputDialog(prompt);
					dlgInput.DialogClosing += (_o, _e) =>
					{
						if (_e.Result == XNADialogResult.Cancel) return;

						if (dlgInput.ResponseText.Length < 4)
						{
							_e.CancelClose = true;
							EOMessageBox.Show(DATCONST1.CHARACTER_CREATE_NAME_TOO_SHORT);
							dlgInput.SetAsKeyboardSubscriber();
							return;
						}

						if (dlg.NamesList.FindIndex(name => name.ToLower() == dlgInput.ResponseText.ToLower()) >= 0)
						{
							_e.CancelClose = true;
							EOMessageBox.Show("You are already friends with that person!", "Invalid entry!", XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
							dlgInput.SetAsKeyboardSubscriber();
							return;
						}

						ListDialogItem newItem = new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
						{
							Text = dlgInput.ResponseText
						};
						newItem.OnLeftClick += (oo, ee) => EOGame.Instance.Hud.SetChatText("!" + newItem.Text + " ");
						newItem.OnRightClick += (oo, ee) =>
						{
							dlg.RemoveFromList(newItem);
							dlg.Title = string.Format("{0}'s {2} [{1}]",
								charName,
								dlg.NamesList.Count,
								World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));
						};
						dlg.AddItemToList(newItem, true);
						dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
							World.GetString(isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST));
					};
				}
			};

			Instance = dlg;

			List<OnlineEntry> onlineList;
			apiHandle.RequestOnlinePlayers(false, out onlineList);
			Instance.SetActiveItemList(onlineList.Select(_oe => _oe.Name).ToList());

			EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, isIgnoreList ? DATCONST2.STATUS_LABEL_IGNORE_LIST : DATCONST2.STATUS_LABEL_FRIEND_LIST,
				World.GetString(DATCONST2.STATUS_LABEL_USE_RIGHT_MOUSE_CLICK_DELETE));
			//show the dialog
		}
示例#2
0
        private void _setState(SkillState newState)
        {
            SkillState old = m_state;

            if (old == newState)
            {
                return;
            }

            int numToLearn  = m_skills.Count(_skill => !OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Exists(_spell => _spell.ID == _skill.ID));
            int numToForget = OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Count;

            if (newState == SkillState.Learn && numToLearn == 0)
            {
                EOMessageBox.Show(DialogResourceID.SKILL_NOTHING_MORE_TO_LEARN, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                return;
            }

            ClearItemList();
            switch (newState)
            {
            case SkillState.Initial:
            {
                string learnNum  = $"{numToLearn}{OldWorld.GetString(EOResourceID.SKILLMASTER_ITEMS_TO_LEARN)}";
                string forgetNum = $"{numToForget}{OldWorld.GetString(EOResourceID.SKILLMASTER_ITEMS_LEARNED)}";

                ListDialogItem learn = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
                {
                    Text               = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_LEARN),
                    SubText            = learnNum,
                    IconGraphic        = LearnIcon,
                    ShowItemBackGround = false,
                    OffsetY            = 45
                };
                learn.OnLeftClick  += (o, e) => _setState(SkillState.Learn);
                learn.OnRightClick += (o, e) => _setState(SkillState.Learn);
                AddItemToList(learn, false);

                ListDialogItem forget = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
                {
                    Text               = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_FORGET),
                    SubText            = forgetNum,
                    IconGraphic        = ForgetIcon,
                    ShowItemBackGround = false,
                    OffsetY            = 45
                };
                forget.OnLeftClick  += (o, e) => _setState(SkillState.Forget);
                forget.OnRightClick += (o, e) => _setState(SkillState.Forget);
                AddItemToList(forget, false);

                ListDialogItem forgetAll = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
                {
                    Text               = OldWorld.GetString(EOResourceID.SKILLMASTER_FORGET_ALL),
                    SubText            = OldWorld.GetString(EOResourceID.SKILLMASTER_RESET_YOUR_CHARACTER),
                    IconGraphic        = ForgetIcon,
                    ShowItemBackGround = false,
                    OffsetY            = 45
                };
                forgetAll.OnLeftClick  += (o, e) => _setState(SkillState.ForgetAll);
                forgetAll.OnRightClick += (o, e) => _setState(SkillState.ForgetAll);
                AddItemToList(forgetAll, false);

                _setButtons(ScrollingListDialogButtons.Cancel);
            }
            break;

            case SkillState.Learn:
            {
                int index = 0;
                for (int i = 0; i < m_skills.Count; ++i)
                {
                    if (OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.FindIndex(_sp => m_skills[i].ID == _sp.ID) >= 0)
                    {
                        continue;
                    }
                    int localI = i;

                    var spellData = OldWorld.Instance.ESF.Data[m_skills[localI].ID];

                    ListDialogItem nextListItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, index++)
                    {
                        Visible            = false,
                        Text               = spellData.Name,
                        SubText            = OldWorld.GetString(EOResourceID.SKILLMASTER_WORD_REQUIREMENTS),
                        IconGraphic        = OldWorld.GetSpellIcon(spellData.Icon, false),
                        ShowItemBackGround = false,
                        OffsetY            = 45,
                        ID = m_skills[localI].ID
                    };
                    nextListItem.OnLeftClick  += (o, e) => _learn(m_skills[localI]);
                    nextListItem.OnRightClick += (o, e) => _learn(m_skills[localI]);
                    nextListItem.OnMouseEnter += (o, e) => _showRequirementsLabel(m_skills[localI]);
                    nextListItem.SetSubtextLink(() => _showRequirements(m_skills[localI]));
                    AddItemToList(nextListItem, false);
                }

                _setButtons(ScrollingListDialogButtons.BackCancel);
            }
            break;

            case SkillState.Forget:
            {
                TextInputDialog input = new TextInputDialog(OldWorld.GetString(DialogResourceID.SKILL_PROMPT_TO_FORGET, false), 32);
                input.SetAsKeyboardSubscriber();
                input.DialogClosing += (sender, args) =>
                {
                    if (args.Result == XNADialogResult.Cancel)
                    {
                        return;
                    }
                    bool found =
                        OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Any(
                            _spell => OldWorld.Instance.ESF.Data[_spell.ID].Name.ToLower() == input.ResponseText.ToLower());

                    if (!found)
                    {
                        args.CancelClose = true;
                        EOMessageBox.Show(DialogResourceID.SKILL_FORGET_ERROR_NOT_LEARNED, EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                        input.SetAsKeyboardSubscriber();
                    }

                    if (!m_api.ForgetSpell(
                            OldWorld.Instance.MainPlayer.ActiveCharacter.Spells.Find(
                                _spell => OldWorld.Instance.ESF.Data[_spell.ID].Name.ToLower() == input.ResponseText.ToLower()).ID))
                    {
                        Close();
                        ((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
                    }
                };

                //should show initial info in the actual dialog since this uses a pop-up input box
                //    to select a skill to remove
                newState = SkillState.Initial;
                goto case SkillState.Initial;
            }

            case SkillState.ForgetAll:
            {
                _showForgetAllMessage(_forgetAllAction);
                _setButtons(ScrollingListDialogButtons.BackCancel);
            }
            break;
            }

            m_state = newState;
        }
		private void _setState(SkillState newState)
		{
			SkillState old = m_state;

			if (old == newState) return;

			int numToLearn = m_skills.Count(_skill => !World.Instance.MainPlayer.ActiveCharacter.Spells.Exists(_spell => _spell.id == _skill.ID));
			int numToForget = World.Instance.MainPlayer.ActiveCharacter.Spells.Count;

			if (newState == SkillState.Learn && numToLearn == 0)
			{
				EOMessageBox.Show(DATCONST1.SKILL_NOTHING_MORE_TO_LEARN, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
				return;
			}

			ClearItemList();
			switch (newState)
			{
				case SkillState.Initial:
				{
					string learnNum = string.Format("{0}{1}", numToLearn, World.GetString(DATCONST2.SKILLMASTER_ITEMS_TO_LEARN));
					string forgetNum = string.Format("{0}{1}", numToForget, World.GetString(DATCONST2.SKILLMASTER_ITEMS_LEARNED));

					ListDialogItem learn = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
					{
						Text = World.GetString(DATCONST2.SKILLMASTER_WORD_LEARN),
						SubText = learnNum,
						IconGraphic = LearnIcon,
						ShowItemBackGround = false,
						OffsetY = 45
					};
					learn.OnLeftClick += (o, e) => _setState(SkillState.Learn);
					learn.OnRightClick += (o, e) => _setState(SkillState.Learn);
					AddItemToList(learn, false);

					ListDialogItem forget = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
					{
						Text = World.GetString(DATCONST2.SKILLMASTER_WORD_FORGET),
						SubText = forgetNum,
						IconGraphic = ForgetIcon,
						ShowItemBackGround = false,
						OffsetY = 45
					};
					forget.OnLeftClick += (o, e) => _setState(SkillState.Forget);
					forget.OnRightClick += (o, e) => _setState(SkillState.Forget);
					AddItemToList(forget, false);

					ListDialogItem forgetAll = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
					{
						Text = World.GetString(DATCONST2.SKILLMASTER_FORGET_ALL),
						SubText = World.GetString(DATCONST2.SKILLMASTER_RESET_YOUR_CHARACTER),
						IconGraphic = ForgetIcon,
						ShowItemBackGround = false,
						OffsetY = 45
					};
					forgetAll.OnLeftClick += (o, e) => _setState(SkillState.ForgetAll);
					forgetAll.OnRightClick += (o, e) => _setState(SkillState.ForgetAll);
					AddItemToList(forgetAll, false);

					_setButtons(ScrollingListDialogButtons.Cancel);
				}
					break;
				case SkillState.Learn:
				{
					int index = 0;
					for (int i = 0; i < m_skills.Count; ++i)
					{
						if (World.Instance.MainPlayer.ActiveCharacter.Spells.FindIndex(_sp => m_skills[i].ID == _sp.id) >= 0)
							continue;
						int localI = i;

						SpellRecord spellData = (SpellRecord) World.Instance.ESF.Data[m_skills[localI].ID];

						ListDialogItem nextListItem = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, index++)
						{
							Visible = false,
							Text = spellData.Name,
							SubText = World.GetString(DATCONST2.SKILLMASTER_WORD_REQUIREMENTS),
							IconGraphic = World.GetSpellIcon(spellData.Icon, false),
							ShowItemBackGround = false,
							OffsetY = 45,
							ID = m_skills[localI].ID
						};
						nextListItem.OnLeftClick += (o, e) => _learn(m_skills[localI]);
						nextListItem.OnRightClick += (o, e) => _learn(m_skills[localI]);
						nextListItem.OnMouseEnter += (o, e) => _showRequirementsLabel(m_skills[localI]);
						nextListItem.SetSubtextLink(() => _showRequirements(m_skills[localI]));
						AddItemToList(nextListItem, false);
					}

					_setButtons(ScrollingListDialogButtons.BackCancel);
				}
					break;
				case SkillState.Forget:
				{
					TextInputDialog input = new TextInputDialog(World.GetString(DATCONST1.SKILL_PROMPT_TO_FORGET, false), 32);
					input.SetAsKeyboardSubscriber();
					input.DialogClosing += (sender, args) =>
					{
						if (args.Result == XNADialogResult.Cancel) return;
						bool found =
							World.Instance.MainPlayer.ActiveCharacter.Spells.Any(
								_spell => ((SpellRecord) World.Instance.ESF.Data[_spell.id]).Name.ToLower() == input.ResponseText.ToLower());

						if (!found)
						{
							args.CancelClose = true;
							EOMessageBox.Show(DATCONST1.SKILL_FORGET_ERROR_NOT_LEARNED, XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
							input.SetAsKeyboardSubscriber();
						}

						if (!m_api.ForgetSpell(
								World.Instance.MainPlayer.ActiveCharacter.Spells.Find(
									_spell => ((SpellRecord) World.Instance.ESF.Data[_spell.id]).Name.ToLower() == input.ResponseText.ToLower()).id))
						{
							Close();
							((EOGame)Game).DoShowLostConnectionDialogAndReturnToMainMenu();
						}
					};

					//should show initial info in the actual dialog since this uses a pop-up input box
					//	to select a skill to remove
					newState = SkillState.Initial;
					goto case SkillState.Initial;
				}
				case SkillState.ForgetAll:
				{
					_showForgetAllMessage(_forgetAllAction);
					_setButtons(ScrollingListDialogButtons.BackCancel);
				}
					break;
			}

			m_state = newState;
		}
示例#4
0
        public static void Show(PacketAPI apiHandle, bool isIgnoreList)
        {
            if (Instance != null)
            {
                return;
            }

            List <string> allLines = isIgnoreList ? InteractList.LoadAllIgnore() : InteractList.LoadAllFriend();

            string charName = OldWorld.Instance.MainPlayer.ActiveCharacter.Name;

            charName = char.ToUpper(charName[0]) + charName.Substring(1);
            string titleText = string.Format("{0}'s {2} [{1}]", charName, allLines.Count,
                                             OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));

            ScrollingListDialog dlg = new ScrollingListDialog
            {
                Title        = titleText,
                Buttons      = ScrollingListDialogButtons.AddCancel,
                ListItemType = ListDialogItem.ListItemStyle.Small
            };

            List <ListDialogItem> characters = allLines.Select(character => new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
            {
                Text = character
            }).ToList();

            characters.ForEach(character =>
            {
                character.OnLeftClick  += (o, e) => EOGame.Instance.Hud.SetChatText("!" + character.Text + " ");
                character.OnRightClick += (o, e) =>
                {
                    dlg.RemoveFromList(character);
                    dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
                                              OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                };
            });
            dlg.SetItemList(characters);

            dlg.DialogClosing += (o, e) =>
            {
                if (e.Result == XNADialogResult.Cancel)
                {
                    Instance = null;
                    if (isIgnoreList)
                    {
                        InteractList.WriteIgnoreList(dlg.NamesList);
                    }
                    else
                    {
                        InteractList.WriteFriendList(dlg.NamesList);
                    }
                }
                else if (e.Result == XNADialogResult.Add)
                {
                    e.CancelClose = true;
                    string          prompt   = OldWorld.GetString(isIgnoreList ? EOResourceID.DIALOG_WHO_TO_MAKE_IGNORE : EOResourceID.DIALOG_WHO_TO_MAKE_FRIEND);
                    TextInputDialog dlgInput = new TextInputDialog(prompt);
                    dlgInput.DialogClosing += (_o, _e) =>
                    {
                        if (_e.Result == XNADialogResult.Cancel)
                        {
                            return;
                        }

                        if (dlgInput.ResponseText.Length < 4)
                        {
                            _e.CancelClose = true;
                            EOMessageBox.Show(DialogResourceID.CHARACTER_CREATE_NAME_TOO_SHORT);
                            dlgInput.SetAsKeyboardSubscriber();
                            return;
                        }

                        if (dlg.NamesList.FindIndex(name => name.ToLower() == dlgInput.ResponseText.ToLower()) >= 0)
                        {
                            _e.CancelClose = true;
                            EOMessageBox.Show("You are already friends with that person!", "Invalid entry!", EODialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
                            dlgInput.SetAsKeyboardSubscriber();
                            return;
                        }

                        ListDialogItem newItem = new ListDialogItem(dlg, ListDialogItem.ListItemStyle.Small)
                        {
                            Text = dlgInput.ResponseText
                        };
                        newItem.OnLeftClick  += (oo, ee) => EOGame.Instance.Hud.SetChatText("!" + newItem.Text + " ");
                        newItem.OnRightClick += (oo, ee) =>
                        {
                            dlg.RemoveFromList(newItem);
                            dlg.Title = string.Format("{0}'s {2} [{1}]",
                                                      charName,
                                                      dlg.NamesList.Count,
                                                      OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                        };
                        dlg.AddItemToList(newItem, true);
                        dlg.Title = string.Format("{0}'s {2} [{1}]", charName, dlg.NamesList.Count,
                                                  OldWorld.GetString(isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST));
                    };
                }
            };

            Instance = dlg;

            List <OnlineEntry> onlineList;

            apiHandle.RequestOnlinePlayers(false, out onlineList);
            Instance.SetActiveItemList(onlineList.Select(_oe => _oe.Name).ToList());

            EOGame.Instance.Hud.SetStatusLabel(EOResourceID.STATUS_LABEL_TYPE_ACTION, isIgnoreList ? EOResourceID.STATUS_LABEL_IGNORE_LIST : EOResourceID.STATUS_LABEL_FRIEND_LIST,
                                               OldWorld.GetString(EOResourceID.STATUS_LABEL_USE_RIGHT_MOUSE_CLICK_DELETE));
            //show the dialog
        }