//--------------------------------------------------------------------------------------------- // private bool initRun = true; private void InitializeComponent() { //initRun = true; //slots = new List<Phoenix.Gui.Controls.ArtImageControlExt>(); Slots = new Dictionary <string, SlotItem>(); this.SuspendLayout(); Font font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); Font fontSmall = new System.Drawing.Font("Arial", 6.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); int defaultPadding = 2; int maxX = 0; int maxY = 0; int currentLine = 0 + defaultPadding; int currentPosition = 0 + defaultPadding; int buttonWidth = 32; int buttonHeight = 32; this.name = new Label(); this.name.AutoSize = true; this.name.BackColor = System.Drawing.Color.Transparent; this.name.Enabled = false; this.name.Font = font; this.name.Location = new System.Drawing.Point(2, 2); this.name.Name = "name"; this.name.TabIndex = 0; this.name.Text = "Slots (hold CTRL to add, Alt to skip, RClick to remove, LClick to use)"; this.Controls.Add(this.name); Control prevCont = this.name; currentPosition = defaultPadding; currentLine = prevCont.Location.Y + prevCont.Size.Height + defaultPadding; int slotIndex = -1; for (int i = 0; i < slotsCount; i++) { slotIndex++; Phoenix.Gui.Controls.ArtImageControlExt slot1 = new Phoenix.Gui.Controls.ArtImageControlExt(); slot1.ArtData = DataFiles.Art.Items; slot1.Hues = DataFiles.Hues; slot1.Enabled = true; slot1.Location = new Point(currentPosition, currentLine); slot1.ImageAlignment = Phoenix.Gui.Controls.ImageAlignment.TopLeft; slot1.Stocked = true; //slot1.Selected = true; slot1.Size = new Size(buttonWidth, buttonHeight); slot1.Name = "Slot_" + slotIndex; slot1.MouseClick += Slot_MouseClick; Graphic g = Graphic.Parse(Config.Profile.UserSettings.GetAttribute("0", "Graphic", "SlotForm_Slots_" + slot1.Name)); UOColor c = UOColor.Parse(Config.Profile.UserSettings.GetAttribute("0", "UOColor", "SlotForm_Slots_" + slot1.Name)); Serial s = Serial.Parse(Config.Profile.UserSettings.GetAttribute("0", "Serial", "SlotForm_Slots_" + slot1.Name)); bool selectable = Config.Profile.UserSettings.GetAttribute(true, "Selectable", "SlotForm_Slots_" + slot1.Name); string itemName = Config.Profile.UserSettings.GetAttribute("", "ItemName", "SlotForm_Slots_" + slot1.Name); SlotItem sl = new SlotItem() { Key = slot1.Name, Control = slot1, Graphic = g, Color = c, Serial = s, Selectable = selectable, SlotType = "Weapon", ItemName = itemName }; SetRemoveSlotItem(slot1.Name, sl); slot1.Selected = IsSelected(sl); slot1.Mark1 = !selectable; if (!sl.IsEmpty) { sl.RegisterCounter(); } if (c > 0 && c.IsConstant) { slot1.UseHue = true; } slot1.HueIndex = c; slot1.DataIndex = g; Controls.Add(slot1); prevCont = slot1; currentPosition = prevCont.Location.X + prevCont.Size.Width + defaultPadding; } currentPosition = currentPosition + 10; for (int i = 0; i < 4; i++) { slotIndex++; Phoenix.Gui.Controls.ArtImageControlExt slot1 = new Phoenix.Gui.Controls.ArtImageControlExt(); slot1.ArtData = DataFiles.Art.Items; slot1.Hues = DataFiles.Hues; slot1.Enabled = true; slot1.Location = new Point(currentPosition, currentLine); slot1.ImageAlignment = Phoenix.Gui.Controls.ImageAlignment.TopLeft; slot1.Stocked = true; //slot1.Selected = true; slot1.Size = new Size(buttonWidth, buttonHeight); slot1.Name = "Slot_" + slotIndex; slot1.MouseClick += Slot_MouseClick; Graphic g = Graphic.Parse(Config.Profile.UserSettings.GetAttribute("0", "Graphic", "SlotForm_Slots_" + slot1.Name)); UOColor c = UOColor.Parse(Config.Profile.UserSettings.GetAttribute("0", "UOColor", "SlotForm_Slots_" + slot1.Name)); Serial s = Serial.Parse(Config.Profile.UserSettings.GetAttribute("0", "Serial", "SlotForm_Slots_" + slot1.Name)); bool selectable = Config.Profile.UserSettings.GetAttribute(true, "Selectable", "SlotForm_Slots_" + slot1.Name); string itemName = Config.Profile.UserSettings.GetAttribute("", "ItemName", "SlotForm_Slots_" + slot1.Name); SlotItem sl = new SlotItem() { Key = slot1.Name, Control = slot1, Graphic = g, Color = c, Serial = s, Selectable = selectable, SlotType = "Klamak", ItemName = itemName }; SetRemoveSlotItem(slot1.Name, sl); slot1.Selected = IsSelected(sl); slot1.Mark1 = !selectable; sl.PrintCounter = true; if (!sl.IsEmpty) { sl.RegisterCounter(); } else { } if (c > 0 && c.IsConstant) { slot1.UseHue = true; } slot1.HueIndex = c; slot1.DataIndex = g; Controls.Add(slot1); prevCont = slot1; currentPosition = prevCont.Location.X + prevCont.Size.Width + defaultPadding; } currentPosition = currentPosition + 10; currentLine = defaultPadding; int potionBarStart = currentPosition; int potionSlotW = 16; int potionSlotH = 24; for (int i = 0; i < 4; i++) { slotIndex++; Phoenix.Gui.Controls.ArtImageControlExt slot1 = new Phoenix.Gui.Controls.ArtImageControlExt(); slot1.ArtData = DataFiles.Art.Items; slot1.Hues = DataFiles.Hues; slot1.Enabled = true; slot1.Location = new Point(currentPosition, currentLine); slot1.ImageAlignment = Phoenix.Gui.Controls.ImageAlignment.TopLeft; slot1.Stocked = true; slot1.CounterTextFontSize = 6.0F; //slot1.Selected = true; slot1.Size = new Size(potionSlotW, potionSlotH); slot1.Name = "Slot_" + slotIndex; slot1.MouseClick += Slot_MouseClick; Graphic g = Graphic.Parse(Config.Profile.UserSettings.GetAttribute("0", "Graphic", "SlotForm_Slots_" + slot1.Name)); UOColor c = UOColor.Parse(Config.Profile.UserSettings.GetAttribute("0", "UOColor", "SlotForm_Slots_" + slot1.Name)); Serial s = Serial.Parse(Config.Profile.UserSettings.GetAttribute("0", "Serial", "SlotForm_Slots_" + slot1.Name)); bool selectable = Config.Profile.UserSettings.GetAttribute(true, "Selectable", "SlotForm_Slots_" + slot1.Name); string itemName = Config.Profile.UserSettings.GetAttribute("", "ItemName", "SlotForm_Slots_" + slot1.Name); SlotItem sl = new SlotItem() { Key = slot1.Name, Control = slot1, Graphic = g, Color = c, Serial = s, Selectable = selectable, SlotType = "Potion", ItemName = itemName }; SetRemoveSlotItem(slot1.Name, sl); slot1.Selected = IsSelected(sl); slot1.Mark1 = !selectable; sl.PrintCounter = true; if (!sl.IsEmpty) { sl.RegisterCounter(); } if (c > 0 && c.IsConstant) { slot1.UseHue = true; } slot1.HueIndex = c; slot1.DataIndex = g; Controls.Add(slot1); prevCont = slot1; currentPosition = prevCont.Location.X + prevCont.Size.Width + defaultPadding; } currentPosition = potionBarStart; currentLine = currentLine + potionSlotH + defaultPadding; for (int i = 0; i < 4; i++) { slotIndex++; Phoenix.Gui.Controls.ArtImageControlExt slot1 = new Phoenix.Gui.Controls.ArtImageControlExt(); slot1.ArtData = DataFiles.Art.Items; slot1.Hues = DataFiles.Hues; slot1.Enabled = true; slot1.Location = new Point(currentPosition, currentLine); slot1.ImageAlignment = Phoenix.Gui.Controls.ImageAlignment.TopLeft; slot1.Stocked = true; slot1.CounterTextFontSize = 6.0F; //slot1.Selected = true; slot1.Size = new Size(potionSlotW, potionSlotH); slot1.Name = "Slot_" + slotIndex; slot1.MouseClick += Slot_MouseClick; Graphic g = Graphic.Parse(Config.Profile.UserSettings.GetAttribute("0", "Graphic", "SlotForm_Slots_" + slot1.Name)); UOColor c = UOColor.Parse(Config.Profile.UserSettings.GetAttribute("0", "UOColor", "SlotForm_Slots_" + slot1.Name)); Serial s = Serial.Parse(Config.Profile.UserSettings.GetAttribute("0", "Serial", "SlotForm_Slots_" + slot1.Name)); bool selectable = Config.Profile.UserSettings.GetAttribute(true, "Selectable", "SlotForm_Slots_" + slot1.Name); string itemName = Config.Profile.UserSettings.GetAttribute("", "ItemName", "SlotForm_Slots_" + slot1.Name); SlotItem sl = new SlotItem() { Key = slot1.Name, Control = slot1, Graphic = g, Color = c, Serial = s, Selectable = selectable, SlotType = "Potion", ItemName = itemName }; SetRemoveSlotItem(slot1.Name, sl); slot1.Selected = IsSelected(sl); slot1.Mark1 = !selectable; sl.PrintCounter = true; if (!sl.IsEmpty) { sl.RegisterCounter(); } if (c > 0 && c.IsConstant) { slot1.UseHue = true; } slot1.HueIndex = c; slot1.DataIndex = g; Controls.Add(slot1); prevCont = slot1; currentPosition = prevCont.Location.X + prevCont.Size.Width + defaultPadding; } currentLine = currentLine - (potionSlotH + defaultPadding); this.warMode = new Button(); this.warMode.Name = "warMode"; this.warMode.Location = new System.Drawing.Point(currentPosition, currentLine); this.warMode.Enabled = true; this.warMode.Font = fontSmall; this.warMode.Size = new Size(40, potionSlotH); //this.btnMixureLC.AutoSize = true; this.warMode.ForeColor = Color.White; this.warMode.Padding = new Padding(0); this.warMode.TabStop = false; this.warMode.FlatStyle = FlatStyle.Flat; this.warMode.FlatAppearance.BorderSize = 0; this.warMode.MouseClick += WarMode_MouseClick; UpdateWarButtonByWarMode(); this.Controls.Add(warMode); prevCont = warMode; currentPosition = prevCont.Location.X; currentLine = prevCont.Location.Y + potionSlotH + defaultPadding; this.btnLootType = new Button(); this.btnLootType.Name = "btnLootType"; this.btnLootType.Location = new System.Drawing.Point(currentPosition, currentLine); this.btnLootType.Enabled = true; this.btnLootType.Font = fontSmall; this.btnLootType.Size = new Size(40, potionSlotH); //this.btnMixureLC.AutoSize = true; this.btnLootType.ForeColor = Color.White; this.btnLootType.Padding = new Padding(0); this.btnLootType.TabStop = false; this.btnLootType.FlatStyle = FlatStyle.Flat; this.btnLootType.FlatAppearance.BorderSize = 0; this.btnLootType.MouseClick += BtnLootType_MouseClick; UpdateLootTypeButton(); this.Controls.Add(btnLootType); prevCont = btnLootType; currentPosition = prevCont.Location.X + prevCont.Size.Width + defaultPadding; foreach (Control c in this.Controls) { if (maxX < c.Location.X + c.Size.Width) { maxX = c.Location.X + c.Size.Width; } if (maxY < c.Location.Y + c.Size.Height) { maxY = c.Location.Y + c.Size.Height; } } this.Size = new Size(maxX + defaultPadding, maxY + defaultPadding); this.DoubleBuffered = true; this.Name = "SlotForm"; this.ResumeLayout(false); this.PerformLayout(); }
//--------------------------------------------------------------------------------------------- private void Slot_MouseClick(object sender, MouseEventArgs e) { Phoenix.Gui.Controls.ArtImageControlExt image = (Phoenix.Gui.Controls.ArtImageControlExt)sender; SlotItem slot = GetSlotItem(image.Name); if (slot == null) { return; } if (e.Button == MouseButtons.Right) { slot.Color = 0; slot.Graphic = 0; slot.Serial = 0; slot.ItemName = ""; slot.Selectable = true; slot.DisposeCounter(); image.Selected = false; image.Mark1 = false; image.Grayscale = false; image.DataIndex = 0; image.HueIndex = 0; } else if (e.Button == MouseButtons.Left) { bool currCtrlHold = (ModifierKeys & Keys.Control) == Keys.Control; bool currAltHold = (ModifierKeys & Keys.Alt) == Keys.Alt; if (currCtrlHold && !currAltHold) { image.Selection = true; UOItem item = new UOItem(UIManager.TargetObject()); image.Selection = false; if (item.Exist) { slot.Graphic = item.Graphic; slot.Color = item.Color; slot.Serial = item.Serial; slot.Selectable = true; if (String.IsNullOrEmpty(item.Name)) { item.Click(); Game.Wait(100); } slot.ItemName = item.Name; image.Mark1 = !slot.Selectable; image.DataIndex = item.Graphic; if (item.Color > 0 && item.Color.IsConstant) { image.UseHue = true; image.HueIndex = item.Color; } else { image.UseHue = false; } if (slot.SlotType == "Klamak" || slot.SlotType == "Potion") { slot.PrintCounter = true; } slot.RegisterCounter(); EnsureUnique(slot); EnsureSelection("Weapon"); //EnsureExists(); } else { //smazat? radsi ne } } else if (currAltHold && !currCtrlHold) { if (slot.SlotType == "Potion") { } else { slot.Selectable = !slot.Selectable; image.Mark1 = !slot.Selectable; } } else { if (slot.SlotType == "Potion") { if (!slot.IsEmpty) { Potion p = PotionCollection.GetPotionBy(slot.Graphic, slot.Color); if (p != null) { Phoenix.Runtime.RuntimeCore.Executions.Execute(Phoenix.Runtime.RuntimeCore.ExecutableList["DrinkPotion"], p.Name); } } } else if (slot.Exist) { if (slot.SlotType == "Weapon") { Phoenix.Runtime.RuntimeCore.Executions.Execute(Phoenix.Runtime.RuntimeCore.CommandList["useobject"], slot.Item.Serial); } else if (slot.SlotType == "Klamak") { //ClearSelection("Klamak"); //image.Selected = true; Phoenix.Runtime.RuntimeCore.Executions.Execute(Phoenix.Runtime.RuntimeCore.ExecutableList["VyhodKlamakNa"], slot.Item.Serial); } } } } image.Invalidate(); }