Ejemplo n.º 1
0
        private void _drawMiniMap()
        {
            Texture2D miniMapText = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 45, true);
            Character c           = World.Instance.MainPlayer.ActiveCharacter;

            _spriteBatch.Begin();
            for (int row = Math.Max(c.Y - 30, 0); row <= Math.Min(c.Y + 30, Map.Height); ++row)
            {
                for (int col = Math.Max(c.X - 30, 0); col <= Math.Min(c.Y + 30, Map.Width); ++col)
                {
                    Rectangle miniMapRectSrc = new Rectangle(0, 0, miniMapText.Width / 9, miniMapText.Height);
                    bool      isEdge         = false;
                    Vector2   loc            = _getMiniMapDrawCoordinates(col, row, c);
                    if (c.X == col && c.Y == row)
                    {
                        //draw orange thing
                        miniMapRectSrc.Offset((int)MiniMapGfx.Orange * miniMapRectSrc.Width, 0);
                    }
                    else
                    {
                        isEdge = _drawObjectAndActorIcons(col, row, ref miniMapRectSrc);
                    }

                    _drawGridBox(isEdge, miniMapText, loc, miniMapRectSrc);
                }
            }
            _spriteBatch.End();
        }
Ejemplo n.º 2
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Begin();
            SpriteBatch.Draw(topBar, new Vector2(49, 7), Color.White);
            SpriteBatch.Draw(mainFrame, Vector2.Zero, Color.White);
            SpriteBatch.Draw(topLeft, Vector2.Zero, Color.White);
            SpriteBatch.Draw(sidebar, new Vector2(7, 53), Color.White);
            SpriteBatch.Draw(sidebar, new Vector2(629, 53), new Rectangle(3, 0, 1, sidebar.Height), Color.White);
            //fill in some extra holes with black lines
            SpriteBatch.Draw(filler, new Rectangle(542, 0, 1, 8), Color.White);
            SpriteBatch.Draw(filler, new Rectangle(14, 329, 1, 142), Color.White);
            SpriteBatch.Draw(filler, new Rectangle(98, 479, 445, 1), Color.White);

            //show the little graphic next
            if (currentChatMode != ChatMode.NoText && !modeTextureLoaded)
            {
                Texture2D chatModeTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 31);
                int       oneMode         = chatModeTexture.Height / 8;
                Color[]   data            = new Color[chatModeTexture.Width * oneMode];  //there are 8 chat mode graphics in the texture
                chatModeTexture.GetData(0, new Rectangle(0, (int)currentChatMode * oneMode, chatModeTexture.Width, oneMode), data, 0,
                                        data.Length);
                modeTexture = new Texture2D(Game.GraphicsDevice, chatModeTexture.Width, oneMode);
                modeTexture.SetData(data);
                modeTextureLoaded = true;
            }

            if (modeTextureLoaded && modeTexture != null)
            {
                SpriteBatch.Draw(modeTexture, new Vector2(16, 309), Color.White);
            }

            SpriteBatch.End();

            base.Draw(gameTime);
        }
Ejemplo n.º 3
0
        public Texture2D GetFace(out XNA.Rectangle faceRect)
        {
            if (charRef.State != CharacterActionState.Emote ||
                _data.emote == Emote.Trade || _data.emote == Emote.LevelUp)
            {
                faceRect = new XNA.Rectangle();
                return(null);
            }

            //14 rows (7 female - 7 male) / 11 columns
            const int ROWS = 14;
            const int COLS = 11;

            Texture2D face = GFXLoader.TextureFromResource(GFXTypes.SkinSprites, 8, true);

            int widthDelta   = face.Width / COLS;
            int heightDelta  = face.Height / ROWS;
            int genderOffset = (face.Height / 2) * _data.gender;
            //'playful' is the last face in the gfx (ndx 10), even though it has enum value of 14 (ndx 13)
            int emote = _data.emote == Emote.Playful || _data.emote == Emote.Drunk ? 10 : (int)_data.emote - 1;

            faceRect = new XNA.Rectangle(widthDelta * emote, heightDelta * _data.race + genderOffset, widthDelta, heightDelta);

            return(face);
        }
Ejemplo n.º 4
0
        public Texture2D GetWeapon(bool isBow = false)
        {
            WeaponSpriteType type = WeaponSpriteType.Standing;

            switch (charRef.State)
            {
            case CharacterActionState.Walking:
                switch (_data.walkFrame)
                {
                case 1: type = WeaponSpriteType.WalkFrame1; break;

                case 2: type = WeaponSpriteType.WalkFrame2; break;

                case 3: type = WeaponSpriteType.WalkFrame3; break;

                case 4: type = WeaponSpriteType.WalkFrame4; break;
                }
                break;

            case CharacterActionState.Attacking:
                if (isBow)
                {
                    switch (_data.attackFrame)
                    {
                    case 1: type = WeaponSpriteType.Shooting; break;

                    case 2: type = WeaponSpriteType.Standing; break;
                    }
                }
                else
                {
                    switch (_data.attackFrame)
                    {
                    case 1: type = WeaponSpriteType.SwingFrame1; break;

                    case 2:
                        type = _data.facing == EODirection.Down || _data.facing == EODirection.Right
                                                                        ? WeaponSpriteType.SwingFrame2Spec
                                                                        : WeaponSpriteType.SwingFrame2;
                        break;
                    }
                }
                break;

            case CharacterActionState.SpellCast:
                type = WeaponSpriteType.SpellCast;
                break;

            case CharacterActionState.Sitting: return(null);                    //no weapon when sitting
            }

            short    baseWeaponValue = (short)((_data.weapon - 1) * 100);
            GFXTypes gfxFile         = _data.gender == 0 ? GFXTypes.FemaleWeapons : GFXTypes.MaleWeapons;
            int      factor          = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 1;

            factor *= getFactor(type);
            int gfxNumber = baseWeaponValue + (int)type + factor;

            return(GFXLoader.TextureFromResource(gfxFile, gfxNumber, true));
        }
Ejemplo n.º 5
0
        public EOInventoryItem(PacketAPI api, int slot, ItemRecord itemData, InventoryItem itemInventoryInfo, EOInventory inventory)
            : base(null, null, inventory)
        {
            m_api       = api;
            m_itemData  = itemData;
            m_inventory = itemInventoryInfo;
            Slot        = slot;

            UpdateItemLocation(Slot);

            m_itemgfx = GFXLoader.TextureFromResource(GFXTypes.Items, 2 * itemData.Graphic, true);

            m_highlightBG = new Texture2D(Game.GraphicsDevice, DrawArea.Width - 3, DrawArea.Height - 3);
            Color[] highlight = new Color[(drawArea.Width - 3) * (drawArea.Height - 3)];
            for (int i = 0; i < highlight.Length; ++i)
            {
                highlight[i] = Color.FromNonPremultiplied(200, 200, 200, 60);
            }
            m_highlightBG.SetData(highlight);

            _initItemLabel();

            m_recentClickTimer = new Timer(
                _state => { if (m_recentClickCount > 0)
                            {
                                Interlocked.Decrement(ref m_recentClickCount);
                            }
                }, null, 0, 1000);
        }
Ejemplo n.º 6
0
        protected override void LoadContent()
        {
            //the content (pun intended) of this method is organized by the control being instantiated
            //maybe split it off into separate "helper" functions for organization? :-/

            spriteBatch = new SpriteBatch(GraphicsDevice);

            DBGFont = Content.Load <SpriteFont>("dbg");

            //texture for UI background image
            UIBackground = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 30 + gen.Next(7));

            PeopleSetOne = new Texture2D[4];
            PeopleSetTwo = new Texture2D[8];
            //the large character drawings
            for (int i = 1; i <= 4; ++i)
            {
                PeopleSetOne[i - 1] = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 40 + i, true);
                //8 graphics in the second set of people: 61-68
                PeopleSetTwo[i - 1] = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 60 + i, true);
                PeopleSetTwo[i + 3] = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 64 + i, true);
            }

            //the username/password prompt background
            LoginUIScreen = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 2);
            //the character display background w/o login+delete buttons
            CharacterDisp = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 11);
            //the account create sheet w/labels for text fields
            AccountCreateSheet = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 12, true);

            InitializeControls();
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the hair texture from the GFX file based on gender, direction, style, and color
        /// </summary>
        /// <param name="refresh">True to refresh from the GFX file, false to use the hair texture cached in this EOSpriteSheet instance</param>
        /// <returns>Texture2D with the hair data</returns>
        public Texture2D GetHair(bool refresh)
        {
            byte     turnedOffset = (byte)((_data.facing == EODirection.Left || _data.facing == EODirection.Up) ? 2 : 0);
            GFXTypes gfxFile      = (_data.gender == 0) ? GFXTypes.FemaleHair : GFXTypes.MaleHair;
            int      gfxNumber    = 2 + ((_data.hairstyle - 1) * 40) + (_data.haircolor * 4) + turnedOffset;

            return(GFXLoader.TextureFromResource(gfxFile, gfxNumber, true, refresh));
        }
Ejemplo n.º 9
0
        public Texture2D GetHat()
        {
            short    baseHatValue = (short)((_data.hat - 1) * 10);
            GFXTypes gfxFile      = _data.gender == 0 ? GFXTypes.FemaleHat : GFXTypes.MaleHat;
            int      factor       = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 2;
            int      gfxNumber    = baseHatValue + factor + 1;

            return(GFXLoader.TextureFromResource(gfxFile, gfxNumber, true));
        }
Ejemplo n.º 10
0
        public override void Draw(GameTime gameTime)
        {
            SpriteBatch.Begin();
            //264 16 43x16
            //307 16 43x16

            //the parent renderer draws all the tabs
            foreach (ChatTab t in tabs)
            {
                Texture2D drawTexture;
                Color[]   data;
                switch (t.WhichTab)
                {
                case ChatTabs.Local:                         //391 433 need to see if this should be relative to top-left of existing chat panel or absolute from top-left of game screen
                case ChatTabs.Global:
                case ChatTabs.Group:
                case ChatTabs.System:
                {
                    data        = new Color[43 * 16];
                    drawTexture = new Texture2D(Game.GraphicsDevice, 43, 16);
                    GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 35).GetData(0, t.Selected ? new Rectangle(307, 16, 43, 16) : new Rectangle(264, 16, 43, 16), data, 0, data.Length);
                    drawTexture.SetData(data);
                }
                break;

                case ChatTabs.Private1:
                case ChatTabs.Private2:
                {
                    if (t.Visible)
                    {
                        data        = new Color[132 * 16];
                        drawTexture = new Texture2D(Game.GraphicsDevice, 132, 16);
                        GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 35).GetData(0, t.Selected ? new Rectangle(132, 16, 132, 16) : new Rectangle(0, 16, 132, 16), data, 0, data.Length);
                        drawTexture.SetData(data);
                    }
                    else
                    {
                        drawTexture = null;
                    }
                }
                break;

                default:
                    throw new InvalidOperationException("This is not a valid enumeration for WhichTab");
                }
                if (drawTexture != null)
                {
                    SpriteBatch.Draw(drawTexture, new Vector2(t.DrawAreaWithOffset.X, t.DrawAreaWithOffset.Y), Color.White);
                }
            }
            SpriteBatch.End();

            base.Draw(gameTime);
        }
Ejemplo n.º 11
0
        public static Texture2D GetSpellIcon(short icon, bool hover)
        {
            Texture2D fullTexture = GFXLoader.TextureFromResource(GFXTypes.SpellIcons, icon);
            Texture2D ret         = new Texture2D(fullTexture.GraphicsDevice, fullTexture.Width / 2, fullTexture.Height);

            Color[] data = new Color[ret.Width * ret.Height];
            fullTexture.GetData(0, new Rectangle(hover ? ret.Width : 0, 0, ret.Width, ret.Height), data, 0, data.Length);
            ret.SetData(data);

            return(ret);
        }
Ejemplo n.º 12
0
        public Texture2D GetEmote(out XNA.Rectangle emoteRect)
        {
            emoteRect = new XNA.Rectangle();
            if (charRef.State != CharacterActionState.Emote)
            {
                return(null);
            }

            const int NUM_EMOTES = 15;
            const int NUM_FRAMES = 4;

            int convertedEmote = 0;

            switch (_data.emote)
            {
            case Emote.Happy: /*0*/ break;

            case Emote.Depressed: convertedEmote = 7; break;

            case Emote.Sad: convertedEmote = 1; break;

            case Emote.Angry: convertedEmote = 5; break;

            case Emote.Confused: convertedEmote = 3; break;

            case Emote.Surprised: convertedEmote = 2; break;

            case Emote.Hearts: convertedEmote = 6; break;

            case Emote.Moon: convertedEmote = 4; break;

            case Emote.Suicidal: convertedEmote = 9; break;

            case Emote.Embarassed: convertedEmote = 8; break;

            case Emote.Drunk:
            case Emote.Trade:
            case Emote.LevelUp:
            case Emote.Playful: convertedEmote = (int)_data.emote - 1; break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Texture2D emote     = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 38, true);
            int       eachSet   = emote.Width / NUM_EMOTES;
            int       eachFrame = emote.Width / (NUM_EMOTES * NUM_FRAMES);

            emoteRect = new XNA.Rectangle((convertedEmote * eachSet) + (_data.emoteFrame * eachFrame), 0, eachFrame, emote.Height);

            return(emote);
        }
Ejemplo n.º 13
0
        public static Texture2D GetChatIcon(ChatType type)
        {
            Texture2D ret = new Texture2D(EOGame.Instance.GraphicsDevice, 13, 13);

            if (type == ChatType.None)
            {
                return(ret);
            }

            Color[] data = new Color[169];             //each icon is 13x13
            GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 32, true).GetData(0, new Rectangle(0, (int)type * 13, 13, 13), data, 0, 169);
            ret.SetData(data);

            return(ret);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// This constructor makes the DamageCounter follow 'actor' on the screen.
        /// </summary>
        /// <param name="actor">EOCharacterRenderer or NPC</param>
        /// <param name="actorType">actor.GetType()</param>
        public DamageCounter(DrawableGameComponent actor, Type actorType)
        {
            m_ref = actor;
            if (actorType == typeof(NPC))
            {
                m_isCharacter = false;
            }
            else if (actorType == typeof(EOCharacterRenderer))
            {
                m_isCharacter = true;
            }
            else
            {
                throw new ArgumentException("Invalid actor type. Use Character or NPC", "actorType");
            }

            lock (gfx_init_lock)
            {
                Texture2D wholeSheet = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
                //lazy init of spritesheet - static so same texture in use for all damage counters
                //this sheet is a subsheet of GFX002/158 that has only the numbers and 'miss' text
                if (s_NumberSprites == null)
                {
                    Color[] data = new Color[122 * 23];
                    wholeSheet.GetData(0, new Rectangle(41, 29, 122, 23), data, 0, data.Length);

                    s_NumberSprites = new Texture2D(Game.GraphicsDevice, 122, 23);
                    s_NumberSprites.SetData(data);
                }

                //same with health bars - subsheet of GFX002/158 that has only the health bars
                if (s_HealthBarSprites == null)
                {
                    Color[] data = new Color[40 * 35];
                    wholeSheet.GetData(0, new Rectangle(0, 28, 40, 35), data, 0, data.Length);

                    s_HealthBarSprites = new Texture2D(Game.GraphicsDevice, 40, 35);
                    s_HealthBarSprites.SetData(data);
                }
            }

            m_numbersToDraw = new List <Rectangle>();
            Visible         = false;
            if (!Game.Components.Contains(this))
            {
                Game.Components.Add(this);
            }
        }
Ejemplo n.º 15
0
        public Texture2D GetNPCTexture()
        {
            EODirection dir     = npc.Direction;
            int         baseGfx = (npc.Data.Graphic - 1) * 40;
            int         offset;

            switch (npc.Frame)
            {
            case NPCFrame.Standing:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 1 : 3;
                break;

            case NPCFrame.StandingFrame1:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 2 : 4;
                break;

            case NPCFrame.WalkFrame1:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 5 : 9;
                break;

            case NPCFrame.WalkFrame2:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 6 : 10;
                break;

            case NPCFrame.WalkFrame3:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 7 : 11;
                break;

            case NPCFrame.WalkFrame4:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 8 : 12;
                break;

            case NPCFrame.Attack1:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 13 : 15;
                break;

            case NPCFrame.Attack2:
                offset = dir == EODirection.Down || dir == EODirection.Right ? 14 : 16;
                break;

            default:
                return(null);
            }

            return(GFXLoader.TextureFromResource(GFXTypes.NPC, baseGfx + offset, true));
        }
Ejemplo n.º 16
0
        public Texture2D GetBoots(bool isBow = false)
        {
            BootsSpriteType type = BootsSpriteType.Standing;

            switch (charRef.State)
            {
            case CharacterActionState.Walking:
                switch (_data.walkFrame)
                {
                case 1: type = BootsSpriteType.WalkFrame1; break;

                case 2: type = BootsSpriteType.WalkFrame2; break;

                case 3: type = BootsSpriteType.WalkFrame3; break;

                case 4: type = BootsSpriteType.WalkFrame4; break;
                }
                break;

            case CharacterActionState.Attacking:
                if (!isBow && _data.attackFrame == 2 ||
                    isBow && _data.attackFrame == 1)
                {
                    type = BootsSpriteType.Attack;
                }
                break;

            case CharacterActionState.Sitting:
                switch (_data.sitting)
                {
                case SitState.Chair: type = BootsSpriteType.SitChair; break;

                case SitState.Floor: type = BootsSpriteType.SitGround; break;
                }
                break;
            }
            short    baseBootsValue = (short)((_data.boots - 1) * 40);
            GFXTypes gfxFile        = _data.gender == 0 ? GFXTypes.FemaleShoes : GFXTypes.MaleShoes;
            int      factor         = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 1;

            factor *= getFactor(type);
            int gfxNumber = baseBootsValue + (int)type + factor;

            return(GFXLoader.TextureFromResource(gfxFile, gfxNumber, true));
        }
Ejemplo n.º 17
0
        protected HUDElement()
        {
            m_stats = World.Instance.MainPlayer.ActiveCharacter.Stats;

            m_textSheet      = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
            m_elemSourceRect = new Rectangle(0, 0, 110, 14);

            if (!Game.Components.Contains(this))
            {
                Game.Components.Add(this);
            }

            m_label = new XNALabel(drawArea.SetPosition(new Vector2(2, 14)), "Microsoft Sans Serif", 8.0f)
            {
                AutoSize  = false,
                BackColor = System.Drawing.Color.Transparent,
                ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                Visible   = false
            };
            m_label.SetParent(this);
        }
Ejemplo n.º 18
0
        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);
            m_scrollBar.IgnoreDialog(typeof(EOPaperdollDialog));
            m_scrollBar.IgnoreDialog(typeof(EOChestDialog));

            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);
            }
        }
Ejemplo n.º 19
0
        private KeyLayout m_keyboard = KeyLayout.English;         //this is not stored or loaded

        //parent x,y - 102,330
        public EOSettingsPanel(XNAPanel parent)
            : base(null, null, parent)
        {
            _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height);

            w           = World.Instance;
            m_leftSide  = new XNALabel[5];
            m_rightSide = new XNALabel[5];

            for (int i = 0; i < m_leftSide.Length; ++i)
            {
                m_leftSide[i] = new XNALabel(new Rectangle(117, 25 + (18 * i), 100, 15), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8)
                };
                m_leftSide[i].SetParent(this);
                m_rightSide[i] = new XNALabel(new Rectangle(356, 25 + (18 * i), 100, 15), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8)
                };
                m_rightSide[i].SetParent(this);
            }

            _setTextForLanguage();

            m_buttons = new XNAButton[10];
            for (int i = 0; i < m_buttons.Length; ++i)
            {
                m_buttons[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true),
                                             new Vector2(i < 5 ? 215 : 454, 25 + (18 * (i % 5))),
                                             new Rectangle(0, 0, 19, 15),
                                             new Rectangle(19, 0, 19, 15));

                m_buttons[i].SetParent(this);
                m_buttons[i].OnClick     += _settingChange;
                m_buttons[i].OnMouseOver += (o, e) => EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE);
            }
        }
Ejemplo n.º 20
0
        public EOMapContextMenu(PacketAPI api)
        {
            m_api = api;
            //first, load up the images. split in half: the right half is the 'over' text
            Texture2D bgImage = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 41, true);

            //this GFX is stupid. a bunch of white space throws off coordinates so I have to use hard-coded values
            const int W = 96, H = 137;

            Color[] dat = new Color[W * H];
            m_bg     = new Texture2D(EOGame.Instance.GraphicsDevice, W, H);
            m_bgOver = new Texture2D(EOGame.Instance.GraphicsDevice, W, H);

            bgImage.GetData(0, new Rectangle(0, 0, W, H), dat, 0, dat.Length);
            m_bg.SetData(dat);

            bgImage.GetData(0, new Rectangle(W, 0, W, H), dat, 0, dat.Length);
            m_bgOver.SetData(dat);

            //define regions for clicking and their associated actions
            //6,11,86,14
            for (int i = 0; i < (int)MenuAction.NUM_MENU_ACTIONS; ++i)
            {
                Rectangle region = new Rectangle(6, (i < 5 ? 11 : 13) + 14 * i, 86, 14);
                m_menuActions.Add(region, _getActionFromMenuAction((MenuAction)i));
            }

            //set the fill color
            m_fill = new Texture2D(EOGame.Instance.GraphicsDevice, 1, 1);
            m_fill.SetData(new [] { Color.White });

            //set default control stuff;
            _setSize(W, H);
            Visible = false;
            SetParent(null);
        }
Ejemplo n.º 21
0
        private void InitializeControls(bool reinit = false)
        {
            //set up text boxes for login
            textBoxTextures[0] = Content.Load <Texture2D>("tbBack");
            textBoxTextures[1] = Content.Load <Texture2D>("tbLeft");
            textBoxTextures[2] = Content.Load <Texture2D>("tbRight");
            textBoxTextures[3] = Content.Load <Texture2D>("cursor");

            loginUsernameTextbox = new XNATextBox(new Rectangle(402, 322, 140, textBoxTextures[0].Height), textBoxTextures, "Microsoft Sans Serif", 8.0f)
            {
                MaxChars    = 16,
                DefaultText = "Username",
                LeftPadding = 4
            };
            loginUsernameTextbox.OnTabPressed   += OnTabPressed;
            loginUsernameTextbox.OnClicked      += OnTextClicked;
            loginUsernameTextbox.OnEnterPressed += (s, e) => MainButtonPress(loginButtons[0], e);
            Dispatcher.Subscriber = loginUsernameTextbox;

            loginPasswordTextbox = new XNATextBox(new Rectangle(402, 358, 140, textBoxTextures[0].Height), textBoxTextures, "Microsoft Sans Serif", 8.0f)
            {
                MaxChars    = 12,
                PasswordBox = true,
                LeftPadding = 4,
                DefaultText = "Password"
            };
            loginPasswordTextbox.OnTabPressed   += OnTabPressed;
            loginPasswordTextbox.OnClicked      += OnTextClicked;
            loginPasswordTextbox.OnEnterPressed += (s, e) => MainButtonPress(loginButtons[0], e);

            //set up primary four login buttons
            Texture2D mainButtonSheet = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 13, true);

            for (int i = 0; i < mainButtons.Length; ++i)
            {
                int       widthFactor  = mainButtonSheet.Width / 2;                   //2: mouseOut and mouseOver textures
                int       heightFactor = mainButtonSheet.Height / mainButtons.Length; //1 row per button
                Rectangle outSource    = new Rectangle(0, i * heightFactor, widthFactor, heightFactor);
                Rectangle overSource   = new Rectangle(widthFactor, i * heightFactor, widthFactor, heightFactor);
                mainButtons[i]          = new XNAButton(mainButtonSheet, new Vector2(26, 278 + i * 40), outSource, overSource);
                mainButtons[i].OnClick += MainButtonPress;
            }

            //the button in the top-right for going back a screen
            Texture2D back = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 24, true);

            backButton = new XNAButton(back, new Vector2(589, 0), new Rectangle(0, 0, back.Width, back.Height / 2),
                                       new Rectangle(0, back.Height / 2, back.Width, back.Height / 2));
            backButton.OnClick  += MainButtonPress;
            backButton.ClickArea = new Rectangle(4, 16, 16, 16);

            //Login/Cancel buttons for logging in
            Texture2D smallButtonSheet = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 15, true);

            loginButtons[0]          = new XNAButton(smallButtonSheet, new Vector2(361, 389), new Rectangle(0, 0, 91, 29), new Rectangle(91, 0, 91, 29));
            loginButtons[1]          = new XNAButton(smallButtonSheet, new Vector2(453, 389), new Rectangle(0, 29, 91, 29), new Rectangle(91, 29, 91, 29));
            loginButtons[0].OnClick += MainButtonPress;
            loginButtons[1].OnClick += MainButtonPress;

            //6 text boxes (by default) for creating a new account.
            for (int i = 0; i < accountCreateTextBoxes.Length; ++i)
            {
                //holy f**k! magic numbers!
                //basically, set the first  3 Y coord to start at 69  and move up by 51 each time
                //			 set the second 3 Y coord to start at 260 and move up by 51 each time
                int        txtYCoord = (i < 3 ? 69 : 260) + (i < 3 ? i * 51 : (i - 3) * 51);
                XNATextBox txt       = new XNATextBox(new Rectangle(358, txtYCoord, 240, textBoxTextures[0].Height), textBoxTextures, "Microsoft Sans Serif", 8.5f);

                switch (i)
                {
                case 0:
                    txt.MaxChars = 16;
                    break;

                case 1:
                case 2:
                    txt.PasswordBox = true;
                    txt.MaxChars    = 12;
                    break;

                default:
                    txt.MaxChars = 35;
                    break;
                }

                txt.DefaultText = " ";

                txt.OnTabPressed         += OnTabPressed;
                txt.OnClicked            += OnTextClicked;
                accountCreateTextBoxes[i] = txt;
            }


            //create account / cancel
            Texture2D secondaryButtons = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 14, true);

            createButtons[0]          = new XNAButton(secondaryButtons, new Vector2(359, 417), new Rectangle(0, 0, 120, 40), new Rectangle(120, 0, 120, 40));
            createButtons[1]          = new XNAButton(secondaryButtons, new Vector2(481, 417), new Rectangle(0, 40, 120, 40), new Rectangle(120, 40, 120, 40));
            createButtons[0].OnClick += MainButtonPress;
            createButtons[1].OnClick += MainButtonPress;

            passwordChangeBtn          = new XNAButton(secondaryButtons, new Vector2(454, 417), new Rectangle(0, 120, 120, 40), new Rectangle(120, 120, 120, 40));
            passwordChangeBtn.OnClick += MainButtonPress;

            lblCredits = new XNALabel(new Rectangle(300, 260, 1, 1))
            {
                Text = @"Endless Online - C# Client
Developed by Ethan Moffat
Based on Endless Online --
Copyright Vult-R

Thanks to :
--Sausage for eoserv + C# EO libs
--eoserv.net community
--Hotdog for Eodev client"
            };

            lblVersionInfo = new XNALabel(new Rectangle(30, 457, 1, 1))
            {
                Text      = string.Format("{0}.{1:000}.{2:000} - {3}:{4}", World.Instance.VersionMajor, World.Instance.VersionMinor, World.Instance.VersionClient, host, port),
                Font      = new System.Drawing.Font("Microsoft Sans Serif", 7.0f),
                ForeColor = System.Drawing.Color.FromArgb(0xFF, 0xb4, 0xa0, 0x8c)
            };

            //login/delete buttons for each character
            for (int i = 0; i < 3; ++i)
            {
                loginCharButtons[i]           = new XNAButton(smallButtonSheet, new Vector2(495, 93 + i * 124), new Rectangle(0, 58, 91, 29), new Rectangle(91, 58, 91, 29));
                loginCharButtons[i].OnClick  += CharModButtonPress;
                deleteCharButtons[i]          = new XNAButton(smallButtonSheet, new Vector2(495, 121 + i * 124), new Rectangle(0, 87, 91, 29), new Rectangle(91, 87, 91, 29));
                deleteCharButtons[i].OnClick += CharModButtonPress;
            }

            //hide all the components to start with
            foreach (IGameComponent iGameComp in Components)
            {
                DrawableGameComponent component = iGameComp as DrawableGameComponent;
                //don't hide dialogs if reinitializing
                if (reinit && (XNAControl.Dialogs.Contains(component as XNAControl) ||
                               (component as XNAControl != null && XNAControl.Dialogs.Contains((component as XNAControl).TopParent))))
                {
                    continue;
                }

                //...except for the four main buttons
                if (component != null && !mainButtons.Contains(component as XNAButton))
                {
                    component.Visible = false;
                }
            }
            lblVersionInfo.Visible = true;

#if DEBUG
            //testinggame will login as testuser and login as the first character
            XNAButton testingame = new XNAButton(new Vector2(5, 5), "in-game");
            testingame.OnClick += (s, e) => new Thread(() =>
            {
                MainButtonPress(mainButtons[1], e);                 //press login
                Thread.Sleep(500);
                if (!World.Instance.Client.ConnectedAndInitialized)
                {
                    return;
                }
                loginUsernameTextbox.Text = "testuser";
                loginPasswordTextbox.Text = "testuser";

                MainButtonPress(loginButtons[0], e);                 //login as acc testuser
                Thread.Sleep(500);
                CharModButtonPress(loginCharButtons[0], e);          //login as char testuser
            }).Start();
#endif
        }
Ejemplo n.º 22
0
        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));
        }
Ejemplo n.º 23
0
        public Texture2D GetSkin(bool isBow, out XNA.Rectangle skinRect)
        {
            const byte sheetRows    = 7;
            byte       sheetColumns = 4;
            byte       gfxNum       = 1;

            //change up which gfx resource to load, and the size of the resource, based on the _data
            if (charRef.State == CharacterActionState.Walking && _data.walkFrame > 0)
            {
                //walking
                gfxNum       = 2;
                sheetColumns = 16;
            }
            else if (charRef.State == CharacterActionState.Attacking && _data.attackFrame > 0)
            {
                if (!isBow)
                {
                    //attacking
                    gfxNum       = 3;
                    sheetColumns = 8;
                }
                else if (_data.attackFrame == 1)    //only 1 frame of bow/gun animation
                {
                    gfxNum = 7;                     //4 columns in this one too
                }
            }
            else if (charRef.State == CharacterActionState.SpellCast)
            {
                gfxNum = 4;
            }
            else if (charRef.State == CharacterActionState.Sitting)
            {
                if (_data.sitting == SitState.Floor)
                {
                    gfxNum = 6;
                }
                else if (_data.sitting == SitState.Chair)
                {
                    gfxNum = 5;
                }
            }
            //similar if statements for spell, emote, etc

            bool      rotated     = _data.facing == EODirection.Left || _data.facing == EODirection.Up;
            Texture2D sheet       = GFXLoader.TextureFromResource(GFXTypes.SkinSprites, gfxNum, true);
            int       heightDelta = sheet.Height / sheetRows;   //the height of one 'row' in the sheet
            int       widthDelta  = sheet.Width / sheetColumns; //the width of one 'column' in the sheet
            int       section     = sheet.Width / 4;            //each 'section' for a different set of graphics

            int walkExtra = _data.walkFrame > 0 ? widthDelta * (_data.walkFrame - 1) : 0;

            walkExtra = !isBow && _data.attackFrame > 0 ? widthDelta * (_data.attackFrame - 1) : walkExtra;

            skinRect = new XNA.Rectangle(
                _data.gender * widthDelta * (sheetColumns / 2) + (rotated ? section : 0) + walkExtra,
                _data.race * heightDelta,
                widthDelta,
                heightDelta);

            return(sheet);
        }
Ejemplo n.º 24
0
        public Texture2D GetShield(bool shieldIsOnBack)
        {
            //front shields have one size gfx, back arrows/wings have another size.
            ArmorShieldSpriteType type = ArmorShieldSpriteType.Standing;
            int factor;

            if (!shieldIsOnBack)
            {
                if (charRef.State == CharacterActionState.Walking)
                {
                    switch (_data.walkFrame)
                    {
                    case 1: type = ArmorShieldSpriteType.WalkFrame1; break;

                    case 2: type = ArmorShieldSpriteType.WalkFrame2; break;

                    case 3: type = ArmorShieldSpriteType.WalkFrame3; break;

                    case 4: type = ArmorShieldSpriteType.WalkFrame4; break;
                    }
                }
                else if (charRef.State == CharacterActionState.Attacking)
                {
                    switch (_data.attackFrame)
                    {
                    case 1: type = ArmorShieldSpriteType.PunchFrame1; break;

                    case 2: type = ArmorShieldSpriteType.PunchFrame2; break;
                    }
                }
                else if (charRef.State == CharacterActionState.SpellCast)
                {
                    type = ArmorShieldSpriteType.SpellCast;
                }
                else
                {
                    //hide shield graphic when sitting
                    return(null);
                }

                factor  = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 1;
                factor *= getFactor(type);
            }
            else
            {
                //sitting is valid for arrows and wings and bag
                //Standing = 1/2
                //Attacking = 3/4
                //Extra = 5 (unused?)
                if (charRef.State == CharacterActionState.Attacking && _data.attackFrame == 1)
                {
                    type = (ArmorShieldSpriteType)3;
                }
                factor = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 1;
            }

            short    baseShieldValue = (short)((_data.shield - 1) * 50);
            GFXTypes gfxFile         = _data.gender == 0 ? GFXTypes.FemaleBack : GFXTypes.MaleBack;
            int      gfxNumber       = baseShieldValue + (int)type + factor;

            return(GFXLoader.TextureFromResource(gfxFile, gfxNumber, true));
        }
Ejemplo n.º 25
0
        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);
            }
        }
Ejemplo n.º 26
0
        //-------------------
        //***** CLEANUP *****
        //-------------------

        protected override void Dispose(bool disposing)
        {
            if (!World.Initialized)
            {
                return;
            }

            if (World.Instance.Client.ConnectedAndInitialized)
            {
                World.Instance.Client.Disconnect();
            }

            if (loginUsernameTextbox != null)
            {
                loginUsernameTextbox.Dispose();
            }
            if (loginPasswordTextbox != null)
            {
                loginPasswordTextbox.Dispose();
            }

            foreach (XNAButton btn in mainButtons)
            {
                if (btn != null)
                {
                    btn.Dispose();
                }
            }
            foreach (XNAButton btn in loginButtons)
            {
                if (btn != null)
                {
                    btn.Dispose();
                }
            }
            foreach (XNAButton btn in createButtons)
            {
                if (btn != null)
                {
                    btn.Dispose();
                }
            }

            foreach (XNAButton btn in loginCharButtons)
            {
                if (btn != null)
                {
                    btn.Dispose();
                }
            }

            if (passwordChangeBtn != null)
            {
                passwordChangeBtn.Dispose();
            }

            if (backButton != null)
            {
                backButton.Dispose();
            }

            if (lblCredits != null)
            {
                lblCredits.Dispose();
            }

            foreach (XNATextBox btn in accountCreateTextBoxes)
            {
                if (btn != null)
                {
                    btn.Dispose();
                }
            }

            if (spriteBatch != null)
            {
                spriteBatch.Dispose();
            }
            ((IDisposable)graphics).Dispose();

            if (lblVersionInfo != null)
            {
                lblVersionInfo.Dispose();
            }

            if (connectMutex != null)
            {
                connectMutex.Dispose();
            }

            GFXLoader.Cleanup();

            World.Instance.Dispose();

            base.Dispose(disposing);
        }
Ejemplo n.º 27
0
        protected override void Initialize()
        {
            try
            {
                //yup. class named the same as a namespace. #whut #rekt
                XNAControls.XNAControls.Initialize(this);
            }
            catch (ArgumentNullException ex)
            {
                MessageBox.Show("Something super weird happened: " + ex.Message);
                Exit();
                return;
            }

            IsMouseVisible = true;
            Dispatcher     = new KeyboardDispatcher(Window);
            ResetPeopleIndices();

            try
            {
                GFXLoader.Initialize(GraphicsDevice);
                World w = World.Instance;                 //set up the world
                w.Init();

                host = World.Instance.Host;
                port = World.Instance.Port;
            }
            catch (WorldLoadException wle)             //could be thrown from World's constructor
            {
                MessageBox.Show(wle.Message, "Error");
                Exit();
                return;
            }
            catch (ConfigStringLoadException csle)
            {
                host = World.Instance.Host;
                port = World.Instance.Port;
                switch (csle.WhichString)
                {
                case ConfigStrings.Host:
                    MessageBox.Show(
                        string.Format("There was an error loading the host/port from the config file. Defaults will be used: {0}:{1}",
                                      host, port),
                        "Config Load Failed",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    break;

                case ConfigStrings.Port:
                    MessageBox.Show(
                        string.Format("There was an error loading the port from the config file. Default will be used: {0}:{1}",
                                      host, port),
                        "Config Load Failed",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);
                    break;
                }
            }
            catch (ArgumentException ex)             //could be thrown from GFXLoader.Initialize
            {
                MessageBox.Show("Error initializing GFXLoader: " + ex.Message, "Error");
                Exit();
                return;
            }

            if (World.Instance.EIF != null && World.Instance.EIF.Version == 0)
            {
                MessageBox.Show("The item pub file you are using is using an older format of the EIF specification. Some features may not work properly. Run the file through a batch processor or use updated pub files.", "Warning");
            }

            GFXTypes curValue = 0;

            try
            {
                Array values = Enum.GetValues(typeof(GFXTypes));
                foreach (GFXTypes value in values)
                {
                    curValue = value;
                    //check for GFX files. Each file has a GFX 1.
                    using (Texture2D throwAway = GFXLoader.TextureFromResource(value, -99))
                    {
                        throwAway.Name = "";                         //no-op to keep resharper happy
                    }
                }
            }
            catch
            {
                MessageBox.Show(string.Format("There was an error loading GFX{0:000}.EGF : {1}. Place all .GFX files in .\\gfx\\", (int)curValue, curValue.ToString()), "Error");
                Exit();
                return;
            }

            try
            {
                SoundManager = new EOSoundManager();
            }
            catch
            {
                MessageBox.Show(string.Format("There was an error initializing the sound manager."), "Error");
                Exit();
                return;
            }

            if (World.Instance.MusicEnabled)
            {
                SoundManager.PlayBackgroundMusic(1);                 //mfx001 == main menu theme
            }

            base.Initialize();
        }
Ejemplo n.º 28
0
        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);
        }
Ejemplo n.º 29
0
        public Texture2D GetArmor(bool isBow = false)
        {
            ArmorShieldSpriteType type = ArmorShieldSpriteType.Standing;

            switch (charRef.State)
            {
            case CharacterActionState.Walking:
                switch (_data.walkFrame)
                {
                case 1: type = ArmorShieldSpriteType.WalkFrame1; break;

                case 2: type = ArmorShieldSpriteType.WalkFrame2; break;

                case 3: type = ArmorShieldSpriteType.WalkFrame3; break;

                case 4: type = ArmorShieldSpriteType.WalkFrame4; break;
                }
                break;

            case CharacterActionState.Attacking:
                if (isBow)
                {
                    switch (_data.attackFrame)
                    {
                    case 1: type = ArmorShieldSpriteType.Bow; break;

                    case 2: type = ArmorShieldSpriteType.Standing; break;
                    }
                }
                else
                {
                    switch (_data.attackFrame)
                    {
                    case 1: type = ArmorShieldSpriteType.PunchFrame1; break;

                    case 2: type = ArmorShieldSpriteType.PunchFrame2; break;
                    }
                }
                break;

            case CharacterActionState.SpellCast:
                type = ArmorShieldSpriteType.SpellCast;
                break;

            case CharacterActionState.Sitting:
                switch (_data.sitting)
                {
                case SitState.Chair:
                    type = ArmorShieldSpriteType.SitChair;
                    break;

                case SitState.Floor:
                    type = ArmorShieldSpriteType.SitGround;
                    break;
                }
                break;
            }

            short    baseArmorValue = (short)((_data.armor - 1) * 50);
            GFXTypes gfxFile        = (_data.gender == 0) ? GFXTypes.FemaleArmor : GFXTypes.MaleArmor;
            int      factor         = (_data.facing == EODirection.Down || _data.facing == EODirection.Right) ? 0 : 1; //multiplier for the direction faced

            factor *= getFactor(type);
            int gfxNumber = baseArmorValue + (int)type + factor;

            return(GFXLoader.TextureFromResource(gfxFile, gfxNumber, true));
        }