| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using Client.MirControls;
- using Client.MirGraphics;
- using Client.MirSounds;
- namespace Client.MirScenes.Dialogs
- {
- public sealed class SocketDialog : MirImageControl
- {
- public MirItemCell[] Grid;
- public MirButton CloseButton;
- public SocketDialog()
- {
- Index = 20;
- Library = Libraries.Prguse3;
- Movable = true;
- Sort = true;
- Location = new Point(0, 0);
- Grid = new MirItemCell[6 * 2];
- for (int x = 0; x < 6; x++)
- {
- for (int y = 0; y < 2; y++)
- {
- int idx = 6 * y + x;
- Grid[idx] = new MirItemCell
- {
- ItemSlot = idx,
- GridType = MirGridType.Socket,
- Library = Libraries.Items,
- Parent = this,
- Location = new Point(x * 36 + 23 + x, y * 33 + 15 + y),
- };
- }
- }
- CloseButton = new MirButton
- {
- HoverIndex = 361,
- Index = 360,
- Location = new Point(Size.Width - 23, 3),
- Library = Libraries.Prguse2,
- Parent = this,
- PressedIndex = 362,
- Sound = SoundList.ButtonA,
- };
- CloseButton.Click += (o, e) => Hide();
- }
- private void BindGrid()
- {
- int count = 0;
- if (GameScene.SelectedItem != null)
- {
- count = GameScene.SelectedItem.Slots.Length;
- }
- for (int x = 0; x < 6; x++)
- {
- for (int y = 0; y < 2; y++)
- {
- int idx = 6 * y + x;
- Grid[idx].Visible = idx < count;
- }
- }
- }
- public MirItemCell GetCell(ulong id)
- {
- for (int i = 0; i < Grid.Length; i++)
- {
- if (Grid[i].Item == null || Grid[i].Item.UniqueID != id) continue;
- return Grid[i];
- }
- return null;
- }
- public override void Hide()
- {
- GameScene.SelectedItem = null;
- base.Hide();
- }
- public void Show(MirGridType grid, UserItem item)
- {
- if (item.Slots.Length == 0)
- {
- GameScene.SelectedItem = null;
- Visible = false;
- return;
- }
- GameScene.SelectedItem = item;
- Index = 20 + (GameScene.SelectedItem.Slots.Length - 1);
- BindGrid();
- CloseButton.Location = new Point(Size.Width - 23, 3);
- switch (grid)
- {
- case MirGridType.Inventory:
- Location = new Point(
- GameScene.Scene.InventoryDialog.Location.X + ((GameScene.Scene.InventoryDialog.Size.Width - Size.Width) / 2),
- GameScene.Scene.InventoryDialog.Location.Y + GameScene.Scene.InventoryDialog.Size.Height + 5);
- break;
- case MirGridType.Equipment:
- Location = new Point(
- GameScene.Scene.CharacterDialog.Location.X + ((GameScene.Scene.CharacterDialog.Size.Width - Size.Width) / 2),
- GameScene.Scene.CharacterDialog.Location.Y + GameScene.Scene.CharacterDialog.Size.Height + 5);
- break;
- }
- Visible = true;
- }
- }
- }
|