示例#1
0
        public static void SetOverheadHue()
        {
            ListViewItem selectedItem = _listView.Items[_listView.SelectedIndices[0]];

            HueEntry h = new HueEntry(GetHue(selectedItem.SubItems[1].Text));

            if (h.ShowDialog(Engine.MainWindow) == DialogResult.OK)
            {
                int hueIdx = h.Hue;

                if (hueIdx > 0 && hueIdx < 3000)
                {
                    selectedItem.SubItems[1].BackColor = Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    selectedItem.SubItems[1].BackColor = Color.White;
                }

                selectedItem.SubItems[1].ForeColor = (selectedItem.SubItems[1].BackColor.GetBrightness() < 0.35
                    ? Color.White
                    : Color.Black);

                foreach (OverheadMessage list in OverheadManager.OverheadMessages)
                {
                    if (list.SearchMessage.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }
            }
        }
示例#2
0
        private bool SetHue(Control ctrl, string cfg)
        {
            HueEntry h = new HueEntry(Config.GetInt(cfg));

            if (h.ShowDialog(this) == DialogResult.OK)
            {
                int hueIdx = h.Hue;
                Config.SetProperty(cfg, hueIdx);
                if (hueIdx > 0 && hueIdx < 3000)
                {
                    ctrl.BackColor = Ultima.Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    ctrl.BackColor = Color.White;
                }
                ctrl.ForeColor = (ctrl.BackColor.GetBrightness() < 0.35 ? Color.White : Color.Black);

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        private void UpdateStats()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ThreadStart(UpdateStats));
                return;
            }

            if (mobile.Name != null)
            {
                name.Text = mobile.Name;
            }

            if (mobile.MaxHits > -1)
            {
                hits.Text         = String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits);
                healthBar.Hits    = mobile.Hits;
                healthBar.MaxHits = mobile.MaxHits;
                healthBar.Poison  = mobile.Poisoned;
            }
            Notoriety n     = mobile.Notoriety;
            HueEntry  notoh = DataFiles.Hues.Get(notorietyColors[(int)n]);
            ushort    noto  = notoh.Colors[12];

            this.BackColor = Color.FromArgb(UOColorConverter.ToArgb(noto) | (0xFF << 24));
        }
示例#4
0
        private bool SetContainerLabelHue()
        {
            ListViewItem selectedItem = containerView.Items[containerView.SelectedIndices[0]];

            HueEntry h = new HueEntry(GetHueFromListView(selectedItem.SubItems[0].Text));

            // TODO: BREAKING DRY!
            if (h.ShowDialog(this) == DialogResult.OK)
            {
                int hueIdx = h.Hue;

                if (hueIdx > 0 && hueIdx < 3000)
                {
                    selectedItem.SubItems[2].BackColor = Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    selectedItem.SubItems[2].BackColor = Color.White;
                }

                selectedItem.SubItems[2].ForeColor = (selectedItem.SubItems[2].BackColor.GetBrightness() < 0.35
                    ? Color.White
                    : Color.Black);

                foreach (Core.ContainerLabels.ContainerLabel list in Core.ContainerLabels.ContainerLabelList)
                {
                    if (list.Id.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }

                foreach (Core.ContainerLabels.ContainerLabel list in NewContainerEntries)
                {
                    if (list.Id.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        private static int RandomHue()
        {
            int random = Utility.Random(23801);               // total weight sum
            int sum    = 0;

            for (int i = 0; i < m_HueEntries.Length; i++)
            {
                HueEntry entry = m_HueEntries[i];

                sum += entry.Weight;

                if (sum > random)
                {
                    return(entry.Hue);
                }
            }

            return(0);
        }
示例#6
0
        private void SetContainerLabelHue()
        {
            ListViewItem selectedItem = cliLocOverheadView.Items[cliLocOverheadView.SelectedIndices[0]];

            HueEntry h = new HueEntry(GetHueFromListView(selectedItem.SubItems[1].Text));

            // TODO: BREAKING DRY!
            if (h.ShowDialog(this) == DialogResult.OK)
            {
                int hueIdx = h.Hue;

                if (hueIdx > 0 && hueIdx < 3000)
                {
                    selectedItem.SubItems[1].BackColor = Hues.GetHue(hueIdx - 1).GetColor(HueEntry.TextHueIDX);
                }
                else
                {
                    selectedItem.SubItems[1].BackColor = Color.White;
                }

                selectedItem.SubItems[1].ForeColor = (selectedItem.SubItems[1].BackColor.GetBrightness() < 0.35
                    ? Color.White
                    : Color.Black);

                foreach (Core.OverheadMessages.OverheadMessage list in Core.OverheadMessages.OverheadMessageList)
                {
                    if (list.SearchMessage.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }

                foreach (Core.OverheadMessages.OverheadMessage list in NewOverheadEntries)
                {
                    if (list.SearchMessage.Equals(selectedItem.Text))
                    {
                        list.Hue = hueIdx;
                        break;
                    }
                }
            }
        }
示例#7
0
        public static void DrawSpectrum(Bitmap bitmap, Hues hues, int index)
        {
            if (bitmap == null)
            {
                throw new ArgumentNullException("bitmap");
            }
            if (hues == null)
            {
                throw new ArgumentNullException("hues");
            }

            if (index < hues.MinIndex || index > hues.MaxIndex)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            HueEntry hue = hues.Get(index);

            BitmapData data = bitmap.LockBits(new Rectangle(new Point(), bitmap.Size), ImageLockMode.WriteOnly, PixelFormat.Format16bppArgb1555);

            float colorWidth = (float)bitmap.Width / 32.0f;

            short[] line = new short[bitmap.Width];

            for (int x = 0; x < bitmap.Width; x++)
            {
                int id = (int)(x / colorWidth);
                if (id < 32)
                {
                    line[x] = (short)(hue.Colors[id] | 0x8000);
                }
            }

            for (int y = 0; y < bitmap.Height; y++)
            {
                int offset = (int)data.Scan0 + y * data.Stride;
                Marshal.Copy(line, 0, (IntPtr)offset, line.Length);
            }

            bitmap.UnlockBits(data);
        }
示例#8
0
            internal Hue(int index, HueEntry entry)
            {
                Index = index;

                for (int i = 0; i < 32; ++i)
                {
                    Colors[i] = (short)(entry.Colors[i] | 0x8000);
                }

                TableStart = (short)(entry.TableStart | 0x8000);
                TableEnd   = (short)(entry.TableEnd | 0x8000);

                int count = 0;

                while (count < 20 && count < entry.Name.Length && entry.Name[count] != 0)
                {
                    ++count;
                }

                Name = Encoding.Default.GetString(entry.Name, 0, count);
                Name = Name.Replace("\n", " ");
            }
示例#9
0
        public void RedrawBitmap()
        {
            bitmap = null;

            if (artData != null)
            {
                if (!stocked)
                {
                    bitmap = artData[dataIndex];
                }
                else
                {
                    Bitmap art = artData[dataIndex];

                    // Offset 5,5 is client-hardcoded
                    // Note: PixelFormat is NEEDED!
                    bitmap = new Bitmap(art.Width + 5, art.Height + 5, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    // Draw second image over the first one
                    using (Graphics g = Graphics.FromImage(bitmap)) {
                        g.DrawImageUnscaled(art, 0, 0);
                        g.DrawImageUnscaled(art, 5, 5);
                    }
                }

                if (useHue && hues != null)
                {
                    HueEntry entry = hues[hueIndex];
                    if (entry != null)
                    {
                        Dyes.RecolorFull(entry, bitmap);
                    }
                }
            }

            Invalidate();
        }
示例#10
0
        public void RedrawBitmap()
        {
            bitmap = null;

            if (artData != null)
            {
                this.BackColor = Color.Black;
                Bitmap art = artData[dataIndex];

                if (useHue && hues != null)
                {
                    try
                    {
                        HueEntry entry = hues[hueIndex];
                        if (entry != null)
                        {
                            Dyes.RecolorFull(entry, art);
                        }
                    }
                    catch { }
                }

                if (!stocked)
                {
                    bitmap = art;
                }
                else
                {
                    bitmap = new Bitmap(art.Width + 5, art.Height + 5, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

                    int minX = 0;
                    int minY = 0;
                    int maxX = 0;
                    int maxY = 0;

                    for (int x = 0; x < art.Width; x++)
                    {
                        for (int y = 0; y < art.Height; y++)
                        {
                            Color c = art.GetPixel(x, y);
                            if (c.IsEmpty || (c.R + c.G + c.G < 12))
                            {
                            }                             //Odstin moc blizky cerne { }
                            else
                            {
                                if (minX == 0 || x < minX)
                                {
                                    minX = x;
                                }

                                if (minY == 0 || y < minY)
                                {
                                    minY = y;
                                }

                                if (x > maxX)
                                {
                                    maxX = x;
                                }

                                if (y > maxY)
                                {
                                    maxY = y;
                                }
                            }
                        }
                    }

                    Color borderColor = Color.LightGray;
                    if (Selection)
                    {
                        borderColor = Color.Yellow;
                    }
                    else if (Selected)
                    {
                        borderColor = Color.DeepSkyBlue;
                    }

                    Color markColor = borderColor;//Color.Crimson;
                    if (this.Mark1)
                    {
                        markColor = Color.Crimson;
                    }


                    for (int x = minX; x < maxX; x++)
                    {
                        art.SetPixel(x, minY, markColor);

                        art.SetPixel(x, maxY - 1, borderColor);
                        art.SetPixel(x, maxY, borderColor);
                    }

                    for (int y = minY; y < maxY; y++)
                    {
                        art.SetPixel(minX, y, borderColor);

                        art.SetPixel(maxX - 1, y, markColor);
                        art.SetPixel(maxX, y, markColor);
                    }

                    if (Grayscale)
                    {
                        int x, y;
                        for (x = 0; x < art.Width; x++)
                        {
                            for (y = 0; y < art.Height; y++)
                            {
                                Color pixelColor = art.GetPixel(x, y);
                                Color newColor   = Color.FromArgb(pixelColor.R, 0, 0);
                                art.SetPixel(x, y, newColor); // Now greyscale
                            }
                        }
                    }

                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.DrawImage(art, new Rectangle(0, 0, this.Width, this.Height), new Rectangle(minX, minY, maxX - minX, maxY - minY), GraphicsUnit.Pixel);
                        if (this.counter.HasValue)
                        {
                            g.FillRectangle(Brushes.Black, 0, 0, 12, 12);
                            g.DrawString(String.Format("{0}", this.counter), new Font("Arial", CounterTextFontSize), CounterBrush, 0, 1);
                        }
                    }
                }
            }
            else
            {
                this.BackColor = Color.LightGray;
            }

            Invalidate();
        }
示例#11
0
        static HueData()
        {
            int index = 0;

            if (CheckFile)
            {
                string path = Core.FindDataFile("hues.mul");

                if (path != null)
                {
                    using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        int blockCount = (int)fs.Length / 708;

                        if (blockCount > 375)
                        {
                            blockCount = 375;
                        }

                        m_Header = new int[blockCount];

                        int    structsize = Marshal.SizeOf(typeof(HueEntry));
                        byte[] buffer     = new byte[blockCount * (4 + 8 * structsize)];

                        GCHandle gc = GCHandle.Alloc(buffer, GCHandleType.Pinned);

                        try
                        {
                            fs.Read(buffer, 0, buffer.Length);

                            long currpos = 0;

                            for (int i = 0; i < blockCount; ++i)
                            {
                                IntPtr ptrheader = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);

                                currpos += 4;

                                m_Header[i] = (int)Marshal.PtrToStructure(ptrheader, typeof(int));

                                for (int j = 0; j < 8; ++j, ++index)
                                {
                                    IntPtr ptr = new IntPtr((long)gc.AddrOfPinnedObject() + currpos);

                                    currpos += structsize;

                                    HueEntry cur = (HueEntry)Marshal.PtrToStructure(ptr, typeof(HueEntry));

                                    List[index] = new Hue(index, cur);
                                }
                            }
                        }
                        finally
                        {
                            gc.Free();
                        }
                    }
                }
            }

            while (index < List.Length)
            {
                List[index] = new Hue(index);

                ++index;
            }
        }
示例#12
0
        private void UpdateStats()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ThreadStart(UpdateStats));
                return;
            }

            if (mobile.Name != null)
            {
                name.Text = mobile.Name;
            }

            //UO.Print("P: " + String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits));

            if (mobile.MaxHits > -1)
            {
                hits.Text         = String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits);
                healthBar.Hits    = mobile.Hits;
                healthBar.MaxHits = mobile.MaxHits;
                healthBar.Poison  = mobile.Poisoned;
                healthBar.Unknown = false;
                statusNeeded      = false;


                if (this.StatusType == StatusType.Player)
                {
                }
                else
                {
                    lastMaxHits = mobile.MaxHits;
                }
            }
            else
            {
                healthBar.Unknown = true;
                if (mobile.Serial == World.Player.Serial)
                {
                }
                else
                {
                    if ((DateTime.Now - initTime).TotalSeconds > 20 && mobile.Hits <= 1)
                    {
                        WindowManager.GetDefaultManager().BeginInvoke(Close);
                        return;
                    }
                }
            }

            Notoriety n = mobile.Notoriety;

            if (mobile.Distance > 18)
            {
                n = Notoriety.Unknown;
                healthBar.Unknown = true;
                if (mobile.Serial == World.Player.Serial)
                {
                }
            }

            HueEntry notoh = DataFiles.Hues.Get(notorietyColors[(int)n]);
            ushort   noto  = notoh.Colors[12];

            if (statDown)
            {
                noto = DataFiles.Hues.Get(0x01c0).Colors[12];
            }
            else
            {
                if (this.StatusType == StatusType.Mob)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];
                }

                if (this.StatusType == StatusType.Player && Game.IsHealOn)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];

                    if (CalebConfig.HealMoby && Game.CurrentGame.HasAliveAlie)
                    {
                        noto = DataFiles.Hues.Get(0x000d).Colors[12];
                    }
                }
            }

            //1c0

            BackColor = Color.FromArgb(UOColorConverter.ToArgb(noto) | (0xFF << 24));

            // Do we need status?
            if (healthBar.Unknown)
            {
                statusNeeded = true;
            }

            // Request if mob is visible
            if (statusNeeded && mobile.Distance < 19 && DateTime.Now - lastRequest < TimeSpan.FromSeconds(10))
            {
                statusNeeded = false;
                lastRequest  = DateTime.Now;
                mobile.RequestStatus();
            }
        }
示例#13
0
        public override void OnButtonPress(int num)
        {
            ConfigItem item = listBox.SelectedItem as ConfigItem;

            if (item == null)
            {
                return;
            }
            if (item.Value is string)
            {
                if (InputBox.Show("Input string") && !string.IsNullOrEmpty(InputBox.GetString()))
                {
                    item.Value = InputBox.GetString();
                }
            }
            else if (item.Value is bool)
            {
                item.Value = !(bool)item.Value;
            }
            else if (item.Value is uint)
            {
                Targeting.OneTimeTarget((l, s, p, g) =>
                {
                    item.Value = s == World.Player.Serial ? 0 : s.Value;
                    listBox.Items[listBox.SelectedIndex] = item;
                });
            }
            else if (item.Value is byte)
            {
                if (InputBox.Show("Input value") && (InputBox.GetInt(-1) >= 0 || InputBox.GetInt(-1) <= 100))
                {
                    item.Value = (byte)InputBox.GetInt(-1);
                }
            }
            else if (item.Value is ushort)
            {
                HueEntry hueEntry = new HueEntry((ushort)item.Value);
                if (hueEntry.ShowDialog(Engine.MainWindow) == DialogResult.OK)
                {
                    item.Value = (ushort)hueEntry.Hue;
                }
            }
            else if (item.Value.GetType().IsEnum)
            {
                Type type  = item.Value.GetType();
                int  value = (int)item.Value;
                while (!Enum.IsDefined(type, ++value))
                {
                    if (value >= Enum.GetValues(type).Length)
                    {
                        value = -1;
                    }
                }
                item.Value = Enum.ToObject(type, value);
            }
            else
            {
                throw new NotImplementedException();
            }
            listBox.Items[listBox.SelectedIndex] = item;
        }
示例#14
0
        //---------------------------------------------------------------------------------------------

        private void UpdateStats()
        {
            if (InvokeRequired)
            {
                BeginInvoke(new ThreadStart(UpdateStats));
                return;
            }

            if (mobile.Name != null)
            {
                name.Text = mobile.Name;
            }

            bool isDmg = lastMaxHits > mobile.MaxHits && mobile.MaxHits > -1;

            if (mobile.MaxHits > -1)
            {
                hits.Text         = String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits);
                healthBar.Hits    = mobile.Hits;
                healthBar.MaxHits = mobile.MaxHits;
                healthBar.Poison  = mobile.Poisoned;
                healthBar.Unknown = false;
                statusNeeded      = false;

                if (this.StatusType == StatusType.Player)
                {
                    mana.Text       = String.Format("{0}/{1}", mobile.Mana, mobile.MaxMana);
                    manaBar.Mana    = mobile.Mana;
                    manaBar.MaxMana = mobile.MaxMana;
                    manaBar.Unknown = false;

                    stam.Text          = String.Format("{0}/{1}", mobile.Stamina, mobile.MaxStamina);
                    staminaBar.Stam    = mobile.Stamina;
                    staminaBar.MaxStam = mobile.MaxStamina;
                    staminaBar.Unknown = false;

                    ar.Text     = String.Format("ar: {0}", World.Player.Armor);
                    weight.Text = String.Format("w: {0}", World.Player.Weight);
                }
                else
                {
                    UpdatePositionAndDirection();

                    lastMaxHits = mobile.MaxHits;
                }
            }
            else
            {
                healthBar.Unknown = true;

                if (this.StatusType == StatusType.Player)
                {
                    staminaBar.Unknown = true;
                    manaBar.Unknown    = true;
                }
                else
                {
                    if (this.chbxKeep.Checked)
                    {
                        UpdatePositionAndDirection();
                    }
                    else
                    {
                        int limit = 8;

                        if ((DateTime.Now - initTime).TotalSeconds > limit && mobile.Hits <= 1)
                        {
                            WindowManager.GetDefaultManager().BeginInvoke(Close);
                            return;
                        }
                    }
                }
            }

            Notoriety n = mobile.Notoriety;

            if (mobile.Distance > 18)
            {
                n = Notoriety.Unknown;
                healthBar.Unknown = true;
                if (mobile.Serial == World.Player.Serial)
                {
                    staminaBar.Unknown = true;
                    manaBar.Unknown    = true;
                }
            }

            HueEntry notoh = DataFiles.Hues.Get(notorietyColors[(int)n]);
            ushort   noto  = notoh.Colors[12];

            if (statDown && this.chbxAlie.Checked)
            {
                noto = DataFiles.Hues.Get(0x01c0).Colors[12];
            }
            else
            {
                if (this.StatusType == StatusType.Mob)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];
                }

                if (this.StatusType == StatusType.Player && Game.IsHealOn)
                {
                    noto = DataFiles.Hues.Get(0x0035).Colors[12];
                }
            }

            if (!DefaultColor.HasValue || !MouseHovering)
            {
                if (this.StatusType == StatusType.Player)
                {
                    BackColor = Color.Black;
                }
                else
                {
                    BackColor = Color.FromArgb(UOColorConverter.ToArgb(noto) | (0xFF << 24));
                }

                if (!DefaultColor.HasValue)
                {
                    DefaultColor = CurrentColor = BackColor;
                }
            }

            if (healthBar.Unknown)
            {
                statusNeeded = true;
            }

            // Request if mob is visible
            if (statusNeeded && mobile.Distance < 22 && DateTime.Now - lastRequest < TimeSpan.FromSeconds(10))
            {
                statusNeeded = false;
                lastRequest  = DateTime.Now;
                mobile.RequestStatus();
            }

            //if (this.currentWrapper != null)
            //{
            //  if ((DateTime.Now - initTime).TotalSeconds > 2 && (this.healthBar.Unknown || this.mobile.Hits <= 0 || this.mobile.Distance > 18))
            //  {
            //    WindowManager.GetDefaultManager().BeginInvoke(Close);
            //    return;
            //  }
            //  else
            //    this.currentWrapper.UpdateLayout();
            //}
        }