| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- using Client.MirControls;
- using Client.MirGraphics;
- using Client.MirNetwork;
- using Client.MirSounds;
- using C = ClientPackets;
- namespace Client.MirScenes.Dialogs
- {
- public sealed class ItemRentingDialog : MirImageControl
- {
- public static UserItem RentalItem;
- public readonly MirItemCell ItemCell;
- public uint RentalPeriod;
- private readonly MirLabel _nameLabel, _rentalPeriodLabel;
- private readonly MirButton _lockButton, _setRentalPeriodButton, _confirmButton;
-
- public ItemRentingDialog()
- {
- Index = 238;
- Library = Libraries.Prguse;
- Movable = true;
- Size = new Size(204, 109);
- Location = new Point(Settings.ScreenWidth - Size.Width - Size.Width / 2, Size.Height * 2 + Size.Height / 2 + 15);
- Sort = true;
- // Confirm Button
- _confirmButton = new MirButton
- {
- Index = 10,
- HoverIndex = 11,
- Location = new Point(130, 76),
- Size = new Size(58, 28),
- Library = Libraries.Prguse3,
- Parent = this,
- PressedIndex = 12,
- Sound = SoundList.ButtonA,
- Enabled = false
- };
- _confirmButton.Click += (o, e) =>
- {
- Network.Enqueue(new C.ConfirmItemRental());
- };
- // Close Button
- var closeButton = new MirButton
- {
- HoverIndex = 361,
- Index = 360,
- Location = new Point(180, 3),
- Library = Libraries.Prguse2,
- Parent = this,
- PressedIndex = 362,
- Sound = SoundList.ButtonA,
- };
- closeButton.Click += (sender, args) =>
- {
- CancelItemRental();
- };
- // Lock Button
- _lockButton = new MirButton
- {
- Index = 250,
- HoverIndex = 251,
- Location = new Point(18, 76),
- Size = new Size(28, 25),
- Library = Libraries.Prguse,
- Parent = this,
- PressedIndex = 252,
- Sound = SoundList.ButtonA,
- };
- _lockButton.Click += (o, e) =>
- {
- if (RentalPeriod < 1 || RentalPeriod > 30)
- return;
- Network.Enqueue(new C.ItemRentalLockItem());
- };
- // Set Rental Period Button
- _setRentalPeriodButton = new MirButton
- {
- Index = 7,
- HoverIndex = 8,
- Location = new Point(46, 76),
- Size = new Size(84, 28),
- Library = Libraries.Prguse3,
- Parent = this,
- PressedIndex = 9,
- Sound = SoundList.ButtonA,
- };
- _setRentalPeriodButton.Click += (o, e) =>
- {
- InputRentalPeroid();
- };
- // Name Label
- _nameLabel = new MirLabel
- {
- Parent = this,
- Location = new Point(30, 8),
- Size = new Size(150, 14),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- NotControl = true,
- };
- // Rental Period Label
- _rentalPeriodLabel = new MirLabel
- {
- Parent = this,
- Location = new Point(60, 42),
- Size = new Size(150, 14),
- DrawFormat = TextFormatFlags.Left | TextFormatFlags.VerticalCenter,
- NotControl = true,
- };
- // Item Cell
- ItemCell = new MirItemCell
- {
- BorderColour = Color.Lime,
- GridType = MirGridType.Renting,
- Library = Libraries.Items,
- Parent = this,
- Location = new Point(16, 35),
- ItemSlot = 0,
- };
- }
- private static void CancelItemRental()
- {
- Network.Enqueue(new C.CancelItemRental());
- }
- public void EnableConfirmButton()
- {
- _confirmButton.Enabled = true;
- }
- public void InputRentalPeroid()
- {
- var inputBox = new MirInputBox(GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RentItemDurationQuestion), RentalItem.FriendlyName, GameScene.Scene.GuestItemRentDialog.GuestName));
- inputBox.OKButton.Click += (o1, e1) =>
- {
- if (!uint.TryParse(inputBox.InputTextBox.Text, out RentalPeriod))
- return;
- if (RentalPeriod < 1 || RentalPeriod > 30)
- return;
- RefreshInterface();
- inputBox.Dispose();
- Network.Enqueue(new C.ItemRentalPeriod { Days = RentalPeriod });
- };
- inputBox.Show();
- }
- public void RefreshInterface()
- {
- _nameLabel.Text = GameScene.User.Name;
- _rentalPeriodLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RentalPeriodDays), RentalPeriod);
- GameScene.Scene.GuestItemRentDialog.RefreshInterface();
- GameScene.Scene.GuestItemRentingDialog.RefreshInterface();
- Redraw();
- }
- public void OpenItemRentalDialog()
- {
- GameScene.Scene.InventoryDialog.Show();
- Show();
- RefreshInterface();
- GameScene.Scene.GuestItemRentDialog.Show();
- }
- public void Reset()
- {
- RentalItem = null;
- RentalPeriod = 0;
- _confirmButton.Enabled = false;
- GameScene.User.RentalGoldAmount = 0;
-
- GameScene.Scene.GuestItemRentingDialog.Reset();
- Unlock();
- RefreshInterface();
- Hide();
- }
- public void Lock()
- {
- _lockButton.Index = 253;
- _lockButton.Enabled = false;
- _setRentalPeriodButton.Enabled = false;
- RefreshInterface();
- }
- private void Unlock()
- {
- _lockButton.Index = 250;
- _lockButton.Enabled = true;
- _setRentalPeriodButton.Enabled = true;
- }
- }
- public sealed class GuestItemRentingDialog : MirImageControl
- {
- public static UserItem GuestLoanItem;
- public uint GuestRentalPeriod;
- private readonly MirLabel _nameLabel, _rentalPeriodLabel;
- private readonly MirButton _lockButton, _setRentalPeriodButton, _confirmButton;
- private string _guestName;
- private MirItemCell _guestItemCell;
-
- public GuestItemRentingDialog()
- {
- Index = 238;
- Library = Libraries.Prguse;
- Movable = true;
- Size = new Size(204, 109);
- Location = new Point(Settings.ScreenWidth - Size.Width - Size.Width / 2, Size.Height * 2 + Size.Height / 2 + 15);
- Sort = true;
- _lockButton = new MirButton
- {
- Index = 250,
- Location = new Point(18, 76),
- Size = new Size(28, 25),
- Library = Libraries.Prguse,
- Parent = this,
- Enabled = false
- };
- _setRentalPeriodButton = new MirButton
- {
- Index = 7,
- Location = new Point(46, 76),
- Size = new Size(84, 28),
- Library = Libraries.Prguse3,
- Parent = this,
- Enabled = false
- };
- _confirmButton = new MirButton
- {
- Index = 10,
- Location = new Point(130, 76),
- Size = new Size(58, 28),
- Library = Libraries.Prguse3,
- Parent = this,
- Enabled = false
- };
- _nameLabel = new MirLabel
- {
- Parent = this,
- Location = new Point(30, 8),
- Size = new Size(150, 14),
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- NotControl = true,
- };
- _rentalPeriodLabel = new MirLabel
- {
- Parent = this,
- Location = new Point(60, 42),
- Size = new Size(150, 14),
- DrawFormat = TextFormatFlags.Left | TextFormatFlags.VerticalCenter,
- NotControl = true,
- Text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.RentalPeriodZeroDays)
- };
- _guestItemCell = new MirItemCell
- {
- BorderColour = Color.Lime,
- GridType = MirGridType.GuestRenting,
- Library = Libraries.Items,
- Parent = this,
- Location = new Point(16, 35),
- ItemSlot = 0,
- };
- }
- public void RefreshInterface()
- {
- _nameLabel.Text = _guestName;
- _rentalPeriodLabel.Text = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RentalPeriodDays), GuestRentalPeriod);
- if (GuestLoanItem != null)
- GameScene.Bind(GuestLoanItem);
-
- Redraw();
- }
- public void Reset()
- {
- Unlock();
- GuestLoanItem = null;
- _guestName = string.Empty;
- Hide();
- }
- public void SetGuestName(string name)
- {
- _guestName = name;
- }
- public void Lock()
- {
- _lockButton.Index = 253;
- RefreshInterface();
- }
- private void Unlock()
- {
- _lockButton.Index = 250;
- }
- }
- }
|