Exemple #1
0
 public MessageUnicodeRequest(MessageType type, Hue hue, MessageFont font, string lang, string text)
     : base(0xAD)
 {
     WriteByte((byte)type);
     WriteUShort(hue);
     WriteUShort((ushort)font);
     WriteASCII(lang, 4);
     WriteUnicode(text);
 }
Exemple #2
0
 public UOMessageEventArgs(string text, Hue hue, MessageType type, MessageFont font, string lang = null)
 {
     Text = text;
     Hue = hue;
     Type = type;
     Font = font;
     Language = lang;
     AffixType = AffixType.None;
 }
Exemple #3
0
 public UOMessageEventArgs(string text, Hue hue, MessageType type, MessageFont font,
     uint cliloc, AffixType affixType = AffixType.None, string affix = null)
 {
     Text = text;
     Hue = hue;
     Type = type;
     Font = font;
     Cliloc = cliloc;
     AffixType = affixType;
     Affix = affix;
 }
Exemple #4
0
 public MessageUnicode(Serial serial, Graphic graphic, MessageType type, Hue hue,
     MessageFont font, string lang, string name, string text)
     : base(0xAE)
 {
     WriteUInt(serial);
     WriteUShort(graphic);
     WriteByte((byte)type);
     WriteUShort(hue);
     WriteUShort((ushort)font);
     WriteASCII(lang, 4);
     WriteASCII(name, 30);
     WriteUnicode(text);
 }
Exemple #5
0
        public static Bitmap GetGump(Hue hue, int index)
        {
            KeyValuePair<Hue, int> key = new KeyValuePair<Hue,int>(EmptyHue, index);

            if (cache.ContainsKey(key))
            {
                return cache[key];
            }
            else
            {
                Bitmap bmp = Ultima.Gumps.GetGump(index, hue, false);
                cache.Add(key, bmp);
                return cache[key];
            }
        }
Exemple #6
0
        private void OnClickApplyHue1to2(object sender, EventArgs e)
        {
            if (!_hue2Loaded)
            {
                return;
            }

            Hue org = Hues.List[_selected];
            Hue sec = SecondHue.List[_selected];

            sec.Colors.CopyTo(org.Colors, 0);
            org.Name            = sec.Name;
            org.TableStart      = org.Colors[0];
            org.TableEnd        = org.Colors[org.Colors.Length - 1];
            _compare[_selected] = true;
            PaintBox1();
            PaintBox2();
            Options.ChangedUltimaClass["Hues"] = true;
            ControlEvents.FireHueChangeEvent();
        }
Exemple #7
0
        public static void DrawLandArt(Graphic graphic, Hue hue, int x, int y)
        {
            Texture2D th = FileManager.Art.GetLandTexture(graphic);

            if (th == null)
            {
                return;
            }

            Vector3 huev = Vector3.Zero;

            if (hue != 0)
            {
                ShaderHuesTraslator.GetHueVector(ref huev, hue);
            }



            //Engine.Batcher.DrawSprite(th, )
        }
Exemple #8
0
        public void CalculateLightCommands_BrightnessGroupMatch_GroupHasMismatch()
        {
            using (ShimsContext.Create())
            {
                Hue hue = new Hue(null);

                hue.UpdateFluxStatus(145, CurrentColorTemperature);

                Dictionary <LightCommand, IList <string> > result = hue.CalculateLightCommands(
                    new List <Light>()
                {
                    new Light()
                    {
                        Name  = "Test 1",
                        Type  = LightExtensions.LightTypeToNameMapping[LightType.WhiteAmbiance],
                        State = new State()
                        {
                            On = true, Brightness = 145, ColorTemperature = CurrentColorTemperature
                        }
                    },

                    new Light()
                    {
                        Name  = "Test 2",
                        Type  = LightExtensions.LightTypeToNameMapping[LightType.WhiteAmbiance],
                        State = new State()
                        {
                            On = true, Brightness = 147, ColorTemperature = CurrentColorTemperature
                        }
                    },
                },
                    CurrentColorTemperature,
                    146);

                LightCommand lightCommandKey = result.Keys.SingleOrDefault(x => x.Brightness == 146 && x.ColorTemperature == null);
                Assert.IsNotNull(lightCommandKey, "Brightness for a group is rounded to the highest common value.");

                Assert.AreEqual(1, result.Count(), $"One light group expected since all lights share the same common name.");
                Assert.AreEqual(2, result[lightCommandKey].Count, $"Both lights should be adjusted.");
            }
        }
Exemple #9
0
        private void PaintBox1()
        {
            using (Graphics g = Graphics.FromImage(bmp1))
            {
                g.Clear(Color.White);

                for (int y = 0; y <= row; y++)
                {
                    int index = GetIndex(y);
                    if (index >= 0)
                    {
                        Rectangle rect = new Rectangle(0, y * ITEMHEIGHT, 200, ITEMHEIGHT);
                        if (index == selected)
                        {
                            g.FillRectangle(SystemBrushes.Highlight, rect);
                        }
                        else if (!Compare(index))
                        {
                            g.FillRectangle(Brushes.Red, rect);
                        }
                        else
                        {
                            g.FillRectangle(SystemBrushes.Window, rect);
                        }

                        float     size       = ((float)(pictureBox1.Width - 200)) / 32;
                        Hue       hue        = Ultima.Hues.List[index];
                        Rectangle stringrect = new Rectangle(3, y * ITEMHEIGHT, pictureBox1.Width, ITEMHEIGHT);
                        g.DrawString(String.Format("{0,-5} {1,-7} {2}", hue.Index + 1, String.Format("(0x{0:X})", hue.Index + 1), hue.Name), Font, Brushes.Black, stringrect);

                        for (int i = 0; i < hue.Colors.Length; i++)
                        {
                            Rectangle rectangle = new Rectangle(200 + ((int)Math.Round((double)(i * size))), y * ITEMHEIGHT, (int)Math.Round((double)(size + 1f)), ITEMHEIGHT);
                            g.FillRectangle(new SolidBrush(hue.GetColor(i)), rectangle);
                        }
                    }
                }
            }
            pictureBox1.Image = bmp1;
            pictureBox1.Update();
        }
Exemple #10
0
        private bool CheckSample(byte r, byte g, byte b)
        {
            if (Red == null)
            {
                return(false);
            }

            if (!Red.IsAcceptableValue(r))
            {
                return(false);
            }
            if (!Green.IsAcceptableValue(g))
            {
                return(false);
            }
            if (!Blue.IsAcceptableValue(b))
            {
                return(false);
            }

            if (Hue.State != ConditionState.NotUsed || Saturation.State != ConditionState.NotUsed ||
                Luminosity.State != ConditionState.NotUsed)
            {
                var hsl = HslConversion.FromRgb(r, g, b);

                if (!Hue.IsAcceptableValue((int)Math.Round(hsl.Item1)))
                {
                    return(false);
                }
                if (!Saturation.IsAcceptableValue((int)Math.Round(hsl.Item2)))
                {
                    return(false);
                }
                if (!Luminosity.IsAcceptableValue((int)Math.Round(hsl.Item3)))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #11
0
        private void PaintBox1()
        {
            using (Graphics g = Graphics.FromImage(_bmp1))
            {
                g.Clear(Color.White);

                for (int y = 0; y <= _row; y++)
                {
                    int index = GetIndex(y);
                    if (index >= 0)
                    {
                        Rectangle rect = new Rectangle(0, y * ItemHeight, 200, ItemHeight);
                        if (index == _selected)
                        {
                            g.FillRectangle(SystemBrushes.Highlight, rect);
                        }
                        else if (!Compare(index))
                        {
                            g.FillRectangle(Brushes.Red, rect);
                        }
                        else
                        {
                            g.FillRectangle(SystemBrushes.Window, rect);
                        }

                        float     size       = (float)(pictureBox1.Width - 200) / 32;
                        Hue       hue        = Hues.List[index];
                        Rectangle stringRect = new Rectangle(3, y * ItemHeight, pictureBox1.Width, ItemHeight);
                        g.DrawString($"{hue.Index + 1,-5} {$"(0x{hue.Index + 1:X})",-7} {hue.Name}", Font, Brushes.Black, stringRect);

                        for (int i = 0; i < hue.Colors.Length; i++)
                        {
                            Rectangle rectangle = new Rectangle(200 + (int)Math.Round(i * size), y * ItemHeight, (int)Math.Round(size + 1f), ItemHeight);
                            g.FillRectangle(new SolidBrush(hue.GetColor(i)), rectangle);
                        }
                    }
                }
            }
            pictureBox1.Image = _bmp1;
            pictureBox1.Update();
        }
Exemple #12
0
        public static void DrawLand(Land land, Hue hue, int x, int y, SpriteVertex[] vertices)
        {
            Graphic   id = land.Graphic;
            Texture2D th = FileManager.Textmaps.GetTexture(id);

            if (th == null)
            {
                DrawLandArt(id, hue, x, y);
            }
            else
            {
                Vector3 huev = Vector3.Zero;

                if (hue != 0)
                {
                    ShaderHuesTraslator.GetHueVector(ref huev, hue);
                }

                Engine.Batcher.DrawSprite(th, vertices);
            }
        }
Exemple #13
0
        public void Add(string text, Hue hue, string name, bool isunicode = true)
        {
            if (Entries.Count >= 100)
            {
                Entries.RemoveFromFront();
            }

            byte font = (byte)(isunicode ? 0 : 9);

            if (Engine.Profile.Current != null && Engine.Profile.Current.OverrideAllFonts)
            {
                font      = Engine.Profile.Current.ChatFont;
                isunicode = Engine.Profile.Current.OverrideAllFontsIsUnicode;
            }

            JournalEntry entry = new JournalEntry(text, font, hue, name, isunicode, Engine.CurrDateTime);

            Entries.AddToBack(entry);
            EntryAdded.Raise(entry);
            _fileWriter?.WriteLine($"[{Engine.CurrDateTime:g}]  {name}: {text}");
        }
Exemple #14
0
        private void AddLayer(byte dir, Graphic graphic, Hue hue, Mobile mobile, EquipConvData?convertedItem = null, bool ispartial = false, int offsetY = 0)
        {
            byte  animGroup = Mobile.GetGroupForAnimation(mobile, graphic);
            sbyte animIndex = GameObject.AnimIndex;

            /* bool isitting = false;
             * if (mobile.IsHuman && !mounted)
             * {
             *  if ((FileManager.Animations.SittingValue = mobile.IsSitting) != 0)
             *  {
             *      animGroup = (byte) (FileManager.Animations.Direction == 3 ? 25 : (byte) PEOPLE_ANIMATION_GROUP.PAG_STAND);
             *      animIndex = 0;
             *
             *      isitting = true;
             *  }
             * } */

            FileManager.Animations.AnimID    = graphic;
            FileManager.Animations.AnimGroup = animGroup;
            FileManager.Animations.Direction = dir;
            ref AnimationDirection direction = ref FileManager.Animations.DataIndex[FileManager.Animations.AnimID].Groups[FileManager.Animations.AnimGroup].Direction[FileManager.Animations.Direction];
Exemple #15
0
        private void PreviewHue(int x, int y)
        {
            Hue hue = m_Hues[this.GetHueIndex(x, y)];

            if (hue != m_Hue)
            {
                m_Hue = hue;

                labName.Text = hue.Name;

                imgHue.Image = hue.GetSpectrum(imgHue.Size);

                this.GCSteps++;

                if (GCSteps == 10)
                {
                    GCSteps = 0;
                    GC.Collect();
                }
            }
        }
Exemple #16
0
        public override void AppendTo(ref SpanWriter writer, OrderedHashSet <string> strings, ref int entries, ref int switches)
        {
            writer.Write((ushort)0x7B20); // "{ "
            writer.Write(LayoutName);
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(X.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Y.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Width.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Height.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(Hue.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(EntryID.ToString());
            writer.Write((byte)0x20);     // ' '
            writer.WriteAscii(strings.GetOrAdd(InitialText).ToString());
            writer.Write((ushort)0x207D); // " }"

            entries++;
        }
Exemple #17
0
        public void AddEntry(string text, int font, Hue hue, bool isUnicode)
        {
            bool maxScroll = _scrollBar.Value == _scrollBar.MaxValue;

            while (_entries.Count > 99)
            {
                _entries.RemoveFromFront().Destroy();
                _hours.RemoveFromFront().Destroy();
            }

            RenderedText h = RenderedText.Create($"{Engine.CurrDateTime:t} ", 1150, 1, true, FontStyle.BlackBorder);

            _hours.AddToBack(h);

            _entries.AddToBack(RenderedText.Create(text, hue, (byte)font, isUnicode, FontStyle.Indention | FontStyle.BlackBorder, maxWidth: Width - (18 + h.Width)));

            _scrollBar.MaxValue += _entries[_entries.Count - 1].Height;
            if (maxScroll)
            {
                _scrollBar.Value = _scrollBar.MaxValue;
            }
        }
Exemple #18
0
        private void DrawBox(Bitmap bmp, short Color16, int Index)
        {
            // Calculate the row and column (zero based)
            int column = (int)(Index / 60);
            int row    = Index % 60;

            // Get the color
            Color color = Hue.ToColor(Color16);

            // Find the top left corner of the box
            int x = (column * 9);
            int y = (row * 5);

            // Color
            for (int iX = 0; iX < 9; iX++)
            {
                for (int iY = 0; iY < 5; iY++)
                {
                    bmp.SetPixel(x + iX, y + iY, color);
                }
            }
        }
Exemple #19
0
        public virtual Bitmap GetImage()
        {
            Bitmap image;

            if (hue == null)
            {
                hue = new Hue(0);
            }

            if (hue.Index == 0)
            {
                image = Ultima.Gumps.GetGump(index);
            }
            else
            {
                image = Ultima.Gumps.GetGump(index, hue, false);
            }

            Size = image.Size;

            return(image);
        }
Exemple #20
0
        public NameOverheadGump(Entity entity) : base(entity.Serial, 0)
        {
            CanMove                = false;
            AcceptMouseInput       = true;
            CanCloseWithRightClick = true;
            Entity = entity;

            Hue hue = entity is Mobile m?Notoriety.GetHue(m.NotorietyFlag) : (Hue)999;

            //_label = new Label(string.IsNullOrEmpty(entity.Name) ? "" : entity.Name, true, hue, style: FontStyle.BlackBorder, align: TEXT_ALIGN_TYPE.TS_CENTER)
            //{
            //    X = 2,
            //    Y = 2,
            //};


            _renderedText = new RenderedText()
            {
                IsUnicode = true,
                Font      = 0xFF,
                Hue       = hue,
                FontStyle = FontStyle.BlackBorder,
                Align     = TEXT_ALIGN_TYPE.TS_CENTER,
                IsHTML    = true,
            };


            Add(_background = new AlphaBlendControl(.3f)
            {
                WantUpdateSize = false,
                //Width = _label.Width + 4,
                //Height = _label.Height + 4
            });
            // Add(_label);

            //X = (int) entity.RealScreenPosition.X;
            //Y = (int) entity.RealScreenPosition.Y;
        }
        private bool Compare(int index)
        {
            if (_compare.Contains(index))
            {
                return((bool)_compare[index]);
            }

            if (!_hue2Loaded)
            {
                return(true);
            }

            Hue org = Hues.List[index];
            Hue sec = SecondHue.List[index];

            if (org == null && sec == null)
            {
                _compare[index] = true;
                return(true);
            }
            if (org == null || sec == null)
            {
                _compare[index] = false;
                return(false);
            }

            for (int i = 0; i < org.Colors.Length; i++)
            {
                if (org.Colors[i] != sec.Colors[i])
                {
                    _compare[index] = false;
                    return(false);
                }
            }

            _compare[index] = true;
            return(true);
        }
Exemple #22
0
        public void CreateCharacterGetBytesTest()
        {
            ClientVersion version = ClientVersion.vMAX;

            SkillValuePair[] skills = new SkillValuePair[] {
                new SkillValuePair()
                {
                    Skill = (Skill)25, Value = 50
                },
                new SkillValuePair()
                {
                    Skill = (Skill)26, Value = 50
                },
                new SkillValuePair()
                {
                    Skill = (Skill)0, Value = 0
                }
            };
            CharStats stats = new CharStats()
            {
                Strength = 50, Dexterity = 24, Intelligence = 1
            };
            RaceAndGender raceandgender = new RaceAndGender(version, RaceAndGender.RaceType.Human, RaceAndGender.GenderType.Female);

            Hue        pantscolor = (Hue)999;
            BeardStyle beardstyle = (BeardStyle)33;

            CreateCharacter target = new CreateCharacter(version, "David", ClientFlag.LBR, (Profession)1, raceandgender, stats, skills, 0, 0, 0, (BeardStyle)33, 0, 0, 0, IPAddress.None, 0, pantscolor);

            int expectedPacketLen = 104;

            PacketWriter packet = target.GetWriter();

            Assert.AreEqual(expectedPacketLen, packet.Length);
            Assert.AreEqual(skills[2].Skill, target.StartSkills[2].Skill);
            Assert.AreEqual(pantscolor, target.PantsColor);
            Assert.AreEqual(beardstyle, target.FacialHairStyle);
        }
Exemple #23
0
        public void AddItem(Graphic graphic, Hue hue, string name, int x, int y, int index)
        {
            StaticPic pic = new StaticPic(graphic, hue)
            {
                X = x,
                Y = y,
                //LocalSerial = (uint) index,
                AcceptMouseInput = true
            };

            pic.MouseDoubleClick += (sender, e) =>
            {
                NetClient.Socket.Send(new PMenuResponse(LocalSerial, (Graphic)ServerSerial.Value, index, graphic, hue));
                Dispose();
            };
            pic.SetTooltip(name);


            _container.Add(pic);

            _container.CalculateWidth();
            _slider.MaxValue = _container.MaxValue;
        }
Exemple #24
0
        public SearchMetadata(int position, [NotNull] string searchText, bool filter,
                              bool highlight,
                              bool useRegex,
                              bool ignoreCase,
                              Hue highlightHue,
                              string iconKind)
        {
            if (searchText == null)
            {
                throw new ArgumentNullException(nameof(searchText));
            }

            Position     = position;
            SearchText   = searchText;
            Filter       = filter;
            Highlight    = highlight;
            UseRegex     = useRegex;
            IgnoreCase   = ignoreCase;
            HighlightHue = highlightHue;
            IconKind     = iconKind;
            RegEx        = this.BuildRegEx();
            Predicate    = this.BuildPredicate();
        }
Exemple #25
0
        public static Static Create(Graphic graphic, Hue hue, int index)
        {
            if (_pool.Count != 0)
            {
                var s = _pool.Dequeue();
                s.Graphic     = s.OriginalGraphic = graphic;
                s.Hue         = hue;
                s.Index       = index;
                s.IsDestroyed = false;
                s._itemData   = null;
                s.AlphaHue    = 0;
                s._oldGraphic = 0;
                s.CharacterIsBehindFoliage = false;
                s.UpdateGraphicBySeason();

                if (s.ItemData.Height > 5)
                {
                    s._canBeTransparent = 1;
                }
                else if (s.ItemData.IsRoof || s.ItemData.IsSurface && s.ItemData.IsBackground || s.ItemData.IsWall)
                {
                    s._canBeTransparent = 1;
                }
                else if (s.ItemData.Height == 5 && s.ItemData.IsSurface && !s.ItemData.IsBackground)
                {
                    s._canBeTransparent = 1;
                }
                else
                {
                    s._canBeTransparent = 0;
                }

                return(s);
            }

            return(new Static(graphic, hue, index));
        }
 public CreateCharacter(ClientVersion version,
                        string charname,
                        ClientFlag clientflags,
                        Profession profession,
                        RaceAndGender raceandgender,
                        CharStats stats,
                        SkillValuePair[] startSkills,
                        Hue skincolor,
                        HairStyle hair,
                        Hue haircolor,
                        BeardStyle beard,
                        Hue beardcolor,
                        ushort locationindex,
                        ushort charslotnum,
                        IPAddress clientip,
                        Hue shirtcolor,
                        Hue pantscolor)
     : base(version)
 {
     CharName           = charname;
     ClientFlags        = clientflags;
     LoginCount         = 0; // ?
     Profession         = profession;
     RaceAndGender      = raceandgender;
     Stats              = stats;
     StartSkills        = startSkills;
     SkinColor          = skincolor;
     HairStyle          = hair;
     HairColor          = haircolor;
     FacialHairStyle    = beard;
     FacialHairColor    = beardcolor;
     StartLocationIndex = locationindex;
     CharSlotNum        = charslotnum;
     ClientIP           = clientip;
     ShirtColor         = shirtcolor;
     PantsColor         = pantscolor;
 }
Exemple #27
0
        public void CalculateLightCommands_Brightness_Single(byte currentBrightness)
        {
            Primitives.Brightness newBrightness = 128;

            using (ShimsContext.Create())
            {
                Hue hue = new Hue(null);

                hue.UpdateFluxStatus(currentBrightness, CurrentColorTemperature);

                Dictionary <LightCommand, IList <string> > result = hue.CalculateLightCommands(
                    new List <Light>()
                {
                    new Light()
                    {
                        Name  = "Test",
                        Type  = LightExtensions.LightTypeToNameMapping[LightType.WhiteAmbiance],
                        State = new State()
                        {
                            On = true, Brightness = currentBrightness, ColorTemperature = CurrentColorTemperature
                        }
                    },
                },
                    CurrentColorTemperature,
                    newBrightness);

                bool brightnessChangeExpected = currentBrightness == 0 || currentBrightness != newBrightness;

                Assert.AreEqual(brightnessChangeExpected ? 1 : 0, result.Count(), $"One light group expected since change is expected.");

                if (brightnessChangeExpected)
                {
                    Assert.AreEqual((byte?)newBrightness, result.First().Key.Brightness, $"Brightness level should be new level.");
                    Assert.AreEqual(1, result.First().Value.Count, $"1 light in group expected.");
                }
            }
        }
Exemple #28
0
        public LabelElement(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            this.mFontIndex = 2;
            int int32 = info.GetInt32("LabelElementVersion");

            this.mText = info.GetString(nameof(Text));
            this.mHue  = Hues.GetHue(info.GetInt32("HueIndex"));
            if (int32 >= 3)
            {
                this.mPartialHue = info.GetBoolean(nameof(PartialHue));
                this.mUnicode    = info.GetBoolean(nameof(Unicode));
            }
            else
            {
                this.mPartialHue = true;
                this.mUnicode    = true;
            }
            this.mFontIndex = info.GetInt32("FontIndex");
            if (int32 <= 2)
            {
                --this.mFontIndex;
            }
            if (int32 >= 2)
            {
                this.mCropped = info.GetBoolean(nameof(Cropped));
                this.mSize    = (Size)info.GetValue(nameof(Size), typeof(Size));
            }
            else
            {
                this.mCropped = false;
                Bitmap stringImage = UnicodeFonts.GetStringImage(this.mFontIndex, this.mText + " ");
                this.mSize = stringImage.Size;
                stringImage.Dispose();
            }
            this.RefreshCache();
        }
Exemple #29
0
        public BridgeDetectionPairingView()
        {
            _pairTimer.Interval    = new TimeSpan(0, 0, 0, 2);
            _pairTimer.Tick       += _pairTimer_Tick;
            _timeoutTimer.Interval = new TimeSpan(0, 0, 1, 0);
            _timeoutTimer.Tick    += _timeoutTimer_Tick;
            _listBridge            = new ObservableCollection <Bridge>();

            if (_listBridge.Count == 0)
            {
                CanAddManualIp = false;
                Cursor_Tools.ShowWaitCursor();
                Hue.OnDetectionComplete     += Hue_OnDetectionComplete;
                Hue.OnBridgeDetectionFailed += Hue_OnBridgeDetectionFailed;
                log.Info("Starting bridge detection.");
                Hue.DetectBridge();

                _canscan = false;
            }
            else
            {
                AssociateApiKey(_listBridge);
            }
        }
Exemple #30
0
        /// <summary>
        /// Reads hues.mul and fills <see cref="List"/>
        /// </summary>
        public static void Initialize(string path)
        {
            int index = 0;

            List = new Hue[3000];

            if (path != null)
            {
                using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    BinaryReader bin = new BinaryReader(fs);

                    int blockCount = (int)fs.Length / 708;

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

                    for (int i = 0; i < blockCount; ++i)
                    {
                        bin.ReadInt32();

                        for (int j = 0; j < 8; ++j, ++index)
                        {
                            List[index] = new Hue(index, bin);
                        }
                    }
                }
            }

            for (; index < List.Length; ++index)
            {
                List[index] = new Hue(index);
            }
        }
Exemple #31
0
        public void AddEntry(string text, int font, Hue hue)
        {
            bool maxScroll = _scrollBar.Value == _scrollBar.MaxValue;

            while (_entries.Count > 99)
            {
                _entries.RemoveAt(0);
            }

            RenderedText entry = new RenderedText
            {
                MaxWidth = Width - 18, IsUnicode = true, Align = TEXT_ALIGN_TYPE.TS_LEFT, FontStyle = FontStyle.Indention | FontStyle.BlackBorder
            };

            entry.Hue  = hue;
            entry.Font = (byte)font;
            entry.Text = text;
            _entries.Add(entry);
            _scrollBar.MaxValue += _entries[_entries.Count - 1].Height;
            if (maxScroll)
            {
                _scrollBar.Value = _scrollBar.MaxValue;
            }
        }
        //Create A Button
        private Button CreateButton(Swatch swatch)
        {
            Button ChangeButton = new Button();

            ChangeButton.Margin = new Thickness(15, 0, 15, 0);
            ChangeButton.Tag    = swatch.Name;

            //Create a stackpanel inside button
            StackPanel content = new StackPanel();

            content.Orientation  = Orientation.Horizontal;
            ChangeButton.Content = content;

            //Add an icon to button's content
            PackIcon icon = CreateIcon();

            content.Children.Add(icon);

            //Add text to button's content
            TextBlock text = new TextBlock();

            text.Text = " Apply";
            content.Children.Add(text);

            //Set the color of the button from hue in swatch
            Hue             hue   = swatch.PrimaryHues.ElementAt(7);
            SolidColorBrush brush = new SolidColorBrush(swatch.PrimaryHues.ElementAt(7).Color); //Selects seventh hue in selected swatch

            ChangeButton.Foreground  = new SolidColorBrush(Colors.White);                       //Sets icon and text color to white in all situations
            ChangeButton.Background  = brush;
            ChangeButton.BorderBrush = brush;

            ChangeButton.Click += ChangeButton_Click;

            return(ChangeButton);
        }
Exemple #33
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (IsDisposed)
            {
                return(false);
            }

            if (AnimationGraphic == Graphic.INVALID)
            {
                return(false);
            }

            Hue hue = Hue;

            if (Source is Item i)
            {
                if (Engine.Profile.Current.FieldsType == 1 && StaticFilters.IsField(AnimationGraphic))
                {
                    AnimIndex = 0;
                }
                else if (Engine.Profile.Current.FieldsType == 2)
                {
                    if (StaticFilters.IsFireField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0020;
                    }
                    else if (StaticFilters.IsParalyzeField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0058;
                    }
                    else if (StaticFilters.IsEnergyField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0070;
                    }
                    else if (StaticFilters.IsPoisonField(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x0044;
                    }
                    else if (StaticFilters.IsWallOfStone(Graphic))
                    {
                        AnimationGraphic = Constants.FIELD_REPLACE_GRAPHIC;
                        hue = 0x038A;
                    }
                }
                else if (i.IsHidden)
                {
                    hue = 0x038E;
                }
            }

            if ((AnimationGraphic != _displayedGraphic || Texture == null || Texture.IsDisposed) && AnimationGraphic != Graphic.INVALID)
            {
                _displayedGraphic = AnimationGraphic;
                Texture           = FileManager.Art.GetTexture(AnimationGraphic);
                Bounds            = new Rectangle((Texture.Width >> 1) - 22, Texture.Height - 44, Texture.Width, Texture.Height);
            }

            Bounds.X = (Texture.Width >> 1) - 22 - (int)Offset.X;
            Bounds.Y = Texture.Height - 44 + (int)(Offset.Z - Offset.Y);

            StaticTiles data = FileManager.TileData.StaticData[_displayedGraphic];

            bool isPartial     = data.IsPartialHue;
            bool isTransparent = data.IsTranslucent;

            if (Engine.Profile.Current.NoColorObjectsOutOfRange && Distance > World.ViewRange)
            {
                HueVector = new Vector3(Constants.OUT_RANGE_COLOR, 1, HueVector.Z);
            }
            else if (World.Player.IsDead && Engine.Profile.Current.EnableBlackWhiteEffect)
            {
                HueVector = new Vector3(Constants.DEAD_RANGE_COLOR, 1, HueVector.Z);
            }
            else
            {
                HueVector = ShaderHuesTraslator.GetHueVector(hue, isPartial, isTransparent ? .5f : 0, false);
            }

            switch (Blend)
            {
            case GraphicEffectBlendMode.Multiply:
                batcher.SetBlendState(_multiplyBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.Screen:
            case GraphicEffectBlendMode.ScreenMore:
                batcher.SetBlendState(_screenBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ScreenLess:
                batcher.SetBlendState(_screenLessBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.NormalHalfTransparent:
                batcher.SetBlendState(_normalHalfBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            case GraphicEffectBlendMode.ShadowBlue:
                batcher.SetBlendState(_shadowBlueBlendState.Value);
                base.Draw(batcher, position, objectList);
                batcher.SetBlendState(null);
                break;

            default:
                base.Draw(batcher, position, objectList);
                break;
            }

            Engine.DebugInfo.EffectsRendered++;

            return(true);
        }
Exemple #34
0
 /// <summary>
 /// Returns a hash code for this instance.
 /// </summary>
 /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
 public override int GetHashCode()
 {
     return(Hue.GetHashCode() ^ Saturation.GetHashCode() ^ Brightness.GetHashCode());
 }
Exemple #35
0
        public AnimatedItemEffect(Serial sourceSerial, int sourceX, int sourceY, int sourceZ, Graphic graphic, Hue hue, int duration) : this(graphic, hue, duration)
        {
            sbyte  zSrc   = (sbyte)sourceZ;
            Entity source = World.Get(sourceSerial);

            if (source != null)
            {
                if (sourceSerial.IsMobile)
                {
                    Mobile mob = (Mobile)source;

                    if (mob != World.Player && !mob.IsMoving && (sourceX != 0 || sourceY != 0 || sourceZ != 0))
                    {
                        mob.Position = new Position((ushort)sourceX, (ushort)sourceY, zSrc);
                    }
                    SetSource(mob);
                }
                else if (sourceSerial.IsItem)
                {
                    Item item = (Item)source;

                    if (sourceX != 0 || sourceY != 0 || sourceZ != 0)
                    {
                        item.Position = new Position((ushort)sourceX, (ushort)sourceY, zSrc);
                    }
                    SetSource(item);
                }
                else
                {
                    SetSource(sourceX, sourceY, sourceZ);
                }
            }
            else
            {
                SetSource(sourceX, sourceY, sourceZ);
            }
        }
Exemple #36
0
 private void lstHue_SelectedIndexChanged(object sender, EventArgs e)
 {
     this.mHue = (Hue) this.lstHue.SelectedItem;
     this.StatusBar.Text = this.mHue.Index.ToString() + ": " + this.mHue.Index.ToString();
 }
Exemple #37
0
 public HuePickerControl(Hue InitialHue)
     : this()
 {
     this.mHue = InitialHue;
 }
 public DefaultHue(string text, Hue hue, bool matchTextOnCase = false)
 {
     Text = text;
     Hue = hue;
     MatchTextOnCase = matchTextOnCase;
 }
        /// <summary>
        /// Alters the hue component of the image.
        /// </summary>
        /// <param name="source">The image this method extends.</param>
        /// <param name="degrees">The angle in degrees to adjust the image.</param>
        /// <param name="rectangle">
        /// The <see cref="Rectangle"/> structure that specifies the portion of the image object to alter.
        /// </param>
        /// <param name="progressHandler">A delegate which is called as progress is made processing the image.</param>
        /// <returns>The <see cref="Image"/>.</returns>
        public static Image Hue(this Image source, float degrees, Rectangle rectangle, ProgressEventHandler progressHandler = null)
        {
            Hue processor = new Hue(degrees);
            processor.OnProgress += progressHandler;

            try
            {
                return source.Process(rectangle, processor);
            }
            finally
            {
                processor.OnProgress -= progressHandler;
            }
        }
Exemple #40
0
 protected void ValueSelected(Hue Hue)
 {
     editorService.CloseDropDown();
     returnValue = Hue;
 }