Ejemplo n.º 1
0
        public ContainerPanel(ClientViewport Viewport, int ContainerID)
        {
            this.Viewport       = Viewport;
            this.ContainerID    = ContainerID;
            ContentView.Padding = new Margin
            {
                Top    = 4,
                Left   = 7,
                Bottom = 4,
                Right  = 0
            };
            ((UIStackView)ContentView).StackDirection = UIStackDirection.Horizontal;
            ((UIStackView)ContentView).Overflow       = true;

            UIButton UpButton = CreateButton("U");

            UpButton.Tag = "_ContainerUpButton";
            AddFrameButton(UpButton);

            Bounds.Width  = 176;
            Bounds.Height = 220;

            // Note: We can't store the ClientContainer since it might be replaced
            // instead we subscribe to update for this container id
            // Subscribe to update for this container ID
            Viewport.UpdateContainer += OnUpdateContainer;
            Viewport.CloseContainer  += OnCloseContainer;

            // Perform the first update with the received container
            OnUpdateContainer(Viewport, Viewport.Containers[ContainerID]);
        }
Ejemplo n.º 2
0
        protected void OnOpenContainer(ClientViewport Viewport, ClientContainer Container)
        {
            ContainerPanel Panel = new ContainerPanel(Viewport, Container.ContainerID);

            Panel.Bounds.Height = 100;
            Sidebar.AddWindow(Panel);
        }
Ejemplo n.º 3
0
 public void ViewportChanged(ClientViewport NewViewport)
 {
     Viewport = NewViewport;
     foreach (InventoryItemButton Button in ContentView.SubviewsOfType <InventoryItemButton>())
     {
         Button.ViewportChanged(NewViewport);
     }
 }
Ejemplo n.º 4
0
        private void VIPStatusChanged(ClientViewport Viewport, ClientCreature Creature)
        {
            if (Viewport != this.Viewport)
            {
                return;
            }

            UpdateList();
        }
Ejemplo n.º 5
0
 protected void OnCloseContainer(ClientViewport Viewport, ClientContainer Container)
 {
     foreach (ContainerPanel CPanel in Sidebar.ContentView.SubviewsOfType <ContainerPanel>())
     {
         if (CPanel.ContainerID == Container.ContainerID)
         {
             CPanel.RemoveFromSuperview();
         }
     }
 }
Ejemplo n.º 6
0
        public ClientState(PacketStream InStream)
        {
            this.InStream = InStream;
            FileStream datFile = new FileStream("./Tibia.dat", FileMode.Open);
            FileStream sprFile = new FileStream("./Tibia.spr", FileMode.Open);

            GameData = new TibiaGameData(datFile, sprFile);
            Protocol = new TibiaGameProtocol(GameData);
            Viewport = new ClientViewport(GameData, Protocol);
        }
Ejemplo n.º 7
0
        protected void OnCloseContainer(ClientViewport Viewport, ClientContainer Container)
        {
            // Ignore updates for other containers
            if (Container.ContainerID != ContainerID)
            {
                return;
            }

            Viewport.UpdateContainer -= OnUpdateContainer;
            Viewport.CloseContainer  -= OnCloseContainer;
        }
Ejemplo n.º 8
0
        protected void OnUpdateContainer(ClientViewport Viewport, ClientContainer Container)
        {
            // Ignore updates for other containers
            if (Container.ContainerID != ContainerID)
            {
                return;
            }

            GetSubviewWithTag("_ContainerUpButton").Visible = false;

            // Update the title
            Name = Container.Name;

            List <ItemButton> ItemButtons = ContentView.SubviewsOfType <ItemButton>();

            // Check if the volume has changed, then we need to recreate the subviews
            if (ItemButtons.Count != Container.MaximumVolume)
            {
                // Replace the child views
                ContentView.RemoveSubviewsMatching(delegate(UIView view)
                {
                    return(view is ItemButton);
                });

                for (int ButtonIndex = 0; ButtonIndex < Container.MaximumVolume; ++ButtonIndex)
                {
                    ContentView.AddSubview(new ItemButton(Renderer, null)
                    {
                        Margin = new Margin
                        {
                            Top    = 0,
                            Right  = 0,
                            Bottom = 3,
                            Left   = 3,
                        }
                    });
                }

                ItemButtons = ContentView.SubviewsOfType <ItemButton>();
            }

            // Update the item buttons with the new contents
            int Slot = 0;

            foreach (ItemButton Button in ItemButtons)
            {
                Button.Item = Container.GetItem(Slot++);
            }

            NeedsLayout = true;
        }
Ejemplo n.º 9
0
        public GameSidebar(GameDesktop Desktop)
            : base(null, UIElementType.Window)
        {
            this.Desktop  = Desktop;
            this.Viewport = Desktop.ActiveViewport;
            Desktop.ActiveViewportChanged += ViewportChanged;

            ContentView        = new UIStackView(UIStackDirection.Vertical);
            ContentView.ZOrder = -1;

            CreateMenu();

            AddSubview(ContentView);
        }
Ejemplo n.º 10
0
        public void DrawScene(SpriteBatch Batch, GameTime Time, ClientViewport Viewport, Dictionary <MapPosition, TileAnimations> PlayingAnimations = null)
        {
            MapPosition Center = Viewport.ViewPosition;

            int StartZ = 7;
            int EndZ   = Center.Z;

            if (Center.Z <= 7)
            {
                Center.Y -= (7 - Center.Z);
                Center.X -= (7 - Center.Z);
            }
            else
            {
                StartZ    = Math.Min(Center.Z + 2, 15);
                EndZ      = Center.Z;
                Center.X -= 2;
                Center.Y -= 2;
            }

            Vector2 TopLeft = new Vector2(
                -(Center.X - 7) * 32,
                -(Center.Y - 5) * 32
                );


            for (int Z = StartZ; Z >= EndZ; --Z)
            {
                for (int X = Center.X - 8; X <= Center.X + 9; ++X)
                {
                    for (int Y = Center.Y - 6; Y <= Center.Y + 7; ++Y)
                    {
                        ClientTile Tile = Viewport.Map[new MapPosition(X, Y, Z)];

                        Vector2 pos = new Vector2(32 * X + TopLeft.X, 32 * Y + TopLeft.Y);

                        TileAnimations Animations = null;
                        if (PlayingAnimations != null && Tile != null)
                        {
                            PlayingAnimations.TryGetValue(Tile.Position, out Animations);
                        }
                        DrawTile(Batch, Time, pos, Tile, Animations);
                    }
                }
                TopLeft -= new Vector2(32, 32);
            }
        }
Ejemplo n.º 11
0
        protected void ViewportChanged(ClientViewport NewViewport)
        {
            if (Viewport != null)
            {
                Viewport.VIPStatusChanged -= VIPStatusChanged;
            }

            // If there is no new state just clear the view
            Viewport = NewViewport;

            if (Viewport != null)
            {
                Viewport.VIPStatusChanged += VIPStatusChanged;
            }

            UpdateList();
        }
Ejemplo n.º 12
0
        protected void ViewportChanged(ClientViewport NewViewport)
        {
            ContentView.RemoveAllSubviews();

            // Don't do anything if we didn't receive a new state
            Viewport = NewViewport;
            if (Viewport == null)
            {
                return;
            }

            ContentView.AddSubview(new SkillLabel(Viewport.Player.Level));

            SkillLabel ExperienceLabel = new SkillLabel("Experience", delegate()
            {
                return(new SkillLabel.SkillValue()
                {
                    Value = Viewport.Player.Experience,
                    Percent = 0
                });
            });

            ContentView.AddSubview(ExperienceLabel);

            SkillLabel HitpointLabel = new SkillLabel("Hitpoints", delegate()
            {
                return(new SkillLabel.SkillValue()
                {
                    Value = Viewport.Player.Health,
                    Percent = 0
                });
            });

            ContentView.AddSubview(HitpointLabel);

            SkillLabel ManaLabel = new SkillLabel("Mana", delegate()
            {
                return(new SkillLabel.SkillValue()
                {
                    Value = Viewport.Player.Mana,
                    Percent = 0
                });
            });

            ContentView.AddSubview(ManaLabel);

            SkillLabel CapacityLabel = new SkillLabel("Capacity", delegate()
            {
                return(new SkillLabel.SkillValue()
                {
                    Value = Viewport.Player.Capacity,
                    Percent = 0
                });
            });

            ContentView.AddSubview(CapacityLabel);

            ContentView.AddSubview(new SkillLabel(Viewport.Player.MagicLevel));

            foreach (ClientSkill Skill in Viewport.Player.Skill.Values)
            {
                ContentView.AddSubview(new SkillLabel(Skill));
            }

            NeedsLayout = true;
        }
Ejemplo n.º 13
0
 public void OnNewState(ClientViewport NewViewport)
 {
     Viewport = NewViewport;
 }
Ejemplo n.º 14
0
        public void DrawSceneForeground(SpriteBatch Batch, Vector2 ScreenOffset, Vector2 Scale, GameTime Time, ClientViewport Viewport, Dictionary <MapPosition, TileAnimations> PlayingAnimations = null)
        {
            MapPosition Center = Viewport.ViewPosition;


            Vector2 TopLeft = new Vector2(
                -(Center.X - 7) * 32,
                -(Center.Y - 5) * 32
                );

            int StartZ = 7;
            int EndZ   = Center.Z;

            if (Center.Z <= 7)
            {
                Center.Y -= (7 - Center.Z);
                Center.X -= (7 - Center.Z);
            }
            else
            {
                StartZ = Math.Min(Center.Z + 2, 15);
                EndZ   = Center.Z;
            }

            for (int X = Center.X - 8; X <= Center.X + 8; ++X)
            {
                for (int Y = Center.Y - 6; Y <= Center.Y + 6; ++Y)
                {
                    ClientTile Tile = Viewport.Map[new MapPosition(X, Y, Center.Z)];

                    Vector2 DrawOffset = new Vector2(32 * X + TopLeft.X, 32 * Y + TopLeft.Y);
                    DrawOffset *= Scale;

                    TileAnimations Animations = null;
                    if (PlayingAnimations != null && Tile != null)
                    {
                        PlayingAnimations.TryGetValue(Tile.Position, out Animations);
                    }
                    DrawTileForeground(Batch, Time, ScreenOffset + DrawOffset, Tile, Animations);
                }
            }
        }
Ejemplo n.º 15
0
 protected void ViewportChanged(ClientViewport Viewport)
 {
     this.Viewport = Viewport;
 }
Ejemplo n.º 16
0
 public void ViewportChanged(ClientViewport NewViewport)
 {
     Viewport = NewViewport;
 }
Ejemplo n.º 17
0
 public InventoryItemButton(ClientViewport Viewport, InventorySlot Slot)
     : base(null, null)
 {
     this.Viewport = Viewport;
     this.Slot     = Slot;
 }