private void UpdateTitleBar() { if (!m_Ready) { return; } if (World.Player != null && Config.GetBool("TitleBarDisplay")) { // reuse the same sb each time for less damn allocations m_TBBuilder.Remove(0, m_TBBuilder.Length); m_TBBuilder.Insert(0, Config.GetString("TitleBarText")); StringBuilder sb = m_TBBuilder; //StringBuilder sb = new StringBuilder( Config.GetString( "TitleBarText" ) ); // m_TitleCapacity PlayerData p = World.Player; if (p.Name != m_LastPlayerName) { m_LastPlayerName = p.Name; Engine.MainWindow.UpdateTitle(); } sb.Replace(@"{char}", Config.GetBool("ShowNotoHue") ? $"~#{p.GetNotorietyColor() & 0x00FFFFFF:X6}{p.Name}~#~" : p.Name); sb.Replace(@"{shard}", World.ShardName); sb.Replace(@"{crimtime}", p.CriminalTime != 0 ? $"~^C0C0C0{p.CriminalTime}~#~" : "-"); sb.Replace(@"{str}", p.Str.ToString()); sb.Replace(@"{hpmax}", p.HitsMax.ToString()); sb.Replace(@"{hp}", p.Poisoned ? $"~#FF8000{p.Hits}~#~" : EncodeColorStat(p.Hits, p.HitsMax)); sb.Replace(@"{dex}", World.Player.Dex.ToString()); sb.Replace(@"{stammax}", World.Player.StamMax.ToString()); sb.Replace(@"{stam}", EncodeColorStat(p.Stam, p.StamMax)); sb.Replace(@"{int}", World.Player.Int.ToString()); sb.Replace(@"{manamax}", World.Player.ManaMax.ToString()); sb.Replace(@"{mana}", EncodeColorStat(p.Mana, p.ManaMax)); sb.Replace(@"{ar}", p.AR.ToString()); sb.Replace(@"{tithe}", p.Tithe.ToString()); sb.Replace(@"{physresist}", p.AR.ToString()); sb.Replace(@"{fireresist}", p.FireResistance.ToString()); sb.Replace(@"{coldresist}", p.ColdResistance.ToString()); sb.Replace(@"{poisonresist}", p.PoisonResistance.ToString()); sb.Replace(@"{energyresist}", p.EnergyResistance.ToString()); sb.Replace(@"{luck}", p.Luck.ToString()); sb.Replace(@"{damage}", String.Format("{0}-{1}", p.DamageMin, p.DamageMax)); sb.Replace(@"{weight}", World.Player.Weight >= World.Player.MaxWeight ? $"~#FF0000{World.Player.Weight}~#~" : World.Player.Weight.ToString()); sb.Replace(@"{maxweight}", World.Player.MaxWeight.ToString()); sb.Replace(@"{followers}", World.Player.Followers.ToString()); sb.Replace(@"{followersmax}", World.Player.FollowersMax.ToString()); sb.Replace(@"{gold}", World.Player.Gold.ToString()); sb.Replace(@"{gps}", GoldPerHourTimer.Running ? $"{GoldPerHourTimer.GoldPerSecond:N2}" : "-"); sb.Replace(@"{gpm}", GoldPerHourTimer.Running ? $"{GoldPerHourTimer.GoldPerMinute:N2}" : "-"); sb.Replace(@"{gph}", GoldPerHourTimer.Running ? $"{GoldPerHourTimer.GoldPerHour:N2}" : "-"); sb.Replace(@"{goldtotal}", GoldPerHourTimer.Running ? $"{GoldPerHourTimer.GoldSinceStart}" : "-"); sb.Replace(@"{goldtotalmin}", GoldPerHourTimer.Running ? $"{GoldPerHourTimer.TotalMinutes:N2} min" : "-"); sb.Replace(@"{bandage}", BandageTimer.Running ? $"~#FF8000{BandageTimer.Count}~#~" : "-"); sb.Replace(@"{skill}", SkillTimer.Running ? $"{SkillTimer.Count}" : "-"); sb.Replace(@"{gate}", GateTimer.Running ? $"{GateTimer.Count}" : "-"); sb.Replace(@"{stealthsteps}", StealthSteps.Counting ? StealthSteps.Count.ToString() : "-"); //Client.ConnectionStart != DateTime.MinValue ) //time = (int)((DateTime.UtcNow - Client.ConnectionStart).TotalSeconds); sb.Replace(@"{uptime}", ConnectionStart != DateTime.MinValue ? Utility.FormatTime((int)((DateTime.UtcNow - ConnectionStart).TotalSeconds)) : "-"); sb.Replace(@"{dps}", DamageTracker.Running ? $"{DamageTracker.DamagePerSecond:N2}" : "-"); sb.Replace(@"{maxdps}", DamageTracker.Running ? $"{DamageTracker.MaxDamagePerSecond:N2}" : "-"); sb.Replace(@"{maxdamagedealt}", DamageTracker.Running ? $"{DamageTracker.MaxSingleDamageDealt}" : "-"); sb.Replace(@"{maxdamagetaken}", DamageTracker.Running ? $"{DamageTracker.MaxSingleDamageTaken}" : "-"); sb.Replace(@"{totaldamagedealt}", DamageTracker.Running ? $"{DamageTracker.TotalDamageDealt}" : "-"); sb.Replace(@"{totaldamagetaken}", DamageTracker.Running ? $"{DamageTracker.TotalDamageTaken}" : "-"); string buffList = string.Empty; if (BuffsTimer.Running) { StringBuilder buffs = new StringBuilder(); foreach (BuffsDebuffs buff in World.Player.BuffsDebuffs) { int timeLeft = 0; if (buff.Duration > 0) { TimeSpan diff = DateTime.UtcNow - buff.Timestamp; timeLeft = buff.Duration - (int)diff.TotalSeconds; } buffs.Append(timeLeft <= 0 ? $"{buff.ClilocMessage1}, " : $"{buff.ClilocMessage1} ({timeLeft}), "); } buffs.Length = buffs.Length - 2; buffList = buffs.ToString(); sb.Replace(@"{buffsdebuffs}", buffList); } else { sb.Replace(@"{buffsdebuffs}", "-"); buffList = string.Empty; } string statStr = String.Format("{0}{1:X2}{2:X2}{3:X2}", (int)(p.GetStatusCode()), (int)(World.Player.HitsMax == 0 ? 0 : (double)World.Player.Hits / World.Player.HitsMax * 99), (int)(World.Player.ManaMax == 0 ? 0 : (double)World.Player.Mana / World.Player.ManaMax * 99), (int)(World.Player.StamMax == 0 ? 0 : (double)World.Player.Stam / World.Player.StamMax * 99)); sb.Replace(@"{statbar}", $"~SR{statStr}"); sb.Replace(@"{mediumstatbar}", $"~SL{statStr}"); sb.Replace(@"{largestatbar}", $"~SX{statStr}"); bool dispImg = Config.GetBool("TitlebarImages"); for (int i = 0; i < Counter.List.Count; i++) { Counter c = Counter.List[i]; if (c.Enabled) { sb.Replace($"{{{c.Format}}}", c.GetTitlebarString(dispImg && c.DisplayImage)); } } SetTitleStr(sb.ToString()); } else { SetTitleStr(""); } }
private static void UpdateTitleBar() { if (World.Player != null && Config.GetBool("TitleBarDisplay")) { // reuse the same sb each time for less damn allocations m_TBBuilder.Remove(0, m_TBBuilder.Length); m_TBBuilder.Insert(0, Config.GetString("TitleBarText")); StringBuilder sb = m_TBBuilder; //StringBuilder sb = new StringBuilder( Config.GetString( "TitleBarText" ) ); // m_TitleCapacity PlayerData p = World.Player; if (p.Name != m_LastPlayerName) { m_LastPlayerName = p.Name; Engine.MainWindow.UpdateTitle(); } if (Config.GetBool("ShowNotoHue")) { sb.Replace(@"{char}", String.Format("~#{0:X6}{1}~#~", p.GetNotorietyColor() & 0x00FFFFFF, p.Name)); } else { sb.Replace(@"{char}", p.Name); } sb.Replace(@"{shard}", World.ShardName); if (p.CriminalTime != 0) { sb.Replace(@"{crimtime}", String.Format("~^C0C0C0{0}~#~", p.CriminalTime)); } else { sb.Replace(@"{crimtime}", "-"); } sb.Replace(@"{str}", p.Str.ToString()); sb.Replace(@"{hpmax}", p.HitsMax.ToString()); if (p.Poisoned) { sb.Replace(@"{hp}", String.Format("~#FF8000{0}~#~", p.Hits)); } else { sb.Replace(@"{hp}", EncodeColorStat(p.Hits, p.HitsMax)); } sb.Replace(@"{dex}", World.Player.Dex.ToString()); sb.Replace(@"{stammax}", World.Player.StamMax.ToString()); sb.Replace(@"{stam}", EncodeColorStat(p.Stam, p.StamMax)); sb.Replace(@"{int}", World.Player.Int.ToString()); sb.Replace(@"{manamax}", World.Player.ManaMax.ToString()); sb.Replace(@"{mana}", EncodeColorStat(p.Mana, p.ManaMax)); sb.Replace(@"{ar}", p.AR.ToString()); sb.Replace(@"{tithe}", p.Tithe.ToString()); sb.Replace(@"{physresist}", p.AR.ToString()); sb.Replace(@"{fireresist}", p.FireResistance.ToString()); sb.Replace(@"{coldresist}", p.ColdResistance.ToString()); sb.Replace(@"{poisonresist}", p.PoisonResistance.ToString()); sb.Replace(@"{energyresist}", p.EnergyResistance.ToString()); sb.Replace(@"{luck}", p.Luck.ToString()); sb.Replace(@"{damage}", String.Format("{0}-{1}", p.DamageMin, p.DamageMax)); if (World.Player.Weight >= World.Player.MaxWeight) { sb.Replace(@"{weight}", String.Format("~#FF0000{0}~#~", World.Player.Weight)); } else { sb.Replace(@"{weight}", World.Player.Weight.ToString()); } sb.Replace(@"{maxweight}", World.Player.MaxWeight.ToString()); sb.Replace(@"{followers}", World.Player.Followers.ToString()); sb.Replace(@"{followersmax}", World.Player.FollowersMax.ToString()); sb.Replace(@"{gold}", World.Player.Gold.ToString()); if (BandageTimer.Running) { sb.Replace(@"{bandage}", String.Format("~#FF8000{0}~#~", BandageTimer.Count)); } else { sb.Replace(@"{bandage}", "-"); } if (StealthSteps.Counting) { sb.Replace(@"{stealthsteps}", StealthSteps.Count.ToString()); } else { sb.Replace(@"{stealthsteps}", "-"); } string statStr = String.Format("{0}{1:X2}{2:X2}{3:X2}", (int)(p.GetStatusCode()), (int)(World.Player.HitsMax == 0 ? 0 : (double)World.Player.Hits / World.Player.HitsMax * 99), (int)(World.Player.ManaMax == 0 ? 0 : (double)World.Player.Mana / World.Player.ManaMax * 99), (int)(World.Player.StamMax == 0 ? 0 : (double)World.Player.Stam / World.Player.StamMax * 99)); sb.Replace(@"{statbar}", String.Format("~SR{0}", statStr)); sb.Replace(@"{mediumstatbar}", String.Format("~SL{0}", statStr)); sb.Replace(@"{largestatbar}", String.Format("~SX{0}", statStr)); bool dispImg = Config.GetBool("TitlebarImages"); for (int i = 0; i < Counter.List.Count; i++) { Counter c = (Counter)Counter.List[i]; if (c.Enabled) { sb.Replace(String.Format("{{{0}}}", c.Format), c.GetTitlebarString(dispImg && c.DisplayImage)); } } SetTitleStr(sb.ToString()); } else { SetTitleStr(""); } }