private void _statskillReset(StatResetData data) { Character c; (c = World.Instance.MainPlayer.ActiveCharacter).Spells.Clear(); EODialog.Show(DATCONST1.SKILL_RESET_CHARACTER_COMPLETE, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); c.Stats.statpoints = data.StatPoints; c.Stats.skillpoints = data.SkillPoints; c.Stats.SetHP(data.HP); c.Stats.SetMaxHP(data.MaxHP); c.Stats.SetTP(data.TP); c.Stats.SetMaxTP(data.MaxTP); c.Stats.SetMaxSP(data.MaxSP); c.Stats.SetStr(data.Str); c.Stats.SetInt(data.Int); c.Stats.SetWis(data.Wis); c.Stats.SetAgi(data.Agi); c.Stats.SetCon(data.Con); c.Stats.SetCha(data.Cha); c.Stats.SetMinDam(data.MinDam); c.Stats.SetMaxDam(data.MaxDam); c.Stats.SetAccuracy(data.Accuracy); c.Stats.SetEvade(data.Evade); c.Stats.SetArmor(data.Armor); m_game.Hud.RefreshStats(); }
private void _tradeRequested(short playerID, string name) { EODialog.Show(char.ToUpper(name[0]) + name.Substring(1) + " ", DATCONST1.TRADE_REQUEST, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader, (o, e) => { if (e.Result == XNADialogResult.OK && !m_packetAPI.TradeAcceptRequest(playerID)) { m_game.LostConnectionDialog(); } }); }
public void LostConnectionDialog() { EODialog.Show(currentState == GameStates.PlayingTheGame ? DATCONST1.CONNECTION_LOST_IN_GAME : DATCONST1.CONNECTION_LOST_CONNECTION); if (World.Instance.Client.ConnectedAndInitialized) { World.Instance.Client.Disconnect(); } doStateChange(GameStates.Initial); }
private void _statskillLearnError(SkillMasterReply reply, short id) { switch (reply) { //not sure if this will ever actually be sent because client validates data before trying to learn a skill case SkillMasterReply.ErrorWrongClass: EODialog.Show(DATCONST1.SKILL_LEARN_WRONG_CLASS, " " + ((ClassRecord)World.Instance.ECF.Data[id]).Name + "!", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); break; case SkillMasterReply.ErrorRemoveItems: EODialog.Show(DATCONST1.SKILL_RESET_CHARACTER_CLEAR_PAPERDOLL, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); break; } }
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 _partyRequest(PartyRequestType type, short id, string name) { EODialog.Show(name + " ", type == PartyRequestType.Join ? DATCONST1.PARTY_GROUP_REQUEST_TO_JOIN : DATCONST1.PARTY_GROUP_SEND_INVITATION, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader, (o, e) => { if (e.Result == XNADialogResult.OK) { if (!m_packetAPI.PartyAcceptRequest(type, id)) { m_game.LostConnectionDialog(); } } }); }
public void WarpAgreeAction(short mapID, WarpAnimation anim, List <CharacterData> chars, List <NPCData> npcs, List <MapItem> items) { if (mapID >= 0) { if (!_tryLoadMap(mapID)) { EOGame.Instance.LostConnectionDialog(); EODialog.Show("Something went wrong when loading the map. Try logging in again.", "Map Load Error"); } MainPlayer.ActiveCharacter.CurrentMap = mapID; if (!_tryLoadMap(mapID)) { EOGame.Instance.LostConnectionDialog(); return; } ActiveMapRenderer.SetActiveMap(MapCache[mapID]); } ActiveMapRenderer.ClearOtherPlayers(); ActiveMapRenderer.ClearOtherNPCs(); ActiveMapRenderer.ClearMapItems(); foreach (var data in chars) { if (data.ID == MainPlayer.ActiveCharacter.ID) { MainPlayer.ActiveCharacter.ApplyData(data); } else { ActiveMapRenderer.AddOtherPlayer(data); } } foreach (var data in npcs) { ActiveMapRenderer.AddOtherNPC(data); } foreach (MapItem mi in items) { ActiveMapRenderer.AddMapItem(mi); } }
public ChestKey CanOpenChest(MapChest chest) { ChestKey permission = chest.key; ItemRecord rec; switch (permission) //note - it would be nice to be able to send the Item IDs of the keys in the welcome packet or something { case ChestKey.Normal: rec = (ItemRecord)World.Instance.EIF.Data.Find(_rec => ((ItemRecord)_rec).Name != null && ((ItemRecord)_rec).Name.ToLower() == "normal key"); break; case ChestKey.Crystal: rec = (ItemRecord)World.Instance.EIF.Data.Find(_rec => ((ItemRecord)_rec).Name != null && ((ItemRecord)_rec).Name.ToLower() == "crystal key"); break; case ChestKey.Silver: rec = (ItemRecord)World.Instance.EIF.Data.Find(_rec => ((ItemRecord)_rec).Name != null && ((ItemRecord)_rec).Name.ToLower() == "silver key"); break; case ChestKey.Wraith: rec = (ItemRecord)World.Instance.EIF.Data.Find(_rec => ((ItemRecord)_rec).Name != null && ((ItemRecord)_rec).Name.ToLower() == "wraith key"); break; default: return(permission); } if (rec != null && Inventory.FindIndex(_ii => _ii.id == rec.ID) >= 0) { permission = ChestKey.None; } else if (rec == null) //show a warning saying that this chest is perma-locked. Non-standard pub files will cause this. { EODialog.Show( string.Format("Unable to find key for {0} in EIF. This chest will never be opened!", Enum.GetName(typeof(ChestKey), permission)), "Warning", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } return(permission); }
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); } }
private void _eventJoinParty(object arg1, EventArgs arg2) { EODialog.Show("TODO: Join this player's party", "TODO ITEM", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); }
public override void Initialize() { base.Initialize(); //position for these: x=50, y = 8,26,44,... for (int i = 0; i < m_basicStats.Length; ++i) { m_basicStats[i] = new XNALabel(new Rectangle(50, 8 + i*18, 73, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8,0xc8,0xc8), AutoSize = false, }; m_basicStats[i].SetParent(this); m_arrows[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(106, 7 + i*18), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15)) { Visible = false, //for testing - this should only be visible when statpoints > 0 FlashSpeed = 500 }; m_arrows[i].SetParent(this); World.IgnoreDialogs(m_arrows[i]); m_arrows[i].OnClick += (s, e) => { if (!m_training) { //apparently this is NOT stored in the edf files... EODialog dlg = new EODialog("Do you want to train?", "Character training", XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader); dlg.DialogClosing += (sender, args) => { if (args.Result != XNADialogResult.OK) return; m_training = true; }; } else { short index = (short)(m_arrows.ToList().FindIndex(_btn => _btn == s) + 1); //1-based index (server-side) if(!((EOGame)Game).API.LevelUpStat(index)) EOGame.Instance.LostConnectionDialog(); } }; } //x=158, y = 8, 26, 44, ... for (int i = 0; i < m_characterStats.Length; ++i) { m_characterStats[i] = new XNALabel(new Rectangle(158, 8 + i * 18, 73, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; m_characterStats[i].SetParent(this); } for (int i = 0; i < m_otherInfo.Length; ++i) { m_otherInfo[i] = new XNALabel(new Rectangle(i < 4 ? 280 : 379 , 44 + (i%4)*18, i < 4 ? 60 : 94, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; m_otherInfo[i].SetParent(this); } //these labels have non-standard sizes so they're done individually //name= 280,8 144,13 m_charInfo[NAME] = new XNALabel(new Rectangle(280, 8, 144, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, Text = c.Name }; //guild = 280,26 193,13 m_charInfo[GUILD] = new XNALabel(new Rectangle(280, 26, 193, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, Text = c.GuildName }; //level = 453,8, 20,13 m_charInfo[LEVEL] = new XNALabel(new Rectangle(453, 8, 20, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; foreach(XNALabel lbl in m_charInfo) lbl.SetParent(this); }
private void _statskillForgetSpell(short id) { World.Instance.MainPlayer.ActiveCharacter.Spells.RemoveAll(_spell => _spell.id == id); EODialog.Show(DATCONST1.SKILL_FORGET_SUCCESS, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); }
private void _eventShowBook(object arg1, EventArgs arg2) { EODialog.Show("TODO: Show quest info", "TODO ITEM", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); }
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); } }
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 EOInventory(XNAPanel parent, PacketAPI api) : base(null, null, parent) { m_api = api; //load info from registry Dictionary <int, int> localItemSlotMap = new Dictionary <int, int>(); m_inventoryKey = _tryGetCharacterRegKey(); if (m_inventoryKey != null) { const string itemFmt = "item{0}"; for (int i = 0; i < INVENTORY_ROW_LENGTH * 4; ++i) { int id; try { id = Convert.ToInt32(m_inventoryKey.GetValue(string.Format(itemFmt, i))); } catch { continue; } localItemSlotMap.Add(i, id); } } //add the inventory items that were retrieved from the server List <InventoryItem> localInv = World.Instance.MainPlayer.ActiveCharacter.Inventory; if (localInv.Find(_item => _item.id == 1).id != 1) { localInv.Insert(0, new InventoryItem { amount = 0, id = 1 }); //add 0 gold if there isn't any gold } bool dialogShown = false; foreach (InventoryItem item in localInv) { ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id); int slot = localItemSlotMap.ContainsValue(item.id) ? localItemSlotMap.First(_pair => _pair.Value == item.id).Key : GetNextOpenSlot(rec.Size); if (!dialogShown && !AddItemToSlot(slot, rec, item.amount)) { dialogShown = true; EODialog.Show("Something doesn't fit in the inventory. Rearrange items or get rid of them.", "Warning", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } } //coordinates for parent of EOInventory: 102, 330 (pnlInventory in InGameHud) //extra in photoshop right now: 8, 31 //current weight label (member variable, needs to have text updated when item amounts change) m_lblWeight = new XNALabel(new Rectangle(385, 37, 88, 18), "Microsoft Sans MS", 8f) { ForeColor = System.Drawing.Color.FromArgb(255, 0xc8, 0xc8, 0xc8), TextAlign = ContentAlignment.MiddleCenter, Visible = true, AutoSize = false }; m_lblWeight.SetParent(this); UpdateWeightLabel(); Texture2D thatWeirdSheet = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27); //oh my gawd the offsets on this bish //(local variables, added to child controls) //'paperdoll' button m_btnPaperdoll = new XNAButton(thatWeirdSheet, new Vector2(385, 9), /*new Rectangle(39, 385, 88, 19)*/ null, new Rectangle(126, 385, 88, 19)); m_btnPaperdoll.SetParent(this); m_btnPaperdoll.OnClick += (s, e) => m_api.RequestPaperdoll((short)World.Instance.MainPlayer.ActiveCharacter.ID); //'drop' button //491, 398 -> 389, 68 //0,15,38,37 //0,52,38,37 m_btnDrop = new XNAButton(thatWeirdSheet, new Vector2(389, 68), new Rectangle(0, 15, 38, 37), new Rectangle(0, 52, 38, 37)); m_btnDrop.SetParent(this); m_btnDrop.IgnoreDialog(typeof(EOPaperdollDialog)); m_btnDrop.IgnoreDialog(typeof(EOChestDialog)); //'junk' button - 4 + 38 on the x away from drop m_btnJunk = new XNAButton(thatWeirdSheet, new Vector2(431, 68), new Rectangle(0, 89, 38, 37), new Rectangle(0, 126, 38, 37)); m_btnJunk.SetParent(this); m_btnJunk.IgnoreDialog(typeof(EOPaperdollDialog)); m_btnJunk.IgnoreDialog(typeof(EOChestDialog)); }
private void _handleDoubleClick() { bool useItem = false; switch (m_itemData.Type) { //equippable items 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: byte subLoc = 0; if (m_itemData.Type == ItemType.Armlet || m_itemData.Type == ItemType.Ring || m_itemData.Type == ItemType.Bracer) { if (World.Instance.MainPlayer.ActiveCharacter.PaperDoll[(int)m_itemData.GetEquipLocation()] == 0) { subLoc = 0; } else if (World.Instance.MainPlayer.ActiveCharacter.PaperDoll[(int)m_itemData.GetEquipLocation() + 1] == 0) { subLoc = 1; } else { EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_EQUIP_TYPE_ALREADY_EQUIPPED); break; } } else if (m_itemData.Type == ItemType.Armor && m_itemData.Gender != World.Instance.MainPlayer.ActiveCharacter.RenderData.gender) { EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_EQUIP_DOES_NOT_FIT_GENDER); break; } if (World.Instance.MainPlayer.ActiveCharacter.EquipItem(m_itemData.Type, (short)m_itemData.ID, (short)m_itemData.DollGraphic)) { if (!m_api.EquipItem((short)m_itemData.ID, subLoc)) { EOGame.Instance.LostConnectionDialog(); } } else { EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_ITEM_EQUIP_TYPE_ALREADY_EQUIPPED); } break; //usable items case ItemType.Teleport: if (!World.Instance.ActiveMapRenderer.MapRef.CanScroll) { EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_ACTION, DATCONST2.STATUS_LABEL_NOTHING_HAPPENED); break; } if (m_itemData.ScrollMap == World.Instance.MainPlayer.ActiveCharacter.CurrentMap && m_itemData.ScrollX == World.Instance.MainPlayer.ActiveCharacter.X && m_itemData.ScrollY == World.Instance.MainPlayer.ActiveCharacter.Y) { break; //already there - no need to scroll! } useItem = true; break; case ItemType.Heal: case ItemType.HairDye: case ItemType.Beer: useItem = true; break; case ItemType.CureCurse: //note: don't actually set the useItem bool here. Call API.UseItem if the dialog result is OK. if (World.Instance.MainPlayer.ActiveCharacter.PaperDoll.Select(id => World.Instance.EIF.GetItemRecordByID(id)) .Any(rec => rec.Special == ItemSpecial.Cursed)) //only do the use if the player has a cursed item equipped { EODialog.Show(DATCONST1.ITEM_CURSE_REMOVE_PROMPT, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader, (o, e) => { if (e.Result == XNADialogResult.OK && !m_api.UseItem((short)m_itemData.ID)) { ((EOGame)Game).LostConnectionDialog(); } }); } break; case ItemType.EXPReward: useItem = true; break; case ItemType.EffectPotion: //todo: get effects working //useItem = true; break; //Not implemented server-side //case ItemType.SkillReward: // break; //case ItemType.StatReward: // break; } if (useItem && !m_api.UseItem((short)m_itemData.ID)) { ((EOGame)Game).LostConnectionDialog(); } m_recentClickCount = 0; }
private void CharModButtonPress(object sender, EventArgs e) { //click delete once: pop up initial dialog, set that initial dialog has been shown //Character_take: delete clicked, then dialog pops up //Character_remove: click ok in yes/no dialog //click login: send WELCOME_REQUEST, get WELCOME_REPLY //Send WELCOME_AGREE for map/pubs if needed //Send WELCOME_MSG, get WELCOME_REPLY //log in if all okay int index; if (loginCharButtons.Contains(sender)) { index = loginCharButtons.ToList().FindIndex(x => x == sender); if (World.Instance.MainPlayer.CharData == null || World.Instance.MainPlayer.CharData.Length <= index) { return; } WelcomeRequestData data; if (!m_packetAPI.SelectCharacter(World.Instance.MainPlayer.CharData[index].id, out data)) { LostConnectionDialog(); return; } //handles the WelcomeRequestData object World.Instance.ApplyWelcomeRequest(m_packetAPI, data); //shows the connecting window EOConnectingDialog dlg = new EOConnectingDialog(m_packetAPI); dlg.DialogClosing += (dlgS, dlgE) => { switch (dlgE.Result) { case XNADialogResult.OK: doStateChange(GameStates.PlayingTheGame); World.Instance.ApplyWelcomeMessage(dlg.WelcomeData); Hud = new HUD(this, m_packetAPI); Components.Add(Hud); Hud.SetNews(dlg.WelcomeData.News); Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.LOADING_GAME_HINT_FIRST); if (data.FirstTimePlayer) { EODialog.Show(DATCONST1.WARNING_FIRST_TIME_PLAYERS, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); } break; case XNADialogResult.NO_BUTTON_PRESSED: { EODialog.Show(DATCONST1.CONNECTION_SERVER_BUSY); if (World.Instance.Client.ConnectedAndInitialized) { World.Instance.Client.Disconnect(); } doStateChange(GameStates.Initial); } break; } }; } else if (deleteCharButtons.Contains(sender)) { index = deleteCharButtons.ToList().FindIndex(x => x == sender); if (World.Instance.MainPlayer.CharData.Length <= index) { return; } if (charDeleteWarningShown != index) { EODialog.Show("Character \'" + World.Instance.MainPlayer.CharData[index].name + "\' ", DATCONST1.CHARACTER_DELETE_FIRST_CHECK); charDeleteWarningShown = index; return; } //delete character at that index, if it exists int takeID; if (!m_packetAPI.CharacterTake(World.Instance.MainPlayer.CharData[index].id, out takeID)) { LostConnectionDialog(); return; } if (takeID != World.Instance.MainPlayer.CharData[index].id) { EODialog.Show("The server did not respond properly for deleting the character. Try again.", "Server error"); return; } EODialog.Show("Character \'" + World.Instance.MainPlayer.CharData[index].name + "\' ", DATCONST1.CHARACTER_DELETE_CONFIRM, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogLargeHeader, (dlgS, dlgE) => { if (dlgE.Result == XNADialogResult.OK) //user clicked ok to delete their character. do the delete here. { CharacterRenderData[] dataArray; if (!m_packetAPI.CharacterRemove(World.Instance.MainPlayer.CharData[index].id, out dataArray)) { LostConnectionDialog(); return; } World.Instance.MainPlayer.ProcessCharacterData(dataArray); doShowCharacters(); } }); } }
//Pretty much controls how states transition between one another private void MainButtonPress(object sender, EventArgs e) { if (!IsActive) { return; } if (World.Instance.SoundEnabled && mainButtons.Contains(sender)) { SoundManager.GetSoundEffectRef(SoundEffectID.ButtonClick).Play(); } //switch on sender if (sender == mainButtons[0]) { //try connect //if successful go to account creation state TryConnectToServer(() => { doStateChange(GameStates.CreateAccount); EOScrollingDialog createAccountDlg = new EOScrollingDialog(""); string message = World.Instance.DataFiles[World.Instance.Localized2].Data[(int)DATCONST2.ACCOUNT_CREATE_WARNING_DIALOG_1]; message += "\n\n"; message += World.Instance.DataFiles[World.Instance.Localized2].Data[(int)DATCONST2.ACCOUNT_CREATE_WARNING_DIALOG_2]; message += "\n\n"; message += World.Instance.DataFiles[World.Instance.Localized2].Data[(int)DATCONST2.ACCOUNT_CREATE_WARNING_DIALOG_3]; createAccountDlg.MessageText = message; }); } else if (sender == mainButtons[1]) { //try connect //if successful go to account login state TryConnectToServer(() => doStateChange(GameStates.Login)); } else if (sender == mainButtons[2]) { doStateChange(GameStates.ViewCredits); } else if (sender == mainButtons[3]) { if (World.Instance.Client.ConnectedAndInitialized) { World.Instance.Client.Disconnect(); } Exit(); } else if ((sender == backButton && currentState != GameStates.PlayingTheGame) || sender == createButtons[1] || sender == loginButtons[1]) { Dispatcher.Subscriber = null; LostConnectionDialog(); //disabled warning: in case I add code later below, need to remember that this should immediately return // ReSharper disable once RedundantJumpStatement return; } else if (sender == backButton && currentState == GameStates.PlayingTheGame) { EODialog.Show(DATCONST1.EXIT_GAME_ARE_YOU_SURE, XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader, (ss, ee) => { if (ee.Result == XNADialogResult.OK) { Dispatcher.Subscriber = null; World.Instance.ResetGameElements(); if (World.Instance.Client.ConnectedAndInitialized) { World.Instance.Client.Disconnect(); } doStateChange(GameStates.Initial); } }); } else if (sender == loginButtons[0]) { if (loginUsernameTextbox.Text == "" || loginPasswordTextbox.Text == "") { return; } LoginReply reply; CharacterRenderData[] dataArray; if (!m_packetAPI.LoginRequest(loginUsernameTextbox.Text, loginPasswordTextbox.Text, out reply, out dataArray)) { LostConnectionDialog(); return; } if (reply != LoginReply.Ok) { EODialog.Show(m_packetAPI.LoginResponseMessage()); return; } World.Instance.MainPlayer.SetAccountName(loginUsernameTextbox.Text); World.Instance.MainPlayer.ProcessCharacterData(dataArray); doStateChange(GameStates.LoggedIn); } else if (sender == createButtons[0]) { switch (currentState) { case GameStates.CreateAccount: { if (accountCreateTextBoxes.Any(txt => txt.Text.Length == 0)) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_FIELDS_STILL_EMPTY); return; } if (accountCreateTextBoxes[0].Text.Length < 4) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_NAME_TOO_SHORT); return; } if (accountCreateTextBoxes[0].Text.Distinct().Count() < 3) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_NAME_TOO_OBVIOUS); return; } if (accountCreateTextBoxes[1].Text != accountCreateTextBoxes[2].Text) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_MISMATCH); return; } if (accountCreateTextBoxes[1].Text.Length < 6) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_TOO_SHORT); return; } if (accountCreateTextBoxes[1].Text.Distinct().Count() < 3) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_TOO_OBVIOUS); return; } if (!System.Text.RegularExpressions.Regex.IsMatch(accountCreateTextBoxes[5].Text, //filter emails using regex @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b")) { EODialog.Show(DATCONST1.ACCOUNT_CREATE_EMAIL_INVALID); return; } AccountReply reply; if (!m_packetAPI.AccountCheckName(accountCreateTextBoxes[0].Text, out reply)) { LostConnectionDialog(); return; } if (reply != AccountReply.Continue) { EODialog.Show(m_packetAPI.AccountResponseMessage()); return; } //show progress bar for account creation pending and THEN create the account string pbmessage = World.Instance.DataFiles[World.Instance.Localized1].Data[(int)DATCONST1.ACCOUNT_CREATE_ACCEPTED + 1]; string pbcaption = World.Instance.DataFiles[World.Instance.Localized1].Data[(int)DATCONST1.ACCOUNT_CREATE_ACCEPTED]; EOProgressDialog dlg = new EOProgressDialog(pbmessage, pbcaption); dlg.DialogClosing += (dlg_S, dlg_E) => { if (dlg_E.Result != XNADialogResult.NO_BUTTON_PRESSED) { return; } if (!m_packetAPI.AccountCreate(accountCreateTextBoxes[0].Text, accountCreateTextBoxes[1].Text, accountCreateTextBoxes[3].Text, accountCreateTextBoxes[4].Text, accountCreateTextBoxes[5].Text, Config.GetHDDSerial(), out reply)) { LostConnectionDialog(); return; } DATCONST1 resource = m_packetAPI.AccountResponseMessage(); if (reply != AccountReply.Created) { EODialog.Show(resource); return; } doStateChange(GameStates.Initial); EODialog.Show(resource); }; } break; case GameStates.LoggedIn: { //Character_request: show create character dialog //Character_create: clicked ok in create character dialog CharacterReply reply; if (!m_packetAPI.CharacterRequest(out reply)) { LostConnectionDialog(); return; } if (reply != CharacterReply.Ok) { EODialog.Show("Server is not allowing you to create a character right now. This could be a bug.", "Server error"); return; } EOCreateCharacterDialog createCharacter = new EOCreateCharacterDialog(textBoxTextures[3], Dispatcher); createCharacter.DialogClosing += (dlg_S, dlg_E) => { if (dlg_E.Result != XNADialogResult.OK) { return; } CharacterRenderData[] dataArray; if (!m_packetAPI.CharacterCreate(createCharacter.Gender, createCharacter.HairType, createCharacter.HairColor, createCharacter.SkinColor, createCharacter.Name, out reply, out dataArray)) { LostConnectionDialog(); return; } if (reply != CharacterReply.Ok) { if (reply != CharacterReply.Full) { dlg_E.CancelClose = true; } EODialog.Show(m_packetAPI.CharacterResponseMessage()); return; } EODialog.Show(DATCONST1.CHARACTER_CREATE_SUCCESS); World.Instance.MainPlayer.ProcessCharacterData(dataArray); doShowCharacters(); }; } break; } } else if (sender == passwordChangeBtn) { EOChangePasswordDialog dlg = new EOChangePasswordDialog(textBoxTextures[3], Dispatcher); dlg.DialogClosing += (dlg_S, dlg_E) => { if (dlg_E.Result != XNADialogResult.OK) { return; } AccountReply reply; if (!m_packetAPI.AccountChangePassword(dlg.Username, dlg.OldPassword, dlg.NewPassword, out reply)) { LostConnectionDialog(); return; } EODialog.Show(m_packetAPI.AccountResponseMessage()); if (reply == AccountReply.ChangeSuccess) { return; } dlg_E.CancelClose = true; }; } }
private void _eventInviteToParty(object arg1, EventArgs arg2) { EODialog.Show("TODO: Invite this player to party", "TODO ITEM", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); }
//-------------------------- //***** HELPER METHODS ***** //-------------------------- private async Task TryConnectToServer(Action successAction) { //the mutex here should simulate the action of spamming the button. //no matter what, it will only do it one at a time: the mutex is only released when the bg thread ends if (connectMutex == null) { connectMutex = new AutoResetEvent(true); if (!connectMutex.WaitOne(0)) { return; } } else if (!connectMutex.WaitOne(0)) { return; } if (World.Instance.Client.ConnectedAndInitialized && World.Instance.Client.Connected) { successAction(); connectMutex.Set(); return; } //execute this logic on a separate thread so the game doesn't lock up while it's trying to connect to the server await TaskFramework.Run(() => { try { if (World.Instance.Client.ConnectToServer(host, port)) { m_packetAPI = new PacketAPI((EOClient)World.Instance.Client); //set up event packet handling event bindings: // some events are triggered by the server regardless of action by the client m_callbackManager = new PacketAPICallbackManager(m_packetAPI, this); m_callbackManager.AssignCallbacks(); ((EOClient)World.Instance.Client).EventDisconnect += () => m_packetAPI.Disconnect(); InitData data; if (m_packetAPI.Initialize(World.Instance.VersionMajor, World.Instance.VersionMinor, World.Instance.VersionClient, Win32.GetHDDSerial(), out data)) { switch (data.ServerResponse) { case InitReply.INIT_OK: ((EOClient)World.Instance.Client).SetInitData(data); if (!m_packetAPI.ConfirmInit(data.emulti_e, data.emulti_d, data.clientID)) { throw new Exception(); //connection failed! } World.Instance.MainPlayer.SetPlayerID(data.clientID); World.Instance.SetAPIHandle(m_packetAPI); successAction(); break; default: string extra; DATCONST1 msg = m_packetAPI.GetInitResponseMessage(out extra); EODialog.Show(msg, extra); break; } } else { throw new Exception(); //connection failed! } } else { //show connection not found throw new Exception(); } } catch { if (!exiting) { EODialog.Show(DATCONST1.CONNECTION_SERVER_NOT_FOUND); } } connectMutex.Set(); }); }
public override void Initialize() { base.Initialize(); //position for these: x=50, y = 8,26,44,... for (int i = 0; i < m_basicStats.Length; ++i) { m_basicStats[i] = new XNALabel(new Rectangle(50, 8 + i * 18, 73, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; m_basicStats[i].SetParent(this); m_arrows[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(106, 7 + i * 18), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15)) { Visible = false, //for testing - this should only be visible when statpoints > 0 FlashSpeed = 500 }; m_arrows[i].SetParent(this); m_arrows[i].IgnoreDialog(typeof(EOChestDialog)); m_arrows[i].IgnoreDialog(typeof(EOPaperdollDialog)); m_arrows[i].IgnoreDialog(typeof(EOLockerDialog)); m_arrows[i].IgnoreDialog(typeof(EOFriendIgnoreListDialog)); m_arrows[i].OnClick += (s, e) => { if (!m_training) { //apparently this is NOT stored in the edf files... EODialog dlg = new EODialog("Do you want to train?", "Character training", XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader); dlg.DialogClosing += (sender, args) => { if (args.Result != XNADialogResult.OK) { return; } m_training = true; }; } else { short index = (short)(m_arrows.ToList().FindIndex(_btn => _btn == s) + 1); //1-based index (server-side) if (!Handlers.StatSkill.AddStatPoint(index)) { EOGame.Instance.LostConnectionDialog(); } } }; } //x=158, y = 8, 26, 44, ... for (int i = 0; i < m_characterStats.Length; ++i) { m_characterStats[i] = new XNALabel(new Rectangle(158, 8 + i * 18, 73, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; m_characterStats[i].SetParent(this); } for (int i = 0; i < m_otherInfo.Length; ++i) { m_otherInfo[i] = new XNALabel(new Rectangle(i < 4 ? 280 : 379, 44 + (i % 4) * 18, i < 4 ? 60 : 94, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; m_otherInfo[i].SetParent(this); } //these labels have non-standard sizes so they're done individually //name= 280,8 144,13 m_charInfo[NAME] = new XNALabel(new Rectangle(280, 8, 144, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, Text = c.Name }; //guild = 280,26 193,13 m_charInfo[GUILD] = new XNALabel(new Rectangle(280, 26, 193, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, Text = c.GuildName }; //level = 453,8, 20,13 m_charInfo[LEVEL] = new XNALabel(new Rectangle(453, 8, 20, 13), "Microsoft Sans Serif", 8.5f) { Visible = true, ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8), AutoSize = false, }; foreach (XNALabel lbl in m_charInfo) { lbl.SetParent(this); } }
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(); } } }