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]); }
protected void OnOpenContainer(ClientViewport Viewport, ClientContainer Container) { ContainerPanel Panel = new ContainerPanel(Viewport, Container.ContainerID); Panel.Bounds.Height = 100; Sidebar.AddWindow(Panel); }
public void ViewportChanged(ClientViewport NewViewport) { Viewport = NewViewport; foreach (InventoryItemButton Button in ContentView.SubviewsOfType <InventoryItemButton>()) { Button.ViewportChanged(NewViewport); } }
private void VIPStatusChanged(ClientViewport Viewport, ClientCreature Creature) { if (Viewport != this.Viewport) { return; } UpdateList(); }
protected void OnCloseContainer(ClientViewport Viewport, ClientContainer Container) { foreach (ContainerPanel CPanel in Sidebar.ContentView.SubviewsOfType <ContainerPanel>()) { if (CPanel.ContainerID == Container.ContainerID) { CPanel.RemoveFromSuperview(); } } }
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); }
protected void OnCloseContainer(ClientViewport Viewport, ClientContainer Container) { // Ignore updates for other containers if (Container.ContainerID != ContainerID) { return; } Viewport.UpdateContainer -= OnUpdateContainer; Viewport.CloseContainer -= OnCloseContainer; }
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; }
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); }
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); } }
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(); }
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; }
public void OnNewState(ClientViewport NewViewport) { Viewport = NewViewport; }
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); } } }
protected void ViewportChanged(ClientViewport Viewport) { this.Viewport = Viewport; }
public void ViewportChanged(ClientViewport NewViewport) { Viewport = NewViewport; }
public InventoryItemButton(ClientViewport Viewport, InventorySlot Slot) : base(null, null) { this.Viewport = Viewport; this.Slot = Slot; }