public EOPartyPanel(XNAPanel parent) : base(null, null, parent) { _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height); m_removeTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 43); m_buttons = new List <XNAButton>(); //will tint this different colors for health bar and fill a rectangle m_healthBar = new Texture2D[4]; m_healthBar[HP_OUTLINE] = Game.Content.Load <Texture2D>("Party\\hp-outline"); m_healthBar[HP_RED] = Game.Content.Load <Texture2D>("Party\\hp-red"); m_healthBar[HP_YELLOW] = Game.Content.Load <Texture2D>("Party\\hp-yellow"); m_healthBar[HP_GREEN] = Game.Content.Load <Texture2D>("Party\\hp-green"); m_numMembers = new XNALabel(new Rectangle(455, 2, 27, 14), "Microsoft Sans Serif", 8.5f) { AutoSize = false, ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8), TextAlign = System.Drawing.ContentAlignment.MiddleRight }; m_numMembers.SetParent(this); m_scrollBar = new EOScrollBar(this, new Vector2(467, 20), new Vector2(16, 97), EOScrollBar.ScrollColors.LightOnMed) { LinesToRender = 7, Visible = true }; m_scrollBar.SetParent(this); World.IgnoreDialogs(m_scrollBar); }
/// <summary> /// This Constructor should be used for all values in ChatTabs /// </summary> public ChatTab(ChatTabs tab, EOChatRenderer parentRenderer, bool selected = false) : base(null, null, parentRenderer) { WhichTab = tab; tabLabel = new XNALabel(new Rectangle(14, 2, 1, 1), "Microsoft Sans Serif", 8.0f); tabLabel.SetParent(this); switch (WhichTab) { case ChatTabs.Local: tabLabel.Text = "scr"; break; case ChatTabs.Global: tabLabel.Text = "glb"; break; case ChatTabs.Group: tabLabel.Text = "grp"; break; case ChatTabs.System: tabLabel.Text = "sys"; break; case ChatTabs.Private1: case ChatTabs.Private2: tabLabel.Text = "[priv " + ((int)WhichTab + 1) + "]"; break; } _selected = selected; relativeTextPos = new Vector2(20, 3); //enable close button based on which tab was specified switch (WhichTab) { case ChatTabs.Private1: case ChatTabs.Private2: { closeRect = new Rectangle(3, 3, 11, 11); drawArea = new Rectangle(drawArea.X, drawArea.Y, 132, 16); Visible = false; } break; default: { closeRect = null; drawArea = new Rectangle(drawArea.X, drawArea.Y, 43, 16); Visible = true; } break; } //568 331 scrollBar = new EOScrollBar(parent, new Vector2(467, 2), new Vector2(16, 97), EOScrollBar.ScrollColors.LightOnMed) { Visible = selected, LinesToRender = 7 }; World.IgnoreDialogs(scrollBar); }
/// <summary> /// This constructor should be used for the news rendering /// </summary> public ChatTab(XNAControl parentControl) : base(null, null, parentControl) { WhichTab = ChatTabs.None; _selected = true; tabLabel = null; relativeTextPos = new Vector2(20, 23); //568 331 scrollBar = new EOScrollBar(parent, new Vector2(467, 20), new Vector2(16, 97), EOScrollBar.ScrollColors.LightOnMed) { LinesToRender = 7, Visible = true }; World.IgnoreDialogs(scrollBar); }
public EOOnlineList(XNAPanel parent) : base(null, null, parent) { m_onlineList = new List <ClientOnlineEntry>(); //this enables scrolling with mouse wheel and mouseover for parent _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height); m_totalNumPlayers = new XNALabel(new Rectangle(455, 2, 27, 14), "Microsoft Sans Serif", 8.5f) { AutoSize = false, ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8), TextAlign = System.Drawing.ContentAlignment.MiddleRight }; m_totalNumPlayers.SetParent(this); m_scrollBar = new EOScrollBar(this, new Vector2(467, 20), new Vector2(16, 97), EOScrollBar.ScrollColors.LightOnMed) { LinesToRender = 7, Visible = true }; m_scrollBar.SetParent(this); World.IgnoreDialogs(m_scrollBar); m_filterClick = new Rectangle(2 + DrawAreaWithOffset.X, 2 + DrawAreaWithOffset.Y, 14, 14); Texture2D weirdOffsets = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true); for (int i = 0; i < m_filterTextures.Length; ++i) { Rectangle offsetsSource = new Rectangle(i % 2 == 0 ? 0 : 12, i >= 2 ? 246 : 233, 12, 13); m_filterTextures[i] = new Texture2D(EOGame.Instance.GraphicsDevice, 12, 13); Color[] dat = new Color[12 * 13]; weirdOffsets.GetData(0, offsetsSource, dat, 0, dat.Length); m_filterTextures[i].SetData(dat); } }
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); }
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); } }
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); World.IgnoreDialogs(m_btnDrop); //'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); World.IgnoreDialogs(m_btnJunk); }