| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895 |
- using Client.MirControls;
- using Client.MirGraphics;
- using Client.MirSounds;
- namespace Client.MirScenes.Dialogs
- {
- public class BuffDialog : MirImageControl
- {
- public List<ClientBuff> Buffs = new List<ClientBuff>();
- protected MirButton _expandCollapseButton;
- protected MirLabel _buffCountLabel;
- protected List<MirImageControl> _buffList = new List<MirImageControl>();
- protected bool _fadedOut, _fadedIn;
- protected int _buffCount;
- protected long _nextFadeTime;
- public Func<bool> GetExpandedParameter;
- public Action<bool> SetExpandedParameter;
- private bool ExpandedBuffWindow
- {
- get { return GetExpandedParameter(); }
- set { SetExpandedParameter(value); }
- }
- protected const long FadeDelay = 55;
- protected const float FadeRate = 0.2f;
- public BuffDialog()
- {
- Index = 20;
- Library = Libraries.Prguse2;
- Movable = false;
- Size = new Size(44, 34);
- Location = new Point(Settings.ScreenWidth - 170, 0);
- Sort = true;
- Opacity = 0f;
- _fadedOut = true;
- _expandCollapseButton = new MirButton
- {
- Index = 7,
- HoverIndex = 8,
- Size = new Size(16, 15),
- Library = Libraries.Prguse2,
- Parent = this,
- PressedIndex = 9,
- Sound = SoundList.ButtonA,
- Opacity = 0f
- };
- _expandCollapseButton.Click += (o, e) =>
- {
- if (_buffCount == 1)
- {
- ExpandedBuffWindow = true;
- }
- else
- {
- ExpandedBuffWindow = !ExpandedBuffWindow;
- }
- UpdateWindow();
- };
- _buffCountLabel = new MirLabel
- {
- Parent = this,
- AutoSize = true,
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- Font = new Font(Settings.FontName, 10F, FontStyle.Bold),
- NotControl = true,
- Sort = true,
- Visible = false,
- ForeColour = Color.Yellow,
- OutLineColour = Color.Black,
- };
- }
- public void CreateBuff(ClientBuff buff)
- {
- var buffImage = BuffImage(buff.Type);
- var buffLibrary = Libraries.BuffIcon;
- if (buffImage >= 20000)
- {
- buffImage -= 20000;
- buffLibrary = Libraries.MagIcon;
- }
- if (buffImage >= 10000)
- {
- buffImage -= 10000;
- buffLibrary = Libraries.Prguse2;
- }
- var image = new MirImageControl
- {
- Library = buffLibrary,
- Parent = this,
- Visible = true,
- Sort = false,
- Index = buffImage
- };
- _buffList.Insert(0, image);
- UpdateWindow();
- }
- public void RemoveBuff(int buffId)
- {
- _buffList[buffId].Dispose();
- _buffList.RemoveAt(buffId);
- UpdateWindow();
- }
- public void Process()
- {
- if (!Visible) return;
- if (_buffList.Count != _buffCount)
- {
- UpdateWindow();
- }
- for (var i = 0; i < _buffList.Count; i++)
- {
- var image = _buffList[i];
- var buff = Buffs[i];
- var buffImage = BuffImage(buff.Type);
- var buffLibrary = Libraries.BuffIcon;
- //ArcherSpells - VampireShot,PoisonShot
- if (buffImage >= 20000)
- {
- buffImage -= 20000;
- buffLibrary = Libraries.MagIcon;
- }
- if (buffImage >= 10000)
- {
- buffImage -= 10000;
- buffLibrary = Libraries.Prguse2;
- }
- var location = new Point(Size.Width - 10 - 23 - (i * 23) + ((10 * 23) * (i / 10)), 6 + ((i / 10) * 24));
- image.Location = new Point(location.X, location.Y);
- image.Hint = ExpandedBuffWindow ? BuffString(buff) : CombinedBuffText();
- image.Index = buffImage;
- image.Library = buffLibrary;
- if (ExpandedBuffWindow || !ExpandedBuffWindow && i == 0)
- {
- image.Visible = true;
- image.Opacity = 1f;
- }
- else
- {
- image.Visible = false;
- image.Opacity = 0.6f;
- }
- if (buff.Paused || buff.Infinite || !(Math.Round((buff.ExpireTime - CMain.Time) / 1000D) <= 5))
- continue;
- var time = (buff.ExpireTime - CMain.Time) / 100D;
- if (Math.Round(time) % 10 < 5)
- image.Index = -1;
- }
- if (IsMouseOver(CMain.MPoint))
- {
- if (_buffCount == 0 || (!_fadedIn && CMain.Time <= _nextFadeTime))
- return;
- Opacity += FadeRate;
- _expandCollapseButton.Opacity += FadeRate;
- if (Opacity > 1f)
- {
- Opacity = 1f;
- _expandCollapseButton.Opacity = 1f;
- _fadedIn = true;
- _fadedOut = false;
- }
- _nextFadeTime = CMain.Time + FadeDelay;
- }
- else
- {
- if (!_fadedOut && CMain.Time <= _nextFadeTime)
- return;
- Opacity -= FadeRate;
- _expandCollapseButton.Opacity -= FadeRate;
- if (Opacity < 0f)
- {
- Opacity = 0f;
- _expandCollapseButton.Opacity = 0f;
- _fadedOut = true;
- _fadedIn = false;
- }
-
- _nextFadeTime = CMain.Time + FadeDelay;
- }
- }
- private void UpdateWindow()
- {
- _buffCount = _buffList.Count;
- var baseImage = 20;
- var heightOffset = Location.Y;
- //foreach (var dialog in GameScene.Scene.BuffDialogs)
- //{
- // if (dialog.Category == Category) break;
- // if (dialog.Buffs.Count > 0)
- // {
- // heightOffset += dialog.Size.Height;
- // }
- //}
- if (_buffCount > 0 && ExpandedBuffWindow)
- {
- var oldWidth = Size.Width;
- if (_buffCount <= 10)
- Index = baseImage + _buffCount - 1;
- else if (_buffCount > 10)
- Index = baseImage + 10;
- else if (_buffCount > 20)
- Index = baseImage + 11;
- else if (_buffCount > 30)
- Index = baseImage + 12;
- else if (_buffCount > 40)
- Index = baseImage + 13;
- var newX = Location.X - Size.Width + oldWidth;
- var newY = heightOffset;
- Location = new Point(newX, newY);
- _buffCountLabel.Visible = false;
- _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
- Size = new Size((_buffCount > 10 ? 10 : _buffCount) * 23, 24 + (_buffCount / 10) * 24);
- }
- else if (_buffCount > 0 && !ExpandedBuffWindow)
- {
- var oldWidth = Size.Width;
- Index = 20;
-
- var newX = Location.X - Size.Width + oldWidth;
- var newY = heightOffset;
- Location = new Point(newX, newY);
- _buffCountLabel.Visible = true;
- _buffCountLabel.Text = $"{_buffCount}";
- _buffCountLabel.Location = new Point(Size.Width / 2 - _buffCountLabel.Size.Width / 2, Size.Height / 2 - 10);
- _buffCountLabel.BringToFront();
- _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
- Size = new Size(44, 34);
- }
- }
- public string BuffString(ClientBuff buff)
- {
- string text = RegexFunctions.SeperateCamelCase(buff.Type.ToLocalizedString()) + "\n";
- bool overridestats = false;
- switch (buff.Type)
- {
- case BuffType.GameMaster:
- GMOptions options = (GMOptions)buff.Values[0];
- if (options.HasFlag(GMOptions.GameMaster)) text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Invisible);
- if (options.HasFlag(GMOptions.Superman)) text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Superman);
- if (options.HasFlag(GMOptions.Observer)) text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Observer);
- break;
- case BuffType.MentalState:
- switch (buff.Values[0])
- {
- case 0:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.AgressiveFullDamageCantShootOverWalls);
- break;
- case 1:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TrickShotMinimalDamage);
- break;
- case 2:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GroupModeMediumDamageDontStealAgro);
- break;
- }
- break;
- case BuffType.Hiding:
- case BuffType.ClearRing:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InvisibleToManyMonsters);
- break;
- case BuffType.MoonLight:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InvisibleToPlayersAndMonstersAtDistance);
- break;
- case BuffType.EnergyShield:
- overridestats = true;
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ChanceGainHpWhenAttacked), buff.Stats[Stat.EnergyShieldPercent], buff.Stats[Stat.EnergyShieldHPGain]);
- break;
- case BuffType.DarkBody:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.InvisibleToManyMonstersAbleToMove);
- break;
- case BuffType.VampireShot:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GivesVampiricAbility);
- break;
- case BuffType.PoisonShot:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GivesPoisonAbility);
- break;
- case BuffType.Concentration:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.IncreaseElementExtractionChance);
- break;
- case BuffType.MagicBooster:
- overridestats = true;
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.IncreaseMcAndConsumption), buff.Stats[Stat.MinMC], buff.Stats[Stat.MaxMC], buff.Stats[Stat.ManaPenaltyPercent]);
- break;
- case BuffType.Transform:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.DisguisesYourAppearance);
- break;
- case BuffType.Mentee:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.LearnSkillPointsTwiceAsQuick);
- break;
- case BuffType.Guild:
- text += GameScene.Scene.GuildDialog.ActiveStats;
- break;
- case BuffType.Blindness:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ReducesVisibility);
- break;
- case BuffType.Newbie:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.GuildMemberBoost);
- break;
- }
- if (!overridestats)
- {
- foreach (var val in buff.Stats.Values)
- {
- var c = val.Value < 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Decreases) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Increases);
- var strKey = val.Key.ToLocalizedString();
- var sign = "";
- if (val.Key.ToString().Contains("Percent"))
- sign = "%";
- else if (val.Key.ToString().Contains("Multiplier"))
- sign = "x";
- var txt = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.BuffEffect), c, strKey, val.Value, sign);
- text += txt;
- }
- }
- if (buff.Paused)
- {
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExpirePaused);
- }
- else if (buff.Infinite)
- {
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ExpireNever);
- }
- else
- {
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.Expire), Functions.PrintTimeSpanFromSeconds(Math.Round((buff.ExpireTime - CMain.Time) / 1000D)));
- }
- if (!string.IsNullOrEmpty(buff.Caster)) text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CasterName), buff.Caster);
- return text;
- }
- private string CombinedBuffText()
- {
- string text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ActiveBuffs);
- var stats = new Stats();
- for (var i = 0; i < _buffList.Count; i++)
- {
- var buff = Buffs[i];
- stats.Add(buff.Stats);
- }
- foreach (var val in stats.Values)
- {
- var c = val.Value < 0 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Decreases) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Increases);
- var strKey = val.Key.ToLocalizedString();
- var sign = "";
- if (val.Key.ToString().Contains("Percent"))
- sign = "%";
- else if (val.Key.ToString().Contains("Multiplier"))
- sign = "x";
- var txt = GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.BuffEffect), c, strKey, val.Value, sign);;
- text += txt;
- }
- return text;
- }
- private int BuffImage(BuffType type)
- {
- switch (type)
- {
- //Skills
- case BuffType.Fury:
- return 76;
- case BuffType.Rage:
- return 49;
- case BuffType.ImmortalSkin:
- return 80;
- case BuffType.CounterAttack:
- return 7;
- case BuffType.MagicBooster:
- return 73;
- case BuffType.MagicShield:
- return 30;
- case BuffType.Hiding:
- case BuffType.ClearRing:
- return 17;
- case BuffType.Haste:
- return 60;
- case BuffType.SoulShield:
- return 13;
- case BuffType.BlessedArmour:
- return 14;
- case BuffType.ProtectionField:
- return 50;
- case BuffType.UltimateEnhancer:
- return 35;
- case BuffType.Curse:
- return 45;
- case BuffType.EnergyShield:
- return 57;
- case BuffType.SwiftFeet:
- return 67;
- case BuffType.LightBody:
- return 68;
- case BuffType.MoonLight:
- return 65;
- case BuffType.DarkBody:
- return 70;
- case BuffType.Concentration:
- return 96;
- case BuffType.VampireShot:
- return 100;
- case BuffType.PoisonShot:
- return 102;
- case BuffType.MentalState:
- return 199;
- //Monster
- case BuffType.RhinoPriestDebuff:
- return 217;
- case BuffType.Blindness:
- return 226;
- //Special
- case BuffType.GameMaster:
- return 173;
- case BuffType.General:
- return 182;
- case BuffType.Exp:
- return 260;
- case BuffType.Drop:
- return 162;
- case BuffType.Gold:
- return 168;
- case BuffType.Knapsack:
- case BuffType.BagWeight:
- return 235;
- case BuffType.Transform:
- return 241;
- case BuffType.Mentor:
- case BuffType.Mentee:
- return 248;
- case BuffType.Lover:
- return 201;
- case BuffType.Guild:
- return 203;
- case BuffType.Rested:
- return 240;
- case BuffType.TemporalFlux:
- return 261;
- case BuffType.Skill:
- return 200;
- case BuffType.Newbie:
- return 182;
- //Stats
- case BuffType.Impact:
- return 249;
- case BuffType.Magic:
- return 165;
- case BuffType.Taoist:
- return 250;
- case BuffType.Storm:
- return 170;
- case BuffType.HealthAid:
- return 161;
- case BuffType.ManaAid:
- return 169;
- case BuffType.Defence:
- return 166;
- case BuffType.MagicDefence:
- return 158;
- case BuffType.WonderDrug:
- return 252;
- default:
- return 0;
- }
- }
- }
- //UNFINISHED
- public class ClientPoisonBuff
- {
- public PoisonType Type;
- public string Caster;
- public int Value;
- public int TickSpeed;
- public long ExpireTime;
- }
- public sealed class PoisonBuffDialog : MirImageControl
- {
- public List<ClientPoisonBuff> Buffs = new List<ClientPoisonBuff>();
- private MirButton _expandCollapseButton;
- private MirLabel _buffCountLabel;
- private List<MirImageControl> _buffList = new List<MirImageControl>();
- private bool _fadedOut, _fadedIn;
- private int _buffCount;
- private long _nextFadeTime;
- private const long FadeDelay = 55;
- private const float FadeRate = 0.2f;
- public PoisonBuffDialog()
- {
- Index = 40;
- Library = Libraries.Prguse2;
- Movable = false;
- Size = new Size(44, 34);
- Location = new Point(Settings.ScreenWidth - 170, 0);
- Sort = true;
- Opacity = 0f;
- _fadedOut = true;
- _expandCollapseButton = new MirButton
- {
- Index = 7,
- HoverIndex = 8,
- Size = new Size(16, 15),
- Library = Libraries.Prguse2,
- Parent = this,
- PressedIndex = 9,
- Sound = SoundList.ButtonA,
- Opacity = 0f
- };
- _expandCollapseButton.Click += (o, e) =>
- {
- if (_buffCount == 1)
- {
- Settings.ExpandedBuffWindow = true;
- }
- else
- {
- Settings.ExpandedBuffWindow = !Settings.ExpandedBuffWindow;
- }
- UpdateWindow();
- };
- _buffCountLabel = new MirLabel
- {
- Parent = this,
- AutoSize = true,
- DrawFormat = TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter,
- Font = new Font(Settings.FontName, 10F, FontStyle.Bold),
- NotControl = true,
- Sort = true,
- Visible = false,
- ForeColour = Color.Yellow,
- OutLineColour = Color.Black,
- };
- }
- public void CreateBuff(ClientPoisonBuff buff)
- {
- var buffImage = BuffImage(buff.Type);
- var buffLibrary = Libraries.BuffIcon;
- if (buffImage >= 20000)
- {
- buffImage -= 20000;
- buffLibrary = Libraries.MagIcon;
- }
- if (buffImage >= 10000)
- {
- buffImage -= 10000;
- buffLibrary = Libraries.Prguse2;
- }
- var image = new MirImageControl
- {
- Library = buffLibrary,
- Parent = this,
- Visible = true,
- Sort = false,
- Index = buffImage
- };
- _buffList.Insert(0, image);
- UpdateWindow();
- }
- public string BuffString(ClientPoisonBuff buff)
- {
- string text = RegexFunctions.SeperateCamelCase(buff.Type.ToLocalizedString()) + "\n";
- switch (buff.Type)
- {
- case PoisonType.Green:
- {
- var tick = buff.TickSpeed / 1000;
- var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ReceiveDamageEveryTick), buff.Value, tick, tickName);
- }
- break;
- case PoisonType.Red:
- {
- var tick = buff.TickSpeed / 1000;
- var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.ReducesArmourRatePerTick), tick, tickName);
- }
- break;
- case PoisonType.Slow:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ReducesMovementSpeed);
- break;
- case PoisonType.Frozen:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsCastingMovingAttacking);
- break;
- case PoisonType.Stun:
- {
- var tick = buff.TickSpeed / 1000;
- var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.DamageReceivedIncrease), tick, tickName);
- }
- break;
- case PoisonType.Paralysis:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsMoveAndAttack);
- break;
- case PoisonType.DelayedExplosion:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.TickingTimeBomb);
- break;
- case PoisonType.Bleeding:
- {
- var tick = buff.TickSpeed / 1000;
- var tickName = tick > 1 ? GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Seconds) : GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.Second);
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.RecieveDamageEveryTime), buff.Value, tick, tickName);
- }
- break;
- case PoisonType.LRParalysis:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsMoveAttackCancelOnHit);
- break;
- case PoisonType.Blindness:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.CausesTemporaryBlindness);
- break;
- case PoisonType.Dazed:
- text += GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.PreventsAttacking);
- break;
- }
- text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.Expire), Functions.PrintTimeSpanFromSeconds(Math.Round((buff.ExpireTime - CMain.Time) / 1000D)));
- if (!string.IsNullOrEmpty(buff.Caster)) text += GameLanguage.ClientTextMap.GetLocalization((ClientTextKeys.CasterName), buff.Caster);
- return text;
- }
- private int BuffImage(PoisonType type)
- {
- switch (type)
- {
- case PoisonType.Green:
- return 221;
- case PoisonType.Red:
- return 222;
- case PoisonType.Slow:
- return 225;
- case PoisonType.Frozen:
- return 223;
- case PoisonType.Stun:
- return 224;
- case PoisonType.Paralysis:
- return 233;
- case PoisonType.DelayedExplosion:
- return 229;
- case PoisonType.Bleeding:
- return 231;
- case PoisonType.LRParalysis:
- return 233;
- case PoisonType.Blindness:
- return 226;
- case PoisonType.Dazed:
- return 230;
- default:
- return 0;
- }
- }
- public void Process()
- {
- if (!Visible) return;
- if (_buffList.Count != _buffCount)
- {
- UpdateWindow();
- }
- for (var i = 0; i < _buffList.Count; i++)
- {
- var image = _buffList[i];
- var buff = Buffs[i];
- var buffImage = BuffImage(buff.Type);
- var buffLibrary = Libraries.BuffIcon;
- //ArcherSpells - VampireShot,PoisonShot
- if (buffImage >= 20000)
- {
- buffImage -= 20000;
- buffLibrary = Libraries.MagIcon;
- }
- if (buffImage >= 10000)
- {
- buffImage -= 10000;
- buffLibrary = Libraries.Prguse2;
- }
- var location = new Point(Size.Width - 10 - 23 - (i * 23) + ((10 * 23) * (i / 10)), 6 + ((i / 10) * 24));
- image.Location = new Point(location.X, location.Y);
- image.Hint = Settings.ExpandedBuffWindow ? BuffString(buff) : CombinedBuffText();
- image.Index = buffImage;
- image.Library = buffLibrary;
- if (Settings.ExpandedBuffWindow || !Settings.ExpandedBuffWindow && i == 0)
- {
- image.Visible = true;
- image.Opacity = 1f;
- }
- else
- {
- image.Visible = false;
- image.Opacity = 0.6f;
- }
- if (!(Math.Round((buff.ExpireTime - CMain.Time) / 1000D) <= 5))
- continue;
- var time = (buff.ExpireTime - CMain.Time) / 100D;
- if (Math.Round(time) % 10 < 5)
- image.Index = -1;
- }
- if (IsMouseOver(CMain.MPoint))
- {
- if (_buffCount == 0 || (!_fadedIn && CMain.Time <= _nextFadeTime))
- return;
- Opacity += FadeRate;
- _expandCollapseButton.Opacity += FadeRate;
- if (Opacity > 1f)
- {
- Opacity = 1f;
- _expandCollapseButton.Opacity = 1f;
- _fadedIn = true;
- _fadedOut = false;
- }
- _nextFadeTime = CMain.Time + FadeDelay;
- }
- else
- {
- if (!_fadedOut && CMain.Time <= _nextFadeTime)
- return;
- Opacity -= FadeRate;
- _expandCollapseButton.Opacity -= FadeRate;
- if (Opacity < 0f)
- {
- Opacity = 0f;
- _expandCollapseButton.Opacity = 0f;
- _fadedOut = true;
- _fadedIn = false;
- }
- _nextFadeTime = CMain.Time + FadeDelay;
- }
- }
- private void UpdateWindow()
- {
- _buffCount = _buffList.Count;
- var baseImage = 20;
- var heightOffset = 36;
- if (_buffCount > 0 && Settings.ExpandedBuffWindow)
- {
- var oldWidth = Size.Width;
- if (_buffCount <= 10)
- Index = baseImage + _buffCount - 1;
- else if (_buffCount > 10)
- Index = baseImage + 10;
- else if (_buffCount > 20)
- Index = baseImage + 11;
- else if (_buffCount > 30)
- Index = baseImage + 12;
- else if (_buffCount > 40)
- Index = baseImage + 13;
- var newX = Location.X - Size.Width + oldWidth;
- var newY = heightOffset;
- Location = new Point(newX, newY);
- _buffCountLabel.Visible = false;
- _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
- Size = new Size((_buffCount > 10 ? 10 : _buffCount) * 23, 24 + (_buffCount / 10) * 24);
- }
- else if (_buffCount > 0 && !Settings.ExpandedBuffWindow)
- {
- var oldWidth = Size.Width;
- Index = 20;
- var newX = Location.X - Size.Width + oldWidth;
- var newY = heightOffset;
- Location = new Point(newX, newY);
- _buffCountLabel.Visible = true;
- _buffCountLabel.Text = $"{_buffCount}";
- _buffCountLabel.Location = new Point(Size.Width / 2 - _buffCountLabel.Size.Width / 2, Size.Height / 2 - 10);
- _buffCountLabel.BringToFront();
- _expandCollapseButton.Location = new Point(Size.Width - 15, 0);
- Size = new Size(44, 34);
- }
- }
- private string CombinedBuffText()
- {
- string text = GameLanguage.ClientTextMap.GetLocalization(ClientTextKeys.ActivePoisons);
- return text;
- }
- }
- }
|