public void SetNews(IList <string> lines) { if (lines.Count == 0) { return; } if (lines.Count == 1) { _doStateChange(InGameStates.Chat); } else { lines = lines.Where(_line => !string.IsNullOrWhiteSpace(_line)).ToList(); for (int i = 1; i < lines.Count; ++i) { newsTab.AddText(null, lines[i], ChatType.Note); if (i != lines.Count - 1) { newsTab.AddText(null, " "); //line breaks between entries } } newsTab.SetButtonFlash(); } chatRenderer.AddTextToTab(ChatTabs.Local, World.GetString(DATCONST2.STRING_SERVER), lines[0], ChatType.Note, ChatColor.Server); }
private void _setTextForLanguage() { m_leftSide[0].Text = World.GetString(w.SoundEnabled ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); m_leftSide[1].Text = World.GetString(w.MusicEnabled ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); m_leftSide[2].Text = World.GetString(DATCONST2.SETTING_KEYBOARD_ENGLISH); m_leftSide[3].Text = World.GetString(DATCONST2.SETTING_LANG_CURRENT); m_leftSide[4].Text = World.GetString(w.HearWhispers ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); m_rightSide[0].Text = World.GetString(w.ShowChatBubbles ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); m_rightSide[1].Text = World.GetString(w.ShowShadows ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); if (w.StrictFilterEnabled) { m_rightSide[2].Text = World.GetString(DATCONST2.SETTING_EXCLUSIVE); } else if (w.CurseFilterEnabled) { m_rightSide[2].Text = World.GetString(DATCONST2.SETTING_NORMAL); } else { m_rightSide[2].Text = World.GetString(DATCONST2.SETTING_DISABLED); } m_rightSide[3].Text = World.GetString(w.LogChatToFile ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); m_rightSide[4].Text = World.GetString(w.Interaction ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); }
public void RemoveMember(short memberID) { int memberIndex = m_members.FindIndex(_member => _member.ID == memberID); if (memberIndex < 0 || memberIndex >= m_members.Count) { return; } if (!((EOGame)Game).API.PartyRemovePlayer(m_members[memberIndex].ID)) { ((EOGame)Game).LostConnectionDialog(); } string name = m_members[memberIndex].Name; m_members.RemoveAt(memberIndex); m_buttons[memberIndex].SetParent(null); m_buttons[memberIndex].Close(); m_buttons.RemoveAt(memberIndex); m_numMembers.Text = "" + m_members.Count; m_scrollBar.UpdateDimensions(m_members.Count); if (m_members.Count <= m_scrollBar.LinesToRender) { m_scrollBar.ScrollToTop(); } ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, name, DATCONST2.STATUS_LABEL_PARTY_LEFT_YOUR); ((EOGame)Game).Hud.AddChat(ChatTabs.System, "", name + " " + World.GetString(DATCONST2.STATUS_LABEL_PARTY_LEFT_YOUR), ChatType.PlayerPartyDark, ChatColor.PM); }
private void _showFindCommandResult(bool online, bool sameMap, string charName) { if (charName.Length == 0) { return; } string lastPart; if (online && !sameMap) { lastPart = World.GetString(DATCONST2.STATUS_LABEL_IS_ONLINE_IN_THIS_WORLD); } else if (online) { lastPart = World.GetString(DATCONST2.STATUS_LABEL_IS_ONLINE_SAME_MAP); } else { lastPart = World.GetString(DATCONST2.STATUS_LABEL_IS_ONLINE_NOT_FOUND); } m_game.Hud.AddChat(ChatTabs.Local, "System", string.Format("{0} " + lastPart, char.ToUpper(charName[0]) + charName.Substring(1)), ChatType.LookingDude); }
private void _playerMuted(string adminName) { string message = World.GetString(DATCONST2.CHAT_MESSAGE_MUTED_BY) + " " + adminName; m_game.Hud.AddChat(ChatTabs.Local, World.GetString(DATCONST2.STRING_SERVER), message, ChatType.Exclamation, ChatColor.Server); m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, "" + Constants.MuteDefaultTimeMinutes, DATCONST2.STATUS_LABEL_MINUTES_MUTED); m_game.Hud.SetMuted(); }
public void SetStatusLabel(DATCONST2 type, DATCONST2 message, string extra = "") { _setStatusLabelCheckType(type); string typeText = World.GetString(type); string messageText = World.GetString(message); SetStatusLabel(string.Format("[ {0} ] {1} {2}", typeText, messageText, extra)); }
private void _junkItem(short id, int amountRemoved, int amountRemaining, byte weight, byte maxWeight) { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amountRemaining, weight, maxWeight); ItemRecord rec = World.Instance.EIF.GetItemRecordByID(id); m_game.Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_JUNK_YOU_JUNKED), amountRemoved, rec.Name), ChatType.DownArrow); m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_JUNK_YOU_JUNKED, string.Format(" {0} {1}", amountRemoved, rec.Name)); }
private void _npcKilled(int newExp) { int expDif = newExp - World.Instance.MainPlayer.ActiveCharacter.Stats.exp; World.Instance.MainPlayer.ActiveCharacter.GainExp(expDif); m_game.Hud.RefreshStats(); m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_YOU_GAINED_EXP, string.Format(" {0} EXP", expDif)); m_game.Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} EXP", World.GetString(DATCONST2.STATUS_LABEL_YOU_GAINED_EXP), expDif), ChatType.Star); }
public void AddMember(PartyMember member) { m_members.Add(member); m_numMembers.Text = string.Format("{0}", m_members.Count); m_scrollBar.UpdateDimensions(m_members.Count); _addRemoveButtonForMember(member); ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, member.Name, DATCONST2.STATUS_LABEL_PARTY_JOINED_YOUR); ((EOGame)Game).Hud.AddChat(ChatTabs.System, "", member.Name + " " + World.GetString(DATCONST2.STATUS_LABEL_PARTY_JOINED_YOUR), ChatType.PlayerParty, ChatColor.PM); }
private void _eventTrade(object arg1, EventArgs arg2) { if (World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap) { EODialog.Show(World.GetString(DATCONST2.JAIL_WARNING_CANNOT_TRADE), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else { EODialog.Show("TODO: Start trade with this player", "TODO ITEM", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } }
private void _getItemFromMap(short uid, short id, int amountTaken, byte weight, byte maxWeight) { if (uid != 0) //$si command has uid of 0 since we're creating a new item from nothing { World.Instance.ActiveMapRenderer.UpdateMapItemAmount(uid, amountTaken); } World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amountTaken, weight, maxWeight, true); ItemRecord rec = World.Instance.EIF.GetItemRecordByID(id); m_game.Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_YOU_PICKED_UP), amountTaken, rec.Name), ChatType.UpArrow); m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_PICKUP_YOU_PICKED_UP, string.Format(" {0} {1}", amountTaken, rec.Name)); }
private void _dropItem(int characterAmount, byte weight, byte maxWeight, MapItem item) { World.Instance.ActiveMapRenderer.AddMapItem(item); if (characterAmount >= 0) //will be -1 when another player drops { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(item.id, characterAmount, weight, maxWeight); ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id); m_game.Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_DROP_YOU_DROPPED), item.amount, rec.Name), ChatType.DownArrow); m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_DROP_YOU_DROPPED, string.Format(" {0} {1}", item.amount, rec.Name)); } }
public void SetData(List <PartyMember> memberList) { if (memberList.TrueForAll(_member => _member.IsFullData)) { if (m_members == null || m_members.Count == 0) { ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_PARTY_YOU_JOINED); ((EOGame)Game).Hud.AddChat(ChatTabs.System, "", World.GetString(DATCONST2.STATUS_LABEL_PARTY_YOU_JOINED), ChatType.PlayerParty, ChatColor.PM); } Visible = true; m_numMembers.Text = string.Format("{0}", memberList.Count); m_members = memberList; m_mainIsLeader = m_members.FindIndex(_member => _member.IsLeader && _member.ID == World.Instance.MainPlayer.ActiveCharacter.ID) >= 0; m_scrollBar.UpdateDimensions(memberList.Count); m_buttons.Clear(); foreach (PartyMember member in m_members) { _addRemoveButtonForMember(member); } } else { //update HP only // ReSharper disable once ForCanBeConvertedToForeach for (int i = 0; i < memberList.Count; ++i) { int ndx = m_members.FindIndex(_member => _member.ID == memberList[i].ID); PartyMember member = m_members[ndx]; member.SetPercentHealth(memberList[i].PercentHealth); m_members[ndx] = member; } } }
private void _chatByPlayerName(TalkType type, string name, string msg) { switch (type) { //invalid types case TalkType.Local: case TalkType.Party: break; case TalkType.PM: m_game.Hud.AddChat(ChatTabs.Local, name, msg, ChatType.Note, ChatColor.PM); ChatTabs tab = m_game.Hud.GetPrivateChatTab(name); m_game.Hud.AddChat(tab, name, msg, ChatType.Note); break; case TalkType.Global: m_game.Hud.AddChat(ChatTabs.Global, name, msg, ChatType.GlobalAnnounce); break; case TalkType.Guild: m_game.Hud.AddChat(ChatTabs.Group, name, msg); break; case TalkType.Server: m_game.Hud.AddChat(ChatTabs.Local, World.GetString(DATCONST2.STRING_SERVER), msg, ChatType.Exclamation, ChatColor.Server); m_game.Hud.AddChat(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), msg, ChatType.Exclamation, ChatColor.ServerGlobal); m_game.Hud.AddChat(ChatTabs.System, "", msg, ChatType.Exclamation, ChatColor.Server); break; case TalkType.Admin: m_game.Hud.AddChat(ChatTabs.Group, name, msg, ChatType.HGM, ChatColor.Admin); break; case TalkType.Announce: World.Instance.ActiveMapRenderer.MakeSpeechBubble(null, msg, false); m_game.Hud.AddChat(ChatTabs.Local, name, msg, ChatType.GlobalAnnounce, ChatColor.ServerGlobal); m_game.Hud.AddChat(ChatTabs.Global, name, msg, ChatType.GlobalAnnounce, ChatColor.ServerGlobal); m_game.Hud.AddChat(ChatTabs.Group, name, msg, ChatType.GlobalAnnounce, ChatColor.ServerGlobal); break; } }
private void _tradeOpen(short p1, string p1name, short p2, string p2name) { EOTradeDialog dlg = new EOTradeDialog(m_packetAPI); dlg.InitPlayerInfo(p1, p1name, p2, p2name); string otherName; if (p1 == World.Instance.MainPlayer.ActiveCharacter.ID) { otherName = p2name; } else if (p2 == World.Instance.MainPlayer.ActiveCharacter.ID) { otherName = p1name; } else { throw new ArgumentException("Invalid player ID for this trade session!", "p1"); } m_game.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_TRADE_YOU_ARE_TRADING_WITH, otherName + " " + World.GetString(DATCONST2.STATUS_LABEL_DRAG_AND_DROP_ITEMS)); }
private void _eventTrade(object arg1, EventArgs arg2) { if (World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap) { EODialog.Show(World.GetString(DATCONST2.JAIL_WARNING_CANNOT_TRADE), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else { if (m_lastTradeRequestedTime != null && (DateTime.Now - m_lastTradeRequestedTime.Value).TotalSeconds < Constants.TradeRequestTimeoutSeconds) { ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_TRADE_RECENTLY_REQUESTED); return; } m_lastTradeRequestedTime = DateTime.Now; if (!m_api.TradeRequest((short)m_rend.Character.ID)) { ((EOGame)Game).LostConnectionDialog(); } //todo: is this correct text? ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_TRADE_REQUESTED_TO_TRADE); } }
public HUD(Game g, PacketAPI api) : base(g) { if (!api.Initialized) { throw new ArgumentException("Need to initialize connection before the in-game stuff will work"); } m_packetAPI = api; DrawOrder = 5; mainFrame = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 1, true); topLeft = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 21, true); sidebar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 22, true); topBar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 23, true); filler = new Texture2D(g.GraphicsDevice, 1, 1); filler.SetData(new[] { Color.FromNonPremultiplied(8, 8, 8, 255) }); Texture2D mainButtonTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 25); mainBtn = new XNAButton[NUM_BTN]; //set up panels Texture2D invBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 44); pnlInventory = new XNAPanel(new Rectangle(102, 330, invBG.Width, invBG.Height)) { BackgroundImage = invBG, Visible = false }; Texture2D spellsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 62); pnlActiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height)) { BackgroundImage = spellsBG, Visible = false }; pnlPassiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height)) { BackgroundImage = spellsBG, Visible = false }; Texture2D chatBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 28); pnlChat = new XNAPanel(new Rectangle(102, 330, chatBG.Width, chatBG.Height)) { BackgroundImage = chatBG, Visible = false }; Texture2D statsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 34); pnlStats = new XNAPanel(new Rectangle(102, 330, statsBG.Width, statsBG.Height)) { BackgroundImage = statsBG, Visible = false }; Texture2D onlineBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 36); pnlOnline = new XNAPanel(new Rectangle(102, 330, onlineBG.Width, onlineBG.Height)) { BackgroundImage = onlineBG, Visible = false }; Texture2D partyBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 42); pnlParty = new XNAPanel(new Rectangle(102, 330, partyBG.Width, partyBG.Height)) { BackgroundImage = partyBG, Visible = false }; Texture2D settingsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 47); pnlSettings = new XNAPanel(new Rectangle(102, 330, settingsBG.Width, settingsBG.Height)) { BackgroundImage = settingsBG, Visible = false }; Texture2D helpBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 63); pnlHelp = new XNAPanel(new Rectangle(102, 330, helpBG.Width, helpBG.Height)) { BackgroundImage = helpBG, Visible = false }; Texture2D newsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 48); pnlNews = new XNAPanel(new Rectangle(102, 330, newsBG.Width, newsBG.Height)) { BackgroundImage = newsBG }; //for easy update of all panels via foreach List <XNAPanel> pnlCollection = new List <XNAPanel>(10) { pnlInventory, pnlActiveSpells, pnlPassiveSpells, pnlChat, pnlStats, pnlOnline, pnlParty, pnlSettings, pnlHelp, pnlNews }; //pnlCollection.Add(pnlMacro); //if this ever happens... pnlCollection.ForEach(_pnl => World.IgnoreDialogs(_pnl)); for (int i = 0; i < NUM_BTN; ++i) { Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN); Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height); Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height); Color[] _outBuf = new Color[_outRec.Width * _outRec.Height]; Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height]; mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length); _out.SetData(_outBuf); mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length); _ovr.SetData(_ovrBuf); //0-5: left side, starting at 59, 327 with increments of 20 //6-10: right side, starting at 587, 347 Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20)); mainBtn[i] = new XNAButton(new [] { _out, _ovr }, btnLoc); World.IgnoreDialogs(mainBtn[i]); } //left button onclick events mainBtn[0].OnClick += (s, e) => _doStateChange(InGameStates.Inventory); mainBtn[1].OnClick += (s, e) => World.Instance.ActiveMapRenderer.ToggleMapView(); mainBtn[2].OnClick += (s, e) => _doStateChange(InGameStates.Active); mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive); mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat); mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats); //right button onclick events mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online); mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party); //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client mainBtn[9].OnClick += (s, e) => _doStateChange(InGameStates.Settings); mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help); SpriteBatch = new SpriteBatch(g.GraphicsDevice); state = InGameStates.News; chatRenderer = new EOChatRenderer(); chatRenderer.SetParent(pnlChat); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1), ChatType.Note, ChatColor.Server); chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER), World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2), ChatType.Note, ChatColor.Server); newsTab = new ChatTab(pnlNews); chatTextBox = new ChatTextBox(new Rectangle(124, 308, 440, 19), g.Content.Load <Texture2D>("cursor"), "Microsoft Sans Serif", 8.0f) { Selected = true, Visible = true, MaxChars = 140 }; World.IgnoreDialogs(chatTextBox); chatTextBox.OnEnterPressed += _doTalk; chatTextBox.OnClicked += (s, e) => { //make sure clicking on the textarea selects it (this is an annoying problem in the original client) if (((EOGame)g).Dispatcher.Subscriber != null) { ((XNATextBox)(g as EOGame).Dispatcher.Subscriber).Selected = false; } (g as EOGame).Dispatcher.Subscriber = chatTextBox; chatTextBox.Selected = true; }; chatTextBox.OnTextChanged += (s, e) => { if (chatTextBox.Text.Length <= 0) { if (modeTextureLoaded && modeTexture != null) { modeTextureLoaded = false; modeTexture.Dispose(); modeTexture = null; currentChatMode = ChatMode.NoText; } return; } if (chatTextBox.Text.Length == 1 && chatTextBox.Text[0] == '~' && World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap) { chatTextBox.Text = ""; SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.JAIL_WARNING_CANNOT_USE_GLOBAL); return; } switch (chatTextBox.Text[0]) { case '!': currentChatMode = ChatMode.Private; break; case '@': //should show global if admin, otherwise, public/normal chat if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player) { goto default; } currentChatMode = ChatMode.Global; break; case '~': currentChatMode = ChatMode.Global; break; case '+': { if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player) { goto default; } currentChatMode = ChatMode.Admin; } break; case '\'': currentChatMode = ChatMode.Group; break; case '&': { if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "") { goto default; } currentChatMode = ChatMode.Guild; } break; default: currentChatMode = ChatMode.Public; break; } }; ((EOGame)g).Dispatcher.Subscriber = chatTextBox; m_muteTimer = new Timer(s => { chatTextBox.IgnoreAllInput = false; currentChatMode = ChatMode.NoText; m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite); }, null, Timeout.Infinite, Timeout.Infinite); statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), "Microsoft Sans Serif", 7f); clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), "Microsoft Sans Serif", 7f); StatusBars[0] = new HudElementHP(); StatusBars[1] = new HudElementTP(); StatusBars[2] = new HudElementSP(); StatusBars[3] = new HudElementTNL(); m_whoIsOnline = new EOOnlineList(pnlOnline); m_party = new EOPartyPanel(pnlParty); m_friendList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(592, 312), new Rectangle(0, 260, 17, 15), new Rectangle(0, 276, 17, 15)) { Visible = true, Enabled = true }; m_friendList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, false); m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST); m_ignoreList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true), new Vector2(609, 312), new Rectangle(17, 260, 17, 15), new Rectangle(17, 276, 17, 15)) { Visible = true, Enabled = true }; m_ignoreList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, true); m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST); m_expInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(55, 0), new Rectangle(331, 30, 22, 14), new Rectangle(331, 30, 22, 14)); m_expInfo.OnClick += (o, e) => EOSessionExpDialog.Show(); m_questInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58), new Vector2(77, 0), new Rectangle(353, 30, 22, 14), new Rectangle(353, 30, 22, 14)); //no need to make this a member variable //it does not have any resources to dispose and it is automatically disposed by the framework // ReSharper disable once UnusedVariable EOSettingsPanel settings = new EOSettingsPanel(pnlSettings); }
private void _setupPacketAPIEventHandlers() { m_packetAPI.OnWarpRequestNewMap += World.Instance.CheckMap; m_packetAPI.OnWarpAgree += World.Instance.WarpAgreeAction; m_packetAPI.OnPlayerEnterMap += (_data, _anim) => World.Instance.ActiveMapRenderer.AddOtherPlayer(_data, _anim); m_packetAPI.OnNPCEnterMap += _data => World.Instance.ActiveMapRenderer.AddOtherNPC(_data); m_packetAPI.OnMainPlayerWalk += _list => { foreach (var item in _list) { World.Instance.ActiveMapRenderer.AddMapItem(item); } }; m_packetAPI.OnOtherPlayerWalk += (a, b, c, d) => World.Instance.ActiveMapRenderer.OtherPlayerWalk(a, b, c, d); m_packetAPI.OnAdminHiddenChange += (id, hidden) => { if (World.Instance.MainPlayer.ActiveCharacter.ID == id) { World.Instance.MainPlayer.ActiveCharacter.RenderData.SetHidden(hidden); } else { World.Instance.ActiveMapRenderer.OtherPlayerHide(id, hidden); } }; m_packetAPI.OnOtherPlayerAttack += (id, dir) => World.Instance.ActiveMapRenderer.OtherPlayerAttack(id, dir); m_packetAPI.OnPlayerAvatarRemove += (id, anim) => World.Instance.ActiveMapRenderer.RemoveOtherPlayer(id, anim); m_packetAPI.OnPlayerAvatarChange += _data => { switch (_data.Slot) { case AvatarSlot.Clothes: World.Instance.ActiveMapRenderer.UpdateOtherPlayer(_data.ID, _data.Sound, new CharRenderData { boots = _data.Boots, armor = _data.Armor, hat = _data.Hat, shield = _data.Shield, weapon = _data.Weapon }); break; case AvatarSlot.Hair: World.Instance.ActiveMapRenderer.UpdateOtherPlayer(_data.ID, _data.HairColor, _data.HairStyle); break; case AvatarSlot.HairColor: World.Instance.ActiveMapRenderer.UpdateOtherPlayer(_data.ID, _data.HairColor); break; } }; m_packetAPI.OnPlayerPaperdollChange += _data => { Character c; if (!_data.ItemWasUnequipped) { ItemRecord rec = World.Instance.EIF.GetItemRecordByID(_data.ItemID); //update inventory (c = World.Instance.MainPlayer.ActiveCharacter).UpdateInventoryItem(_data.ItemID, _data.ItemAmount); //equip item c.EquipItem(rec.Type, (short)rec.ID, (short)rec.DollGraphic, true, (sbyte)_data.SubLoc); //add to paperdoll dialog if (EOPaperdollDialog.Instance != null) { EOPaperdollDialog.Instance.SetItem(rec.GetEquipLocation() + _data.SubLoc, rec); } } else { c = World.Instance.MainPlayer.ActiveCharacter; //update inventory c.UpdateInventoryItem(_data.ItemID, 1, true); //true: add to existing quantity //unequip item c.UnequipItem(World.Instance.EIF.GetItemRecordByID(_data.ItemID).Type, _data.SubLoc); } c.UpdateStatsAfterEquip(_data); }; m_packetAPI.OnViewPaperdoll += _data => { if (EOPaperdollDialog.Instance != null) { return; } Character c; if (World.Instance.MainPlayer.ActiveCharacter.ID == _data.PlayerID) { //paperdoll requested for main player, all info should be up to date c = World.Instance.MainPlayer.ActiveCharacter; Array.Copy(_data.Paperdoll.ToArray(), c.PaperDoll, (int)EquipLocation.PAPERDOLL_MAX); } else { if ((c = World.Instance.ActiveMapRenderer.GetOtherPlayer(_data.PlayerID)) != null) { c.Class = _data.Class; c.RenderData.SetGender(_data.Gender); c.Title = _data.Title; c.GuildName = _data.Guild; Array.Copy(_data.Paperdoll.ToArray(), c.PaperDoll, (int)EquipLocation.PAPERDOLL_MAX); } } if (c != null) { EOPaperdollDialog.Show(m_packetAPI, c, _data); } }; m_packetAPI.OnDoorOpen += (x, y) => World.Instance.ActiveMapRenderer.OnDoorOpened(x, y); m_packetAPI.OnChestOpened += data => { if (EOChestDialog.Instance == null || data.X != EOChestDialog.Instance.CurrentChestX || data.Y != EOChestDialog.Instance.CurrentChestY) { return; } EOChestDialog.Instance.InitializeItems(data.Items); }; m_packetAPI.OnChestAgree += data => EOChestDialog.Instance.InitializeItems(data.Items); m_packetAPI.OnChestAddItem += (id, amount, weight, maxWeight, data) => { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amount, weight, maxWeight); EOChestDialog.Instance.InitializeItems(data.Items); Hud.RefreshStats(); }; m_packetAPI.OnChestGetItem += (id, amount, weight, maxWeight, data) => { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amount, weight, maxWeight); EOChestDialog.Instance.InitializeItems(data.Items); Hud.RefreshStats(); }; m_packetAPI.OnServerPingReply += timeout => Hud.AddChat(ChatTabs.Local, "System", string.Format("[x] Current ping to the server is: {0} ms.", timeout), ChatType.LookingDude); m_packetAPI.OnPlayerFace += (playerId, dir) => World.Instance.ActiveMapRenderer.OtherPlayerFace(playerId, dir); m_packetAPI.OnPlayerFindCommandReply += (online, sameMap, charName) => { if (charName.Length == 0) { return; } string lastPart; if (online && !sameMap) { lastPart = World.GetString(DATCONST2.STATUS_LABEL_IS_ONLINE_IN_THIS_WORLD); } else if (online) { lastPart = World.GetString(DATCONST2.STATUS_LABEL_IS_ONLINE_SAME_MAP); } else { lastPart = World.GetString(DATCONST2.STATUS_LABEL_IS_ONLINE_NOT_FOUND); } Hud.AddChat(ChatTabs.Local, "System", string.Format("{0} " + lastPart, char.ToUpper(charName[0]) + charName.Substring(1)), ChatType.LookingDude); }; m_packetAPI.OnPlayerRecover += (hp, tp) => { World.Instance.MainPlayer.ActiveCharacter.Stats.SetHP(hp); World.Instance.MainPlayer.ActiveCharacter.Stats.SetTP(tp); Hud.RefreshStats(); }; m_packetAPI.OnRecoverReply += (exp, karma, level) => { World.Instance.MainPlayer.ActiveCharacter.Stats.exp = exp; World.Instance.MainPlayer.ActiveCharacter.Stats.karma = karma; if (level > 0) { World.Instance.MainPlayer.ActiveCharacter.Stats.level = level; } Hud.RefreshStats(); }; m_packetAPI.OnRecoverStatList += _data => { CharStatData localStats = World.Instance.MainPlayer.ActiveCharacter.Stats; World.Instance.MainPlayer.ActiveCharacter.Class = _data.Class; localStats.SetStr(_data.Str); localStats.SetInt(_data.Int); localStats.SetWis(_data.Wis); localStats.SetAgi(_data.Agi); localStats.SetCon(_data.Con); localStats.SetCha(_data.Cha); localStats.SetMaxHP(_data.MaxHP); localStats.SetMaxTP(_data.MaxTP); localStats.SetMaxSP(_data.MaxSP); World.Instance.MainPlayer.ActiveCharacter.MaxWeight = _data.MaxWeight; localStats.SetMinDam(_data.MinDam); localStats.SetMaxDam(_data.MaxDam); localStats.SetAccuracy(_data.Accuracy); localStats.SetEvade(_data.Evade); localStats.SetArmor(_data.Armor); Hud.RefreshStats(); }; m_packetAPI.OnPlayerHeal += (playerID, hpGain, playerPctHealth) => World.Instance.ActiveMapRenderer.OtherPlayerHeal(playerID, hpGain, playerPctHealth); m_packetAPI.OnGetItemFromMap += (uid, id, amountTaken, weight, maxWeight) => { if (uid != 0) //$si command has uid of 0 since we're creating a new item from nothing { World.Instance.ActiveMapRenderer.UpdateMapItemAmount(uid, amountTaken); } World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amountTaken, weight, maxWeight, true); ItemRecord rec = World.Instance.EIF.GetItemRecordByID(id); Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_YOU_PICKED_UP), amountTaken, rec.Name), ChatType.UpArrow); Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_PICKUP_YOU_PICKED_UP, string.Format(" {0} {1}", amountTaken, rec.Name)); }; m_packetAPI.OnRemoveItemFromMap += uid => World.Instance.ActiveMapRenderer.RemoveMapItem(uid); m_packetAPI.OnJunkItem += (id, amountRemoved, amountRemaining, weight, maxWeight) => { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(id, amountRemaining, weight, maxWeight); ItemRecord rec = World.Instance.EIF.GetItemRecordByID(id); Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_JUNK_YOU_JUNKED), amountRemoved, rec.Name), ChatType.DownArrow); Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_JUNK_YOU_JUNKED, string.Format(" {0} {1}", amountRemoved, rec.Name)); }; m_packetAPI.OnDropItem += (characterAmount, weight, maxWeight, item) => { World.Instance.ActiveMapRenderer.AddMapItem(item); if (characterAmount >= 0) //will be -1 when another player drops { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(item.id, characterAmount, weight, maxWeight); ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id); Hud.AddChat(ChatTabs.System, "", string.Format("{0} {1} {2}", World.GetString(DATCONST2.STATUS_LABEL_ITEM_DROP_YOU_DROPPED), item.amount, rec.Name), ChatType.DownArrow); Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_DROP_YOU_DROPPED, string.Format(" {0} {1}", item.amount, rec.Name)); } }; m_packetAPI.OnUseItem += data => { World.Instance.MainPlayer.ActiveCharacter.UpdateInventoryItem(data.ItemID, data.CharacterAmount, data.Weight, data.MaxWeight); switch (data.Type) { case ItemType.Teleport: /*Warp packet handles the rest!*/ break; case ItemType.Heal: { World.Instance.MainPlayer.ActiveCharacter.Stats.SetHP(data.HP); World.Instance.MainPlayer.ActiveCharacter.Stats.SetTP(data.TP); int percent = (int)Math.Round(100.0 * ((double)data.HP / World.Instance.MainPlayer.ActiveCharacter.Stats.maxhp)); if (data.HPGain > 0) { World.Instance.ActiveCharacterRenderer.SetDamageCounterValue(data.HPGain, percent, true); } Hud.RefreshStats(); } break; case ItemType.HairDye: { World.Instance.MainPlayer.ActiveCharacter.RenderData.SetHairColor(data.HairColor); } break; case ItemType.Beer: World.Instance.ActiveCharacterRenderer.MakeDrunk(); Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_ITEM_USE_DRUNK); break; case ItemType.EffectPotion: { //World.Instance.ActiveCharacterRenderer.ShowEffect(data.EffectID); //todo: get effects working } break; case ItemType.CureCurse: { //actually remove the item(s) from the main character Character c = World.Instance.MainPlayer.ActiveCharacter; for (int i = 0; i < (int)EquipLocation.PAPERDOLL_MAX; ++i) { int nextID = c.PaperDoll[i]; if (nextID > 0 && World.Instance.EIF.GetItemRecordByID(nextID).Special == ItemSpecial.Cursed) { c.PaperDoll[i] = 0; switch ((EquipLocation)i) { case EquipLocation.Boots: c.RenderData.SetBoots(0); break; case EquipLocation.Armor: c.RenderData.SetArmor(0); break; case EquipLocation.Hat: c.RenderData.SetHat(0); break; case EquipLocation.Shield: c.RenderData.SetShield(0); break; case EquipLocation.Weapon: c.RenderData.SetWeapon(0); break; } } } //update main character's stats CharStatData s = c.Stats; s.SetMaxHP(data.CureStats.MaxHP); s.SetMaxTP(data.CureStats.MaxTP); s.SetStr(data.CureStats.Str); s.SetInt(data.CureStats.Int); s.SetWis(data.CureStats.Wis); s.SetAgi(data.CureStats.Agi); s.SetCon(data.CureStats.Con); s.SetCha(data.CureStats.Cha); s.SetMinDam(data.CureStats.MinDam); s.SetMaxDam(data.CureStats.MaxDam); s.SetAccuracy(data.CureStats.Accuracy); s.SetEvade(data.CureStats.Evade); s.SetArmor(data.CureStats.Armor); Hud.RefreshStats(); } break; case ItemType.EXPReward: { CharStatData s = World.Instance.MainPlayer.ActiveCharacter.Stats; if (s.level < data.RewardStats.Level) { //level up! World.Instance.MainPlayer.ActiveCharacter.Emote(Emote.LevelUp); World.Instance.ActiveCharacterRenderer.PlayerEmote(); s.level = data.RewardStats.Level; } s.exp = data.RewardStats.Exp; s.statpoints = data.RewardStats.StatPoints; s.skillpoints = data.RewardStats.SkillPoints; s.maxhp = data.RewardStats.MaxHP; s.maxtp = data.RewardStats.MaxTP; s.maxsp = data.RewardStats.MaxSP; } break; } }; m_packetAPI.OnMapMutation += () => { if (File.Exists("maps\\00000.emf")) { string fmt = string.Format("maps\\{0,5:D5}.emf", World.Instance.MainPlayer.ActiveCharacter.CurrentMap); if (File.Exists(fmt)) { File.Delete(fmt); } File.Move("maps\\00000.emf", fmt); World.Instance.Remap(); } else { throw new FileNotFoundException("Unable to remap the file, something broke"); } }; }
public override void Update(GameTime gameTime) { if (!Game.IsActive) { return; } //check for drag-drop here MouseState currentState = Mouse.GetState(); if (!m_beingDragged && MouseOverPreviously && MouseOver && PreviousMouseState.LeftButton == ButtonState.Pressed && currentState.LeftButton == ButtonState.Pressed) { //Conditions for starting are the mouse is over, the button is pressed, and no other items are being dragged if (((EOInventory)parent).NoItemsDragging()) { //start the drag operation and hide the item label m_beingDragged = true; m_nameLabel.Visible = false; m_preDragDrawOrder = DrawOrder; m_preDragParent = parent; //make sure the offsets are maintained! //required to enable dragging past bounds of the inventory panel m_oldOffX = xOff; m_oldOffY = yOff; SetParent(null); m_alpha = 128; DrawOrder = 100; //arbitrarily large constant so drawn on top while dragging } } if (m_beingDragged && PreviousMouseState.LeftButton == ButtonState.Pressed && currentState.LeftButton == ButtonState.Pressed) { //dragging has started. continue dragging until mouse is released, update position based on mouse location DrawLocation = new Vector2(currentState.X - (DrawArea.Width / 2), currentState.Y - (DrawArea.Height / 2)); } else if (m_beingDragged && PreviousMouseState.LeftButton == ButtonState.Pressed && currentState.LeftButton == ButtonState.Released) { //need to check for: drop on map (drop action) // drop on button junk/drop // drop on grid (inventory move action) // drop on chest dialog (chest add action) DrawOrder = m_preDragDrawOrder; m_alpha = 255; SetParent(m_preDragParent); if (((EOInventory)parent).IsOverDrop() || (World.Instance.ActiveMapRenderer.MouseOver && EOChestDialog.Instance == null && EOPaperdollDialog.Instance == null && EOLockerDialog.Instance == null)) { Microsoft.Xna.Framework.Point loc = World.Instance.ActiveMapRenderer.MouseOver ? World.Instance.ActiveMapRenderer.GridCoords: new Microsoft.Xna.Framework.Point(World.Instance.MainPlayer.ActiveCharacter.X, World.Instance.MainPlayer.ActiveCharacter.Y); //in range if maximum coordinate difference is <= 2 away bool inRange = Math.Abs(Math.Max(World.Instance.MainPlayer.ActiveCharacter.X - loc.X, World.Instance.MainPlayer.ActiveCharacter.Y - loc.Y)) <= 2; if (m_itemData.Special == ItemSpecial.Lore) { EODialog.Show(DATCONST1.ITEM_IS_LORE_ITEM, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (World.Instance.JailMap == World.Instance.MainPlayer.ActiveCharacter.CurrentMap) { EODialog.Show(World.GetString(DATCONST2.JAIL_WARNING_CANNOT_DROP_ITEMS), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (m_inventory.amount > 1 && inRange) { EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.DropItems, m_inventory.amount); dlg.DialogClosing += (sender, args) => { if (args.Result == XNADialogResult.OK) { //note: not sure of the actual limit. 10000 is arbitrary here if (dlg.SelectedAmount > 10000 && m_inventory.id == 1 && !safetyCommentHasBeenShown) { EODialog.Show(DATCONST1.DROP_MANY_GOLD_ON_GROUND, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader, (o, e) => { safetyCommentHasBeenShown = true; }); } else if (!m_api.DropItem(m_inventory.id, dlg.SelectedAmount, (byte)loc.X, (byte)loc.Y)) { ((EOGame)Game).LostConnectionDialog(); } } }; } else if (inRange) { if (!m_api.DropItem(m_inventory.id, 1, (byte)loc.X, (byte)loc.Y)) { ((EOGame)Game).LostConnectionDialog(); } } else /*if (!inRange)*/ { EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_ITEM_DROP_OUT_OF_RANGE); } } else if (((EOInventory)parent).IsOverJunk()) { if (m_inventory.amount > 1) { EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.JunkItems, m_inventory.amount, DATCONST2.DIALOG_TRANSFER_JUNK); dlg.DialogClosing += (sender, args) => { if (args.Result == XNADialogResult.OK && !m_api.JunkItem(m_inventory.id, dlg.SelectedAmount)) { ((EOGame)Game).LostConnectionDialog(); } }; } else if (!m_api.JunkItem(m_inventory.id, 1)) { ((EOGame)Game).LostConnectionDialog(); } } else if (EOChestDialog.Instance != null && EOChestDialog.Instance.MouseOver && EOChestDialog.Instance.MouseOverPreviously) { if (m_itemData.Special == ItemSpecial.Lore) { EODialog.Show(DATCONST1.ITEM_IS_LORE_ITEM, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (m_inventory.amount > 1) { EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.DropItems, m_inventory.amount); dlg.DialogClosing += (sender, args) => { if (args.Result == XNADialogResult.OK && !m_api.ChestAddItem(EOChestDialog.Instance.CurrentChestX, EOChestDialog.Instance.CurrentChestY, m_inventory.id, dlg.SelectedAmount)) { EOGame.Instance.LostConnectionDialog(); } }; } else { if (!m_api.ChestAddItem(EOChestDialog.Instance.CurrentChestX, EOChestDialog.Instance.CurrentChestY, m_inventory.id, 1)) { EOGame.Instance.LostConnectionDialog(); } } } else if (EOPaperdollDialog.Instance != null && EOPaperdollDialog.Instance.MouseOver && EOPaperdollDialog.Instance.MouseOverPreviously) { //equipable items should be equipped //other item types should do nothing switch (m_itemData.Type) { case ItemType.Accessory: case ItemType.Armlet: case ItemType.Armor: case ItemType.Belt: case ItemType.Boots: case ItemType.Bracer: case ItemType.Gloves: case ItemType.Hat: case ItemType.Necklace: case ItemType.Ring: case ItemType.Shield: case ItemType.Weapon: _handleDoubleClick(); break; } } else if (EOLockerDialog.Instance != null && EOLockerDialog.Instance.MouseOver && EOLockerDialog.Instance.MouseOverPreviously) { if (m_inventory.id == 1) { EODialog.Show(DATCONST1.LOCKER_DEPOSIT_GOLD_ERROR, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (m_inventory.amount > 1) { EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.ShopTransfer, m_inventory.amount, DATCONST2.DIALOG_TRANSFER_TRANSFER); dlg.DialogClosing += (sender, args) => { if (args.Result == XNADialogResult.OK) { if (EOLockerDialog.Instance.GetNewItemAmount(m_inventory.id, dlg.SelectedAmount) > Constants.LockerMaxSingleItemAmount) { EODialog.Show(DATCONST1.LOCKER_FULL_SINGLE_ITEM_MAX, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (!Handlers.Locker.AddItem(m_inventory.id, dlg.SelectedAmount)) { EOGame.Instance.LostConnectionDialog(); } } }; } else { if (EOLockerDialog.Instance.GetNewItemAmount(m_inventory.id, 1) > Constants.LockerMaxSingleItemAmount) { EODialog.Show(DATCONST1.LOCKER_FULL_SINGLE_ITEM_MAX, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (!Handlers.Locker.AddItem(m_inventory.id, 1)) { EOGame.Instance.LostConnectionDialog(); } } } else if (EOBankAccountDialog.Instance != null && EOBankAccountDialog.Instance.MouseOver && EOBankAccountDialog.Instance.MouseOverPreviously && m_inventory.id == 1) { if (m_inventory.amount == 0) { EODialog.Show(DATCONST1.BANK_ACCOUNT_UNABLE_TO_DEPOSIT, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } else if (m_inventory.amount > 1) { EOItemTransferDialog dlg = new EOItemTransferDialog(m_itemData.Name, EOItemTransferDialog.TransferType.BankTransfer, m_inventory.amount, DATCONST2.DIALOG_TRANSFER_DEPOSIT); dlg.DialogClosing += (o, e) => { if (e.Result == XNADialogResult.Cancel) { return; } if (!Handlers.Bank.BankDeposit(dlg.SelectedAmount)) { EOGame.Instance.LostConnectionDialog(); } }; } else { if (!Handlers.Bank.BankDeposit(1)) { EOGame.Instance.LostConnectionDialog(); } } } //update the location - if it isn't on the grid, the bounds check will set it back to where it used to be originally //Item amount will be updated or item will be removed in packet response to the drop operation UpdateItemLocation(ItemCurrentSlot()); //mouse has been released. finish dragging. m_beingDragged = false; m_nameLabel.Visible = true; } if (!m_beingDragged && PreviousMouseState.LeftButton == ButtonState.Pressed && currentState.LeftButton == ButtonState.Released && MouseOver && MouseOverPreviously) { Interlocked.Increment(ref m_recentClickCount); if (m_recentClickCount == 2) { _handleDoubleClick(); } } if (!MouseOverPreviously && MouseOver && !m_beingDragged) { m_nameLabel.Visible = true; EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ITEM, m_nameLabel.Text); } else if (!MouseOver && !m_beingDragged && m_nameLabel != null && m_nameLabel.Visible) { m_nameLabel.Visible = false; } base.Update(gameTime); //sets mouseoverpreviously = mouseover, among other things }
public void UpdateInventoryItem(short id, int characterAmount, byte characterWeight, byte characterMaxWeight, bool addToExistingAmount = false) { InventoryItem rec; if ((rec = Inventory.Find(item => item.id == id)).id == id) { InventoryItem newRec = new InventoryItem { amount = addToExistingAmount ? characterAmount + rec.amount : characterAmount, id = id }; if (this == World.Instance.MainPlayer.ActiveCharacter) { //false when AddItem fails to find a good spot if (!EOGame.Instance.Hud.UpdateInventory(newRec)) { EODialog.Show(World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); return; } } //if we can hold it, update local inventory and weight stats if (!Inventory.Remove(rec)) { throw new Exception("Unable to remove from inventory!"); } if (newRec.amount > 0) { Inventory.Add(newRec); } Weight = characterWeight; MaxWeight = characterMaxWeight; if (this == World.Instance.MainPlayer.ActiveCharacter) { EOGame.Instance.Hud.RefreshStats(); } } else { //for item_get/chest_get packets, the item may not be in the inventory yet InventoryItem newRec = new InventoryItem { amount = characterAmount, id = id }; if (newRec.amount <= 0) { return; } Inventory.Add(newRec); if (this == World.Instance.MainPlayer.ActiveCharacter) { //false when AddItem fails to find a good spot if (!EOGame.Instance.Hud.UpdateInventory(newRec)) { EODialog.Show(World.GetString(DATCONST2.STATUS_LABEL_ITEM_PICKUP_NO_SPACE_LEFT), World.GetString(DATCONST2.STATUS_LABEL_TYPE_WARNING), XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); return; } } Weight = characterWeight; MaxWeight = characterMaxWeight; if (this == World.Instance.MainPlayer.ActiveCharacter) { EOGame.Instance.Hud.RefreshStats(); } } }
private void _settingChange(object sender, EventArgs e) { if (sender == m_buttons[0]) { if (!m_soundChanged && !w.SoundEnabled) { EODialog.Show(DATCONST1.SETTINGS_SOUND_DISABLED, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader, (o, args) => { if (args.Result == XNADialogResult.OK) { m_soundChanged = true; w.SoundEnabled = !w.SoundEnabled; World.Instance.ActiveMapRenderer.PlayOrStopAmbientNoise(); m_leftSide[0].Text = World.GetString(w.SoundEnabled ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } }); } else { if (!m_soundChanged) { m_soundChanged = true; } w.SoundEnabled = !w.SoundEnabled; World.Instance.ActiveMapRenderer.PlayOrStopAmbientNoise(); m_leftSide[0].Text = World.GetString(w.SoundEnabled ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } } else if (sender == m_buttons[1]) { if (!m_musicChanged && !w.MusicEnabled) { EODialog.Show(DATCONST1.SETTINGS_MUSIC_DISABLED, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader, (o, args) => { if (args.Result == XNADialogResult.OK) { m_musicChanged = true; w.MusicEnabled = !w.MusicEnabled; World.Instance.ActiveMapRenderer.PlayOrStopBackgroundMusic(); m_leftSide[1].Text = World.GetString(w.MusicEnabled ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } }); } else { if (!m_musicChanged) { m_musicChanged = true; } w.MusicEnabled = !w.MusicEnabled; World.Instance.ActiveMapRenderer.PlayOrStopBackgroundMusic(); m_leftSide[1].Text = World.GetString(w.MusicEnabled ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } } else if (sender == m_buttons[2]) { m_keyboard++; if (m_keyboard > KeyLayout.Azerty) { m_keyboard = 0; } m_leftSide[2].Text = World.GetString(DATCONST2.SETTING_KEYBOARD_ENGLISH + (int)m_keyboard); } else if (sender == m_buttons[3]) { if (w.Language != EOLanguage.Portuguese) { w.Language++; } else { w.Language = 0; } _setTextForLanguage(); //need to reset all strings when language changes } else if (sender == m_buttons[4]) { w.HearWhispers = !w.HearWhispers; m_leftSide[4].Text = World.GetString(w.HearWhispers ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); Packet pkt = new Packet(PacketFamily.Global, w.HearWhispers ? PacketAction.Remove : PacketAction.Player); pkt.AddChar(w.HearWhispers ? (byte)'n' : (byte)'y'); w.Client.SendPacket(pkt); } else if (sender == m_buttons[5]) { w.ShowChatBubbles = !w.ShowChatBubbles; m_rightSide[0].Text = World.GetString(w.ShowChatBubbles ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } else if (sender == m_buttons[6]) { w.ShowShadows = !w.ShowShadows; m_rightSide[1].Text = World.GetString(w.ShowShadows ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } else if (sender == m_buttons[7]) { DATCONST2 str; if (w.StrictFilterEnabled) { w.StrictFilterEnabled = false; str = DATCONST2.SETTING_DISABLED; } else if (w.CurseFilterEnabled) { w.CurseFilterEnabled = false; w.StrictFilterEnabled = true; str = DATCONST2.SETTING_EXCLUSIVE; } else { w.CurseFilterEnabled = true; str = DATCONST2.SETTING_NORMAL; } m_rightSide[2].Text = World.GetString(str); } else if (sender == m_buttons[8]) { w.LogChatToFile = !w.LogChatToFile; m_rightSide[3].Text = World.GetString(w.LogChatToFile ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } else if (sender == m_buttons[9]) { w.Interaction = !w.Interaction; m_rightSide[4].Text = World.GetString(w.Interaction ? DATCONST2.SETTING_ENABLED : DATCONST2.SETTING_DISABLED); } }